Author Topic: Reading PWM on Axon  (Read 3062 times)

0 Members and 1 Guest are viewing this topic.

Offline OperationIvyTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
Reading PWM on Axon
« 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

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Reading PWM on Axon
« Reply #1 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.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
    • Current projects
Re: Reading PWM on Axon
« Reply #2 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

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,704
  • Helpful? 173
    • Society of Robots
Re: Reading PWM on Axon
« Reply #3 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

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Reading PWM on Axon
« Reply #4 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.

Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,704
  • Helpful? 173
    • Society of Robots
Re: Reading PWM on Axon
« Reply #5 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!!!

 

SMF spam blocked by CleanTalk