4 ms·
So, I'm actually looking right now for a microcontroller to run a bunch of real-time I/O that may involve a certain amount of fairly timing dependent bit-bangin
by lambda 13y ago
So, I'm actually looking right now for a microcontroller to run a bunch of real-time I/O that may involve a certain amount of fairly timing dependent bit-banging. I'm planning on building a pinball machine, and so need something that can take input from a couple of buttons, a bunch of switches and some sensors, and drive a bunch of solenoids, LEDs, and the like.
Since I will need to do a bunch of PWM or possibly bit-banged serial protocols to drive all of the LEDs, and I want to have good real-time guarantees on input from the buttons and driving the solenoids, I'm trying to figure out what microcontroller I should use; something like a Propeller, or an FPGA, or maybe one of these, or something else entirely.
Anyone have any experience with these kinds of issues? Will the GA144 be able to do some fairly timing-dependent bit-banging reliably? I notice in the docs that they say the time it takes for each instruction to execute is not fixed. How would you go about doing a timing dependent protocol on these? Is there a high-resolution timer you can poll to ensure that your transitions occur in a timely manner? Or should I bite the bullet and start learning FPGA programming?
- sehugg 13y agoYour solenoid response time is likely to be much, much slower than the bit-banging rate of any modern uC. A standard PIC or similar would do fine (assuming it has the I/Os you need).
- lambda 13y agoFor solenoids, sure, though some of them (the flipper solenoids) need to be PWMed to vary their strength; you do a full-strength pulse at the beginning to drive the flipper with a good amount of force to hit the ball, but when you hit the end of the stroke, there's a switch that tells you to switch to PWM with a low duty cycle so you avoid overheating the solenoid but can still hold the flipper up to trap the ball. So you need at least the ability to PWM that. Sure, I could probably build a little timer circuit to do that, but it would be convenient if I could just bit-bang a GPIO pin instead of building more hardware. For driving a few dozen RGB LEDs with PWM to control brightness on each of the three channels, you're very quickly going to reach the limits of what you can do with a standard PIC. Or even if not driving the LEDs directly but using something like these: http://www.adafruit.com/datasheets/WS2812.pdf http://www.adafruit.com/datasheets/WS2812.pdf you need to be able to produce a fairly high precision 800 khz serial signal with no clock. Between the number of inputs and outputs needed (lots of switches and sensors on the playfield, lots of solenoids to kick out balls and control various toys, lots of LEDs), and the high-speed output needed to drive the LEDs, I'm not sure a standard PIC is going to cut it, though I haven't actually sat down to calculate out the precise number of I/Os and speed that I'll need so I may be wrong. I'm more looking for a ballpark of what I should get a dev board for and start playing around with, I may wind up changing my mind and switching to something else later.
- ers35 13y agoTake a look at XMOS: http://www.xmos.com/ http://www.xmos.com/
- lambda 13y agoCan you tell me a little about it, and why I should prefer it over a GA144, FPGA, or Propeller? I have a lot of options already, I'm looking to narrow them down, not expand the list to have even more to consider; but if there's a compelling reason I'll take a look.
- digikata 13y agoYou might look into an io expander chip to hook to your pic via I2C or some other protocol. Many of them also have a few PWM outputs. 4, 8, or 16 additional GPIO's are pretty common, and higher pin count expanders are out there, but they get a bit more specialized as the counts go up.
- sehugg 13y agoFor the LEDs and solenoids I'm guessing the PWM frequency is in the sub 1 kHz range, so you should be able to bit-bang perfectly well with even a low-powered uC. Timing precision for those shouldn't be very strict. As for the WS2812, that's annoying :) It would be nice if it could use SPI or a UART. I see the NeoPixel library uses bit-banging with interrupts disabled and relies on instruction timing, yuck. But hey, it might work. I've seen single-wire stuff work on Windows CE, for crying out loud. AFAIK you don't need a continuous 800 kHz signal, you can just send it when you want to update.
- lambda 13y agoYeah, the WS2812 does have a fairly unique interface, but at 45¢ for an RGB LED with a built in constant current driver, it's pretty much the cheapest option per LED. Other options I've seen like the A6281 are $2 for just the driver itself, without the LED. Since there are probably going to be at least a few dozen LEDs, the per LED cost can add up quickly, so I'm fine with spending a bit more on a more powerful microcontroller or FPGA and learning a new system. And of course, part of the goal is to learn new things and have fun with the project, so some of these new highly parallel microcontrollers like the GA144, Propeller, XMOS, or even an FPGA would be more interesting to work with than a standard PIC, even if they may technically be overkill. This is the first time I've done hardware hacking in a while; the last time I did it I used a 68008 as my microcontroller. So I'm hoping to find something that will be interesting to learn, not too hard to use, and capable of everything I'm going to throw at it, so I don't have to go through several iterations of buying expensive development boards only to discover that I can't drive my dot matrix display or I can only drive half of the playfield LEDs that I need or that interrupts from the flipper buttons cause my LED color fades to flicker since they screwed up the timing of my signal to the driver or something of the sort. One of the problems is that since there are so many choices, and I haven't done hardware hacking in a while, I don't have a good sense of what I'll be able to do yet. Maybe I should start small, with an Arduino or a PIC or something of the sort, and move up if I discover that that can't do something that I want.
- xradionut 13y agoCheck out what Ben Hack did when he built his custom pinball machines. http://benheck.com/02-12-2012/run-your-pinball-dmd-with-a-parallax-propeller http://benheck.com/02-12-2012/run-your-pinball-dmd-with-a-pa...
- lambda 13y agoYes, that's what inspired me to look into the Propeller, which is an interesting architecture with 8 cores and no interrupts; instead of interrupts, you just dedicate one or more cores to polling for input, while the other cores continue on doing their thing with no interruption. The GA144 basically looks like an even more extreme version of that idea. Instead of eight small cores, it has 144 really small cores. So now I'm trying to figure out which I want to start playing around with; a Propeller, a GA144, an FPGA, or something else.