LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you use boolean values to switch between cases?

Hi all,
I am constructing a VI is working as a maximum power point tracker.  So far I measure current and voltage, multiply them together and use a shift register to compare them to the next consecutive value.  In the meantime the program generates a voltage (onto a transistor) that modifies the resistance in the circuit.  So, if the second power value is higher than the first, i want the program to continue increasing (or decreasing) the voltage output.  If, on the other hand, it is lower, I want the signal generation to go in the opposite direction.    I have experimented with case structures but can't seem to get a "false value" to switch the signal generation.  Can anyone help me?  THANKS!!!
Alison
ps. I've attached what I have so far in case it will help.
0 Kudos
Message 1 of 13
(4,433 Views)

Hi Alison,

Can you repost the VI saved for LV 7.1 ?

I think I can provide you a solution once I see the code. Smiley Wink

- Partha ( CLD until Oct 2027 🙂 )
Message 2 of 13
(4,413 Views)
Hi ambro,

maybe you test the wrong numbers?

See the comments in my attachment!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 13
(4,410 Views)

GerdW,

thanks a lot for your help.  I appreciate the improvements!  Anyway, I'm still sort of confused.  how would you suggest fixing the adding and subtracting problem?  If I am testing teh wrong values how would i fix that?  Thanks again,

alison

0 Kudos
Message 4 of 13
(4,401 Views)
Hi ambrownster,

adding/subtracting case: the express vi generates just a '0'-signal (offest=0) and then you add or subtract 0.1. Why not make a diagram constant instead of express vi?
In the other case you generate just offset=1, make a constant from it.
(My personal opinion:
I don't use express vis. They are big, take much memory and loading time increases.
I also don't like dynamic datatype as it hides the underlying datatype. For example: you compare your dynamic data with 9.8 with 'compare elements' and feed the results to the case structure. What's the result when there is an array in the dynamic data?)

Testing wrong value:
The outer case is testing the generated 'DC' signal from last iteration, which is always in the range of -0.1 - +1.0! So the comparision (<9.8) is always true! The power-test is just switching the generation of -0.1 and +0.1 signals...
I would use a numeric control/indicator for the voltage (which seems to be your driving force) and change this value according to the power-test.

Rounding errors will occur when you repeatedly add/subtract 0.1 from your starting value (as long as you use floating point number). If this is a problem you have to do some rounding on your own (for example round to the nearest multiple of 0.01).
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 13
(4,393 Views)

Partha,

thanks for your help.  Here is the code in labview 7.1.  I hope you can help me out!! Is there some sort of switch that will toggle between two values whenever it recieves a true value or something.  The case structure I'm using has an assigned true and false, but I don't want each case to have an assigned true or false value because as soon as they go false, I want to switch to the other curve.

THANKS!!

Alison

0 Kudos
Message 6 of 13
(4,390 Views)

GerdW,

Doesn't the offset into the simulate signal VI make the VI change its value as it grows and shrinks?  When i run the curve the offset varies between 0 and 9.8, so i think the second comparison is necessary to protect the DAQ.  Or is there something else that I'm missing?  I'm a total novice, so I'm making things up as I go along.

Thanks,

Alison

0 Kudos
Message 7 of 13
(4,385 Views)
Hi ambrownster,

when it comes to express vis I'm also a novice Smiley Wink That's why I prefer standard datatypes!

I cannot run your vi as the DAQ hardware is missing...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 13
(4,381 Views)

GerdW,

So, how would I make  adiagram constant that would has some sort of offset?  But more importantly, is there some sort of way in which I can toggle between what would be my two cases of the case structure each time the shift register power value is greater than the newer power value?  So essentially a switch that turns on whenever a false reading comes on?  Thanks again and again,

Alison

0 Kudos
Message 9 of 13
(4,374 Views)

Hello Ambrownster,

i have looked at your vi, which seem interresting. however i have several remarks, some of them already pointed in this thread:

1)i understand you try to make some kind of PID regulation on your output board as a function of input (PID stands for proportional, integrator, derivative feedback). you could then try to make a little more elaborate response to your output dependant not only on the direction of change but also its violence (rate of change), and correct for offset.

2) try not to use express vis and dynamic data conversion. also, try to minimise nb of operations (*, ^2, /...) when possible.

3) i strongly suggest avoiding feedback nodes in case you are not totally sure what value it will have, expecially at the first iteration of the loop.

4) your card is going to send 10V out no matter what higher input you give (if you put 15V, your card cannot deliver such value). i would simply propose to use a "in range and coerce" function if you want to keep track of the value.

all the best

 

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 10 of 13
(4,371 Views)