Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to do such if statement in Labview

Hi
I am creating program in labview that generates sine wave and then sends it to Analog output channel of AT-MIO-16E boardfrom this channel to electronic circuit board and then to Analog input channel.
I have to measure the maximum value of the signal that I retrieve from Analog input channel and if this value doesnt meet the requirements I have to change the amplify on the electronic circuit board (by sending "high" to one of the digital channels - and it will change the amplify).
 I use 4 digital channels to 4 resistors (they are represented by R1 to R4).

My question is how to do such a fi statement in labview. There are probably some errors in this code - but I hope that you know what I mean:

"decrease" = 1
"increase"=1
if (decrease=1)
    if (R4=1) then {R4=0; R3=1}
    if (R3=1) then {R3=0; R2=1}
    if (R2=1) then {R2=0; R1=1}
    decrease=0;
if (increase=1)
    if (R1=1) then {R1=0; R2=1}
    if (R2=1) then {R2=0; R3=1}
    if (R3=1) then {R3=0; R4=1}
     increase=0;
if (decrease=0) and (increase=0) measure

Some theory: The maximum value of the measured signal can be 10Volts. I have to do some ranges if the max value is below 0,5 Volts he signal must be amplified, (the resistor will change) and programm will generate the sine once again and then I measure the value again if it is still below 0,5 it must be amplified and again generation. If the amplify can't be higher that it should stay this way.
And another range is from 9,5 Volts to 10 Volts. It must be done the same way as above but instead of amlifying the signal it must be reduced.


best regards for any help
RQsz
0 Kudos
Message 1 of 17
(4,737 Views)

Hi RQsz,

This looks to be a problem that should be very simple to solve using an FSM within a while look with each state containing case statements to deal with the conditions you have laid down. Unfortunately I don't really understand your algorithm as some of the code appears to be redundant i.e.

    if (R4=1) then {R4=0; R3=1}
    if (R3=1) then {R3=0; R2=1}
    if (R2=1) then {R2=0; R1=1}
  

looking at this code if R4=1 then the value will cascade down as you're setting the next bit, so you know that if R4=1 then R2 will always be 0 and R1 will always be 1.

I'm wondering if you meant :-

    if (R4=1) then {R4=0; R3=1}
    else if (R3=1) then {R3=0; R2=1}
    else if (R2=1) then {R2=0; R1=1}

I'm also a bit confused by setting Decrease and Increase to 1 at the beginning of the sequence, and then testing this condition halfway through when you don't need to, as you know they'll always be 1.

It looks as though it should be fairly straight forward problem, but it needs a bit more detail in the explanation.
   

David Clark
CLA | CTA
Genesee Technologies Ltd
Hampshire, England
0 Kudos
Message 2 of 17
(4,720 Views)
Increase and decrease I wanted to use as flags, but maybe they aren't necessary.
As for the first question it should work this way that when I will get the signal, tha max value shuld be between 0 and 10 volts, if its over 10Volts it should be decreased - it will be done by  choosing R4, Than the signal should be generated again and analysed. although it is possible that after R4 the max value will again be too high than it shoul be left this way and the measurements should start with R4 turned on.
And if the signal (max value) is below 0,5 the signal should be amplified by choosing R1 than the signal should be generated once again and it should be analysed if it is in the range between 0,5 and 10 the measurements can start if it is still below 0,5 instead of R1, R2 should be connected and the generation should start again, and so on. There is also a possibility that after amplifing the signal with R3 the max will be still below 0,5 Volts, than the measurements shoul start anyway.

Amplifies are like this:
R1 x 10
R2 x 100
R3 x 1
R4 x 0,1

I hope it helps
RQsz
0 Kudos
Message 3 of 17
(4,705 Views)
Done a vi that sort of shows what I think you're trying to achieve - hopefully it's the kind of thing you're looking for.
David Clark
CLA | CTA
Genesee Technologies Ltd
Hampshire, England
0 Kudos
Message 4 of 17
(4,704 Views)
Well, unfortunatelly I have labview 6.1 and it doesn't work, maybe you can doa print screen?
0 Kudos
Message 5 of 17
(4,696 Views)

David's solution is good , but a pic of it will not help you since he uses case structure with multiple conditions.

Either he has to post a pic of each case or still better,  will somebody convert it to 6.1 and pass it to rqsz??

Message 6 of 17
(4,680 Views)
I would be grateful if someone could have made it.
Rqsz
0 Kudos
Message 7 of 17
(4,676 Views)
I Can't convert to 6.0 as 7.1 only rolls back to 7.0, but I've attached a copy of the documentation that might help. Otherwise it might be worth seeing if NI has any demo versions of Labview 7.1 you can download.
David Clark
CLA | CTA
Genesee Technologies Ltd
Hampshire, England
0 Kudos
Message 8 of 17
(4,671 Views)

Hi rqsz,

Two Save for Previous and here we go--I've attached the VI in LabVIEW version 6.1.  I hope that this helps (although it's still a great idea to take a look at the evaluation version).  Please let me know if you have trouble with this VI.

Good luck!
Megan B.
National Instruments

Message 9 of 17
(4,661 Views)

Thanks for transforming it to Labview 6.1.

RQsz

Message 10 of 17
(4,639 Views)