again about voltage shifts and encoders

Status
Not open for further replies.

ig-or

Active member
Hello! I was trying to measure the rotation angle (of the motor) with encoders, on Teensy 4.1. The mistake was to feed the encoders with 5V power, and send encoder output to teensy pins. (Encoders needed at least 4 volts). Teensy survived though, maybe due to thin and long wires. And "standard" _Encoders_ library worked and counted approximately correct rotation. Then I added this logic level shifter https://www.pololu.com/product/2595 . to make 3.3 volts from 5 volts, and looks like it worked again somehow.

But based on this thread, https://forum.pjrc.com/threads/26803-Hardware-Quadrature-Code-for-Teensy-3-x?p=74544&viewfull=1#post74544 this kind of logic Logic Level Shifter are not OK for those tasks. But they (Pololu) claimed that it could be OK for 400 kHz I2C. And encoder signal maximum frequency in my case is less then 12 kHz. So what are good alternatives to those MOSFET logic shifters? I'm asking because the original thread about this is old. Or, maybe current MOSFET solution works OK? Then how to check if everything works fine and I'm not missing pulses because of this MOSFET hardware?

Another question: for two 12 kHz frequency encoder signals, is it OK to use "Encoder" library (using interrupts) or better to use "QuadEncoder" which may be probably faster?

Best regards!
 
Hello! I was trying to measure the rotation angle (of the motor) with encoders, on Teensy 4.1. The mistake was to feed the encoders with 5V power, and send encoder output to teensy pins. (Encoders needed at least 4 volts). Teensy survived though, maybe due to thin and long wires. And "standard" _Encoders_ library worked and counted approximately correct rotation. Then I added this logic level shifter https://www.pololu.com/product/2595 . to make 3.3 volts from 5 volts, and looks like it worked again somehow.

But based on this thread, https://forum.pjrc.com/threads/26803-Hardware-Quadrature-Code-for-Teensy-3-x?p=74544&viewfull=1#post74544 this kind of logic Logic Level Shifter are not OK for those tasks. But they (Pololu) claimed that it could be OK for 400 kHz I2C. And encoder signal maximum frequency in my case is less then 12 kHz. So what are good alternatives to those MOSFET logic shifters? I'm asking because the original thread about this is old. Or, maybe current MOSFET solution works OK? Then how to check if everything works fine and I'm not missing pulses because of this MOSFET hardware?

Another question: for two 12 kHz frequency encoder signals, is it OK to use "Encoder" library (using interrupts) or better to use "QuadEncoder" which may be probably faster?

Best regards!

The comment on the MOSFET circuit is still valid, it will probably distort your square waves. You would have to test and look at scope. If you are only 12KHz, it might be fine. But it's not the right circuit for the job here, as you don't need bidirectional shifting, just one way.

Best design I would use is a SN74LV14APWR, power it off 3.3V, as it will handle 5V on the inputs. Or you can use simple resistor dividers to bring your 5V down to 3.3V. See https://randomnerdtutorials.com/how-to-level-shift-5v-to-3-3v/ You won't suffer any speed loss with that setup.

Use the QuadEncoder, as it uses hardware counters to count your pulses, no interrupts needed for that, except for rollover on the counter, which is every so often.
 
For signals this slow, that mosfet level shifter is probably ok.

Of course a proper unidirectional buffer is best. SN74LV14APWR is a very good one.
 
Status
Not open for further replies.
Back
Top