position encoder

Do you have a python example to read a simple quadrature encoder with the cam 7?

Hi, the OpenMV Cam would not be good for this type of thing. While you can definitely interrupt it to count the encoder ticks using interrupts you’re not going to capture all ticks due to USB stuff happening at 1KHz.

If you still want to use an encoder see here:


I understand ithe example Python code would not run well while run as a script. However, would it run OK when it is loaded onto the uProcessor and run with a battery or just a power only USB cable?

Hi, the camera interrupts the processor per line of data coming in. In general, there are too many interrupts on the system to do a good job like an Arduino monitoring interrupts. If the encoder is a low resolution one and updates slowly then this is okay. However, realistically the processor can’t be trusted to have super real-time performance for anything that doesn’t have hardware pheripals to montitor.

This all said… the timers on the STM32 have the ability to do encoder logic in hardware and can do quadrature encoding. However, I don’t know how to use this from the python interface. But, if you want to figure it out the microcontroller can definitely do it.

The STM processor does use interupts on its QEModule.
Will I still have interrupt problems if I take a picture; wait until the uP is done processing the image; and then use the QEmodule. I can do this because I will not be moving when I’m using the camera and there won’t be any QEModule interrupts being generated.

Would it be much simpler if you use an arduino to read the encoder and transmit position using I2C or SPI to OpenMV. This is usually what we do with wheel encoder, there are numerous examples on the web and an arduino pro mini is 2$

I like that solution, patrickpoirier51 . What do you think Kwagyeman? I could collect the data, calculate the distance traveled and transmit a 2 byte word to Cam7 every 0.1 second.

Yeah, it’s easier to do. Serial input on the cam is tribal.