Resolved/switch case looping?
Moderator: Benj
-
- Posts: 50
- Joined: Mon Apr 10, 2017 12:53 pm
- Has thanked: 39 times
- Been thanked: 13 times
- Contact:
Resolved/switch case looping?
Can some one please help me out with this file for flowcode v7.
What i am trying to do is for the loop to go through the switch case five
times then end, whats happening is the four leds light up when going
through the switch case then ending, with out going back to the loop again.
being trying varies ways but cannot sort this out.
thanks for looking.
regards astro1234
What i am trying to do is for the loop to go through the switch case five
times then end, whats happening is the four leds light up when going
through the switch case then ending, with out going back to the loop again.
being trying varies ways but cannot sort this out.
thanks for looking.
regards astro1234
- Attachments
-
- Switch_Case.fcfx
- (12.13 KiB) Downloaded 269 times
Last edited by astro1234 on Thu May 04, 2017 9:46 am, edited 1 time in total.
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: switch case looping?
Hi Try this
use the simulator in single step mode and you will see the loop execute 5 times
use the simulator in single step mode and you will see the loop execute 5 times
- Attachments
-
- Switch_Case.fcfx
- (13.45 KiB) Downloaded 261 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 50
- Joined: Mon Apr 10, 2017 12:53 pm
- Has thanked: 39 times
- Been thanked: 13 times
- Contact:
Re: switch case looping?
Thank you QMESAR for helping me out with the problem, just two questions, whatQMESAR wrote:Hi Try this
use the simulator in single step mode and you will see the loop execute 5 times
is red circle by the left side of the calculation icon used for , and how can i let the file run
on its own with out using the step into icon.
Regards astro1234
- 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: switch case looping?
Hello Astro1234,
https://www.matrixtsl.com/wikiv7/index. ... reakpoints
That is signifying a breakpoint. Simply right click the flowchart icon and from the menu you can switch off the breakpoint functionality.what is red circle by the left side of the calculation icon used for , and how can i let the file run on its own with out using the step into icon.
https://www.matrixtsl.com/wikiv7/index. ... reakpoints
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
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: switch case looping?
You are welcome and Ben answered your questions Thanks Ben
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 50
- Joined: Mon Apr 10, 2017 12:53 pm
- Has thanked: 39 times
- Been thanked: 13 times
- Contact:
Re: switch case looping?
Thanks QMESAR, i removed the breakpoint(i am learning ),but the loop does not stop at all,Benj wrote:Hello Astro1234,
That is signifying a breakpoint. Simply right click the flowchart icon and from the menu you can switch off the breakpoint functionality.what is red circle by the left side of the calculation icon used for , and how can i let the file run on its own with out using the step into icon.
https://www.matrixtsl.com/wikiv7/index. ... reakpoints
the loop needs to run for five loops then stop, is your file ok ?.
i appreciate your help,thanks again.
Regards astro1234
-
- 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: switch case looping?
Hi astro1234
Do you mean like the attached Flowchart?
Martin
Do you mean like the attached Flowchart?
Martin
- Attachments
-
- Switch_Case V2.fcfx
- (12.81 KiB) Downloaded 249 times
Martin
-
- 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: switch case looping?
Unless you want the program to totally end?
The above one restarted switch after 5th cycle
There is a much more efficient way to LED chase 5 times.
I can post that as well if you like?
The above one restarted switch after 5th cycle
There is a much more efficient way to LED chase 5 times.
I can post that as well if you like?
- Attachments
-
- Switch_Case V3.fcfx
- (12.66 KiB) Downloaded 253 times
Martin
-
- Posts: 50
- Joined: Mon Apr 10, 2017 12:53 pm
- Has thanked: 39 times
- Been thanked: 13 times
- Contact:
Re: switch case looping?
Hello medelec35,medelec35 wrote:Hi astro1234
Do you mean like the attached Flowchart?
Martin
well its different, but its not what i am after,
if you put a led in a say a five loop routine, when the flowchart as completed the five loops
the flowchart ends. when you run your flowchart the loop neven ends, it just keeps on for ever.
what i am trying to do is, put a switch icon in a loop which runs five times then the flowchart ends
if that make sense.
thanks for looking at the flowchart.
Regards astro1234
-
- 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: switch case looping?
Yes,astro1234 wrote:what i am trying to do is, put a switch icon in a loop which runs five times then the flowchart ends
if that make sense
The Flowchart is Switch_Case V3.fcfx which is one post above your latest reply.
At the time of writing has not been downloaded yet.
Switch_Case V2.fcfx was created in case you need to do something else fter the 5 loops.
Martin
-
- Posts: 50
- Joined: Mon Apr 10, 2017 12:53 pm
- Has thanked: 39 times
- Been thanked: 13 times
- Contact:
Re: switch case looping?
Thank you medelec35/QMESAR/Benj.medelec35 wrote:Yes,astro1234 wrote:what i am trying to do is, put a switch icon in a loop which runs five times then the flowchart ends
if that make sense
The Flowchart is Switch_Case V3.fcfx which is one post above your latest reply.
At the time of writing has not been downloaded yet.
Switch_Case V2.fcfx was created in case you need to do something else fter the 5 loops.
Thats the flowchart routine what i was after,works great, thanks for your
help in getting it to work.
Regards astro1234
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: switch case looping?
HI
Happy you have it running now good luck
I am sorry I missed the part that the loop should end after 5 times ,Thanks to the other guys picking it up also my Flowchart had no intentions of optimizing your Flowchart ,I wanted to point out that you can use for loop to loop a number of timesswitch case five times then end,
Happy you have it running now good luck
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- 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: switch case looping?
Hi astro1234,
Glad it's working for you.
alternatively you don't need the loop variable.
You could just set loop count as 20
I have attached a more efficient way with less icons for educational interest.
I'm using bit manipulation:
just shift bits left by 1 which is a more efficient way of multiplying by 2
& is bitwise AND; compares pairs of bits and returns 1 if both bits are 1, otherwise returns 0
In our case it determines the maximum number i.e. 15
So with5 then if x starts off at 1, you should get:
Since maximum number can never be more than 15
Glad it's working for you.
alternatively you don't need the loop variable.
You could just set loop count as 20
I have attached a more efficient way with less icons for educational interest.
I'm using bit manipulation:
Code: Select all
x = ((x << 1) & 15)
Code: Select all
<< 1
& is bitwise AND; compares pairs of bits and returns 1 if both bits are 1, otherwise returns 0
In our case it determines the maximum number i.e. 15
So with
Code: Select all
((x << 1) & 15)
Code: Select all
1
2
4
8
0
- Attachments
-
- Switch_Case V4.fcfx
- (11.35 KiB) Downloaded 202 times
Martin
-
- Posts: 50
- Joined: Mon Apr 10, 2017 12:53 pm
- Has thanked: 39 times
- Been thanked: 13 times
- Contact:
Re: switch case looping?
medelec35 wrote:Hi astro1234,
Glad it's working for you.
alternatively you don't need the loop variable.
You could just set loop count as 20
I have attached a more efficient way with less icons for educational interest.
I'm using bit manipulation:Code: Select all
x = ((x << 1) & 15)
just shift bits left by 1 which is a more efficient way of multiplying by 2Code: Select all
<< 1
& is bitwise AND; compares pairs of bits and returns 1 if both bits are 1, otherwise returns 0
In our case it determines the maximum number i.e. 15
So with5 then if x starts off at 1, you should get:Code: Select all
((x << 1) & 15)
Since maximum number can never be more that 15Code: Select all
1 2 4 8 0
Thank you medelec35 for your time in helping me out with this problem.(lot more questions to come to the forum regarding stepper drives, need to update my drive system for my telescope mount in the observatory ).
Now that flowchart i under stand, lot simpler than the other flowcharts.
Regards astro1234.