Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

converting steps to PWM

We've inherited some 16 year old hardware. Long story. Some of it is in another post:  https://forums.ni.com/t5/Motion-Control-and-Motor-Drives/Looking-for-a-manual-for-a-Physik-Instrumen...

The 7344 motion card can put out steps or DC servo. It talks to an amp that requires PWM input. This worked previously due to custom FPGA code NI supplied for the 7334, but that may not be an option for use with current software and firmware updates. So I'm thinking of using a cRIO or sbRIO to read the step signal. Continuously measure the time between rising edges. The shorter that is, the faster the controller is telling the motor to go. In another loop, output a PWM pulse of constant frequency - whatever the PWM amp likes. Every time a PWM pulse starts, its HI duration (e.g. duty cycle) is calculated based on the most recently measured step time. The 7334 can continue to handle the encoder, the limit switches, even the PID logic that varies the velocity.

Can anyone see if there is any major conceptual issue with doing this? Any reason why it just won't work? I would never suggest it for a new system, but it could be the answer for keeping this system running...

 

Thanks,

      DaveT

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 1 of 3
(2,254 Views)

Dave,

 

It should work, but you have to pay attention to the edge cases - slowing down to a stop, going really fast, etc.  I have done this for measuring velocities using encoders, and after many iterations I have some good code.  It also depends on the relative frequencies of the steps and the PWM output.  When you are waiting for the next edge, make sure you use the max of the last step time and the current time.  You also need a cutoff that decides the pulses have stopped after a certain amount of time with no pulses.

 

Another option that might be simpler would be counting the edges from the start of the last step of the PWM, and using that count to determine the width of the next PWM step.  The PWM width would vary slightly, but probably not enough to make a difference.  It might not work well at low speeds, if there are several PWM cycles with no steps.  If low speeds only happen when starting and stopping, that would probably be fine.  I would guess it would work well when there are more than ten steps per PWM cycle.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 3
(2,229 Views)

Thanks, Bruce. Excellent hints. I appreciate your advice.


DaveT

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 3 of 3
(2,227 Views)