I have seen circuits and used devices similar to this:
It simply applies power to the track in a direction for a fixed time, then reverses the voltage for the same time.
I want to do this using an Arduino (ATTiny58 digispark module) and a motor driver (Pololu DRV8838). Maybe overkill, but this leaves me pins to do other fun stuff later. Here is what I am thinking. Will I let the smoke out?
My questions:
The 2 caps are values from the 7812. Would I use the same values for the 7805?
Am I going to have problems with the 2 grounds on the DRV8838?
Feel free to ask questions or critique the work. I barely know what I am doing.
edit: Oh, I should mention what the sketch would do. Set pin 4 high for about 30 seconds, then set pin 4 low for about 30 seconds, with the expectation that it will make the model train run in one direction, then the other, and repeat forever.
If the track outputs are 14V DC, you don't need the bridge rectifier. Check the datasheet for your specific 7805 chip to see what the appropriate capacitors are.
Do not leave nSLEEP floating. It has an internal pull-down resistor so that the pin is LOW when unconnected.
Other than that, no problems that I can see, as long as the H-bridge can handle the motor current.
Jiggy-Ninja:
If the track outputs are 14V DC, you don't need the bridge rectifier.
My thought is that it is very easy for the user to hit reverse on the transformer. Some transformers have a switch for reverse, some just have it turning the throttle the other way.
I put in that rectifier to always apply + to the VIN and - to the GND
Is this a good idea?
Check the datasheet for your specific 7805 chip to see what the appropriate capacitors are.
Will do!
Do not leave nSLEEP floating. It has an internal pull-down resistor so that the pin is LOW when unconnected.
That is different than my recollection. More datasheet reading in order!
Other than that, no problems that I can see, as long as the H-bridge can handle the motor current.
I did test this driver with an Uno R3. Nothing got warm. N-gauge train with no cars or one car.
vinceherman:
That is different than my recollection. More datasheet reading in order!
Ah HAH! The chip has SLEEP pulled low, making the default mode to be disabled.
But the Pololu module pulls the SLEEP high, making the default mode enabled. From the Pololu product page - The SLEEP pin can be driven low to put the driver into a low-power sleep mode and turn off the motor outputs, which is useful if you want to let the motor coast. The SLEEP pin is pulled high through a 10 kΩ pull-up resistor on the carrier board so that the driver is awake by default
aarg:
What happens when the train reaches the end of the track?
The site that has the 555 circuit explains it, but the simple solution is that it runs until it hits the diode in the track and waits for the power to be reversed.
If it takes 30 seconds for the train to traverse the track, you put in a run time of 40 seconds each way. That way the train sits idle for about 10 seconds at each end. Long enough for human attention to move elsewhere on the layout, giving a sense of realism that is missing from small loops where the train just goes round in circles. http://home.cogeco.ca/~rpaisley4/AutoRevCheap.html
I was trying to put this into the wiring diagram but I could not remember which way the diodes pointed.
And I found the link to my proof of concept work. The line will be a bit longer when we put it on an layout. And rather than commit my $35 Uno, I wanted to use a $1.38 ATTiny85.
vinceherman:
My thought is that it is very easy for the user to hit reverse on the transformer. Some transformers have a switch for reverse, some just have it turning the throttle the other way.
I put in that rectifier to always apply + to the VIN and - to the GND
Is this a good idea?
If that's a possible situation, than a bridge rectifier is a very good idea.
Jiggy-Ninja:
a bridge rectifier is a very good idea.
WooHOOOO!!!!
Hey, I take em where I can get em!
edit: and here is a video of my buddy's layout. 3' x 4' with 11 moving trains. There are several point to point reversing lines in this. He wants more.
you might try adding a pull-up resistor alongside that diode. And allowing the Arduino to since the voltage on that section of track. When the train gets to that section of track, The voltage will be pulled low. The Arduino can then stop the train, wait a few seconds and then reverse it. The actual track length, and time it took for the train to traverse the track would be irrelevant. Only the stop time would be relevant.
Yes, there are a lot of ways the reversing circuit can be done.
The advantage of this one is that it requires no sensors. One pin from the Tiny to control direction.
Oh, I certainly have plans to do more, and with lots of sensors too. Something like this automated layout. 3 trains running on a single loop.
I tried this out. This did successfully power my arduino and (I think) power the motor driver.
I say 'I think' because before I got my engine on the track, it tripped the thermal shutdown on the model train transformer.
I am hoping you can help me reason out why.
I suspect that the 2 diode bridges do not have the same ground level.
OK, I am really making wild guesses but it is pretty much where I am with this.
The first image in my original post shows that the original design used a DPDT relay rather than a motor driver so the 2 systems never shared a ground.
My use of the motor driver (which does not CLICK on each change of direction) does have a common ground.
I must admit that I do not know the model number of that engine.
This is going on my buddy's N-scale layout and I borrowed the engine from him.
If I get a chance, I will post some more info on the engine when I get home tonight.
Assuming that it's just a transformer and no electronics in there, my guess is that the secondary coils aren't isolated. Check resistances between the accessory and track outputs, they could be sharing a tap from the secondary.