Page 1 of 1

position encoder

Posted: Mon Aug 06, 2018 3:40 pm
by pcls1026
Do you have a python example to read a simple quadrature encoder with the cam 7?

Re: position encoder

Posted: Mon Aug 06, 2018 10:34 pm
by kwagyeman
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:

http://docs.openmv.io/library/pyb.ExtInt.html

Re: position encoder

Posted: Tue Aug 07, 2018 3:08 pm
by pcls1026
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?

Re: position encoder

Posted: Tue Aug 07, 2018 4:29 pm
by kwagyeman
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.

Re: position encoder

Posted: Thu Aug 09, 2018 6:16 pm
by pcls1026
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.

Re: position encoder

Posted: Thu Aug 09, 2018 9:35 pm
by patrickpoirier51
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$

Re: position encoder

Posted: Fri Aug 10, 2018 5:58 pm
by pcls1026
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.

Re: position encoder

Posted: Fri Aug 10, 2018 8:46 pm
by kwagyeman
Yeah, it's easier to do. Serial input on the cam is tribal.