PDA

View Full Version : Cheapest Microcontrollers?



NogginBoink
12-06-2008, 12:22 AM
I'm planning an integrated DMX512 4 channel SSR board.

Since SSR boards are boards that I'll be making many copies of, containing cost is a priority.

I'm looking for the cheapest microcontroller I can find that'll support 6 I/O pins. The cheapest I've found that might (might) work is the PIC16F54, which retails for $0.48 in single unit quantities.

I'm not at all certain that I'll be able to get the project working with this chip. Receiving serial data at 250 kbps while simultaneously dimming 4 channels, without a UART, without interrupts, and with only an 8-bit timer (with no overflow interrupt!) is going to be a challenge, to say the least.

So I'm hoping some of you might know of some dirt cheap non-Microchip parts that might interest me.

P. Short
12-06-2008, 12:38 AM
My personal opinion is that you are not going to be able to receive DMX without the use of a UART. One micro that has a built-in UART is the 89LPC903, which was mentioned in another thread here. It is an 8051-style micro from Philips. I've never used it nor read the datasheet in detail, so I can't really comment on it.

YMMV.

NogginBoink
12-06-2008, 01:17 AM
The problem is that a UART adds a dollar or more to the cost of the chip.

Receiving data without a UART isn't too hard (well, at least not when you can detect the start bit with an interrupt and have a timer interrupt).

The 8051 you pointed to costs over three times the cost of the 16F54. Which is no big deal if you're making one SSR board, but if you're making fifty, that money can add up.

mrpackethead
12-06-2008, 03:01 AM
My personal opinion is that you are not going to be able to receive DMX without the use of a UART. One micro that has a built-in UART is the 89LPC903, which was mentioned in another thread here. It is an 8051-style micro from Philips. I've never used it nor read the datasheet in detail, so I can't really comment on it.

YMMV.

For what its worth, i'll be really impressed if you can reliably do DMX ( at 250kHz ) without a UART either, on a really low cost chip. Never say never, but it seems pretty unlikely..

maybe you coudl look at the PIC16F688.. Its the lowest cost PIC with a UART on it, internal clocking and enough IO pins.. mind you then you could probalby just use the code that has already been done..

P. Short
12-06-2008, 12:11 PM
My estimate is that you need to execute instructions at approximately 25 times the bit rate in order to do a software UART while doing three or four PWM outputs at the same time. That is my experience with the the PIC10F200, anyway. Using this rule you would need to be able to execute around 6 Million instructions/sec to handle DMX512 speeds. To do this with a PIC would require a clock rate of 24 MHz, which (if the PIC could handle this clock rate), which needs more pins for the resonator/crystal.

Maybe something out of the ATtiny family would work, as I think that they have a smaller internal clock divisor.

P. Short
12-06-2008, 12:21 PM
The problem is that a UART adds a dollar or more to the cost of the chip.

Receiving data without a UART isn't too hard (well, at least not when you can detect the start bit with an interrupt and have a timer interrupt).

The 8051 you pointed to costs over three times the cost of the 16F54. Which is no big deal if you're making one SSR board, but if you're making fifty, that money can add up.

If you take a look at your BOM I suspect that you will find that the cost of the micro is not the dominating factor. In my 1-channel SSR project the micro is only about 1/3 of the cost, the rest is PCB, SCRs/Triacs, connectors and the like. I suspect that the same thing will be true of your project, with the added advantage that the microcontroller costs are divided over four channels.

NogginBoink
12-06-2008, 04:07 PM
This is all good input. Like I said, I'm not at all certain I could do it, but pondering the challenge is kind of fun. I'll let the board know if I go anywhere with this.

awhaley
12-10-2008, 03:35 PM
Noggin, I'm considering a similar idea, so we should talk at some point...

I also came to the conclusion that a low end chip without an uart wouldn't be able to handle the full DMX data rate, plus pwm for 4 channels, etc...

My idea to fix it was use a separate controller board with a higher spec PIC that takes the dmx signal(Via UART), processes it, then bit bangs it out in parallel down several lines - So for example if you used 8 pins of the controller chip, you would send only 64 channels down each wire. So the backside of this topology would be operating 8 times slower than the dmx front side, which seems way more feasible. The controller chip would also process the zero cross signal, and relay a zero cross pulse (on a different data line) to the downstream 'sub controllers.'

As for wiring, I was thinking about cutting people's costs by running it down either 4 or 6 conductor phone line. Each line would carry 64 channels of data on one wire, zero cross pulses on a second, then +V and ground on the remaining two. If I had trouble making the low end chips receive the data reliably, I was thinking about upgrading to 6 conductor wire, so I could add a 'clock' line, which would be used similarly to the clock that PIC programmers use during the chip's flashing.... transitioning the clock line everytime there was a new data bit available on the data line, so there would be no timing to worry about on the bit banged side of things...

My first project for the new year is probably going to be using PARTS of this idea to make a cheap intelligent pixel system... I'll post more details when I start tinkering, but a 50 cent 16F54, directly driving Red, Green, Blue, and White LEDS could make for a completely addressable pixel for around a dollar... using the 'bag of 100' LEDs from ebay... Also for this project (though not as useful for the SSR/dimmer project) I'm going to run the numbers, as one PIC with a higher pin count running 4 or 5 pixels instead of a very low end chip running just one may prove more cost effective, and give me more onboard features to work with for my money. Anyway about it, a one dollar serial data, fully adressable pixel could be quite cool. :) I know it's not going to be as bright as the 12 dollar jobs, but you get what you pay for.

And before someone points it out from what I said above.... Yes, I know that the White LED should be unnecessary, as you can mix the RGB pixels to something resembling white, but in my experience (as a theatrical lighting designer) color mixing is a valuable and useful feature to have in your tool box, but is never a substitute for having the right color available in the first place. Mixing white light from saturated primary colors always leaves me wishing I hadn't, even with incandescent sources and the wide variety of primary color shades that can be bought in gels... It's even worse with LEDs, because they produce a very narrow part of the spectrum, so there's even MORE lacking when they mix to white. I'm not happy with the whites I get out of very high end (Color Blast, and Colorado 3) LED fixtures, so I'm certain that my 1 dollar 'ebay special' would leave me unhappy. So I'm including a separate white LED of the highest brightness I can drive directly from the PIC. It's worth it to me, and think about how bright a white I'll be able to achieve when I turn on all FOUR leds at full, and how I'll be able to shift the color temperature, by turning on the white LED at full, then using the blue LED to cool it off, or the red and green to warm it up....

Anyway. If any of what I spewed out helps you on your dimmer project, feel free to chat with me about it. :) Best of luck, and keep soldering!

Art

P. Short
12-10-2008, 03:53 PM
It seems to me that adding a clock line makes things more difficult on the receiving end rather than easier. It takes extra instructions to deal with the clock line, harder to code and probably runs slower. It would be better in my opinion to stick with just a data line.

As far as a zero-crossing goes (if you really need it), you may be able combine it with the power line on a single wire. Connect that wire directly to the zero-crossing input pin on the PIC, and use a diode and electrolytic cap to get the power for the PIC and the output devices.

mrpackethead
12-10-2008, 05:33 PM
Noggin, I'm considering a similar idea, so we should talk at some point...

I also came to the conclusion that a low end chip without an uart wouldn't be able to handle the full DMX data rate, plus pwm for 4 channels, etc...

My idea to fix it was use a separate controller board with a higher spec PIC that takes the dmx signal(Via UART), processes it, then bit bangs it out in parallel down several lines - So for example if you used 8 pins of the controller chip, you would send only 64 channels down each wire. So the backside of this topology would be operating 8 times slower than the dmx front side, which seems way more feasible. The controller chip would also process the zero cross signal, and relay a zero cross pulse (on a different data line) to the downstream 'sub controllers.'

As for wiring, I was thinking about cutting people's costs by running it down either 4 or 6 conductor phone line. Each line would carry 64 channels of data on one wire, zero cross pulses on a second, then +V and ground on the remaining two. If I had trouble making the low end chips receive the data reliably, I was thinking about upgrading to 6 conductor wire, so I could add a 'clock' line, which would be used similarly to the clock that PIC programmers use during the chip's flashing.... transitioning the clock line everytime there was a new data bit available on the data line, so there would be no timing to worry about on the bit banged side of things...

My first project for the new year is probably going to be using PARTS of this idea to make a cheap intelligent pixel system... I'll post more details when I start tinkering, but a 50 cent 16F54, directly driving Red, Green, Blue, and White LEDS could make for a completely addressable pixel for around a dollar... using the 'bag of 100' LEDs from ebay... Also for this project (though not as useful for the SSR/dimmer project) I'm going to run the numbers, as one PIC with a higher pin count running 4 or 5 pixels instead of a very low end chip running just one may prove more cost effective, and give me more onboard features to work with for my money. Anyway about it, a one dollar serial data, fully adressable pixel could be quite cool. :) I know it's not going to be as bright as the 12 dollar jobs, but you get what you pay for.

And before someone points it out from what I said above.... Yes, I know that the White LED should be unnecessary, as you can mix the RGB pixels to something resembling white, but in my experience (as a theatrical lighting designer) color mixing is a valuable and useful feature to have in your tool box, but is never a substitute for having the right color available in the first place. Mixing white light from saturated primary colors always leaves me wishing I hadn't, even with incandescent sources and the wide variety of primary color shades that can be bought in gels... It's even worse with LEDs, because they produce a very narrow part of the spectrum, so there's even MORE lacking when they mix to white. I'm not happy with the whites I get out of very high end (Color Blast, and Colorado 3) LED fixtures, so I'm certain that my 1 dollar 'ebay special' would leave me unhappy. So I'm including a separate white LED of the highest brightness I can drive directly from the PIC. It's worth it to me, and think about how bright a white I'll be able to achieve when I turn on all FOUR leds at full, and how I'll be able to shift the color temperature, by turning on the white LED at full, then using the blue LED to cool it off, or the red and green to warm it up....

Anyway. If any of what I spewed out helps you on your dimmer project, feel free to chat with me about it. :) Best of luck, and keep soldering!

Art

A $1... Good luck.

NogginBoink
12-11-2008, 01:25 AM
The hard part that I forsee isn't so much receiving serial data, as it is that the chip has to handle two time-sensitive tasks (receiving data and dimming), and those two time intervals have absolutely no relationship to each other.

Without interrupts, I don't know if that's possible.

Phil, you're right that the uC is not the biggest line-item expense on an SSR, but I think it's still worth it to optimize the cost. If I'm building a hundred SSR's, each penny saved in parts on one board is a dollar saved overall.

awhaley
12-11-2008, 02:26 AM
Thanks Phil! I'd asked if exactly that (sending zero cross as dips in the power line, which a cap could filter out for the power pin of the pic) might be possible a while back, and I didn't get a response. It was on my 'to try after christmas' list.... and I guess still is. :)

Why do you say that using a clock line is more difficult? I guess I should start off with the fact that I've never programmed a bit banging routine before - this is ALSO something I'll be forcing myself to learn over the next few months. But to my mental reasoning, convincing two PICs to synch up and making sure you never miss a bit and create a framing error seems like a touchy thing if neither is using a UART? I guess when I start reading up on the subject I'll be able to talk more intelligently about the subject... but polling a clock line at around double the expected transmission speed, then if the value is different than last cycle's value reading in a new bit off the data line seems like a very straightforward approach to pretty fault free communications? I need to do some reading before I get too into a conversation about it, so you don't have to repeat info that's easy to google. :)


Edit: because Noggin got in another post while I was typing...
I think you just have to make those two things relate in time.... you update the pwm every timer interval, and read in data every 10th interval, or something like that...


Art

P. Short
12-11-2008, 01:15 PM
Reading the state of a clock signal will chew up a lot of cycles. It might take only 2 or 3 instructions, but that is still a lot when you are talking about a processor executing only 1 million instructions/second and a 30-40 Kbaud data rate.

phenagan
12-11-2008, 02:19 PM
Thanks Phil! I'd asked if exactly that (sending zero cross as dips in the power line, which a cap could filter out for the power pin of the pic) might be possible a while back, and I didn't get a response. It was on my 'to try after christmas' list.... and I guess still is. :)

It's absolutely possible. There is actually a commercial product out there there that scavenges power from the serial stream to power the remote nodes - the iButton system, which utilizes the Dallas One-wire microlan. Dallas was aquired by Maxim a while back and they seem to have removed the how it works info, so here's what I remember...

The remote chips have an onboard diode/capacitor bridged across the signal and ground wires. The signal wire is logic 0 at 5v and logic 1 at ground, and is held at 0 (5V) when no data transmission is occuring. This charges the cap, allowing the chip to continue to operate during the transmission of 1s. The remotes only have to pull the signal line down to ground to transmit 1s rather than provide power to pull it up to 5v as you would with a positive logic system.

Hope this helps!

P. Short
12-15-2008, 06:32 PM
Another possibility is to use the A6281 controllers from Allegro. Since people are talking about using another micro to interface to the PC, there wouldn't be any significant complication in driving this part from the micro instead of bit-banging asynchronous serial data streams. The biggest disadvantage that I see wrt this thread is that there are three output bits instead of the desired four bits. Also, it is a little bit more expensive than the low-end micros, around $0.75 vs $.50.

P. Short
12-15-2008, 07:17 PM
There also might be a way to do native DMX decoding using a PIC16F57 and a 74HCT164, which cost about $.80 total in the SOIC/SSOP packages in qty 100 from mouser...it won't look pretty, though.

One obnoxious apparent 'feature' of the both PIC16F54 and PIC16F57 is that there doesn't seem to be an internal oscillator, so you need either an external oscillator/crystal/resonator or to send a clock signal down the wire.