two condition loop until?
Moderator: Benj
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
two condition loop until?
is it possible to do this, for example what i wanted to do is loop until a count variable= another count variable which i do all the time, but also i would like to logicly OR it with a switch input, so it would loop until the compaired count is reached or until the switch is logic 1.... is pic boolean logic the same as cd4000 series component logic? i would like to be able to use this kind of stuff in fc frequently if it is the same
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: two condition loop until?
Hi Brandon,
Try attached flowchart.
I have created a loop that Will exit if Count = 50 OR Input goes high
Although I have got (Count=50)||(A0_Input=1) for the conditional testing you can have an additional variable for example called Count_Value.
the before loop starts you can assign Count_Value to 50 i.e Count_Value = 50
then have:
(Count=Count_Value)||(A0_Input=1)
You can have more than two conditions if required.
Note:
Flowchart is set up so if single stepping or normal running,you can press number 0 on keyboard to operate switch
|| is the pipe character * 2 which can be found using Shift \ key (in between left shift and Z keys)
Martin
Try attached flowchart.
I have created a loop that Will exit if Count = 50 OR Input goes high
Although I have got (Count=50)||(A0_Input=1) for the conditional testing you can have an additional variable for example called Count_Value.
the before loop starts you can assign Count_Value to 50 i.e Count_Value = 50
then have:
(Count=Count_Value)||(A0_Input=1)
You can have more than two conditions if required.
Note:
Flowchart is set up so if single stepping or normal running,you can press number 0 on keyboard to operate switch
|| is the pipe character * 2 which can be found using Shift \ key (in between left shift and Z keys)
Martin
- Attachments
-
- Two Decisions witin loop.fcf
- (6 KiB) Downloaded 278 times
Martin
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
Re: two condition loop until?
thanks martin, now to clearify if i were to use AND logic i could have 3 parameters that would have to be logic high for the loop to stop, would that work also? ...was wondering what the other short hand symbols look like for and,nand,nor,not,exclusive nor, exclusive or... so in flowcode ( ) means look here for value? ..... on an unrealated topic was wondering if in v5 the variable delays allow me to use numbers above 255 or would i still have to do 10 loops to get correct delay?
- JonnyW
- Posts: 1230
- Joined: Fri Oct 29, 2010 9:13 am
- Location: Matrix Multimedia Ltd
- Has thanked: 63 times
- Been thanked: 290 times
- Contact:
Re: two condition loop until?
Morning.
You can use these operators for logical and bit-wise operations:
You can combine these as you see fit, eg: a & ~b is 'a' and not 'b', or NAND.
I would advise using logical operators (||, &&, !) in conditions/decisions instead of bit-wise as the compiler tends to be able to optimise this better.
Cheers,
Jonny
No need, you can use one call in v5. The delays support values up to 65536 of whatever unit you are delaying by. Inserting as an immediate constant allows up-to (and including) 2000, so you could delay by, say, 1.5 seconds (1500 ms).in v5 the variable delays allow me to use numbers above 255 or would i still have to do 10 loops to get correct delay
You can use these operators for logical and bit-wise operations:
Code: Select all
&& - Logical AND, eg: a && b
|| - Logical OR, eg: a || b
^ - Exclusive OR, eg: a ^ b
| - Bitwise OR (same as operator OR)
& - Bitwise AND (same as operator AND)
~ - Bitwise NOT (ones-compliment, same as NOT), eg: ~a
! - Logical not (Any non-zero value becomes zero, any zero value becomes 1), eg: !a
I would advise using logical operators (||, &&, !) in conditions/decisions instead of bit-wise as the compiler tends to be able to optimise this better.
Cheers,
Jonny