Page 1 of 1

Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 3:32 pm
by daveb0360
Hi all,
As part of an ongoing thermal control project, I have a flowcode that tests for various valid temperature points and decisions are made depending on value read.

I have set up a macro that reads the ADC 64 times and creates an average Integer value at each pass.
The problem is that the temperature decays are so slow that the program is very indecisive at the thresholds.

I have a variety of decision icons at each temperature thresholds that go and run the temperature read macro.
Problem is, the main loop gets progressively longer at each decision Icon. I want to be able to skip a loop if the first test is false.

Is it possible to trigger a loop count of say 10 loops on the first 'true' reading but skip the loop to the next decision stage if false.

In other words, I have a falling (or rising) voltage at thermistor. I have a 'goto test temperature' macro call........return with value, if value true - test a further 10 times for validity and return a false if validity is not 10x true. If first value tested is false, skip decision icon to next level.

Hope I made this clear

Cheers
Dave

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 3:50 pm
by Enamul
HI,
What you said should not be impossible, can you please post the latest program and give the hint which portion you need to speed up.

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 4:00 pm
by daveb0360
Hi Enamul,
It's more important that I create this 'hysteresis' method that does not carry out unnecessary tests....I'm sure you can see what I mean.
The ability to skip a test if the value is nowhere near but test multiple times if first value is true......is a great way to keep speed consistency within a control loop.....at least in my mind it is......lol

The program works great on my test setup but the final product will have much more slowly moving adc value and I don't want the program to be jittery at the different transition temperatures.

The overall loop needs to be quite fast so that I can incorporate all my different led patterns without slowing them down or without them slowing the program down too much.

I would like to add this verification or skip process at each decision icon in the main loop.


Dave

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 4:08 pm
by daveb0360
For example....the first icon.
- IF ((DegC>954)||(DegC<250))
False = skip to next decision icon.
True = test another 10 times.............if true for the 10 times = then true........if true for <10 times......then false at first fail - skip to next decision.

Decision is YES only if condition satisfied for the 10 times loop - take YES branch
Decision is NO if first test is false......OR if further tests in the loop read false.....then skip to next test icon........

clear I hope

Dave

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 4:11 pm
by daveb0360
Put another way.
If first test is true - start to test another 10 times in a loop.
If on 5th (or 6th, 7th etc.) loop - fail is detected - exit loop and skip to next test.

This might be easier to understand..

Dave

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 4:21 pm
by daveb0360
Hi all,
I think I solved it.........what do you think of this method..


And, doing it this way, I get to re-use the count variable for the next stage....
Basically, I don't want the program to waste time testing until the first 'true' value is present at first test.......but if first value is true, then test to make sure it's true 10 more times before returning a YES to the overall decision...... am I right?

Dave

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 5:10 pm
by Enamul
Yes, I guess you get this. If you have initialized count already before loop and tested for it to be 10 but skip if found logic false..
You are learning fast :)

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 5:12 pm
by daveb0360
Actually, just decided this doesn't work.
I need a decision of 'satisfied condition' OR ' NOT satisfied condition when loop exits..........not during each pass of the loop.

hmmmm......close but not quite there..

Dave

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 5:16 pm
by Enamul
I need a decision of 'satisfied condition' OR ' NOT satisfied condition when loop exits..........not during each pass of the loop.
What did you mean by that?

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 5:24 pm
by daveb0360
Hi,
I finally got it............seems complex but works in simulation well.
If anyone can spot anything wrong, please let me know.

Dave

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 5:32 pm
by Enamul
So you mean you don't want to have LED pattern if condition becomes false in 1 to 10 count..only after count =10 you will give that certificate..if that's the idea..it's doing that perfectly.

Re: Skip a test loop if first read is false otherwise loop

Posted: Fri Aug 31, 2012 11:40 pm
by daveb0360
Hi Enamul......totally correct........this idea is to make certain that the threshold is definite and not just a transient.

Dave