Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Control several Stepper Motors, each with independent sample/frequency PCI 6534

Hello,

 

first of all, sorry for the poor english.

 

I searched the forum and the help files/examples up and down, but i can not find a solution for my problem.

 

I want to controll 16 step motors with the PCI 6534 card. Each motor got two input signals, one for the direction und the other for the sample number at a specified frequency. At the beginning, i tried to put each line from 0 to 1 und back in a loop in MatLab. It worked, but I could not reach more than approx 300Hz by driving only one line.

Each motor will have to drive with 10k samples up to 10kHz, so putting the values in MatLab manuelly is not an option for me.

 

The next step was trying to understand the commands, which i can use to solve my problem. I got some help in C++ and  wrote a .dll file (attached) and loaded it into MatLab. 

There i used the functions  DAQmxCreateDOChan to create one Line for one Motor to test it. Then i wanted to specify the samples and speed by DAQmxCfgSampClkTiming.

 

Using this function in a task i got the Error -200898: DAQmxErrorPartialUseOfPhysicalLinesWithinPortNotSupported653x

Partial use of physical lines within a physical port is not supported by this device, given the requested Sample Timing Type.

Consider specifying the entire port and tristating the lines you do not want driven.

Property: SampTimingType
Requested Value: Sample Clock

Output Channels: Dev1/port0/line0

When I use the whole port for the DO, this error do not occur. But I don't want all lines to put out the same data, because each motor have to drive with various samples at various frequencies.

 

Is it even possible with this card to do this? I have no experience with programming such hardware.

I hope somebody can lead me in the right direction to solve this problem or say that this is not possible 😉

 

Thanks,

 

Christian

0 Kudos
Message 1 of 6
(4,264 Views)

Christian,

 

Thanks for posting on the NI forums! My best suggestion for this application would be to do what we call oversampling, or finding a faster rate that would be a common multiple of the different speeds that you need for each of the motor drives. For instance is you need a PWM signal to be going at 10 Hz and 5 Hz (just using this as a simple example), you could write data for both lines that was being generated samples at a rate of 20 Hz. 

 

Line 1: 10101010 (10Hz square wave)

Line 2: 11001100 (5Hz square wavel)

 

In the case of line two you will still be generating samples at 20 Hz, but you would be able to generate two different waveforms that would appear to have different rates. So, for your project you should sample at a rate high enough that you can do something similar. Let me know if you have any follow up questions. Thanks!

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 2 of 6
(4,233 Views)

Hi Aaron,

 

I understand the way you would solve the problem and it sounds promising. I red a lot about PWM signal and found many codes for it but in every example a counter is used to get it work. I know that the PCI 6534 did not have a counter onboard so i tried to figure out how i can do it without. Till now I can't find a way. Is it the timing on the card I have to use?

 

I would appreciate it, if you could  help me to find the right commands.

 

I also searched for the right data according to your example. Didn't understand how die frequency of the square wave can be calculated of the 8 numbers. Probably you have a link for me with a short explanation on this.

 

Thnaks a lot!

 

Christian

0 Kudos
Message 3 of 6
(4,146 Views)

Christian,

 

You can use either counters or hardware timed digital I/O to solve the problem with this. We have some shipping examples that will help you with your development. If you have the NI-DAQmx driver installed on your computer you should be able to go to the Start Menu >> All Programs >> National Instruments >> NI-DAQ >> Text-Based Code Support >> ANSI C Examples >> Digital >> Generate Values. These examples will show you what commands to use to generate pulses with your 6534. You might look at the example for Write Dig Chan - Ext Clk, but instead of using an external clock you could use the internal clock on the board. With the timing of the 6534 you would be able to pre-load a digital waveform onto the card and then begin generating that waveform at the frequency that you select. 

 

You can also look into the DAQmx  C Reference Help for details on the individual functions used. This is also located at Start Menu >> All Programs >> National Instruments >> NI-DAQ >> Text-Based Code Support. This is just a help file that will give details on all the functions calls that are supported by the DAQmx driver. 

 

As far as what data you need to write to your card that would depend on the PWM values that you need to generate. Basically, you will need to determine the smallest percentage of duty cycle you will need. For example if you need to be able to change your duty cycle in 10% increments you would need to oversample your signal by 10 times. A duty cycle of 50% would look like 1111100000 for one period of your signal, and a duty cycle of 10% would look like 1000000000. This would just make your device see square waves with different duty cycles, but the rate would appear consistent. Thanks!

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 4 of 6
(4,130 Views)

Hi Aaron,

 

first of all a big thank you for your explaining! With your help I'm making great progres!

 

On the other side I have to asked same more questions.

I'm now generating externaly an array for all 32 Lines with random output and write it with DAQmxWriteDigitalU32 to the card. The output is the way I want it. I'm sampling at a rate of 10kHz and my array is getting bigger and bigger the longer the output have to be. With the 32Mbyte memory on the card I can theoretically output data continuously for about 15 minutes. Mesurements may take several hours and the question is how I can output the array in a loop?

 

I know that it works if i put a loop around the complete task so that I have to start, stop and clear it every iteration. But in that case I have a delay where all steppers would stand still for milliseconds. 

 

1) Is there a way to loop the single array without stopping the task?

2) Or is it possible to write a new array to the card while the first is running, so that when the first is completed the second follows without delay?

 

Thanks once more!

 

Christian

0 Kudos
Message 5 of 6
(4,079 Views)

Chrisitian,

 

Glad to hear that you are making progress with your program. Now, in regards to your question, both of the options are actually possible for your application. The PCI-6534 and other DAQmx devices have a Property for the device called "Regeneration Mode". This can either allow the data that was placed on memory by the user to be generated multiple times until the program terminates. 

 

If you allow Regeneration this will regenerate samples that the device previously generated. When you choose this value, the write marker returns to the beginning of the buffer after the device generates all samples currently in the buffer.

 

If you do not allow NI-DAQmx to regenerate samples the device previously generated. When you choose this value, NI-DAQmx waits for you to write more samples to the buffer or until the timeout expires. If you choose this option you will need to give new values to the buffer before all the samples that you have previous generated run out. 

 

I pulled most of this information from the NI-DAQmx C Reference Help, but if you look under the NI-DAQmx C Properties >> List of Write Properties, you will see and option for "Regeneration Mode". You could also search for Regeneration Mode from the search. I have also linked a KnowledgeBase Document that describes the Regeneration Mode. 

 

Continuous Pattern Output with Regeneration for PC-DIO-32HS or 6533 Devices

 

Hope this helps. 

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 6 of 6
(4,076 Views)