-
Need help with a Microcontroller beginners project.
Posted by
Falcon69
on 14 Jun, 2015 21:29
-
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.
-
#1 Reply
Posted by
Falcon69
on 14 Jun, 2015 21:44
-
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.
-
#2 Reply
Posted by
10101
on 14 Jun, 2015 21:48
-
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-wantedWish you good luck with the learning process
-
#3 Reply
Posted by
Falcon69
on 14 Jun, 2015 21:53
-
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.
-
#4 Reply
Posted by
karlmag
on 14 Jun, 2015 22:54
-
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.
-
#5 Reply
Posted by
SL4P
on 14 Jun, 2015 23:15
-
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.
-
#6 Reply
Posted by
Falcon69
on 14 Jun, 2015 23:18
-
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.
-
#7 Reply
Posted by
SL4P
on 14 Jun, 2015 23:29
-
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!
-
#8 Reply
Posted by
10101
on 14 Jun, 2015 23:38
-
Yeh shift registers can confuse a bit
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
-
#9 Reply
Posted by
Falcon69
on 14 Jun, 2015 23:40
-
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.
-
#10 Reply
Posted by
10101
on 14 Jun, 2015 23:41
-
PS: From the equation shown in wiki you would need 7 pins to drive the 42 outputs.
-
#11 Reply
Posted by
Falcon69
on 14 Jun, 2015 23:42
-
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.)
-
#12 Reply
Posted by
SL4P
on 14 Jun, 2015 23:45
-
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.
-
#13 Reply
Posted by
Falcon69
on 14 Jun, 2015 23:46
-
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.
-
#14 Reply
Posted by
Falcon69
on 15 Jun, 2015 00:06
-
Okay, here's a quick sketch. Does this make sense?
-
#15 Reply
Posted by
SL4P
on 15 Jun, 2015 00:08
-
Darn those invisible attachments!
-
#16 Reply
Posted by
Falcon69
on 15 Jun, 2015 02:32
-
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.
-
#17 Reply
Posted by
SL4P
on 15 Jun, 2015 02:34
-
Limited to somewhat less per port
-
#18 Reply
Posted by
Falcon69
on 15 Jun, 2015 02:41
-
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?
-
#19 Reply
Posted by
SL4P
on 15 Jun, 2015 02:45
-
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
-
#20 Reply
Posted by
Falcon69
on 15 Jun, 2015 02:53
-
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 (
? 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.
-
#21 Reply
Posted by
Falcon69
on 15 Jun, 2015 02:57
-
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.
-
#22 Reply
Posted by
hamster_nz
on 15 Jun, 2015 03:57
-
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)
-
#23 Reply
Posted by
SL4P
on 15 Jun, 2015 04:05
-
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
-
#24 Reply
Posted by
miguelvp
on 15 Jun, 2015 04:15
-