Skip a test loop if first read is false otherwise loop

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

Skip a test loop if first read is false otherwise loop

Postby daveb0360 » Fri Aug 31, 2012 3:32 pm

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

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

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

Postby Enamul » Fri Aug 31, 2012 3:50 pm

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.
Enamul
University of Nottingham
enamul4mm@gmail.com

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

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

Postby daveb0360 » Fri Aug 31, 2012 4:00 pm

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
Attachments
HeaterControl_eval20.fcf
(17.29 KiB) Downloaded 180 times

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

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

Postby daveb0360 » Fri Aug 31, 2012 4:08 pm

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

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

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

Postby daveb0360 » Fri Aug 31, 2012 4:11 pm

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

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

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

Postby daveb0360 » Fri Aug 31, 2012 4:21 pm

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
Attachments
verify or skip.PNG
verify or skip.PNG (26.68 KiB) Viewed 4218 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

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

Postby Enamul » Fri Aug 31, 2012 5:10 pm

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 :)
Enamul
University of Nottingham
enamul4mm@gmail.com

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

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

Postby daveb0360 » Fri Aug 31, 2012 5:12 pm

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

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

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

Postby Enamul » Fri Aug 31, 2012 5:16 pm

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?
Enamul
University of Nottingham
enamul4mm@gmail.com

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

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

Postby daveb0360 » Fri Aug 31, 2012 5:24 pm

Hi,
I finally got it............seems complex but works in simulation well.
If anyone can spot anything wrong, please let me know.

Dave
Attachments
verify or skip.PNG
(32.87 KiB) Downloaded 1721 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

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

Postby Enamul » Fri Aug 31, 2012 5:32 pm

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.
Enamul
University of Nottingham
enamul4mm@gmail.com

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

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

Postby daveb0360 » Fri Aug 31, 2012 11:40 pm

Hi Enamul......totally correct........this idea is to make certain that the threshold is definite and not just a transient.

Dave