LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with VI

Hello !

I am trying to connect and Arduino UNO to an easydriver 4.4 that drives a stepper motor, and control the motor via Labview.

I can't seem to make this VI work. Maybe I'm not setting it up correctly.

The LIFA firmware for the Arduino is ok and the connection is ok, because I tested it with the "Simple LED Example.vi" and it works perfectly.

I will attach the very simple VI that I made and also the motor stepper example VI from LabVIEW.

Thank you !

Download All
0 Kudos
Message 1 of 7
(4,299 Views)

I haven't checked the stepper firmware to see if commands are buffered, blocked or over-written, but I suspect that your while loop is running so fast that the commands to move are being canceled by Stepper Close.vi before the stepper has a chance to move.

First, try moving Stepper Configure.vi  out of the loop and have it run after Init.vi.and before the loop. Same with Stepper Close.vi, put it outside the loop and have it run after the loop and before Arduino Close.vi. You only need to run Stepper Configure.vi  or  Stepper Close.vi once in this configuration.

Second, since the While Loop will run as fast as it can, you'll need to incorporate Stepper to Go.vi or Stepper Wait to Complete.vi to prevent a new command from over-writing the previous one. Alternately, you could wait (Steps# divided by Speed/sec) seconds for the steps to finish. Or, use a vi architecture that only sends a command to Arduino when you want to change something.

The constants Step#, Speed/steps and Set Acceleration could be changed to controls, then you will be able to control the step count and step rate during execution.

The example you attached does all of the above plus checks for any unfinished steps. I'm curious, why didn't you use the example?

Do you get any error messages?

John

0 Kudos
Message 2 of 7
(3,197 Views)

I will try what you said.

I have tried to use the example from the toolkit but it doesn't work.

I will post the print screen from the "Highlight Execution Mode"

ard_stepp.jpg

0 Kudos
Message 3 of 7
(3,197 Views)

I made the modifications that you said. It still doesn't work. The two led's from the arduino board (TX and RX) light up and stay lit , but when I press the "Start stepping" button, nothing happens.

I do not know what the problem could be.

Thank you

0 Kudos
Message 4 of 7
(3,197 Views)

Did you try the example as it was written in the Arduino menu pallet? It should work right out of the box.

The branch to enable a digital pin that you added to the example  will probably kill the connection to the Arduino and release  the VISA session before your main while loop even has a chance to get going. Just because you put the vi on the right side of the BD, that has no effect on the execution order of the primitives.  Remember that LabVIEW is a data flow language and a vi will run when all the required data is present at its connector.

Stick your Digital Set Pin Mode.vi and Digital Write.vi on the Arduino Resource and Error(out) outputs of the of the Arduino Init.vi in series with the Stepper Configure.vi. On the output side, you are already killing the Arduino Resource with the existing code in the example, so just get rid of the second Close.vi and error handler.

When using a reference to a resource or device,  its a good idea to avoid branches especially if either leg can close the resource.

Its always better to post the vi rather than a screen shot.

JohnCS

0 Kudos
Message 5 of 7
(3,197 Views)

I didn't realise that. Thank you for your explanation. I'm new to LabVIEW.

I forgot to say that I've tried running the example unmodified and it didn't work. I thought the enable pin was not initialised, but that was not the problem. It still didn't work. I don't know why it doesn't just work as it is because as far as I can tell, all the settings are ok.

0 Kudos
Message 6 of 7
(3,197 Views)

Just did a quick setup using the example vi with an EasyDriver and Arduino Nano. It didn't work very well for me, either. It looks like the vi is set up to go too fast to easily observe the stepper in action and there is a problem with the way the Dial is read. So we won't use the Dial when testing your setup.

Start with a fresh copy of the Stepper Motor Example.vi. On the BD, add the VISA resource for your Arduino to the Init.vi like you did in the sample you posted. Change the timeout of the Event Structure to 250.

On the FP, reduce the step speed to 1 step/sec, and set the number of steps to 10. Run the vi and hit Start Stepping.

The LEDs on the Arduino should flash continuously. The Steps Remaining LED on the FP should come on for about 10 seconds. Don't make any changes while that LED is lit.

Does your motor move? By changing the # of Steps to a negative number, can you make it go both ways?

JohnCS

0 Kudos
Message 7 of 7
(3,197 Views)