I try to control a nema 17 stepper motor with Raspberry Pi but i failed. I use LINX Toolkit for connecting my Raspberry pi 4. There is no problem with connection between LabVIEW and Raspberry but despite any error in block diagram it is not control the motor. When the program runs, the event structure does not pass from timeout to start subplot. Please help me. I have also tried using arduino and have been successful.
Solved! Go to Solution.
How are you running the VI?
If you are deploying it to the Raspberry Pi then you will not be able to use this architecture in the long run as the Raspberry Pi does not have the Front Panel to allow you to interact with the VI. It will work for development as you can run the VI from your PC but if you want to run this headless on the Raspberry Pi you will not be able to use Front Panel events.
Looking at the code I question if you are actually running your VI as it is set to run while the Stop control is true but if you try to set the Stop control to true and run the VI it exits after the first loop. Set the While loop stop to Stop if True and your VI should run the way you expect it to.
I am trying your suggestions right now. I tried this program with arduino uno and was able to control the stepper motor. I use the program with my pc. When I try to control it with Raspberry it stays in the timout structure. When I use the start or stop buttons, it does not switch from block diagram timout to start or stop structure. But there was no such problem in arduino.
When using LabVIEW with an Arduino you do not deploy the VI to the Arduino and have to keep the VI on the PC. When you deploy to a Raspberry Pi you can run headless so the whole VI is deployed to the Raspberry Pi. Due to these differences it will behave differently when working with the 2 devices.
Please expand on how you are deploying and trying to interact with the VI on the Raspberry Pi. Additional screenshot of this process will help to understand what you are doing.
We communicate with the computer via raspberry wifi connection (Local I / O). We do not upload any files to raspberry. We just connect with labview and run vi. Also, we previously controlled raspberry with labview using led blinking vi.
I add how we deploy the VI in the screenshot. Raspberry and PC communicates with WiFi. First I connect the Raspberry in LabVIEW/LINX and add my VI on the connected Raspberry and Run my VI on the PC then the deployment process work. After that you can see there is no error in error windows and the device name write there. But The GPIO pins of Raspberry not activating. Program always stay in timeout loop.
Sorry for the late reply, I got caught up in some other tasks.
Your issue is you cannot use the Event structure based off Front Panel changes on a deployed VI to the Raspberry Pi. VIs run without Front Panels on the Raspberry Pi so the Event is never being triggered. You need to use a different method to interact with the VI like polling a button.
You probably want to have 1 run button. If enabled the stepping is running and is disabled the stepping is stopped. In your timeout case you look at the state of the run button and if the state has changed from the previous value you decide to start or stop your the stepping.