From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

PCI-6221, 16-Bit / Digital output timer

Hello,

 

I I am new to labview and due to time restrictions I would appreciate it if you could help me with a problem that I am facing.

I need to write a code that the digital output opens and closes an external port. The problem is that the frequency that I need this to happen is: open for two minutes,closed for 18 minutes and so on.I have searched though the manuals and here at the discussion forum but I didn't saw something that will quide me.

 

Many thanks in advance.

0 Kudos
Message 1 of 5
(3,421 Views)

Hi phys1,

 

the requirement you describe could easily be achieved by a standard state machine, please have a closer look at this and this link.

For example you could have one state that sets the digital lines to hi, one that sets them to lo and one state that checks the time that hase elapsed (the elapsed time can easily be monitored using the "Elapsed Time Express VI").

 

Regards,

Bernd

 

0 Kudos
Message 2 of 5
(3,392 Views)

You could also use one of the on-board counters if you wanted a deterministic high and low time.  The programming is also relatively straightforward, see this example:

 

Generate Continuous Pulse Train

 

 

You would just change the instance of DAQmx Create Channel from Frequency to Time, and then specify the high and low time appropriately (in terms of seconds).

 

 

Best Regards,

John Passiak
0 Kudos
Message 3 of 5
(3,372 Views)

Hi BerndF and John,

 

many thanks for your advices but I manage to do this with a different way. I attach the file in order to help someone else who is having a similar issue.

 

The only problem that I still have, is that I can record the time that my system is open but I can't do the same when it is closed.For my work this is not important but I would appreciate it if someone could give me a solution so I can understand Labview's philosophy better.

 

Regards

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

Hi phys1,

 

please have a look at the state machine design pattern, it's definitely worth it Smiley Happy. Your implementation works, but it's highly unflexible: Sequence structures should rarely be used, in fact I can hardly imagine a case where they can't be replaced by something better.

 

Just imagine: If the order of your sequence changes or there's an additional state, you have to re-organize all of your code. The other big disadvantage is, that you can't stop a sequence. Also the sequence order is static, whereas in a case structure you can make changes the fast and easy way.

 

Regards,

Bernd

0 Kudos
Message 5 of 5
(3,281 Views)