Page 1 of 1

RESOLVED Help please with stepper file.

Posted: Fri Apr 14, 2017 1:08 pm
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

Re: Help please with stepper file.

Posted: Fri Apr 14, 2017 4:02 pm
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

Re: Help please with stepper file.

Posted: Fri Apr 14, 2017 4:39 pm
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

Re: Help please with stepper file.

Posted: Fri Apr 14, 2017 4:40 pm
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

Re: Help please with stepper file.

Posted: Fri Apr 14, 2017 5:50 pm
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

Re: Help please with stepper file.

Posted: Fri Apr 14, 2017 6:52 pm
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

Re: Help please with stepper file.

Posted: Fri Apr 14, 2017 7:44 pm
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

Re: Help please with stepper file.

Posted: Sat Apr 15, 2017 4:30 pm
by QMESAR
:D great good luck