Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: again about voltage shifts and encoders

  1. #1
    Member
    Join Date
    Jan 2018
    Location
    Livermore
    Posts
    26

    again about voltage shifts and encoders

    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...ll=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!

  2. #2
    Quote Originally Posted by ig-or View Post
    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...ll=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-...ft-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.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,057
    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.

  4. #4
    Member
    Join Date
    Jan 2018
    Location
    Livermore
    Posts
    26
    TeensyWolf, Paul, thank you for the information and support.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •