Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

6343 syncronizing 3 counter pulse generators

hi all, 

i am triying to pruduce 3 pulses useing the counter ports, i need the 3 pulsess to have a varable dealy from the first to second and from the first to third pulsees (delay in micro seconds).

i am using the ni daq 6343 and coding in matlab.

i thought to use the InitialDelay property but they dont start together.

 

please help me!!

 

this is my code:

 

pulsWidth=0.000001;

s= daq.createSession('ni');

ch=s.addCounterOutputChannel('dev1','ctr0','PulseGeneration');
ch.IdleState = 'Low';
ch.DutyCycle=pulsWidth;
ch.InitialDelay=0;

ch1=s.addCounterOutputChannel('dev1','ctr1','PulseGeneration');
ch1.IdleState = 'Low';
ch1.DutyCycle=pulsWidth;
ch1.InitialDelay=1E-6;

 

ch2=s.addCounterOutputChannel('dev1','ctr2','PulseGeneration');
ch2.IdleState = 'Low';
ch2.DutyCycle=pulsWidth;
ch2.InitialDelay=10E-6;

 

s.startForeground;

0 Kudos
Message 1 of 4
(4,014 Views)

I do not have Matlab, so no code. 

To start together, counters need start trigger, only it will ensure hardware timing. Now your generation is software synchronized.

First pulse starts on its own, other pulses are triggered by its rising edge. Start Trigger, trigger source /dev1/Ctr0InternalOutput (or standard /Dev1/PFIxx)

 

A few notes

You specify only DutyCycle. It is not in seconds, it is a fraction of period that pulse stays high. It is better to set Pulse High time and Pulse low time. Or at least set the period.

 

How are you running you pulses? 

If continuously, it is better to set only the first one to run continuosly, others in single retriggerable mode. It will maintain constant delay between pulses forever, not only at first iteration.

0 Kudos
Message 2 of 4
(3,992 Views)

thank you!

 

do you know what property i need to set in order for the outputs to wait for a trigger?

i need a single pulse from each counter.

i will change the dutycycle to pulse high time. i did not know that was posible..

 

0 Kudos
Message 3 of 4
(3,990 Views)

>> do you know what property i need to set in order for the outputs to wait for a trigger?

Properties of the class DAQmx trigger are

Start -> Trigger type: Digital Edge

Start -> DigitalEdge -> Source

Start -> DigitalEdge -> Edge (do not need to set it, default = rising)

Start Trigger configuration.png

I do not know how to get to this class  in Matlab. LabVIEW code does not have any function like SetTrigger (similar to addCounterOutputChannel) that gives you this class output. 

It looks like it is derivative class from session (session is called task in LabVIEW) not from the channel.

 

I would say you need 2 different sessions (I have 2 separate tasks in LabVIEW). First - ctr0, no trigger. Second - ctr2 and 3 - start trigger. Then you first start session 2, then session 1: session ctr2, ctr3 should be already running and waiting for the trigger when you start session 1 (immediately sends trigger).

 

 

0 Kudos
Message 4 of 4
(3,982 Views)