Thu May 10, 2012 6:25 pm
brandon said:
GordonH said:
You might need one uln chip per different Vc supply...
What are the cases for "might"?
Well, everycase. If you have a set of 5v for LEDs, then 12V for bulbs, then 2 driver chips, etc.
There is only ONE easilly avalable PWM output. The chip supports 2, but you can't easilly get the 2nd one out.
I'm assuming you're referring to the r-pi only having one easily available PWM output? I may need to rethink this, I thought all the gpio's could be toggled on/off quickly?
There is one pin that can be controlled in a PWM fashion by the hardware - you write a value and it gets on with it.
You can toggle the other pins on & off - but it will need a very tight-loop of a program to do it to achieve something usable - and that will leave nothing left for other program to run and it will not be smooth as Linux will periodically interrupt the program to do something else...
It's just struck me though - you're going to need a lot more outputs than the Pi can provide! You have a maximum of 17 pins on the Pi (if you sacrifice serial, i2c and spi) My own thoughts might be to use something else to do the control - e.g. an Adruino Mega which has lots of digital IO and PWM, and just send it higher level commands from the Pi which is doing the overall control (and e.g. putting up a pretty picture on the display of the track layout, etc.)
Gordon
I can get by with fewer but my current idea was to have individual control over:
Front headlights
Rear headlights
Interior Cab light
Smoke Unit
Ditch Lights (there are two led's and they either are both on or they cross fade with each other -- this is what I wanted to PWM for, so I could have a gpio for each headlight and pwm them independently to dim/cross fade when needed)
Now here is an intersting thing - You can cross fade 2 LEDs with one PWM output. You wire the pin via a series resistor (e.g. 220 ohms) then to the mid-point of 2 LEDs wired from +3.3 to ground in reverse. When the output pin is high, one LED will light, when it's low the other will light. Make that the PWM pin and you can cross-fade from one to the other... I've done this on my Pi.
So I'd need 6 channels/gpio pins ideally. In the future I might also do servo controlled couplers but not atm and they would have two states obviously, open or closed so I'd need 8 channels/gpio pins at most.
sounds like enough then.
I don't think there's anything I'd use serial for. I want to keep wiring/circuits as simple as possible (I'm planning on making this all plug into the G scale plug-n-play sockets so it's a drop in solution) and I'm already writing software to automate a layout based on rfid tags under the track and each locomotive will have a rfid reader and wifi so trains can talk thus make this all easy for other hobbiests to implement, including even outside of Garden Railroading.
So are you putting a Pi on each train? Have to say, I'd probably use something else for this like an arduino, however the Pi solution might be "cooler" ...
Gordon