03-06-2023 04:48 PM
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
Solved! Go to Solution.
03-06-2023 11:27 PM
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
03-09-2023 02:11 PM
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?
03-09-2023 09:06 PM
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.