chipKIT® Development Platform

Inspired by Arduino™

How input capture works?

Created Mon, 17 Feb 2014 20:58:42 +0000 by mhintzke


mhintzke

Mon, 17 Feb 2014 20:58:42 +0000

I am using the Digilent Robot Starter Kit for my Embedded Systems class and am trying to use Input Capture to figure out the speed of the motors, however, I still am unsure how to implement Input Capture in order to do this. I thought input capture gets the timestamp of an event on a specific pin, but I do not get what this "event" actually is and how I can use it to measure the speed of the motor. Any help in the right direction would help. Thanks!


Ian_B

Wed, 19 Feb 2014 20:59:44 +0000

So my understanding (from glancing at the Input Capture section of the PIC32MX460F512L family reference manual) is that on an event, the ICxBUF registers will contain the timer value at which that event happened.

According to the reference manual, you have these events for input capture to choose from:

• Capture timer value on every falling edge of input applied at the ICx pin • Capture timer value on every rising edge of input applied at the ICx pin • Capture timer value on every fourth rising edge of input applied at the ICx pin • Capture timer value on every sixteenth rising edge of input applied at the ICx pin • Capture timer value on every rising and falling edge of input applied at the ICx pin • Capture timer value on the specified edge and every edge thereafter

Not quite sure the best way to go about implementing that for motor control. It really depends on what signal from the motors or H-bridges you are using for triggering the input capture.

[url]https://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en534177[/url]


Jacob Christ

Fri, 21 Feb 2014 06:54:34 +0000

The PONTECH UAV100 project on github has examples of using input capture to time rc servo pwm signals. It may not be portable but it works on a pic32.

Jacob


Jacob Christ

Sat, 22 Feb 2014 23:34:10 +0000

I was reminded yesterday that the UAV100 code does not use input capture but instead change notice interrupts and the millis function. Sorry.

Jacob