10-28-2023 09:12 PM
I am currently controlling a Stepper Motor (I don't remember its designation, but it is a small NEMA motor similar, I believe, to what you are using), but I'm using a different Driver Chip, an A4988 (cost < $10). I'm driving it with a USB-6212, which is very simple with LabVIEW. It does not need an Arduino to figure out the pulse sequence. The best part about it is that it does almost all of the work for you. It has 8 "control pins" (Pins 1-8) and 8 "power/motor pins" (Pins 9-16), two for 5V logic power, two for motor voltage (8 to 35 V), and 4 for the 4 pins from the motor.
The interesting pins are the Control pins. Three (Enable, Sleep, and Reset) control Power on the Chip, and we've connected them to either +5 or Gnd right on the Chip (we don't plan to control these pins from LabVIEW -- we plan to just turn it on and leave it on while using the Motor). Three of the pins control "micro-stepping" -- setting them can make the motor take a full step, a half step, 1/4,1/8, and 1/16, allowing you to "slow down" the motor and make its motion "smoother" (because it takes more pulses to make a full rotation). That leaves two pins. DIR, when high, makes the motor turn Clockwise, and when low, makes the motor turn Counter-clockwise. The final pin, STEP, makes the motor take a single step.
So we've programmed the 6212 as follows: We use the low 8-bits of Port 0 to wire to Pins 2-4 and 8 (the micro-stepping and Direction bits) of the A4988. I only need to write this Port when the Direction changes (since we generally set the micro-stepping and leave it set while using the motor). So the only thing left is to send a digital Pulse Train to Pin 7 of the A4988. Here we use a Counter Output pin from the 6212. We are currently using a pulse train that transitions at 2 kHz, making TTL pulses at 1 kHz. Our motor, when run at a microstep of 1/4, has 3800 steps per revolution, so the motor spins at 3.8 seconds/revolution. If you want a 90° rotation, we generate a Pulse train of 950 Pulses.
We developed the code to run the Stepper by studying the logic of the Example shipping with LabVIEW. Search for Hardware Input and Output, DAQmx, Counter Output, Counter - Finite Output.vi. This example will work with the USB-6212 (we coded our own version to leave out the "bits we don't need"). Give this Driver Chip a try -- it was almost as though it was "made" for the USB-6212 + A4988 + Stepper motors.
Bob Schor