Quadrature encoder Interface

Do particle photon have a quadrature decoding interface on it for directly connecting an encoder?

@lzooml, the STM32F205 processor does support this functionality but it is not supported in the firmware.

@peekay123 I just wanted to check in and make sure the Photons Firmware still does not support direct quadrature decoding. I’m searching for some ready to go code for this now and most of it is for the older Core.

@RWB, based on the STM32 AN4013 App Note:

This requires 2 or 3 channels of a single hardware timer. Using Hall Effect sensors requires 3 timer channels. The only timer with 3 exposed (to GPIO pins) channels on the Photon is TIMR2 which is used for the RGB LED.

Using an external incremental quadrature encoder requires 2 timer channels and a GPIO pin for a zero position sensor to create an interrupt to trigger counter resets. This configuration could use TIMR1 or TIMR3.

There is no Photon code or library for doing quadrature encoding directly that I know of.

Thanks for the info Paul.

Another quick question about the Photon and Quadurature Encoding.

I’m using the encoder to track the left & right movement + Up and Down movement of a solar panel so the movement will be very slow and will never make a 360 degree rotation. Other than that the Photon will just be reading GPS location data and calculating the current suns position which takes not much time and only happens every 5 mins or so.

Do you think there would be any benefit to using a separate chip like this that is designed to simply keep track of the encoders output and then just use the Photon to read the current position when ever needed?

The main benefit I see with the LS7366R encoder counting chip is that it only uses micro amps while ON while the Photon uses much more power than that.

Other than that is there any reason the Photon would not be up to the job of reading the A & B outputs from the magnetic encoder chip?

Here is the chip I’m evaluating and it works great. http://ams.com/eng/Products/Magnetic-Position-Sensors/Linear-Position/AS5311

This is all new to me so I’m asking questions for clarifications. I’m pretty sure the Photon could do the job just fine but I’m not 100% sure about that :smile:

@RWB, for the Photon to track the raw quadrature encoder output then it needs to be awake all the time so it can respond to GPIO interrupts. There are some good libraries for implementing a software decoder, some using timer sampling and others using interrupts.

The LS7366R will work fine but requires several external components. The other chip just seems plain complicated as it is the actual sensing chip and a suitable magnet needs to be in place on the panel assembly. @bko has lots of experience in this domain if I recall. :smile:

@peekay123 Thanks for the feedback.

I have the evaluation board for the chip along with a few different recommended ring magnets and it works beautifully actually. The demo board is pretty cool also since they basically built a mini computer to show off the chip which you can see below.

I’m also testing a magnetic 360 degree position sensor chip from the same company and the more I look at the differences between the 2 different chips I think the On Axis magnet chip that simply provides the heading from 0-360 degrees is the way to go because you can put it to sleep anytime the system is not driving the pan / tilt motors which is not very often.

I can tell you after testing both magnetic sensors I am very impressed with how accurate they actually are. They provide very high resolution which is pretty impressive.

1 Like

@peekay123: I also have an application that is a good fit for the Photon, except it must have a fast quadrature encoder interface (A/B only, not the zero signal). The ST documentation is confusing so I’m hoping you can kick start my learning curve. Is it possible to disable the RGB functionality and use the TMR2 pins (via test point pads) for encoder input? Alternatively, are the pins for TMR1 or TMR3 available?


@rayz, to use TMR2 you will need to remove the RGB LED first. You can now remap the RGB pins in code. As for TMR1 and TMR3, you will need to look at the Photon pinout in the docs. I’m currently on my way to the San Francisco Maker Fair.

@peekay123, thank you! The pinout doc I was using didn’t list the associated timers. Now I see on the official Photon datasheet that I can use TMR3_CH1 and TMR3_CH2 as long as I don’t need SPI1. I will attempt to get a library set up for this.

1 Like