Notifications
Clear all

LGB-trains, Arduino and PWM

6 Posts
6 Users
0 Likes
3,977 Views
(@marcelinnorway)
Member
Joined: 4 years ago
Posts: 9
Topic starter  

I have a garden railroad. I use LGB material. It's all analogue. I'm an analogue guy. That's why they call me The Old Man, Dinosaur or The Fossile at our Makerspace. Any way, I am working with a model dragline with DC motors, which are PWM driven by an Arduino. Works fine. My model locomotives are no different. It's a DC motor that drives it. PWM makes a motor turn real slow, making it ideal for slow moving locomotives in a yard, shuffeling cars. So the idea arose to have a certain amount of track and program an Arduino to control it. I coupled the Arduino setup for the dragline to a locomotive and yes, it works too. The only disadvantage is the sound and possibility to control the speed.  A steamlocomotive producing a skreeking sound is not that elegant and max speed is slow. Bill did a topic on modifying the PWM pulse on the Arduino, maybe that might help with the sound and smoothening the PWM-wave. 

I have a sound modul in my locomotive. It works on 12v DC, starting making sound at 7 v or so. PWM is a kind of AC. Is it possible to rectify it so I can use it to supply the soundmodule with "a regular" DC  voltage?

Any suggestions on this item anyone?


   
Quote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
 
Posted by: @marcelinnorway

PWM is a kind of AC. Is it possible to rectify it so I can use it to supply the soundmodule with "a regular" DC  voltage?

PWM is already DC so there's no need to rectify it.  But it is possible to filter it back into a nice smooth dc if what you are driving (like a sound module) doesn't actually need the PWM.   You'll just need filter capacitors  at the input of the sound module.

Posted by: @marcelinnorway

A steamlocomotive producing a skreeking sound is not that elegant and max speed is slow. Bill did a topic on modifying the PWM pulse on the Arduino, maybe that might help with the sound and smoothening the PWM-wave. 

Yes, you can try using different frequencies for the PWM.  PWM is pulse WIDTH modulation.  So the modulation is being done via the timing of a pulse width.   But the frequency you use is unrelated to pulse width.  So you can try using different frequencies to reduce unwanted sounds.   A lot of code uses  a PWM frequency of 50 or 60 hertz which is compatible with many servo motors.  But since you are driving PM motors there's no need to stick to those frequencies.   So you can experiment in the code using different PWM frequencies.  That should be in the code where you first setup the PWM  parameters.  Just try some different frequencies and see if the sound changes.  

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 

I've been reading all of your responses with much interest. As a want-a-be train enthusiast I have thought many times about how the old model electric trains could be improved but I never considered the challenges that come with an outdoor environment.

This suggestion may be model train heresy but here goes. Considering that one of the more costly challenges (both initial cost and maintenance) seems to be the track. I was wondering if using something inexpensive yet durable like concrete, pave stones or stepping stones as the base. For aesthetics, track could be painted or stenciled on to the bed. The painted rail lines could then be utilized by a line following camera/software and an engine that's self powered and steerable. This would require some significant modification to the engine by exchanging the steal wheels to something like rubber and the creation of a steering mechanism as well as remote control. The line following, speed control, robotic steering and remote control all seem to be in the wheelhouse of this group.


   
ReplyQuote
Fpeter3
(@fpeter3)
Member
Joined: 4 years ago
Posts: 6
 

I know that this is an older thread, but I am a new member just coming across it!  😉

From your description I understand that you are controlling the track voltage with the Arduino. Have you thought about installing the Arduino inside the engine?

On a smaller scale, I took an 027 gauge trolley for my wife's Precious Moments Christmas village and put a Nano inside it (after gutting out a lot of plastic.) I then used a wireless remote to control the speed, the lights (Why would a trolley shut off its interior lights when it stops to pick up passengers?), and to even play an mp3 of a trolley bell clanging.

The track is set at a constant 12 volts, using a buck converter inside the trolley to run the electronics.

 

If I had it to do over again, I would install a rechargeable lithium battery, charged off of the track, to run the electronics. The reason is that unless the track is perfectly clean, a momentary lapse in contact causes the Nano to reboot!

Now that the ESP32-CAM is on my workbench, I might rebuild so that my grandsons can watch the trolley from the drivers point of view as they control it!

 


   
ReplyQuote
 Foxy
(@foxy)
Member
Joined: 3 years ago
Posts: 56
 

@fpeter3

Just an amusing observation re clean track. 

Many years ago I was trying to track down a problem in a real, full scale locomotive which had a single phase synchronous motor fed from a trolley wire to drive the motor-generator set for propulsion power. It was a full automatic train with no crew on board running in an arctic climate and occasionally it would not show up at its destination. After a hunt along the line we would find it shut down and waiting for us.  After a lot of detective work I found that a tiny icicle the size of your pinky finger on the trolley wire could cause a bump of a millisecond or so in the ac supply which made the synchronous motor draw a shot of high current which the control interpreted as a fault and cause a shutdown. 

Such was the importance of a clean trolley, I know that a trolley is not a track but it illustrates the situations that unforeseen dirt (or ice) can cause. 


   
ReplyQuote
butch
(@butch)
SLOTCARS
Joined: 3 years ago
Posts: 12
 

@fpeter3 A CAPACITOR WOULD KEEP IT GOING UNTIL YOU MOVED AGAIN! DEPENDS ON THE SIZE OF CAP YOU CAN PUT IN THE MACHINE AS TO HOW LONG IT WILL LAST BEFORE VOLTAGE DROPS TO LOW. LIKE THE INTERIOR LIGHTS IN YOUR CAR. THEY USE A CAP AND AS THE LIGHT PULLS OUT THE POWER THE LIGHTS GET DIMMER.


   
ReplyQuote