Convert PWM output to analogue DC

Discussion in 'Embedded Systems and Microcontrollers' started by AlbertM, Dec 28, 2009.

  1. AlbertM

    Thread Starter New Member

    Dec 28, 2009
    9
    0
    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.
     
  2. JDT

    Well-Known Member

    Feb 12, 2009
    658
    85
    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?
     
  3. AlbertM

    Thread Starter New Member

    Dec 28, 2009
    9
    0
    The frequency of the PWM is 2,5kHz. The voltage is 12 V and the maximum continuous motor current is 1,5A.
     
  4. zhgart

    New Member

    Dec 28, 2009
    19
    1
    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.
     
  5. zhgart

    New Member

    Dec 28, 2009
    19
    1
    vague at this describe. what s meaning?
    is the pwm driving two motor or one? or every wheel has a motor to be driven?
     
  6. AlbertM

    Thread Starter New Member

    Dec 28, 2009
    9
    0
    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.
     
  7. zhgart

    New Member

    Dec 28, 2009
    19
    1
    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?
     
  8. zhgart

    New Member

    Dec 28, 2009
    19
    1
    if it were, you should select right time to switch the supply.in order that there would no across(overlap) time.
     
  9. AlbertM

    Thread Starter New Member

    Dec 28, 2009
    9
    0
    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.
     
  10. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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.
     
  11. AlbertM

    Thread Starter New Member

    Dec 28, 2009
    9
    0
    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) ?
     
  12. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Are you measuring with train on track? The inductance of the train motor will make quite a difference.
     
  13. AlbertM

    Thread Starter New Member

    Dec 28, 2009
    9
    0
    The tests were made with the train on the track.
     
  14. zhgart

    New Member

    Dec 28, 2009
    19
    1
    you can use one output to two tracks. the two tracks connect by a piece of wires.betwwen its gap.
     
  15. AlbertM

    Thread Starter New Member

    Dec 28, 2009
    9
    0
    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.
     
  16. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,347
    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
     
  17. AlbertM

    Thread Starter New Member

    Dec 28, 2009
    9
    0
    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.
     
  18. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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.
     
Loading...