Page 1 of 1

Program of encoder counts badly

Posted: Mon Jun 13, 2016 4:51 pm
by Francisco Cabrera
Hello good evening, this program does not work well...And I cannot discover for that :? ,
I turn the encoder to the right, the program counts well, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
But if I turn the encoder to the left side, the program counts ...16,15,14,13,12,10,90,80,70,60,50,40,30,20,10,01 :shock:

Someone might help me?´,

PD:Forgive my ignorance, I am a new user.

Re: Program of encoder counts badly

Posted: Mon Jun 13, 2016 5:07 pm
by Benj
Hello,

If you print a space or two after you print the number then this should solve the problem.

What you are doing is printing "10"

Then the next time around you print "9" however the "0" from the "10" is still there so you get "90".


Another way is to detect if the number is less than 10 and if it is then print a 0 before you print the number.

this gives you "10" and "09"

Re: Program of encoder counts badly

Posted: Mon Jun 13, 2016 8:54 pm
by Francisco Cabrera
hello everybody, I think that it is possible to do the program of different form, I leave here this program, he is working perfectly,For if someone needs it.

PD:Thank you Benj

Re: Program of encoder counts badly

Posted: Tue Jun 14, 2016 8:35 am
by Francisco Cabrera
I have a last question please, in flowcode it is not possible to activate interruption in RB0 and with flank of raise Or flank of descent ?
I have used interruption in (rb4, rb5, rb6, rb7) because not as doing it with interruption rb0

PD:Regards

Re: Program of encoder counts badly

Posted: Wed Jun 15, 2016 7:13 pm
by Francisco Cabrera
After many hours of study, I have seen how to do interruption in rb0 with flank of raise and flank of descent, yes we can in flowcode, I have used it to detect the step for z of the encoder, I leave here capture of screen for if someone needs some day...

PD: I´m very grateful for your help, without her the program had never worked regards. :D