Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling 16 Stepper Motors, any way to simplify?

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

0 Kudos
Message 1 of 14
(3,030 Views)

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.

 

0 Kudos
Message 2 of 14
(2,994 Views)

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.

0 Kudos
Message 3 of 14
(2,967 Views)

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?

0 Kudos
Message 4 of 14
(2,960 Views)

What would happen, If I specify the VI as re entrant and just copy/paste the Code 16 times?

0 Kudos
Message 5 of 14
(2,936 Views)

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

0 Kudos
Message 6 of 14
(2,915 Views)

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

0 Kudos
Message 7 of 14
(2,896 Views)

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

Download All
0 Kudos
Message 8 of 14
(2,887 Views)

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? 

0 Kudos
Message 9 of 14
(2,857 Views)

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? 

Download All
0 Kudos
Message 10 of 14
(2,856 Views)