LGB-trains, Arduino and PWM
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?
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.
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
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.
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!