Author Topic: Reading PWM into Axon  (Read 1952 times)

0 Members and 1 Guest are viewing this topic.

Offline TomasTopic starter

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 0
Reading PWM into Axon
« on: January 22, 2009, 04:55:58 PM »
Im currently in the making of a radio-controller for my robot, to tell it when its allowed to drive and when its not.

The deal is that whenever the radiocontroller is on, the radioreciever sends out a PWM signal with a 1,5ms peak of a total 20ms. When the radiocontroller is off, its no peak in this signal (just low).

So right now for the override function basically reads if there is any high value on the port the radioreciever is connected to. If it reads any signal from the radioreciever, the robot should continue with its regular code. If not, it should stand still with the servo centered and motorcontroller "centered" (they are quiet when its a PWM signal with 1,5 ms peaks).

The problem here is that its very much noise, so the car will some times go even if the radiocontroller is off. This is because it just needs a peak in the signal, but it doesnt care how long the peak is. In my example, I need it to look for 1.5 ms long peaks to reduce the possibility of noise activating the rest of the code.

So anyone know where I could start for reading PWM signals into axon?

Thanks for any help.


edit; here's the code for the function as it is now

Code: [Select]
void checkSignal(void)
{
#define PINNR 3 //Connected to PIN A3
#define DDR DDRA
#define PORT PORTA
#define PIN PINA
PORT_ON(DDR, PINGPIN); //Turn port A3 on
FLIP_PORT(DDR, PINGPIN); //Turning output port into input port

if (bit_is_set(PIN, PINNR)==0) //if there is no signal coming from control unit
{
pwmSetH4(1500); //turn motor to "quiet mode"
pwmSetH3(1550); //center servo
}
loop_until_bit_is_set(PIN, PINNR); //Loop this until signal is coming from control unit
PORT_OFF(PORT, PINNR); //Turn port A3 off, not sure if necassary
}
« Last Edit: January 22, 2009, 05:10:22 PM by Tomas »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Reading PWM into Axon
« Reply #1 on: January 22, 2009, 08:24:55 PM »
Quote
The problem here is that its very much noise, so the car will some times go even if the radiocontroller is off. This is because it just needs a peak in the signal, but it doesnt care how long the peak is.
Do you have an oscilloscope to have a look at the noise?

Are there motors or other stuff near by to cause this?

Anyway, here is some code:
http://www.societyofrobots.com/robotforum/index.php?topic=3099.msg25106#msg25106

Offline TomasTopic starter

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 0
Re: Reading PWM into Axon
« Reply #2 on: January 23, 2009, 01:49:24 AM »
There is a motor pretty near by the antenna. Ill try moving it. Also, Ill try some of the suggestions in the other topic. Thanks

 


data_list