luni64 / EncoderTool

The EncoderTool is a library to manage and read out rotary encoders connected either directly or via multiplexers to ARM based boards. Encoder push buttons are supported. Callback functions can be attached to encoder changes and button presses to allow for event driven applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any way to output debug info?

djex opened this issue · comments

commented

I've been trying to get EncorderTool to work for hours now. I'm trying to use it with two SN74HC165N shift registers and a few Burns PEC16 mechanical quadrature encoders (no detent). I'm using a Teensy 3.2. I've tried every possible wiring combination and code but nothing seems to work. I made sure to follow the multiplexed 74165 example as well. I guess next step is to validate if the shift registers are even working. Is there any debug info I can get from EncoderTool? Maybe like raw data or something so I can see if it's reading anything from the shift registers?

There is no dedicated debug output mechanism in the library. Here the relevant function which handles the multiplexer:

void EncPlex74165::tick()

Should be easy to place a few prints in the function to see what is going wrong. I assume you are using the provided example for your tests?

In case you don't have a logic analyzer I strongly recommend to get one for this kind of project. It makes debugging hardware so much easier. You get cheap china clones for about 10$

commented

I have a Rigol DS1054Z scope which I'll have to use to troubleshoot further. Yes, I am using the provided examples to test. If I hook up the encoder directly to two pins on the Teensy and use EncoderTool to read this works great with no issues but for some reason I can not get it to work with the multiplexed 74HC165.

Also there is something in the latest git that breaks the Serial.printf function and stops it from printing to serial. The 2.2.1 release works though. Just thought I would let you know.

Edit: So I redid all the wiring using different pins on the Teensy for the Load, Clock and QH pins. It now outputs random numbers without even moving the encoder. Any idea what would cause this? I've tried all encoder CountModes but nothing helps.

commented

I solved the problem ... Turns out pin A on the 74HC165 is not encoder index 0. It's encoder index 8. I was trying to test with just 1 encoder and setting the encoderCount to 1 will never work if you wire it into pin A on the 74HC165. The way I figured it out was to set encoderCount to 8 and add a call back for every encoder index. Then when the encoder was moved encoder index 8 was the one that worked.... Is this how this is suppose to work or is something reversed in your code? I know I had issues in the past with the output of the 74HC165 being reversed.

Great, someone else stumbled over this some time ago. Completely forgot it. Might be a good idea to mention this somewhere in the documentation...

Is this how this is suppose to work or is something reversed in your code?

Kind of. I named the encoders according to the pins (A=0, B=1...). However, the '165 clocks them in in the opposite direction. If you only have e.g. 3 encoders you should connect them to F/G/H. Otherwise you need to always clock in the empty pins A-E.

Also there is something in the latest git that breaks the Serial.printf function and stops it from printing to serial. The 2.2.1 release works though. Just thought I would let you know

Thanks I'll have a look on the weekend.

commented

Kind of. I named the encoders according to the pins (A=0, B=1...). However, the '165 clocks them in in the opposite direction. If you only have e.g. 3 encoders you should connect them to F/G/H. Otherwise you need to always clock in the empty pins A-E.

I figured so. Since you already have a separate class for the 165 it might be possible to add custom code for the 165 to handle this reverse order? Though to get pin A as index 0 you would need to clock in all 8 bits every tick regardless of how many encoders are being used taking the last bit as index 0 and so on. Not as elegant as just clocking in what you need I guess. Maybe like you said, mentioning it in the documentation and possibly some code comments would help others.

Great, someone else stumbled over this some time ago. Completely forgot it. Might be a good idea to mention this somewhere in the documentation...

Please do so IMMEDIATELY! I have four encoders attached to A-D on the shift register and couldn't get any output. Thanks for all the work on this.

Done