Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

24 Stepper motors FPGA control - Polling or random ?

Read the problem section directly unless you need more info.

 

Background:

I need to control the speed and direction of 24 stepper motors simultaneously.The values of Speed and direction (how long it rotates in the same dir) should be randomized within a given limit.

Hardware:

LABview > PCI7813R (FPGA) > SCB68 > Steper drive P70530 > stepper motor.

(I simulate the FPGA card as of now)

Application:

Active turbulance generator (ATG)

Every input needs to be randomized between a given value.

For this application Random => better.

Other info:

I need to send two digital pulses to each motor viz. - Step and Dir.

Each motor has to rotate at different speed and direction chosen randomly.

The FPGA vi needs 48 inputs. The input is the value of the frequency of a wave generator. (full control possible with only that)

The main Vi gets its randomized input from a subVI. this value is stored in a shared variable and used inside while loops.

 

Problem:

I need to choose one of the methods below to control all the stepper motors.

Which one of the two algorithm is better?

1. I have 24 while loops for each signal(dir and step) to FPGA VI. Each connects to one input of the FPGA vi. inside the while loop i have a time delay connected to a random number generator.

So after a random time the value from the sub vi at that instant will be used as the signal to be sent to the fpga vi. so I send data to each i/p by a random time delay.

 

2. I have 2 loop that polls 24 inputs each and updates the value from the sub VI in a systematic way.

*polling = updating the inputs one by one in a seqential manner;

 

Other questions:

With the first method the computer processor usage went to full. so I felt it needs more processing power. I am wondering if a change in algorithm is necessary. Is there a possibility that 100% CPU usage is due to the use of simulation n not the real card?

 

Attachments:

1. Comp_Main.vi - the vi in wihich i need to implement this algorthim

I have done only for dir. I am yet to do the same for step.

 

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

the 100% usage is due to your loops running full tilt.  this would happen even with one loop.  add an indicator for loop iteration and see how fast each one is trying to execute.  is this what you want?

how often do you want the speed and direction to be evaluated for change?  every millisecond? then add the metronome to each of your loops.  you will see the processor utilization go down.

you can do this with separate loops or polling.

 

It looks like your program spins the motors in the same direction but at different velocities.  what is the inertia that you are driving? can it stand the acceleration changes that you are producing with your method without stalling?

Stu
Message 2 of 2
(3,816 Views)