If Decision Fails Flowcode 5
Moderator: Benj
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
If Decision Fails Flowcode 5
I thought I had a grip but tonight I’m stumped.
I set a Decision statement to see if PORTA > 2 so it can jump into a routine to check which switch has been activated.
I activate ( Ball ) or Port A Bit 7.
So the Decision does activate because PORT A is value 7.
The display for Ball advances then I stop the switch so now PORTA = 0
The Decision FAILS and just keep looping thru all my scan keys.
Here is a picture
Here I have 1 = Ball displayed
The Variable table list PORTA as value 0 but for some reason when I get back to the Loop and into Decision does PortA > 2 it buzzes right past ??
John
I set a Decision statement to see if PORTA > 2 so it can jump into a routine to check which switch has been activated.
I activate ( Ball ) or Port A Bit 7.
So the Decision does activate because PORT A is value 7.
The display for Ball advances then I stop the switch so now PORTA = 0
The Decision FAILS and just keep looping thru all my scan keys.
Here is a picture
Here I have 1 = Ball displayed
The Variable table list PORTA as value 0 but for some reason when I get back to the Loop and into Decision does PortA > 2 it buzzes right past ??
John
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: If Decision Fails Flowcode 5
Hello John,
The $PORTA reads the entire port including the pins you are using to drive the 7-seg displays.
I would instead use an input icon with masking to copy the input pins into a variable and then use that variable in your decision icon.
The $PORTA reads the entire port including the pins you are using to drive the 7-seg displays.
I would instead use an input icon with masking to copy the input pins into a variable and then use that variable in your decision icon.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: If Decision Fails Flowcode 5
Hi Benj,
Thank you for your endless help.
So the decision works the first time waiting for the switch say A7 to go active and then the flow picks up the A7 and activates Ball 1 segment. But oddly why does the Variable window say PORTA = 0 ?
Let me follow you thoughts.
1. use an input icon with masking to copy the input pins into a variable ( So I would need 1 variable to cover the corresponding switches ? )
2. and then use that variable in your decision icon. ( I will give this a try )
John
Thank you for your endless help.
So the decision works the first time waiting for the switch say A7 to go active and then the flow picks up the A7 and activates Ball 1 segment. But oddly why does the Variable window say PORTA = 0 ?
Let me follow you thoughts.
1. use an input icon with masking to copy the input pins into a variable ( So I would need 1 variable to cover the corresponding switches ? )
2. and then use that variable in your decision icon. ( I will give this a try )
John
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: If Decision Fails Flowcode 5
Hi Benj
Well I think I tried but I tried everything I could think of for the Decision step but I could not get the flow to come in to detect the switch.
I simplified it to be just 1 switch A5 Port A.
I believe I followed your steps. But I must be missing something.
I spend just about equal time doing images as to working the project.
John
Well I think I tried but I tried everything I could think of for the Decision step but I could not get the flow to come in to detect the switch.
I simplified it to be just 1 switch A5 Port A.
I believe I followed your steps. But I must be missing something.
I spend just about equal time doing images as to working the project.
John
-
- Posts: 125
- Joined: Mon Aug 15, 2011 1:54 pm
- Has thanked: 8 times
- Been thanked: 11 times
- Contact:
Re: If Decision Fails Flowcode 5
If you want to check one bit (bit 7) your if should be:
($PORTA AND 128) > 0
The other bits are:
($PORTA AND 1) > 0 - bit 0
($PORTA AND 2) > 0 - bit 1
($PORTA AND 4) > 0 - bit 2
($PORTA AND 8 ) > 0 - bit 3
($PORTA AND 16) > 0 - bit 4
($PORTA AND 32) > 0 - bit 5
($PORTA AND 64) > 0 - bit 6
The 'AND' values are the mask. If you wanted to check multiple values on at the same time, say bit 0 & bit 7, the if would be
($PORTA AND 129) = 129
($PORTA AND 128) > 0
The other bits are:
($PORTA AND 1) > 0 - bit 0
($PORTA AND 2) > 0 - bit 1
($PORTA AND 4) > 0 - bit 2
($PORTA AND 8 ) > 0 - bit 3
($PORTA AND 16) > 0 - bit 4
($PORTA AND 32) > 0 - bit 5
($PORTA AND 64) > 0 - bit 6
The 'AND' values are the mask. If you wanted to check multiple values on at the same time, say bit 0 & bit 7, the if would be
($PORTA AND 129) = 129
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: If Decision Fails Flowcode 5
Thank you,
dbasnett & Enamul
I totally missed the point and will take the information and work with it.
I really thank everyone,
John
dbasnett & Enamul
I totally missed the point and will take the information and work with it.
I really thank everyone,
John
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: If Decision Fails Flowcode 5
Hi all,
It worked and now I just nee to see how to address the common Anode issue.
John
it is a happy day with the great help.It worked and now I just nee to see how to address the common Anode issue.
John
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: If Decision Fails Flowcode 5
Hello all,
Well with the help of "dbasnett ' outlining the code to determine when a incoming request was sent.
Now I would like to add a little more. it is inspiring to learn more.
I tried to read the PORTA variable but I could not read the value. I know the formula works because when I requested a switch the decision returned the result.
now I would like to add a further step and calculate the PortA and return the value so I can speed up the next step. I have 8 buttons to scan and send of to display the correct score.
Seeing the ($PORTA AND 224 ) > 0 results in that decision I would like to take the PORTA value and come up with a 1 - 8 selection so I can go directly to the segment selection. At present I have to scan button from 1 - 8 so If I could jump say to 5 if PortA bit 5 (32) comes up I could - 27 from PortA and come up with Selection 5. I think I would need 8 formulas to cover all the keys but maybe their is a better way.
If I can address the Switch to select the correct key it would be a Little cleaner
John
Well with the help of "dbasnett ' outlining the code to determine when a incoming request was sent.
Now I would like to add a little more. it is inspiring to learn more.
I tried to read the PORTA variable but I could not read the value. I know the formula works because when I requested a switch the decision returned the result.
now I would like to add a further step and calculate the PortA and return the value so I can speed up the next step. I have 8 buttons to scan and send of to display the correct score.
Seeing the ($PORTA AND 224 ) > 0 results in that decision I would like to take the PORTA value and come up with a 1 - 8 selection so I can go directly to the segment selection. At present I have to scan button from 1 - 8 so If I could jump say to 5 if PortA bit 5 (32) comes up I could - 27 from PortA and come up with Selection 5. I think I would need 8 formulas to cover all the keys but maybe their is a better way.
If I can address the Switch to select the correct key it would be a Little cleaner
John
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: If Decision Fails Flowcode 5
Hi
I am not totally sure what you are trying to do.
If you were to somehow encode 8 selections onto PORTA bits 7,6,5
Then your formula would be
SW = (($PORTA AND 224) >> 5) + 1
Where SW now has a value 1 to 8
If you are using all of PORTA for 8 separate switches, then you could have a Switch icon to test for values 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
That will only work when only one switch is pressed at a time, otherwise you will need 8 separate If icons and test ($PORTA AND 0x80) etc, as Ben’s code.
Hope that helps.
Leigh
I am not totally sure what you are trying to do.
If you were to somehow encode 8 selections onto PORTA bits 7,6,5
Then your formula would be
SW = (($PORTA AND 224) >> 5) + 1
Where SW now has a value 1 to 8
If you are using all of PORTA for 8 separate switches, then you could have a Switch icon to test for values 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
That will only work when only one switch is pressed at a time, otherwise you will need 8 separate If icons and test ($PORTA AND 0x80) etc, as Ben’s code.
Hope that helps.
Leigh
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: If Decision Fails Flowcode 5
Hello Leigh
Thank you for the further information. My plan is to see if it is possible to take the single Push buttons and use the value to route directly down the Switch Value.
Here is a sample flow I put together to show the flow.
I tried to different formulas but it is not my forte. I had trouble coming up with a formula.
There will be 8 incoming push buttons. They will be PORT B ( 0 - 7 ).
The vision is have PORT B - 0-7 as Port B set to (INCOMING) then the code will switch to Port B to (OUTPUT) and send the bit pattern out to control chips.
Thank you for the further information. My plan is to see if it is possible to take the single Push buttons and use the value to route directly down the Switch Value.
Here is a sample flow I put together to show the flow.
I tried to different formulas but it is not my forte. I had trouble coming up with a formula.
There will be 8 incoming push buttons. They will be PORT B ( 0 - 7 ).
The vision is have PORT B - 0-7 as Port B set to (INCOMING) then the code will switch to Port B to (OUTPUT) and send the bit pattern out to control chips.
-
- 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: If Decision Fails Flowcode 5
Hi John,
Attached is how I detect which switch has been pressed.
It's the easiest way I can think of.
Martin
Attached is how I detect which switch has been pressed.
It's the easiest way I can think of.
Martin
- Attachments
-
- Direction Flow 414 V2.fcf
- (73.92 KiB) Downloaded 203 times
Martin
-
- Posts: 125
- Joined: Mon Aug 15, 2011 1:54 pm
- Has thanked: 8 times
- Been thanked: 11 times
- Contact:
Re: If Decision Fails Flowcode 5
I am confused. Is port B or port A the push buttons? In the attachment you are reading A.JLeith wrote:Hello Leigh
Thank you for the further information. My plan is to see if it is possible to take the single Push buttons and use the value to route directly down the Switch Value.
Here is a sample flow I put together to show the flow.
I tried to different formulas but it is not my forte. I had trouble coming up with a formula.
There will be 8 incoming push buttons. They will be PORT B ( 0 - 7 ).
The vision is have PORT B - 0-7 as Port B set to (INCOMING) then the code will switch to Port B to (OUTPUT) and send the bit pattern out to control chips.
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: If Decision Fails Flowcode 5
Sorry about the mix up.
When I copied the picture I was trying to see what Port would work out.
I have a odd process that is causing me a Little concern is that I will be using a process that was in the OLD scoreboard I was given to try and bring back to life. I determined that I could use the PIC 16F1826 that the same process with Port A as timer and Port B as the port to receive the Wireless input that will be providing momentary outputs to PORT B 0 - 7. and once the push button in principle goes High then I can still develop the code in Flowcode 5. So I was trying to use Port B push buttons to simulate the wireless inputs.
I was hoping to determine the Port B state and select the correct path. Currently I come into the "Switch Value" and scan all 8 looking for the button. I thought that If I could get into the "Switch Value" quicker it will make sure the push button was still active.
I hope this helps. I have a development power point but I can't upload it.
John
When I copied the picture I was trying to see what Port would work out.
I have a odd process that is causing me a Little concern is that I will be using a process that was in the OLD scoreboard I was given to try and bring back to life. I determined that I could use the PIC 16F1826 that the same process with Port A as timer and Port B as the port to receive the Wireless input that will be providing momentary outputs to PORT B 0 - 7. and once the push button in principle goes High then I can still develop the code in Flowcode 5. So I was trying to use Port B push buttons to simulate the wireless inputs.
I was hoping to determine the Port B state and select the correct path. Currently I come into the "Switch Value" and scan all 8 looking for the button. I thought that If I could get into the "Switch Value" quicker it will make sure the push button was still active.
I hope this helps. I have a development power point but I can't upload it.
John
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: If Decision Fails Flowcode 5
Hello Martin,
Wonderful work on the Switch Value and this allow the switch value to process correctly.
Now I have 1 more glitch that maybe you can help.
How can I set the switches to be Input on port B and once it goes into the routine to produce the display be Port B output. Do I have to add in "C" code to make that happen.
Just so I don't have the LED on port b respond to the buttons. When I make the PIC I have to have that working.
I have added the new improved Switch action to the growing work.
I really like getting the Knowledge and excellent help.
John
Wonderful work on the Switch Value and this allow the switch value to process correctly.
Now I have 1 more glitch that maybe you can help.
How can I set the switches to be Input on port B and once it goes into the routine to produce the display be Port B output. Do I have to add in "C" code to make that happen.
Just so I don't have the LED on port b respond to the buttons. When I make the PIC I have to have that working.
I have added the new improved Switch action to the growing work.
I really like getting the Knowledge and excellent help.
John
- Attachments
-
- Direction Flow with new switch.fcf
- New switch layout.
- (93.63 KiB) Downloaded 192 times