LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Relays control with time

Solved!
Go to solution

Hi people

 

I need to tun On and OFF a 4 relays module with ni usb 6008 (digital outputs).

 

relay 1 ON - from 0 to 20min

relay 2 ON - from 20 to 22 min

relay 3 ON  - from 22 to 60 min

relay 4 ON - from 60 to 120 min

And repeat the cycle n times

At the same time I need to measure temperatures from some lm35 sensors to save.

 

Below is my first example but I can run it only with 2 loops to get a refresh temperature at each 1 secound, if somebody can help me to developt an example more simple I will appreciate.

 

cpalka

 

 

 

0 Kudos
Message 1 of 10
(3,343 Views)

Hi cpalka,

 

use a statemachine to solve your problem…

 

if somebody can help me to developt an example more simple I will appreciate.

You need to learn THINK DATAFLOW!

Your "relay" loop does NOT what you want it to do - due to missing dataflow understanding…

Here you need to apply a statemachine approach: use atleast 2 states of "set relays" and "wait"!

 

Btw. what is the result of ANDing TRUE and FALSE? What do you expect as result?

And why dou you create 1D arrays from your boolean constants?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,316 Views)

Hi GerdW

 

Can you please starts with a very simple example for 1 relay?

 

Bes

cpalka

0 Kudos
Message 3 of 10
(3,303 Views)

Hi Palka,

 

You can try a simple logic for getting time in Minutes and use case structure for setting relay output.

The following VI reads temperature at every 100ms.

Relay Test.png

0 Kudos
Message 4 of 10
(3,288 Views)

Thanks Nanthakumar

 

This example starts and stops all relays at same time right?

As I want an ON/OFF relay diferente for each one I will need to replicate the code?

Other problem is the ON time diferent for each relay and sequencialy.

 

Thanks a lot

cpalka

0 Kudos
Message 5 of 10
(3,280 Views)

Hi cpalka,

You can drag and drop the image in the block diagram so that you can see all the cases and no need to code.

 

That earlier case structure will decide which relay needs to be switched based on time. when it exceeds 120 mins it will reset the time.

In your case, when one relay is ON others should be OFF right?

0 Kudos
Message 6 of 10
(3,275 Views)

I Nanthakumar

 

Good tip to drag and drop...

Unfortunately my version is 13 and yours is 14.

 

best

cpalka

0 Kudos
Message 7 of 10
(3,264 Views)

In post #3 of my Nugget on Action Engines found here I wrote about how an Action Engine wrapping up the operation of otherwise unrelated relays can be used to abstract away the hardware details such that indepently timed opeations can share a common set of hardware.

 

Using that approach you can develope sepearte state machines to control the diverse relays and make your code simple to develop and evenutally when you get promoted to beigger and better things, easier to transfer to you replacement.

 

Just my 2 cents,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 10
(3,259 Views)
Solution
Accepted by topic author cpalka

Converted to lower version(See attachment).

0 Kudos
Message 9 of 10
(3,253 Views)

Thanks Ben for your information

Ben  seems this example will work.

 

I will give more details about he final version.

 

Thanks 

 

cpalka

0 Kudos
Message 10 of 10
(3,245 Views)