Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating more than 4 PWM signals

Solved!
Go to solution

Hello all,

 

First I have a NI DAQ mx USB 6343 board.

I have to control 6 stepper motor drivers by a PWM signal, I can do this with a pulse train on ctr0..ctr3.

4 of them I control with the code below and this works perfect, only I have to control 6 !!!!

Is there a possibility to produce 6 pulse trains (frequecy, duty cycle adjustable) with my NI board ?????

Maybe using the frequency generator now I use the 4 counters, Iam really stuck now.

 

Working code for 4 stepper motor drivers:

 

string ports = $"Dev1/ctr0,Dev1/ctr1,Dev1/ctr2,Dev1/ctr3";

DAQTask.COChannels.CreatePulseChannelFrequency(ports, "StepperDriver", COPulseFrequencyUnits.Hertz, COPulseIdleState.High, initialDelay, RPM, dutyCycle / 100.0);

DAQTask.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples, 1000);

 

Somebody any idea??

 

Regards,

Herbert Veldhuis

0 Kudos
Message 1 of 6
(934 Views)
Solution
Accepted by topic author VeH

Soution found !!

 

Create 1 counter redirect Ctr0 -> PFI12 to 6 others

 


DaqSystem.Local.ConnectTerminals("/Dev1/PFI12", "/dev1/PFI0");
DaqSystem.Local.ConnectTerminals("/Dev1/PFI12", "/dev1/PFI1");
DaqSystem.Local.ConnectTerminals("/Dev1/PFI12", "/dev1/PFI2");
DaqSystem.Local.ConnectTerminals("/Dev1/PFI12", "/dev1/PFI3");
DaqSystem.Local.ConnectTerminals("/Dev1/PFI12", "/dev1/PFI4");
DaqSystem.Local.ConnectTerminals("/Dev1/PFI12", "/dev1/PFI5");

0 Kudos
Message 2 of 6
(883 Views)

This is just sending the 1 PWM signal to 6 destinations.  It does not give you the ability to control the 6 motors individually.  They all get the exact same control signal.

 

You could have done pretty much the same thing by just wiring all 6 motor controllers directly to PFI12 in the first place.  

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 6
(877 Views)

Thats right, but in that case i needed extra electronics because the load of 6 stepper motor drivers (i use the PWM 

for 6 stepper motor drivers) is too much for 1 terminal of the NI board.

Now i can split it into 6.

 

Youre right, maybe you have an idea how i can produce 6 WPM signals instead of 4 of the 4 counters.

 

 

Herbert

 

 

0 Kudos
Message 4 of 6
(873 Views)

That's a good point that you get more drive capability by doing signal routing to different physical terminals.

 

I'm not familiar with stepper drivers that operate based on PWM and respond to differences in duty cycle.  I mainly know of ones that accept frequency and direction signals.

 

With *that* kind of driver, there'd be a chance to vary the frequency of 6 distinct outputs.  4 would use your device's counters.  The other 2 would use dummy AO and DO tasks whose only purpose is to set a sample rate frequency and then route the sample clock out to a PFI terminal.

 

I know that many (most?  all?) NI's modern multifunction boards allow you to change an AO task's sample rate on the fly.  I don't know if I've tried the same with DO, but suspect it would also be possible there.   And that would get you up to 6 variable frequency outputs with pretty good frequency resolution available (unlike the frequency generator output you queried about in another thread that only allows a small number of discrete output frequencies).

 

If you need to be able to vary duty cycle, you either need more DAQ hardware or take a pretty complicated and non-ideal approach using hardware-clocked DO on port 0.  But that'll force you to have a buffer of data which will inevitably add latency before the new duty cycle takes effect.  You'd probably need to fiddle around a lot with USB transfer properties to find a good balance among latency, reliability, buffer size, and duty cycle resolution.  Overall, it'd be kind of a desperate move to try to do things that way.

 

If you can't afford another NI DAQ device, maybe you could find simple cheap hobbyist board you could use for 2 of your freq / duty cycle channels?   Maybe something along the lines of an Arduino or a Raspberri Pi?   You'll still have latency over your communication channel, but it's liable to be smaller than you'd get with the buffered DO approach.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 6
(862 Views)

Hi,

 

I already tested it with one counter that drives a stepper motor driver, when I vary the frequency and/or duty cycle it worked perfectly.

All the stepper motors (6) have to work at the same time at the same speed. The only problem was I had 4 output while I needed 6 of them.

The drivers whe use can be controlled by a PWM signal.

Otherwise whe had to install extra electronics because the load for the NI board output was to big.

So for me the problem is solved.

But anyway thanks for your reply.

 

Regards,

Herbert

0 Kudos
Message 6 of 6
(844 Views)