RESOLVED Help please with stepper file.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
astro1234
Posts: 50
Joined: Mon Apr 10, 2017 12:53 pm
Has thanked: 39 times
Been thanked: 13 times
Contact:

RESOLVED Help please with stepper file.

Post by astro1234 »

Can some kind person please look at this flowcode file for me,
stepper number 2 will not move for/rev using sw3/sw4.
Stepper 1 works ok, as i am new to flowcode i am looking for some help
with the file.
Also i now have 5 keys for flowcode v7, because of purchasing more
chip packs (Thanks Matrix for the easter offer 50% of chip packs)
can i delete the first four keys, and just keep the latest, or do i keep
all the keys ?.
Thanks for looking
Regards Astro1234
Attachments
Steper-Forward_Reverse.fcfx
(22.2 KiB) Downloaded 261 times
Last edited by astro1234 on Sun Apr 16, 2017 3:35 pm, edited 1 time in total.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Help please with stepper file.

Post by QMESAR »

Hi Attached your corrected Flowchart,
However I did it in away that you can see what I did but there are many better ways to do than what you are doing now
but first learn as you are doing now and later you can improve your style
good luck and enjoy :D
Attachments
Steper-Forward_Reverse.fcfx
(22.2 KiB) Downloaded 280 times

astro1234
Posts: 50
Joined: Mon Apr 10, 2017 12:53 pm
Has thanked: 39 times
Been thanked: 13 times
Contact:

Re: Help please with stepper file.

Post by astro1234 »

QMESAR wrote:Hi Attached your corrected Flowchart,
However I did it in away that you can see what I did but there are many better ways to do than what you are doing now
but first learn as you are doing now and later you can improve your style
good luck and enjoy :D
thank you QMESAR for your help, i see that i set the properties switch to the wrong settings. :D
Regards astro1234

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Help please with stepper file.

Post by QMESAR »

you are welcome :D
The important thing here is not that it the wrong setting, however that you understood how we get to value 4 and 8 for SW3 and SW4 :D

astro1234
Posts: 50
Joined: Mon Apr 10, 2017 12:53 pm
Has thanked: 39 times
Been thanked: 13 times
Contact:

Re: Help please with stepper file.

Post by astro1234 »

QMESAR wrote:you are welcome :D
The important thing here is not that it the wrong setting, however that you understood how we get to value 4 and 8 for SW3 and SW4 :D
is the value 4 and 8 seen as a binary number,? because i see in the props/switch boxes 1,2,4,8 are used. :?:
Regards astro1234

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Help please with stepper file.

Post by QMESAR »

is the value 4 and 8 seen as a binary number
the 4 and 8 is not the binary number but the decimal equivalent of the binary number of your PORTB which you read the SW inputs

We can think of each pin on an IO port as a single bit in an 8-bit binary number,as the PORT is 8 bit wide and starting from left to right the the bits are
7 6 5 4 3 2 1 0 bits
RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0

SW3 connected to bit 2(RB2)
SW4 connected to bit 3(RB3)

your SW3 is connected to RB2 when it is pressed the voltage at the is 5V then the value you read into the PORTB is 0b00000100 in decimal that is 4 , that is way you have to test for 4 and not 1 as you did the same is valid for SW4 it is connected to RB3 when the button is pressed you have 0b00001000 binary is 8 decimal, for SW4 pressed you have to test for the value of 8 and not 2 just notice 0b is the prefix for binary numbers.
secondly this will also only work when you press 1 button at the time if you would press 2 buttons at the same time your code will not work again ,see if you can figure out why not

hope this helps I am no good teacher :D

astro1234
Posts: 50
Joined: Mon Apr 10, 2017 12:53 pm
Has thanked: 39 times
Been thanked: 13 times
Contact:

Re: Help please with stepper file.

Post by astro1234 »

QMESAR wrote:
is the value 4 and 8 seen as a binary number
the 4 and 8 is not the binary number but the decimal equivalent of the binary number of your PORTB which you read the SW inputs

We can think of each pin on an IO port as a single bit in an 8-bit binary number,as the PORT is 8 bit wide and starting from left to right the the bits are
7 6 5 4 3 2 1 0 bits
RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0

SW3 connected to bit 2(RB2)
SW4 connected to bit 3(RB3)

your SW3 is connected to RB2 when it is pressed the voltage at the is 5V then the value you read into the PORTB is 0b00000100 in decimal that is 4 , that is way you have to test for 4 and not 1 as you did the same is valid for SW4 it is connected to RB3 when the button is pressed you have 0b00001000 binary is 8 decimal, for SW4 pressed you have to test for the value of 8 and not 2 just notice 0b is the prefix for binary numbers.
secondly this will also only work when you press 1 button at the time if you would press 2 buttons at the same time your code will not work again ,see if you can figure out why not

hope this helps I am no good teacher :D
Thank you i understand now.I am new to flowcode so have a lot to learn. :D
regards astro1234

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Help please with stepper file.

Post by QMESAR »

:D great good luck

Post Reply