Hi all:
I've been struggling with a rather simple project using a PICAXE08M2 to try to randomly light and un-light some LED containing cars on a small HO train layout. The cars need 12v (or at least 9v) to light their LED's, so I thought that using transistors with the base connected to an output pin that the PICAXE could pseudo-randomly switch between high to low to light and un-light them. The cars would be on a 12v circuit that passes through the collector-emitter on a transistor.
I'm a bit new to this electronics stuff, so I might have something mis-wired, but I've attached a circuit diagram and my code trying to drive it. The diagram contains 2 manifestations of the circuit, just look at the left or right half (to the left/right of the 5v and 12v input blocks) that runs either cars #1 and #2 or cars #3 and #4. When I run the code in the simulator, the two pins (C.2 and C.4) switch semi-randomly between high and low as the random variable in the code dictates .. so I believe the code is correct. It my physical implementation that is suspect.
But when I take the chip and put it in my circuit board and look at the voltages relative to ground, C.2 stays high all the time (at essentially the same voltage as the 5v supply) and that car's lights remain lit all the time, while C.4 bounces all over the place (but never seems to drop below 0.7v) and that cars lights stay off. I've tried both having a 10kOhm resistor as a pull down resistor on the two output pins (thinking that maybe the PICAXE sends it low but might not drive it down) and not having anything else connected to those pins (i.e. in this case the PICAXE pin is only connected to the base of the transistor. I've also tied the grounds from the two supplies with the dotted green jumper from the top to bottom grounding rails. I have not bothered putting and diodes across the Collector-emitter of the transistor as the LED lighted cars should have very, very low currents (the wires are like gauge 26 or smaller).
I plan to ultimately use a photo-resistor as an override on the random circuit to turn on all lights if the room goes dark. So you'll see remnants of that code in there, but it's been commented out while I test things.
Anyone see what I'm doing wrong? Thanks a bunch!
Jeff
I've been struggling with a rather simple project using a PICAXE08M2 to try to randomly light and un-light some LED containing cars on a small HO train layout. The cars need 12v (or at least 9v) to light their LED's, so I thought that using transistors with the base connected to an output pin that the PICAXE could pseudo-randomly switch between high to low to light and un-light them. The cars would be on a 12v circuit that passes through the collector-emitter on a transistor.
I'm a bit new to this electronics stuff, so I might have something mis-wired, but I've attached a circuit diagram and my code trying to drive it. The diagram contains 2 manifestations of the circuit, just look at the left or right half (to the left/right of the 5v and 12v input blocks) that runs either cars #1 and #2 or cars #3 and #4. When I run the code in the simulator, the two pins (C.2 and C.4) switch semi-randomly between high and low as the random variable in the code dictates .. so I believe the code is correct. It my physical implementation that is suspect.
But when I take the chip and put it in my circuit board and look at the voltages relative to ground, C.2 stays high all the time (at essentially the same voltage as the 5v supply) and that car's lights remain lit all the time, while C.4 bounces all over the place (but never seems to drop below 0.7v) and that cars lights stay off. I've tried both having a 10kOhm resistor as a pull down resistor on the two output pins (thinking that maybe the PICAXE sends it low but might not drive it down) and not having anything else connected to those pins (i.e. in this case the PICAXE pin is only connected to the base of the transistor. I've also tied the grounds from the two supplies with the dotted green jumper from the top to bottom grounding rails. I have not bothered putting and diodes across the Collector-emitter of the transistor as the LED lighted cars should have very, very low currents (the wires are like gauge 26 or smaller).
I plan to ultimately use a photo-resistor as an override on the random circuit to turn on all lights if the room goes dark. So you'll see remnants of that code in there, but it's been commented out while I test things.
Anyone see what I'm doing wrong? Thanks a bunch!
Jeff
Attachments
-
2.8 KB Views: 5
-
188.5 KB Views: 25