Measuring frequencies with PWM channel

Based on DMP's Vortex processor / SoC this board is a full computer capable of running a standard Windows and Linux installation on the backpack of your robot.
2 postsPage 1 of 1
2 postsPage 1 of 1

Measuring frequencies with PWM channel

Post by Marsman » Fri Mar 01, 2013 8:01 pm

Post by Marsman
Fri Mar 01, 2013 8:01 pm

Hi,

is there a command in the RoBoard library to read a frequency of a digital signal from a PWM port?

I have an optocoupler near the axis of a wheels from my robot which switches on and off according to the speed of the wheel (disc with black/white stripes). When the wheel turns, the frequency of the digital signal is proportional to the speed. So far, I am using a routine which looks for say a rising edge, captures the time, then waits for the falling edge, and captures the time, again.

It would be more elegant if the RoBoard could deliver the frequency with a library command.

Thanks,

marsman
Hi,

is there a command in the RoBoard library to read a frequency of a digital signal from a PWM port?

I have an optocoupler near the axis of a wheels from my robot which switches on and off according to the speed of the wheel (disc with black/white stripes). When the wheel turns, the frequency of the digital signal is proportional to the speed. So far, I am using a routine which looks for say a rising edge, captures the time, then waits for the falling edge, and captures the time, again.

It would be more elegant if the RoBoard could deliver the frequency with a library command.

Thanks,

marsman
Marsman offline
Robot Builder
Robot Builder
Posts: 13
Joined: Sun Sep 27, 2009 9:47 am

Post by PaulL » Sun Mar 03, 2013 1:28 pm

Post by PaulL
Sun Mar 03, 2013 1:28 pm

What you have is correct. I have been through the libraries quite a bit (older version), and if you look at how position feedback is done on the servos (RCSERVO.cpp, ReadPosition functions), it's basically the same (using counters in the PWM circuitry instead, but it's functionally the same as RDTSC or whatever time method you choose).

The only difference is in how you go after the duration. You can block, this is what's done in RCSERVO, or you can poll for state change (which is what blocking does, except that the idea here is that you go do other things instead of waiting), or you can use interrupts.

I haven't tried this, but here's some info:

http://robosavvy.com/Builders/PaulL/DMP_Vortex86_Series_Software_Programming_Reference_091216.pdf

Go to page 26, section 3.5. There's info there on GPIO with interrupts. Use an ISR to generate cycle start / cycle end time stamps to get duration.

OR, you can just do blocking or polling. :)

Paul
What you have is correct. I have been through the libraries quite a bit (older version), and if you look at how position feedback is done on the servos (RCSERVO.cpp, ReadPosition functions), it's basically the same (using counters in the PWM circuitry instead, but it's functionally the same as RDTSC or whatever time method you choose).

The only difference is in how you go after the duration. You can block, this is what's done in RCSERVO, or you can poll for state change (which is what blocking does, except that the idea here is that you go do other things instead of waiting), or you can use interrupts.

I haven't tried this, but here's some info:

http://robosavvy.com/Builders/PaulL/DMP_Vortex86_Series_Software_Programming_Reference_091216.pdf

Go to page 26, section 3.5. There's info there on GPIO with interrupts. Use an ISR to generate cycle start / cycle end time stamps to get duration.

OR, you can just do blocking or polling. :)

Paul
PaulL offline
Savvy Roboteer
Savvy Roboteer
Posts: 423
Joined: Sat Sep 15, 2007 12:52 am


2 postsPage 1 of 1
2 postsPage 1 of 1