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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Do something every time I have a new Max Value

Solved!
Go to solution

So I'm trying to implement a Hill Climbing Algorithm on a set of 10 motors.I run one motor at a time and increment it in small steps and take power readings from them. All my power readings go into an array. Now each time I find a maximum in the Array I want to perform some functions (read all the motor positions and save them). How do I do something every tiume I find a new maximum. I'm using the Max Min Array Function. A VI is attached for further reference. It's not the whole thing but a part of the entire code. 

0 Kudos
Message 1 of 3
(1,131 Views)
Solution
Accepted by topic author bajajvishal11

Hi bajaj,

 


@bajajvishal11 wrote:

How do I do something every tiume I find a new maximum.


You  already know how to use shift registers: store the "max" value in a shift register and compare it in the next iteration with your "new max" value to determine your condition…

 

Btw. you don't need to build an array just to determine max values: just keep the latest "max" value in the shift register and compare with current "reading" using a MinMax function!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 3
(1,125 Views)

Thanks a lot. Now that you say it it's very easy. But sometimes I just have this code block, where I don't know what to do. 

0 Kudos
Message 3 of 3
(1,120 Views)