07-20-2018 07:32 AM - edited 07-20-2018 07:34 AM
Hello to all,
For a project I need to control 16 stepper motors individually. I have already written a code for one stepper motor which completely satisfies my needs. Since I have to control 16 of them, I wanted to ask if there is a way to simplify the code, instead of copying the code 16 times. I tried putting it in a subVI, it gave me a warning that the code might not work because of some while loops. I tried it and it did not work. Any ideas?
Also, at best, I need to enable all of them with one button, and not click the toggle 16 times. Is there a way to do this?
Can you somehow set a preset for selecting all the line ins (direction, pulse, enable) instantly? I think it would be really tiresome to select them from the drop down menue manually every time I want to run them.
I am using a NI PXIe 6341 connected to a scb 68. All the motos are connected to Leadshine Drivers.
Attached you find the code I am using right now.
Thanks for any help in advance!
Best regards
07-26-2018 12:05 AM
Create re-entrant VI with 3 state in a case structure:
Init
Create task with your different IO
Run
Set the step you want to do
Close
Close the task
This VI will have basically little input:
the PIN definition
The task name (different for all 16)
The state (init, run, close)
Then you can call this in a for loop with 16 parallel process. the for loop can have the parameter that you want per motor in multiple array or a cluster of array.
07-31-2018 06:27 AM
Thank you for your help. This sounds manageable. Since I am new to Labview my problem is how to exactly create a re entrant VI and how to run the 16 processes parallel with the different IO inputs. Do you have a more step by step answer?
I appreaciate your help and thank you in advance.
07-31-2018 11:41 AM
I think for reentrant vi, refer to labview beginer class. The same goes for the for loop with parallel iteration.
You start from very far to have a such project. How long do you have to realise it?
08-01-2018 04:19 AM
What would happen, If I specify the VI as re entrant and just copy/paste the Code 16 times?
08-01-2018 08:11 PM
Hi there,
It is very simple, since they are re-entrant, they will just execute at the same time without dependency to other except if they contain vi that are not re-entrant.
go to check in VI property and execution... read the documentation carefully to make sure you understand it.
Benoit
08-07-2018 01:07 AM
Thank you very much, I just copied the code 16 times, and I will see how it works. Anyway, can you give me another rundown on how to do this parallel?
And since I have 16 control buttons now, how can I just control them with one button press? For example If i want to change the frequency the motor is running at, I just want to type in the frequency once, and not 16 times. How can I achieve that?
Thank you in advance,
best regards
08-07-2018 08:22 PM
My dear friend, You really are a novice.
OK here is the step by step you need to do:
First use a for loop instead of 16 code in parallel.
-right click on the border of the for loop and select Configure iteration parallelism. put a value of 16
Second, I suggest you to be more familiar with GetSet.vi. It is what we call a functional global variable. This can contain all your parameter. In the for loop do a get and in your GUI you can do a set when you have a value change.
Look at the file i joined to this reply.
Benoit
08-14-2018 06:02 AM
Thank you for your help.
I really don't grasp how to route my inputs (direction, pulse) in the case structure and how to route them in the run state. I tried to run only with the enable state. Is this good so far?
08-14-2018 06:02 AM
Thank you for your help.
I really don't grasp how to route my inputs (direction, pulse) in the case structure and how to route them in the run state. I tried to run only with the enable state. Is this good so far?