Need help with a Microcontroller beginners project. - Page 1
Forum section: electronics / general

author: Falcon69
author_rank: Super Contributor
timestamp: June 14, 2015, 09:29:14 pm
content: 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.

author: Falcon69
author_rank: Super Contributor
timestamp: June 14, 2015, 09:44:47 pm
content: 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.

author: 10101
author_rank: Contributor
timestamp: June 14, 2015, 09:48:20 pm
content: 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

author: Falcon69
author_rank: Super Contributor
timestamp: June 14, 2015, 09:53:14 pm
content: 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.

author: karlmag
author_rank: Contributor
timestamp: June 14, 2015, 10:54:01 pm
content: 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 outputsleds 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.

author: SL4P
author_rank: Super Contributor
timestamp: June 14, 2015, 11:15:39 pm
content: 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.

author: Falcon69
author_rank: Super Contributor
timestamp: June 14, 2015, 11:18:38 pm
content: 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 inOUTPUT - 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.

author: SL4P
author_rank: Super Contributor
timestamp: June 14, 2015, 11:29:40 pm
content: 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!

author: 10101
author_rank: Contributor
timestamp: June 14, 2015, 11:38:46 pm
content: Yeh shift registers can confuse a bitAnother 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

author: Falcon69
author_rank: Super Contributor
timestamp: June 14, 2015, 11:40:49 pm
content: 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.

author: 10101
author_rank: Contributor
timestamp: June 14, 2015, 11:41:21 pm
content: PS: From the equation shown in wiki you would need 7 pins to drive the 42 outputs.

author: Falcon69
author_rank: Super Contributor
timestamp: June 14, 2015, 11:42:06 pm
content: 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.)

author: SL4P
author_rank: Super Contributor
timestamp: June 14, 2015, 11:45:18 pm
content: ok, a bit of clarification...With SRs, you can most likely get away with 3-4pins for all your I/oYes 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.

author: Falcon69
author_rank: Super Contributor
timestamp: June 14, 2015, 11:46:44 pm
content: 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.

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 12:06:51 am
content: Okay, here's a quick sketch. Does this make sense?

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 12:08:10 am
content: Darn those invisible attachments!

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 02:32:47 am
content: 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.

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 02:34:27 am
content: Limited to somewhat less per port

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 02:41:41 am
content: 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?

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 02:45:03 am
content: Let's take a step back.Donotin this case connect the LEDs directly to the micro.Use 74xx595 or TPIC595 chips for output. And the complement to those as input registersIf you think as a rule of 10-20mA max per pin, andmaybe100mA per 8-bit port

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 02:53:12 am
content: 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.

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 02:57:12 am
content: 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.

author: hamster_nz
author_rank: Super Contributor
timestamp: June 15, 2015, 03:57:20 am
content: 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)

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 04:05:10 am
content: NoUse (say 6 pins)totalfor 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

author: miguelvp
author_rank: Super Contributor
timestamp: June 15, 2015, 04:15:04 am
content: 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-billboardhttp://www.cypress.com/?rID=103610http://www.cypress.com/?rID=57336Edit: I forgot:http://www.element14.com/community/thread/23736/l/100-projects-in-100-daysBut 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)

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 04:22:02 am
content: how do you put the inputs onto a shift register?I've been tryin to understand, but, ....well, I'm still confused on how the Microcontroller sends data.Say the N/O jumper is on, will the microcontroller recognize it is on, and send different signal to light the correct LED's? Or, if all the Sensors are on one shift register (still don't understand the input into Microcontroller that way), will the microcontrol again send the correct signal to the corresponding LED's related to that sensor?

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 05:08:35 am
content: Okay, I'm more of a visual person, and now that I see how it works, I understand, at least this part of it...So, the microcontroller sends the information to the shift register, 8 bits at a time (each time he presses 'clock' is 1 bit), based on the 1 or 0 that is in those 8 bits, determines which LED is turned on. Then, the microcontroller sends a latch command (sends that pin to high), and those LED's that had 1 as the byte come on. It all happens so quick, that all the LED's that are suppose to be on, while others shift off, don't flicker to the human eye.However, I'm concerned with this. If the optoMOS flickers, even though I won't be able to see it (even if I could see inside the optoMOS), it could turn off/on rapidly whatever is turned on/off with the optoMOS.So, I need to know how to solve that problem, perhaps a small cap (0.01uF) on the gate of the optoMOS?So, I understand how that works. The microcontroller can read the program and check and see if certain inputs are high or low, and assign the proper bytes to the shift register to turn on the correct LED's. Easy enough, I just need to understand how to do the programming.However, what SL4P says about all the inputs on one (or 3 shift registers in this case, 8 sensors times 3 inputs each with an extra for Reset LED Switch, which can be on its own microcontroller output) shift register confuses me. I don't understand how that works.

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 05:22:00 am
content: The shift registers cascade up to 8-6-24-32--- bits in a rowFor SR inputs, use a similar 'latch-in' strobe to capture all the optos / sensors at one moment in time, repeating every however often you want to sample.

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 05:28:32 am
content: sorry, I don't understand what you mean. I have not learned those terms yet.

author: MarkF
author_rank: Super Contributor
timestamp: June 15, 2015, 05:32:35 am
content: I haven't personally used these. But you may want to consider one of the SPI or I2C I/O Expander chips available.The MAX6757 is a LED Display Driver and I/O Expander and is available at Mouser. Each pin can be configured as a LED driver or a Schmitt logic input.http://www.mouser.com/ProductDetail/Maxim-Integrated/MAX6957ANI+/?qs=sGAEpiMZZMsPdFgpQMKDR%2fOo0Y%252b3%2fmKRtz9bQzpEbwI%3dThese could be driven by an Arduino or Microchip PIC microcontroller.The update rate for the sensors will be something you need to figure out in picking your hardware and microcontroller.I would stay away from shift registers. It's a lot of extra work packing and unpacking the data. If you want to do something along these lines, consider parallel I/O with an address and data buses to something like 74LS365 Hex Buffers and 74LS174 D Flip-Flops . Similar to reading and writing to memory. This would require a microcontroller with 2 ports to clock the data in and out. It's also a lot faster than the serial option.

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 05:41:43 am
content: Thank you MarkThat chip is $8 though, and I would still require a Microcontroller (another $5). I'm trying to keep the cost down. If it is just code that could be a pain, code is free. I think for my application, this all will be fast enough (i think).What would the speed be anyway, from Sensor>Microcontroller>OptoMOS, using the Microcontroller with Shift Register method? I know it will be slower than the Sensor>LogicGate>OptoMOS. But, How much slower we talking about? A full second?

author: MarkF
author_rank: Super Contributor
timestamp: June 15, 2015, 05:46:36 am
content: A good option for all you LEDs might be a small display where you could draw a large filled dot to represent a LED at a minimum.These Color OLED displays from Adafruit have a SPI interface and are easy to program.http://www.adafruit.com/products/1431

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 06:00:25 am
content: that would be cool, never thought of using a full display. but, I think that will bring my cost way up! Currently, I'm at $63 cost per when making 100 units (includes 5 sensors/switches and cable). So, just for the circuit board/display, I need to be under $20 if I can.Using shift registers, I think I can get like an 18 I/O pin microcontroller? Those are only like $0.80 each, that will help, but the shift registers are about $0.20 each.

author: Hideki
author_rank: Frequent Contributor
timestamp: June 15, 2015, 06:01:53 am
content: You would use ONE, yes only ONE microcontroller pin for ALL inputs. Each shift register takes 8 inputs and outputs them as a series stream of data, and you can chain as many shift registers together as you want, with still only ONE output coming out of the final shift register (74HC165 or similar). So with 3 shift registers you get 24 inputs, serialized down to a single bit. To get the data out, you need one more microcontroller pin to latch all 24 inputs before you start reading them and yet another microcontroller pin to clock out each single bit.24 inputs now only require 3 pins.For driving LEDs, the same idea is used, just in the other direction. ONE microcontroller output goes into a different kind of shift register (74HC595 or similar) which each has 8 outputs, so with three of those changed together you can get 24 outputs. Now, they also need clock and latch signals, but if you program it properly, you can reuse the same signals as for the inputs.24 inputs and 24 outputs then only requires 4 microcontroller pins in total.

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 06:07:44 am
content: FFSwe're going off on tangents here!SPI / I2C are both effectively shift-register interfaces anyway - you do the same in code for the most part (unless SPI is implemented in hardware, but not much different). I2C has learning curve that is probably not warranted in this application.If you like to look at SPI, think of software pumping to/from shift registersexactlythe same way (MISO / MOSI / CLK) they are EXACTLY the same.If you do what you're thinking of in a PIC or AVR - with shift-registers (of any sort) - the component cost for CPU & interfaces & standard R+G LEDs will be well under $10. Add a PCB and the physical connectors / pushbuttons - all done.I'd be surprised if it costs you any more than $20 with smart shopping-around.Adding an OLED will push you up to the next level of CPU and development skills with font memory and OLED libraries etc. forget it unless the device is going to be reconfigured every day for different applications. Worst case - you could use a TTY serial port to make config changes.Add in the enclosure, the opto whatsits - and you're still in around $30 for a finished device cost

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 06:12:08 am
content: Quote from: MarkF on June 15, 2015, 05:32:35 amYes - clocking 8 bits in, then copying that to a byte variable is hard work, and vice-versa for output.

author: MarkF
author_rank: Super Contributor
timestamp: June 15, 2015, 06:12:57 am
content: Quote from: Falcon69 on June 15, 2015, 05:41:43 amYou have to consider all the other chips it replaces plus all your time to build and debug 100 of these.Quote from: Falcon69 on June 15, 2015, 05:41:43 amIf you have three 8-bit shift registers in series to make up your 24 bits, you need to 24 clock cycles one bit at a time. Where as if you have three 8-bit latches, you only need 3 clock cycles to get all 24 bits out. I don't know how fast you hall effect sensor data is changing but for a momentary push button switch that a human will push you would want to read the data at 20Hz. At slower rates you will probably miss some of the presses.At a 20Hz sample rate:Serial shift registers will take a 24 * 20Hz = 480Hz update rate for the processorParallel registers will take 3 * 20Hz = 60Hz update rate for the processorAnd this is just for the input. Clocking serial data from a processor will eat up a lot of processor time. Plus adding the time you need to actually process the data and you can quickly reach the limits of the processor.

author: rs20
author_rank: Super Contributor
timestamp: June 15, 2015, 06:25:46 am
content: MarkF -- I've made a display with 88 output LEDs on traditional shift registers running at 512 Hz refresh rate (just for laughs) with a majority of CPU time free to burn. If you're think bit banging 80 I/Os at 60 Hz is even remotely difficult, you're doing something seriously wrong (e.g., using Arudino's super-slow digitalWrite function). Also, I didnt, but as SL4P points out, SPI is a shift register based protocol -- so you could use the SPI feature on the uC to drive a traditional shift register if performance is an issue (which it really, really isn't).Falcon69 - shift registers are the answer, whether traditional, SPI, or i2c. If you find them confusing, find some way to learn, including asking specific questions.SL4P -- I feel for you.

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 06:25:51 am
content: Not worth continuing until a clear spec is provided.We can design it any number of ways, but none will be any good if it doesn't do the job at the price.Thanks R2D2. (RS2)

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 06:38:25 am
content: AN OLED or TFT Display would be nice, but I think the cost will be too much. Right now, I'm having panels etched with name on them, as well as board made for the LED's and reset switch laser etched/cut from Black Acrylic. I could save that money by replacing all of that with a small 1.8" or slightly larger TFT Touch Display (touch to activate the switch).But, again, I think that will make the cost higher.But, here's another thought.....I could buy a butt load of Arduino Minis, and TFT Displays. I think with some smart shopping i can get cheaphttp://www.aliexpress.com/item/Free-Shipping-New-3-0-TFT-LCD-Module-Display-For-Arduino-Touch-Panel-240x400-Pixels/1399950278.htmlhttp://www.aliexpress.com/item/Free-Shipping-new-version-5pcs-lot-QFN-Pro-Mini-328-Mini-ATMEGA328-ATMEGA328P-MU-3-3V/2020619250.htmlhowever, I am not sure if the bootloader program is loaded on these chinese ones.Then, all I would need to do is have 4 hc165 and 1 hc595 shift register. 1 of the HC165 to control the 8 sensor inputs, 1 to control the N/O or N/C jmpr inputs, another to control the switch connect (to sense if sensor plugged in or not), and the last HC165 to control the rear panel LED's. Then just two HC595 to control the optoMOS and the rear Panel LEDs. All I would need then is just a 8-way Dip switch for the jmpr for the N/O or N/C selection. Except for a few resistors, 8x optomos's, and caps, I don't think I would need anything else, except maybe for some ESD protection devices on the optomos'.But, going this route, I don't think I can get under that $20, but maybe. The Etched front Panel cost will still be there, because I'll have to redesign it to fit the display, but, I would save alot of labor plus the cost of the board for soldering up all those front panel LED's.

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 06:42:44 am
content: Ok I can't resist one last post for now.One PIC or AVR will do all of this in spades. Nothing special at all.You're making this sound like a lunar landing. It isn't - sorry.

author: Falcon69
author_rank: Super Contributor
timestamp: June 15, 2015, 06:48:59 am
content: oh, i know it's an easy program, but, I'm new at this, so until I can understand more, it is a Lunar Landing for me. LOLAnyway, this is what I have currently....EDIT: I give up on tryin to make the youtube video start at a time. just fast forward to 25 seconds, and you'll see my current design working. Heh, you can even see the board with all the logic chips. And yes, this is my first ever project done with electronics. A few here on the forum helped me with it earlier this year/last year. Although, this is like the 4th try (4th time ordering circuit boards/prototyping)I don't make much money off these currently (why i need to get cost down) as it takes me like 8 hours to make one kit. But, I'm learning this electronic stuff and it gives me something to do during the day. I sell maybe one of these every couple of months.So, as you can see, there can be a huge improvement on time to make (mostly it's the darn switches that take forever, having to solder components, cable, then cast in resin).

author: SL4P
author_rank: Super Contributor
timestamp: June 15, 2015, 06:51:08 am
content: That's a really good point.For production - eliminateeverymanual connection that you can.No soldering, lugs, crimps - anything if you can do it!

author: Rick Law
author_rank: Super Contributor
timestamp: June 16, 2015, 04:10:24 am
content: Quote from: Falcon69 on June 15, 2015, 06:38:25 amAlso look at this 1.8 inch 160x128 TFT; it is in the $4 range plus shipping. The Github library works without modification, so the software challenge is minimal.The SD doesn't have to be connected for the TFT to work.It is however on the slow side. I can do I2C with the 2004 LCD writing the same string at about the speed of writing to this TFT with SPI.

author: westfw
author_rank: Super Contributor
timestamp: June 17, 2015, 03:34:39 am
content: To me, it looks like you have 8 (hall effect) sensors controlling 8 (SSR/MOS) outputs.In addition, you have a bunch of configuration jumpers (~16), and a bunch of status LEDs, and a "test" switch. However, these are human-scale timed rather than 'real time', so they can be read and written much more slowly and "creatively"ifthat turns out to be cheaper. For example, you mentioned that you can't drive all 52 LEDs and meet the power restrictions of most microcontrollers, but I say you don't have to because you can use a multiplexing scheme that appears to light 52 LEDs, but actually only applies power to, say, 8 at a time - a simple multiplexing scheme will do this with in between 8 and 15 pins. Similarly, the jumpers can be read using other schemes that preserve pins.On the other hand... I don't quite understand the suggestions for fancy LED controllers that I keep seeing. I'm sure a MAX6757 is a swell chip, but at $8+, it's likely to be more expensive than adding pins to some microcontroller family member. (price of ATmega1280 (100 pins) minus price of ATmega328 (28 pins) is also ... abut $8 :-) ) (OTGH, the maxim chip may also eliminate a bunch of "minor" support devices (current limiting resistors, etc) that end up costing extra anyway...)Implementing a Digital Clock using an Arduino or similar board would be a good introduction into the sort of programming and display driving that your product is likely to require. It's also a really common project, with lots of information available...

author: rs20
author_rank: Super Contributor
timestamp: June 17, 2015, 04:33:34 am
content: Westfw,Shift registers do not cost $8. Maybe someone found some $8 chip during their search, but 8-bit shift registers are well under $1. And, as you hint at, some of them eliminate current limit resistors too.Also, all the pins on a high-pin-count micro will generally have the same max current limit, which is the real killer. With shift registers, the LED current does not count acounts your uC supply pin current budget. However, as you point out, with multiplexing, the current requirement might not be as high as it seems, and a single uC might be an acceptable solution. Just depending how bright you need the LEDs to be; and therefore how much sum total average current you need running through them.

author: Richard Crowley
author_rank: Super Contributor
timestamp: June 17, 2015, 05:15:05 am
content: Quote from: rs20 on June 17, 2015, 04:33:34 amThey appear to be talking about the MAX7219 and MAX7221 LED driver chips. They do cost nearly $10 each.However, they are designed to drive 64 LEDs (wired in an 8x8 matrix)

author: Kremmen
author_rank: Super Contributor
timestamp: June 17, 2015, 10:10:51 am
content: Quote from: Falcon69 on June 15, 2015, 05:41:43 amJust as a data point to your question regarding speed: I have a project where i drive a touch panel LCD display using SPI interface on an Arduino Due. The clock is maxed out at half MCU clock speed, i.e. 42 MHz. The SPI channel is also Direct Memory Accessed so it is as fast as easily possible to make it. The display updates far faster than the eye can see so i would be very surprised if you had any speed issues whatsoever with a few LEDs. In any case you can easily clock into the MHz range using any modern MCU. At 1 MHz it takes 8 us to send/receive one byte of data. Should be a piece of cake.

author: MarkF
author_rank: Super Contributor
timestamp: June 18, 2015, 11:16:36 am
content: Quote from: Falcon69 on June 14, 2015, 11:18:38 pmYou seem to have many LEDs displaying the same data at different locations??? Can you have LEDs only the front panel and reuse them to display your different data sets? It doesn't seem like you really need to show which sensors are plugged in and their N/C selection all the time.Food for thought: Reduce the number of LEDs allowing you to recall the data as needed.For example, can the switch sequence through your "Normal Status" to "Lamp Test" to "Sensor Plugged In" to "N/C or N/O Select" and loop back. Having the processor time-out and return to "Normal Status" after no switch presses for 5 or 10sec.Maybe even save the configuration info (sensors plugged in and N/C or N/O) in the microcontroller EEPROM instead of switches. How often does this data change?Do you really have 8 optoMOS? If you have 6 or less, you can have In-circuit Serial Programming for the microcontroller.Here's a drawing of what I was thinking:

author: rs20
author_rank: Super Contributor
timestamp: June 18, 2015, 11:29:35 am
content: As a counterpoint, a device that displays all salient information at a glance is worth an extra $20 to the end user. But since I don't really understanding the specific use-case here, I freely admit I don't know how important/relevant all this information is to the end user.

author: Falcon69
author_rank: Super Contributor
timestamp: June 19, 2015, 04:01:36 am
content: close MarkF, But not quite.here is a sketch i drew of what i'm after.Each sensor will be on its own cable, up to 50ft (depending on machine size, as the cable needs to travel through Cable Drag Chains), and have two LED's. The sensors are encased in clear resin, and when the LED lights up, the whole case lights up that color. So the visual effect is neat looking. So, when the sensors is plugged in and in it's normal state, a green LED is lit (or blue if the customer chooses blue instead), and then when the magnet triggers the sensor, it will switch from the green to the red color, when the magnet is pulled away, or the machine is done homing, then it switches back to the green LED...Normal state.Now, when the user wants the switches to work in normally open mode (instead of the default normally closed), then a jumper is selected and the optomos will switch to that. So, in Normally closed state (default), the LED inside the optoMOS will be ON, indicating that the optoMOS is fully turned ON and in normally closed mode and will only turn off when the sensor is triggered. But, if the jumper is selected, then that LED is off and ONLY turns on when the sensor is triggered, thus, normally open mode. Each normally open or normally closed selection will also have a 2 color identifier to let the user know which is selected.Now, there will be a front panel that will have the matching LED's of each sensor. So when the sensor is triggered, not only do the colors switch on the sensor, but they also switch on the front panel.Also on the front panel will be a test switch that will turn on all LED's in the circuit, so that they can be identified easily if one has burned out. That test switch will have a red LED that will turn on when the switch is pressed.Now, for the rear panel where all the connections for the sensors are made, there will be two LED's on that panel. A green (or, again, a blue if user desires) and a red. The green stays on, but switches to a red color if a sensor has triggered (ANY sensor). Kinda like the jack where your Ethernet cable plugs into, as it blinks when data is received.I also want to make it so later, an LCD or graphical LCD can be plugged in. Later in the future, I want to add features such as monitoring stepper positions that will read out on the display, as well as maybe some other things I may think of, so I will need some extra inputs on the Microcontroller for that.The rear panel will also have some kind of a plug in sensor on it to monitor if a sensor has been plugged in. If a sensor is NOT plugged in, then all LED's on the front panel for that Sensor jack will be turned off, as well as the optoMOS and NC/NO jumper LED's. There's no sense in having visual indication for something not even plugged in.Also, if there is another option...the optoMOS is abit expensive at $0.85 each when bought in 100. But, I am not sure that a transistor based (i.e. optoisolator) will work. It might make too much of a voltage drop across the optoisolator.I'd like to have the voltage down the cables for the sensors to operate at 24volt if possible. That would be at par with some of the more expensive industrial machines whose proximity sensors and mechanical switches operate at 24volts.Currently, I have four 28awg wires inside the double shielded cable going to the sensors. I would like to reduce that amount, so that the cable can be smaller diameter, if possible.

author: MarkF
author_rank: Super Contributor
timestamp: June 19, 2015, 11:11:21 am
content: WOW....I think you need to go back and define what your requirements are. You seem to be wanting more and more and still expecting to reduce the cost. I'm seeing two options here:LOW COST OPTION:1) Add microcontroller2) Move as much functionality into software3) Keep the hardware to a minimum4) Eliminate all LEDs and switches on your main board. Set the number of sensors and the N/C selection in software when the microcontroller is programmed. Provide a way to examine the configuration from the front panel.5) Combine the Rear Panel and the Main Board into one6) No expansion capabilitiesMUCH HIGHER COST OPTION:1) Add a larger microcontroller2) Add a general purpose I/O system (No shift registers). The I/O would be accessed the same way the microcontroller accesses memory. With an address bus and a data bus. It would be expandable from 1 to 256 bytes of inputs and/or outputs.3) Allow for LCD or other type of display. Microcontroller would need extra memory and have a hardware SPI at a minimum. Provide buttons and/or an Encoder to control the display.4) Level shift sensor inputs for 24V option.5) Allow for stepper motor monitoring.As an aside question:What do the optoMOS do? Could they be driven directly from the sensors and not come from the microcontroller?

author: miguelvp
author_rank: Super Contributor
timestamp: June 19, 2015, 11:53:20 am
content: This $10 PSoC 5LP prototyping kit should fit the bill:http://www.cypress.com/?rid=108038Specs and datasheet:http://www.cypress.com/?mpn=CY8C5888LTI-LP097But you will have to consider the ramp-up to learn what it can do and how to program it appropriately.I think it has all the support for everything you need including driving the LCD.Edit: the prototyping kit is definitely subsidized by cypress because the cost of the actual main MCU is more than the kit, plus the kit has 2 PSoC 5LPs (one used to program the other)So for something already built into your design you will have to consider the cost per chip (~$10 large quantities) or just make sure you can provision enough prototyping boards

author: MarkF
author_rank: Super Contributor
timestamp: June 22, 2015, 05:14:07 am
content: Quote from: Falcon69 on June 19, 2015, 04:01:36 amI modified a circuit I'm using for another project that I think will check a few boxes on your wish list for the sensors. I'm assuming a 20mA current for your LEDs and that the Hall Effect sensors are capable of switching 24V @ 20mA to be on the safe side. The circuit will eliminate all your configuration switches for the sensors. It will provide the plugged-in status and the processor will always receive the same True/False state polarity.Not sure what the impact of a 50 ft cable will have on the LED brightness. Also, your cable will only need 2 conductors.

author: Falcon69
author_rank: Super Contributor
timestamp: June 22, 2015, 05:38:44 am
content: Thanks Mark.My original design called for an opamp/comparator as well, but i took it out and it operates fine without it.Also, that design will not work. The NO/NC is done at the optoMOS point, not at the sensor point, as the way you show it, the sensor needs to operate as normally open, which just can't happen with a unipolar hall sensor. at least, not operate the way i want. Also, that's just a single color LED visual indication. I'm after a two color set-up.Yes, the sensor works up to 28 volts and switches up to 25mA of current. the LED's on the sensors are operating at max mA to try and get the brightest possible effect. Ultimately, with a microcontroller, I'd like a dimming option for this for areas where it isn't so bright and the led's can be turned down.at 50ft, I'm noticing about a 0.3v drop from mainboard to sensor. so it does effect the LED's a little bit. That is why my current design operates at 5.3v to compensate for the voltage drop along the length of cable.

author: MarkF
author_rank: Super Contributor
timestamp: July 04, 2015, 12:36:05 pm
content: I ran across the drawings I did on my desktop and I was wondering how you're making out with your design?I started fooling around with it this morning and put together my initial thoughts of an addressable I/O where you read/write bytes of data. The drawing shows latches with individual clock lines from a PIC (i.e. PORT_B). This way you can write to more than one set of LEDs if the data is the same. There are still a few unused PIC pins if you need more LEDs. The enables to read the switches are on PORT_E.I believe 74HC374 Latches can drive your LEDs directly without the need for the ULN2803.Also, the extra pins on PORT_A could be used for individual LEDs like the 'any sensor activity' indication.You could eliminate your switches by entering the data via a touch panel display.

author: MarkF
author_rank: Super Contributor
timestamp: July 06, 2015, 06:21:17 am
content: An option to use RGB LEDs to provide a single row with multi-color instead of your current two rows (one red and one green).Where:3 = Off2 = Red1 = Green0 = YellowIt would require more driver chips if you want the option of all three colors.

author: rs20
author_rank: Super Contributor
timestamp: July 06, 2015, 07:01:37 am
content: Quote from: MarkF on July 06, 2015, 06:21:17 amYou can also get two-legged two-colour LEDs, which are simpler to layout and presumably cheaper.Quote from: someoneOh, but yes you can: PWM rapidly between red and green and you'll get yellow.Also, you can get red/green three legged LEDs. All I'm saying is, don't be buying blue LEDs you're not going to use! Unless, indeed, it's cheaper through the madness of supply and demand.