position encoder

Discussion related to "under the hood" OpenMV topics.
pcls1026
Posts: 62
Joined: Tue Aug 22, 2017 1:33 am

position encoder

Postby pcls1026 » Mon Aug 06, 2018 3:40 pm

Do you have a python example to read a simple quadrature encoder with the cam 7?
User avatar
kwagyeman
Posts: 2277
Joined: Sun May 24, 2015 2:10 pm

Re: position encoder

Postby kwagyeman » Mon Aug 06, 2018 10:34 pm

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
Nyamekye,
pcls1026
Posts: 62
Joined: Tue Aug 22, 2017 1:33 am

Re: position encoder

Postby pcls1026 » Tue Aug 07, 2018 3:08 pm

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?
User avatar
kwagyeman
Posts: 2277
Joined: Sun May 24, 2015 2:10 pm

Re: position encoder

Postby kwagyeman » Tue Aug 07, 2018 4:29 pm

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.
Nyamekye,
pcls1026
Posts: 62
Joined: Tue Aug 22, 2017 1:33 am

Re: position encoder

Postby pcls1026 » Thu Aug 09, 2018 6:16 pm

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.
patrickpoirier51
Posts: 33
Joined: Sat Apr 08, 2017 9:04 am

Re: position encoder

Postby patrickpoirier51 » Thu Aug 09, 2018 9:35 pm

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$
pcls1026
Posts: 62
Joined: Tue Aug 22, 2017 1:33 am

Re: position encoder

Postby pcls1026 » Fri Aug 10, 2018 5:58 pm

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.
User avatar
kwagyeman
Posts: 2277
Joined: Sun May 24, 2015 2:10 pm

Re: position encoder

Postby kwagyeman » Fri Aug 10, 2018 8:46 pm

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

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 9 guests