08-22-2016 04:00 AM
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
Solved! Go to Solution.
08-22-2016 04:47 AM
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?
08-22-2016 06:24 AM
Hi GerdW
Can you please starts with a very simple example for 1 relay?
Bes
cpalka
08-22-2016 07:27 AM
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.
08-22-2016 07:41 AM
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
08-22-2016 07:52 AM
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?
08-22-2016 08:27 AM
I Nanthakumar
Good tip to drag and drop...
Unfortunately my version is 13 and yours is 14.
best
cpalka
08-22-2016 08:36 AM
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
08-22-2016 08:46 AM
Converted to lower version(See attachment).
08-22-2016 08:53 AM
Thanks Ben for your information
Ben seems this example will work.
I will give more details about he final version.
Thanks
cpalka