Society of Robots - Robot Forum

Software => Software => Topic started by: OperationIvy on February 21, 2009, 04:09:23 PM

Title: Reading PWM on Axon
Post by: OperationIvy on February 21, 2009, 04:09:23 PM
Anyone have any experience/resources regarding reading a PWM signal on an Axon? I'm using a Devantech digital compass, and my options are PWM or I2C. There doesn't seem to be much support for I2C on the Axon so hopefully there is a solution available for PWM.

Thanks
Title: Re: Reading PWM on Axon
Post by: Webbot on February 21, 2009, 04:25:15 PM
I would suggest you look at the I/O pins. You can turn on interrupts on most of the IO pins to detect, and interrupt, voltage changes on an interrupt pin. You can then make the interrupt routines store the time-of-day at the start of a signal, and then work out the elapsed time at the end of the signal.
Title: Re: Reading PWM on Axon
Post by: chelmi on February 21, 2009, 04:45:43 PM
Anyone have any experience/resources regarding reading a PWM signal on an Axon? I'm using a Devantech digital compass, and my options are PWM or I2C. There doesn't seem to be much support for I2C on the Axon so hopefully there is a solution available for PWM.

Thanks

The axon has support for I2C, but for legal reason Atmel didn't use the I2C (protected) name and named it TWI (Two Wire Interface). Look in the datasheet, page 241.

A great tutorial:
http://www.instructables.com/id/I2C_Bus_for_ATtiny_and_ATmega/

Chelmi
Title: Re: Reading PWM on Axon
Post by: Admin on February 25, 2009, 10:06:32 AM
It's just like interfacing the Ping))) sonar (check Axon source code).

Also, just like the SRF05:
http://www.societyofrobots.com/robotforum/index.php?topic=5943.0
Title: Re: Reading PWM on Axon
Post by: Webbot on February 25, 2009, 05:48:55 PM
It's just like interfacing the Ping))) sonar (check Axon source code).

Also, just like the SRF05:
http://www.societyofrobots.com/robotforum/index.php?topic=5943.0

Depending on what the requirement is: then 'not quite'.

The sonars work by sending an output pulse and then wait for an input pulse and measure how long they are (as per your links).

But if you are trying to read a non-stop stream of pulses, whilst running other code, then you dont know when the pulse will start, let alone end. So you cant use the same algorithm as the timer. (As the PWM pulse may start when you are off doing other things).

Hence my suggestion to use io pin interrupts to signal the start of a pulse. In the interrupt you can then measure it in the same way as admin said.

Title: Re: Reading PWM on Axon
Post by: Admin on February 26, 2009, 04:51:28 AM
oops wait ignore my last post. It was after midnight . . . I read 'Devantech' and immediately thought of their sonar . . . sorry for the confusion!!!