Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Reducing Pulse Width for Square Wave Generated with Real-Time

Solved!
Go to solution

Hi All,

 

I'm using a cRIO-9056 with a NI 9403 module (digital inputs and outputs) to generate a square wave for driving a stepper motor. The stepper motor can read pulses of widths down to microseconds, but on my hardware, I seem to be limited to about a quarter of a second before the pulse becomes inconsistent.

 

I wanted to check if my method for generating the pulse in labview was optimal or if there is a better way to generate this pulse. In the attached picture, the wire coming into N holds the number of pulses we need out of the system (this relates to how far the motor needs to move). Then I have used a for loop repeating on and off outputs separated by the pulse width

 

Any help to optimize this code or insight into the problem in general would be appreciated.

 

Best,

 

Alex

 

labview_square_wave_generator.PNG

0 Kudos
Message 1 of 4
(632 Views)
Solution
Accepted by topic author loomisa6

Hi there,

 

To generate pulses widths down to microseconds, it's best that you use the FPGA on your CompactRIO.  The clock on the FPGA has much fine resolution than real-time (nanoseconds vs milliseconds), and you'll be able to generate Mhz pulses on the FPGA.  Check out this article:

 

How to Generate Simple Digital Pulse Train in LabVIEW FPGA

 

Alternatively, you can search for "pulse generation" examples in the LabVIEW example finder, there are usually some shipping examples that you can use.

 

If you're doing simple stepper motor control, this method should be enough.  I controlled some stepper motors with my myRIO just for fun a long time ago: https://www.youtube.com/watch?v=pdbDDZlHsr0 

 

However, if you want to control motors for accurate positioning with full control of parameters such as velocity and acceleration, you'll probably need a motion controller.  See my signature for details.

 

BR

John


Add motion to LabVIEW in 30min or less - GECO Motion
Finding it hard to source NI hardware? Try NI Trading Post

0 Kudos
Message 2 of 4
(610 Views)

Thank you very much for the help! I have changed my system over to FPGA. I'm not quite acclimated to FPGA and I'm struggling with one small problem. When I try to change the DIO type from input to output, the table in the properties section changes, but the actual object in the block diagram is still an input type. How do I fix this?

 

loomisa6_1-1678392684735.png

 

loomisa6_0-1678392642311.png

 

0 Kudos
Message 3 of 4
(572 Views)

Try deleting that object, and then make a new object by dragging the DIO channel from your LabVIEW project into the block diagram.  That usually works.

0 Kudos
Message 4 of 4
(548 Views)