Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

timed control loop

Hello

 

I am trying to control some devices (triggers for other devices, etc) at given "absolute" times, not related to any other events. I consider that the best way would be to use the sample clock of my PCI 6229 card.

 

Although this must be a very elementary question, I am not able to find a natural way  to solve. According to DAQmx help, I could use a "Wait for Next Sample Clock" to align the steps of a loop with time. However, I find it artificious to create a I/O task only to be used as a clock (apart from reserving useful resources).

 

I more text-oriented, so I use ANSI-C programming. I have had a lool to the "configured timed loop" VI but I cannot access its code. Furthermore, there must be a simple basic concept answer applicable to ANSI-C.

 

The application tries to control the feeding of differente gaseous reactives at different times to a chemical reactor. Apart from the time loop, the PCI 6229 is controlling several temperatures by reading thermocouples and switching on/off several heaters through relays.

 

Thank you

 

Carlos Soria-Hoyo

Sevilla, SPAIN

0 Kudos
Message 1 of 4
(5,990 Views)

Hi Carlos,

 

It sounds like you are proposing to use hardware events to regulate a software loop which would then toggle your I/O.  Going through software like this is going to add a good deal of non-determinism to when the actual event is generated.  If this degree of inaccuracy is acceptable for your application, you might consider just running a software-timed loop to issue the pulse commands.  However...

 

A better way would be to configure a digital output task, clocked at the required timing resolution (1 MHz max rate on the 6229 would give 1 us resolution).  Build your digital output array such that the desired line toggles at the appropriate time.  You would need to generate the clock for your digital output task from one of the on-board counters (I would use the frequency generator to generate 1 MHz so you can keep the counters available should you need them at a later time).  This way you don't require any software involvement and your timing will be very accurate (the oscillator on the 6229 is accurate to 50 ppm).

 

 

Best Regards,

John Passiak
0 Kudos
Message 2 of 4
(5,958 Views)

Thank you for your answer, John.

 

That is, more or less, what I did. I configured a Counter Output task at a convenient frequency and Implicit Timing to stop at a given number of ticks. I measured the output pulses with an oscilloscope to check that the task worked as I wanted.

 

In any case, I was not able to get the base clock without actually generating a signal.

 

Best regards.

 

Carlos

0 Kudos
Message 3 of 4
(5,954 Views)

If you want to generate the base clock without actually outputting a clock signal, you can set CO.Pulse.Term (DAQmx Channel Property Node) to an empty terminal.

 

To reference this base clock internally you use the internal output terminal (e.g. "/Dev1/Ctr0InternalOutput").  It won't show up in the dropdown list for DAQmx Terminals unless you right-click the constant/control and select I/O Name Filtering > Include Advanced Terminals.

 

Also worth noting is that a finite counter output task uses both counters on M Series DAQ devices.  If you're using the counter to clock a finite digital output task, you could just make the digital output task finite and let the counter run continuously (stop it in software once the DO task has completed).  This would accomplish the same thing but will use one less counter (which could be used for other tasks if necessary).

 

 

Best Regards,

John Passiak
0 Kudos
Message 4 of 4
(5,949 Views)