LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

stepper motor # of steps - 32767

Hello, Im running LIFA stepper motor example on an easy driver. When I run the motor , the maximum number of steps I can give is 32767. Any higher number , and the VI would automatically change it to this. I did some searching and saw that's because of 'closed loop stepper control'. I haven't got an idea what this is and would really appreciate if someone can give me an idea as to what I should do to fix it.

Thank you

0 Kudos
Message 1 of 5
(5,944 Views)

The "# of Steps to Move" input is a 16-bit signed integer so has a max value of 32767. This is simply the result of an early design decision for the Stepper Write VI.

There isn't a technical reason why you can't modify the VI and the firmware to both pass and accept and larger value. You'd need to split a 32-bit number into 4 bytes and pass those into the Send Receive VI. Then modify the Arduino firmware to reconstruct the 32-bit number on the other side.

Have fun!

Fred Visser -- SystemLink R&D -- National Instruments
0 Kudos
Message 2 of 5
(4,977 Views)

Thank you Fred. But I do not have much of an idea how to do it. Could you possibly explain it more or point me to any helpful resource.Thanks again !!

0 Kudos
Message 3 of 5
(4,977 Views)

I haven't tested this in the slightest, but I'll illustrate what I was describing before.

Screen Shot 2013-08-27 at 3.56.52 PM.png

First, modify the Stepper Write VI to move the Set Acceleration control to the inputs below the Stepper # control (eventual command arrary indexes 5 & 6).

Second, change the # of Steps to Move control to a I32 representation, split it into 4 bytes, and wire to the next four array inputs (eventual command array indexes 7, 8, 9, & 10)

Third, change the AccelStepper_Write function (within <vi.lib>LabVIEW Interface for Arduino\Firmware\LIFA_Base\LabVIEWInterface.ino) to expect a 32-bit value for Steps to Move:

// Stepper Functions

#ifdef STEPPER_SUPPORT

void AccelStepper_Write(unsigned char command[]){

    //int steps = 0;

    long steps = 0;

    int step_speed = 0;

    int acceleration = 0;

   

    //Speed is a 16 bit value, split for data transfer. Reassemble 2 bytes to an int 16

    //Steps is a 32 bit value, split for data transfer. Reassemble 4 bytes to an int 32

   

    //steps = (int)(command[5] << 8) + command[6];

    steps = ((long)command [7] << 24) | ((long)command [8] << 16) | ((long)command [9] << 8) | ((long)command [10]);

    step_speed = (int)(command[2] << 8) + command[3];

    //acceleration = (int)(command[7] << 8) + command[8];

    acceleration = (int)(command[5] << 8) + command[6];

    steppers[command[4]].setMaxSpeed(step_speed);

Good luck!

Fred Visser -- SystemLink R&D -- National Instruments
Message 4 of 5
(4,977 Views)

Thanks a lot Fred. I'll try this out !!

0 Kudos
Message 5 of 5
(4,977 Views)