Using the PSoC4 Pioneer Kit and a 500 PPR encoder I am trying to get it to count up when I turn the encoder in one direction then count down hen turned it the other direction; but it is not working correctly.
When I turn the encoder in what I believe to be the count-up direction (A leads B) it does count up.
When I turn the encoder in the count-down direction (B leads A) it does NOT count down.
It just toggle back-and-forth between two values.
I capture the counts through Hyper Terminal and log them to a .txt file.
My project and the text file are attached.
I manually edited the .txt file to give indicators when I changed encoder direction.
The provided project does not match your count output. I cannot see where you print "DN ".
Your components are outdated, consider updating to Creator 4.0 SP1 and updating tje components.
Thank you everyone for your replies.
I had HyperTerminal save the incoming counts to three .txt files.
1.) First I turned the encoder in the count-up direction and saved the counts to: counts01.txt and then closed that file
2.) Then I turned the encoder in the count-down direction and saved the counts to: counts02.txt and then closed that file.
3.) Last I turned the encoder in the count-up direction and saved the counts to: counts03.txt and then closed that file
4.) I combined the three files into one and changed the UP to DN at the right places and added the ---------------- between the UP and DN counts.
I tried to up-date my components but it looks like I have all the latest versions.
Any other help is appreciated.
This is my version of PSoC Creator:
I took a look at your project and I noticed that the "Encoding mode" under the "Quadrature Decoder" tab is set to 1x. That is fine for a tack to read RPM but you are interested in counting up and counting down so the Encoding mode should be set to 2x. That way the decoder can tell direction, up or down.
That worked Ken, thanks. But when I look at the counts on Hyper Terminal or look at them in the text file there are missing counts.
There are 20 numbers here, there should be 31. The 11 listed below were missed.
33411, 33413, 33414, 33418, 33420, 33422, 33423, 33428, 33431, 33433, 33436
I upped the UART's and Hyper Terminal's baud rate from 9600 to 19200. It seemed to of helped, but the numbers above were taken at 19200 so that didn't solve the problem.
Also, I stopped logging the numbers to a text file in case that was slowing things down but that didn't help.
I would think that others, maybe many others, have used the quadrature decoder component before with success and I am hoping they can give me some helpful input to my problem.
Can you please provide us with your actual project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
When you say the decoder is missing counts I don't think that is the case. Looking at your numbers such as 33410 and 33412, you are thinking that the decoder is missing counts, but it can't count from 33410 to 33412 unless it has already counted 33411. Just like you can't count from 1 to 10 by adding 1 to the previous number and not count all the numbers, you can't get to 5 from 3 by adding 1 unless you have already went from 3 to 4 first.
I think you data logging/display part is too slow, the count is there, it has already come-and-gone by the time the UART sends it to Hyper Terminal and it gets displayed.
I would try upping you BAUD rate, as odissey1 suggested.
Other possible bottlehecks could be:
1.) serial communication wiring from the PSoC board to your computer.
2.) your computer running slow.
3.) delay due to writing to the log file.
4.) UART-to-USB Bridge if you are using the PSoC 4 Pioneer board.
Thank you Odissey1, thank you Ken.
I upped the baud rate to 115200 and got the missing counts which proved Ken's theory correct. The quadrature decoder was working as it should, I just couldn't see it because of the missing counts. The missing counts from the too slow baud rate and not from the PSoC component.
So thanks again.