Convert PWM output to analogue DC

Thread Starter

AlbertM

Joined Dec 28, 2009
9
Basically I'm trying to use a computer to control a model railroad. I have one motor controller (http://www.phidgets.com/products.php?product_id=1060) with 2 outputs for controlling 2 blocks of track. The output is PWM and it drives the locomotive whithout a problem. However when the locomotive crosses from one segment of track to the other, it almost doubles its speed. Once it has crossed over with all wheels, the speed returns to normal. I believe this happens because when the locomotive is crossing the gap, it puts the 2 outputs in parralel, and the PWM outputs are somehow "superimposed", and so a double duty cycle results for the composed PWM signal.

My question is how can I convert the PWM signal to pure analogue DC voltage on both outputs. Basically I'm looking for some sort of "RC filter", but in this case the PWM signal is powerful enough to drive the motor just fine; if I add even a small resistor in a RC filter, then already the voltage drops significantly, and the locomotive moves considerably slower. Also i would like to keep this circuit because it has an USB interface and a good API behind.
 

JDT

Joined Feb 12, 2009
657
Instead of a resistor-capacitor filter, use an inductor-capacitor filter. Make sure the DC resistance of the inductor is low enough not to cause too much voltage drop. Depending on the PWM frequency, the inductor will probably be iron cored. You may be able to make one out of an old transformer. Because DC current is passing through it, the iron core needs an air gap.

What frequency is the PWM? What voltage and current?
 

zhgart

Joined Dec 28, 2009
19
You needn't to convey pwm into dc to drive dc motor. because the current in motor is dc because the pwm was filtered by motor inductor.
rc is only used for small current filter. so lc is best bet.
 

zhgart

Joined Dec 28, 2009
19
Basically I'm trying to use a computer to control a model railroad. I have one motor controller
--- However when the locomotive crosses from one segment of track to the other, it almost doubles its speed. Once it has crossed over with all wheels, the speed returns to normal.

API behind.
vague at this describe. what s meaning?
is the pwm driving two motor or one? or every wheel has a motor to be driven?
 

Thread Starter

AlbertM

Joined Dec 28, 2009
9
There are 2 segments of track, isolated from each other. One Phidget circuit has 2 independent outputs, so it can control 2 DC motors. So one output of the Phidget circuit is applied to one track segment, and the other output to the other track segment. The voltage is applied between the right and the left rail, for each track segment. The locomotive has one motor that picks up current using all the wheels eg. right side wheels pick up current from the right rail and left side wheels from the left rail, then feed it to the motor.
 

zhgart

Joined Dec 28, 2009
19
you mean to use rail as conductors to apply power supply to motor. one segment of track was powered by one output of the driver. the trailer has only one. when it cross the border. the one ouput was switched to another one?
 

Thread Starter

AlbertM

Joined Dec 28, 2009
9
Both track segments are powered using the same output voltage. But when the locomotive has the wheels on both segments, the right rails from both track segments, respectively the left rails in the track segments became effectively connected, so now the outputs from the Phidget circuit are placed in parralel. The result is that now the motor is being driven by two PWM signals, unfortunately one has an offset, so the motor "sees" a resulting double duty PWM signal. I cannot "switch" the power supplies on/off, because it's out of my control when the locomotive crosses the gap. That's why I need an analogue voltage fed to the motor.
 

Markd77

Joined Sep 7, 2009
2,806
I don't know anything about filters but as the motor in the train has inductance it may well be a case of trial and error. I'm not sure if adding a capacitor could damage the power supply. Maybe worth a try in the general electronics forum as well.
There is a quick and dirty manual fix which would be to unpower a section of the track just shorter than the section of train picking up power. That way it would be connected to both supplies for a shorter distance.
 

Thread Starter

AlbertM

Joined Dec 28, 2009
9
From my tests using the oscilliscope, just one capacitor applied for each of the outputs will not work. This is because the capacitor charges very quickly. For low values (hundreds of nF) it charges quickly and then discharges with a slight curve - basically just tracking the original PWM signal. For any higher values (1, 10 uF) it charges and then doesn't have time to discharge, so the motor sees the high value of the PWM signal all the time.

JDT, would a inductor-capacitor filter work for the given values, even with a different motor / different voltages applied (varying the PWM duty cycle) ?
 

Thread Starter

AlbertM

Joined Dec 28, 2009
9
The idea is that the trains are computer controlled. So once the locomotive crosses to a different, it can stop there, and another train can enter behind on the now free track segment. So I need the track segments to remain isolated one from another.
 

bertus

Joined Apr 5, 2008
22,278
Hello,

As told a PWM signal can be smoothend with a LC network.
In switchmode power supplies this technique is also used.
In the attached application note on SMPS circtuits you will find several examples.

Greetings,
Bertus
 

Attachments

Thread Starter

AlbertM

Joined Dec 28, 2009
9
It works ! Thank you Bertus for the application note. Now the output voltage is nice smooth analogue voltage (with a 1000uH inductor and one big 4700 uF capacitor). Unfortunately there is still a 'power surge' (not so powerful as before, but still noticeable) when the motor is fed by 2 outputs at the same time. I will migrate the system to DCC to overcome this and other disadvantages of the DC mode.

Thank you.
 

THE_RB

Joined Feb 11, 2008
5,438
You need the same analog voltage on both sections of the track AND a very low source impedance. I would filter both PWMs (as you have) then buffer each analog voltage somehow with a FET or power transistor so there is a very low impedance.

Then the motor will get the same voltage, regardless of whether there is 1 or 2 voltages connected.
 
Top