LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control steppermotor via arduino and VISA

Hi,

 

I had a program where I could insert an amount of revolutions, rotation direction and the motor speed. This program works perfect, but for my application I would like to change the amount of revolutions to the amount of steps that my stepper need to do. For my stepper 48 steps =  1 revolution. I did change some parameters in the C code and I thought it would work, but it didn't. Here is my code:

 

C code.JPG

last line couldn't fit on my screen it's just  a }

 

The result from this program is a little strange, the text bellow describes the steps that are done with my input of steps to do.

 

Steps to do              Steps done

1                                2

2                                6                     =+4

3                                12                   =+6

4                                20                   =+8

5                                30                   =+10

 

Is there maybe someone who can help me with this problems? I have attached my VI, although I think the problem isn't located there.

0 Kudos
Message 1 of 3
(2,319 Views)

What is happening in the motor.step method?  I somehow doubt your want to be putting "steps" as the argument since you are using that for the FOR loop.  A definition of what the step method is would clear that up.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3
(2,304 Views)

I took a closer look to an example code to do 1 step every loop. The example program works, but when I made some adjustments for my application it didn't work. Although it doesn't work I think I'm getting close to make it work. My guess is that there is a little problem with my C code.

 

When I run my VI it does send a 1 or 2 (clockwise or counter clockwise)  via VISA. But in the C code something goes wrong, instead of doing 1 step in CW or CCW direction it gives me the ERROR status output.

Here is my VI and C++ code:

 

StepperVI.JPG

StepperCode.JPG

0 Kudos
Message 3 of 3
(2,267 Views)