Author Topic: Need help with a Microcontroller beginners project.  (Read 15348 times)

0 Members and 1 Guest are viewing this topic.

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Need help with a Microcontroller beginners project.
« on: June 14, 2015, 09:29:14 pm »
So, I've made a product that works, and after some thinking, I think it can be made cheaper with a microcontroller.

So, I've made this truth table for what I want the microcontroller to do. Does it make sense? From the truth table below, I would need a microcontroller that has 25 inputs, with 42 outputs (some can be used by multiple switches, i.e. rear panel LED's (only 1 red and 1 green LED). That's 67 total input/outputs.  This would operate up to 8 individual switches. Later, I'd like to design it for only operation of 3 and 5 switches only.

I have a product that consists of 9 hall effect sensors, when triggered by a magnet, they activate LED's and/or a OptoMOS to switch on/off a device.

Now, from my understanding, most microcontrollers can not sink or source enough amps to power multiple LED's, so I would need to get logic level mosFETs to switch the led's on and off?. 

Is this doable with a microcontroller? Do they make them so that they can sink/source mA to light LED's, without having the need for transistors or logic level mosfets to light them up? Would, perhaps, using logic gates to drive the LED's instead of the transistors/mosfets be better (what I have now, but no microcontroller).

I figured this would be a good project to get started in the world of microcontrollers.  It's pretty simple (i think) since there really isn't any LCD's to control, clocks, frequencies, etc. Although, a backlit LED would be pretty cool instead of LED's, if it's possible. Depends on how complex it is to set one up.

Any help would be great. I thought about getting and learning on an arduino, but there's so much information out there for the arduino, i'm lost.

Anyone have any simple microcontroller projects? Some with links to programs used for the programming and stuff?

FYI, I'm open to also paying an engineer to help me with this set-up, but I also WANT to learn how to work with microcontrollers as well. I have other projects I'd like to do, like make a sequential LED controller for my car and my nephews car later in the future.


« Last Edit: June 14, 2015, 09:31:16 pm by Falcon69 »
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #1 on: June 14, 2015, 09:44:47 pm »
hmm, i been reading alittle of the arduino lessons over on adafruit. seems like a good start i guess, but, I still want to learn to effectively control a microcontroller other than an arduino, in the meantime while I work on THIS project, I may buy the arduino and get one for my little nephew, and we can learn together.

But, I still want to continue on this project as well.
 

Offline 10101

  • Contributor
  • Posts: 48
  • Country: pt
Re: Need help with a Microcontroller beginners project.
« Reply #2 on: June 14, 2015, 09:48:20 pm »
Idk if it works with your project but since you have so many outputs you might wanna use shift register, about the inputs idk if there's anything that can help with that. Speaking of mosfets i made a post with a similar question couple days ago :
https://www.eevblog.com/forum/beginners/mosfet-wanted

Wish you good luck with the learning process :D
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #3 on: June 14, 2015, 09:53:14 pm »
ya, i've been told shift registers before, but I don't understand at all how they work. I've tried to understand, and it is just confusing.

I figured with a microcontroller that house outputs that only do 0 or 1, it is simple to understand, although, i understand they can do alot more than just 0 and 1 logic level output.

But for my project, that's all i'm looking to do.

Currently, my project costs about $63each to make (if i make in quantities of 100), and that doesn't even account for all the labor. I need to figure a way of getting the cost down, and I thought maybe a microcontroller would be cheaper, as I would not need as many logic gates/mosfets/transistors I'm currently using.
 

Offline karlmag

  • Contributor
  • Posts: 33
  • Country: no
Re: Need help with a Microcontroller beginners project.
« Reply #4 on: June 14, 2015, 10:54:01 pm »
Hi,

I must admit I fail to figure out where you get the numbers 25 and 42 from.

9 hall effect sensors (input)
8 switches (input ones, right?)
1 reset switch of some sort? (input)

2x2 leds (front and back panels, output)
8 optomos (output)  I'd  assume # input switches is same as # of optomos outputs
leds per switch too? One or two if so?

Since there are more hall effect sensors than switches and optomos outputs I assume there is no one-to-one relation between them.
What is the the relation?

I guess one has to understand the problem somewhat properly before trying to come up with a (hopefully) useful solution.
I just wonder if it's  somehow possible to simplify the design so # inputs and outputs might be reduced.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Need help with a Microcontroller beginners project.
« Reply #5 on: June 14, 2015, 11:15:39 pm »
Can you post a conceptual block diagram of the circuit and external factors?
I expect you can do exactly what you want fairly easily, but at the moment the objective is a bit fuzzy.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #6 on: June 14, 2015, 11:18:38 pm »
sorry, let me explain.

INPUT  -   8 hall effect sensors (on separate board with red and green led for each sensor)
           -   1 reset switch (turns on all LED's)
           -   8 jumpers to select N/C
           -   8 jumpers to tell microcontroller a sensor is plugged in
 
OUTPUT  -    8 LED's (Green if N/C jumper)
               -    8 LED's (Red for if N/O jumper)
               -    8 LED's (Green on front panel, activate with sensor input---- each LED corresponds with it's sensor input, i.e LED 1 with sensor 1))
               -    8 LED's (Green on hall sensor board, activate with sensor input---- each LED corresponds with it's sensor input, i.e LED 1 with sensor 1))
               -    8 LED's (Red on front panel, activate with sensor input---- each LED corresponds with it's sensor input, i.e LED 1 with sensor 1)
               -    8 LED's (Red on hall sensor board, activate with sensor input---- each LED corresponds with it's sensor input, i.e LED 1 with sensor 1)
               -    1 LED (Green, on when any sensor is plugged in, off when no sensors plugged in)
               -    1 LED (Red, on when any sensor is triggered, off when no sensors plugged in)
               -    8 optoMOS (each optoMOS corresponds with it's sensor input, i.e. optoMOS 1 with sensor 1)

I guess if the microcontroller senses a floating pin (like if a sensor is not plugged in), it will default to a 0......wait, that won't work, because then it would mess up other parts of the truth table, turning on LED's that shouldn't be on.  I was just thinking of a way to eliminate the '8 jumpers to tell microcontroller a sensor is plugged in' input, but it won't work now that I think about it.

Kinda like the 'IF and only IF' thing. If the microcontroller senses a sensor is not plugged in and sees that pin as 0, the it would still turn on the LED's on the panel.  So, I would need a separate input to tell the microcontroller that a sensor is not plugged in.

.....

Yes, I will do what I can SL4P, give me a few to draw it up.

 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Need help with a Microcontroller beginners project.
« Reply #7 on: June 14, 2015, 11:29:40 pm »
10101 had the right starting point with shift-registers.
- or you could look at chips like tha MAX7219 to drive 64 LEDs-with a bit more sophisticated control.

There's a little more to It, but not much - just ensure the stability of your I/o when states are changing.
The shift regs can take your inputs directly, and each sr output will drive a couple of LEDS directly.
if you need to drive multiple LEDs wired in parallel, then start moving up to a small FET.

Depending on the idle state at reset, you may or may not be able to automatically detect the presence of sensors... there are many ways and options.  You have allowed for jumpers already, that's good.

Something positive for your project is the range of 8 I/o ports, made to measure for working in a byte oriented process!
Don't ask a question if you aren't willing to listen to the answer.
 

Offline 10101

  • Contributor
  • Posts: 48
  • Country: pt
Re: Need help with a Microcontroller beginners project.
« Reply #8 on: June 14, 2015, 11:38:46 pm »
Yeh shift registers can confuse a bit  :P
Another simple solution (not giving you the best but the simplest) would be charlieplexing (used many times in arduino projects) and using mosfets to drive it.
Here is the wikipedia page about it (there's tons of more info about it on the web) :  https://en.wikipedia.org/wiki/Charlieplexing

:-+
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #9 on: June 14, 2015, 11:40:49 pm »
what i have right now is the sensors are connected via 5-pin USBs. There's an extra pin on it, pin 5. so with that pin 5, it goes to one of the logic gates. when that pin goes high, it turns off all the led's for that corresponding switch input.

On the male side, that is wired to the sensor, I took the 5 volts going to the sensor and tied it to pin 5, so the logic gates only go high when the sensor is plugged in.

So, You are saying to NOT use any microcontroller and only use shift registers?  I'm confused. I thought they only work with data clocks to shift and latch and output.

FYI, still working on drawing.
 

Offline 10101

  • Contributor
  • Posts: 48
  • Country: pt
Re: Need help with a Microcontroller beginners project.
« Reply #10 on: June 14, 2015, 11:41:21 pm »
PS: From the equation shown in wiki you would need 7 pins to drive the 42 outputs.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #11 on: June 14, 2015, 11:42:06 pm »
FYI, I don't want to use an arduino for this project, I simply said Arduino so I can get used to how a microcontroller works.  FOr this project, I need a self sustainging microcontroller on it's own board with all the other bits of this project (sensors, optoMOS, etc.)
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Need help with a Microcontroller beginners project.
« Reply #12 on: June 14, 2015, 11:45:18 pm »
ok, a bit of clarification...
With SRs, you can most likely get away with 3-4pins for all your I/o
Yes shift registers need a host (micro or other) to clock data in and out of the chain.
What you do inside the processor is up to the. software.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #13 on: June 14, 2015, 11:46:44 pm »
just quickly reading that wiki link...

it says that if one LED fails, then all of them will not work. That won't be idea for my project. It would be hard to find which one failed to fix.  Kinda like the Christmas Light thing.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #14 on: June 15, 2015, 12:06:51 am »
Okay, here's a quick sketch.  Does this make sense?

 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Need help with a Microcontroller beginners project.
« Reply #15 on: June 15, 2015, 12:08:10 am »
Darn those invisible attachments!
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #16 on: June 15, 2015, 02:32:47 am »
Been reading alittle about the Atmega2560 chip. Am I right in reading that it can source up to 40mA per I/O pin? If that's correct, there are 54 I/O pins, that's 2.16A.  That doesn't seem right. If it is true, awesome, I would not have to use mosFETs to switch the LED's on. It might be the right chip, however, even ordering them off Aliexpress, they are about $5 each, still may be too expensive.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Need help with a Microcontroller beginners project.
« Reply #17 on: June 15, 2015, 02:34:27 am »
Limited to somewhat less per port
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #18 on: June 15, 2015, 02:41:41 am »
well, the LED's only operate at <= 20mA.  But, I'm concerned that if I have , say, 51 LED's all turned on at maybe 10mA each, that's 510mA.

I am having trouble finding exact specs on the chip. All I can find so far is that it outputs 40mA max per I/O pin, but is there a cap on that for total for all pins?
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Need help with a Microcontroller beginners project.
« Reply #19 on: June 15, 2015, 02:45:03 am »
Let's take a step back.
Do not in this case connect the LEDs directly to the micro.
Use 74xx595 or TPIC595 chips for output. And the complement to those as input registers

If you think as a rule of 10-20mA max per pin, and maybe 100mA per 8-bit port
« Last Edit: June 15, 2015, 02:49:33 am by SL4P »
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #20 on: June 15, 2015, 02:53:12 am »
okay, found it. The CHIP as a whole can only operate with a max of 200mA.  That includes the power and ground connections to the chip itself.  So yes, I will have to use a shift register? 74HC595?  That will source the current for all outputs (8)?  What about sinking as well?  Like the logic chips do?

It sounds like this could be more expensive going this route, then it would be just to keep with what I got, logic gates to do everything.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #21 on: June 15, 2015, 02:57:12 am »
so, if I understand correctly.

Micorcontroller
   -Output to Shift register (3pins used)
Shift register
   -Input from Microcontroller (3pins used) output to 8 LED's (8pins used)

So, one shift register per Sensor, that will use up 24 pins of the microcontroller just for outputs. then I still need the 3 pins per sensor (plus the one for reset) to control each shift register.

So I would need 25 pins for the input to the microcontroller and 24 output pins from the micorcontroller. that's 49 total I/O pins.

I'm still kinda confused.

I'll draw something up on the schematic, and see if it's correct.
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Need help with a Microcontroller beginners project.
« Reply #22 on: June 15, 2015, 03:57:20 am »
You can chain multiple shift registers together if you need more than 8 outputs.

The 'neopixel' intelligent LEDs strips  (and similar) act as  a really long shift register, allowing you to drive 100s of RGBs LEDs using just one microcontroller pin. This might be worth considering if you want to keep part counts down - no current limiting resisters are needed, and the one RGB LED can show information (which might be a good or bad thing, depending on your user interface requirements)

Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Need help with a Microcontroller beginners project.
« Reply #23 on: June 15, 2015, 04:05:10 am »
No
Use (say 6 pins) total for all LEDS, sensors and inputs.
Daisy chain the shift registers to the required length.
And if you run the input and output register chains in parallel it  maker things a bit faster to help out
Don't ask a question if you aren't willing to listen to the answer.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Need help with a Microcontroller beginners project.
« Reply #24 on: June 15, 2015, 04:15:04 am »
I love PSoC as many know so I gotta throw these in here:

http://www.element14.com/community/message/89756/l/psoc-4-pioneer-kit-community-project100-psoc-4-times-square-led-billboard

http://www.cypress.com/?rID=103610

http://www.cypress.com/?rID=57336

Edit: I forgot:

http://www.element14.com/community/thread/23736/l/100-projects-in-100-days

But really the $10 PSoC 5LP prototype board is a better bet than the Pioneer kit, but the pioneer has more sample code (even if you can port each of those to the other ones)

« Last Edit: June 15, 2015, 04:19:23 am by miguelvp »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf