Author Topic: Axon II with 6 channel RC receiver code  (Read 1496 times)

0 Members and 1 Guest are viewing this topic.

Offline BANETopic starter

  • Supreme Robot
  • *****
  • Posts: 639
  • Helpful? 4
  • E=roboticsC^2
Axon II with 6 channel RC receiver code
« on: April 09, 2011, 06:14:48 PM »
Hello all,
Does anybody have some code snipts or how-to advice for receiving signals from and RC receiver? 

thnx,

any help would be appreciated

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: Axon II with 6 channel RC receiver code
« Reply #1 on: April 10, 2011, 08:00:02 AM »
Hi Bane,

I have not done it on the Axon2, but have done if for Basic Atom Pros. 

There are a few different approaches:

1) To start off you might try the function: pin_pulseIn
You would do this for each IO pin connected to your receiver. This is the simplest way, but could be real slow, especially if you order your pulsein's in the wrong order.  That is suppose that you order it in the logical order: 1, 2, 3, 4, 5, 6 and suppose the pulses are also generated in that order. This will probably cause real slow code.  As after your pulsein for 1 completes and it enters into the code for pin 2, the transition may(probably) already happened and you have to wait for full RC cycle time until it can process it (20ms typically). So you would be much better off, reading the pulses in some other order like: (1, 3, 5, 2, 4, 6), this way you can get all 8 in the time of 2 to 3 RC cycles.

2) You could write a function that looks at all 6 IO pins at once and it looks for any of them to transition to high, grab time, wait for it to transition low and calc the delta time and again check to see if any of the other IO lines changed... Do this until you get a reading for all channels.  I did this in H8 assembly language for BAPs, worked fine for Hitec and I believe Spectrum, but ran into issues with Futaba, as some of the channels overlap significantly.  I wrote up an outline of code to handle this in basic, but never completed it as I have a Hitec...

3) You could try using the Pin Change interrupt and use it to capture the pulse widths in the background. 

4) You may be able to Hack the RC receiver and solder a wire onto the clock pin of one of the chips and get the signals for all X channels on one pin.  There are several places up on the web that talk about this.  I did this on a Hitec 6 receiver... More details about this on the thread: http://www.lynxmotion.net/viewtopic.php?f=21&t=6629. 

Hope that helps
Kurt

Offline BANETopic starter

  • Supreme Robot
  • *****
  • Posts: 639
  • Helpful? 4
  • E=roboticsC^2
Re: Axon II with 6 channel RC receiver code
« Reply #2 on: April 12, 2011, 09:50:36 AM »
thanks for the response,
Yes, this isnt the first time ive attempted to do this.  awhile back i posted something similar on lynxmotion forum for the BS2 but couldnt get anything to work. 
Im programming in C so does anyone know what the equivalent is for the pulsein is?

Just for simplicity reasons; Im only going to attempt one channel.

also, it seems like converting the ppm signal from the receiver to an analog signal will be the easiest solution, however, i can imagine and great deal of accuracy is lost

Quote
You may be able to Hack the RC receiver and solder a wire onto the clock pin of one of the chips and get the signals for all X channels on one pin.  There are several places up on the web that talk about this.  I did this on a Hitec 6 receiver... More details about this on the thread: http://www.lynxmotion.net/viewtopic.php?f=21&t=6629. 

I have the exact same receiver as you and have recently bought a oscope so ill give this as well.

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: Axon II with 6 channel RC receiver code
« Reply #3 on: April 12, 2011, 04:03:24 PM »
There is a version built-in to webbotlib (pin_pulseIn).

But if you were to write it yourself and assuming that the pin will go high at the start of a pulse, you simply:
1) loop while it is high, such that you don't try to measure a partial pulse.
2) Loop until it goes high.
3) Get the starting time.
4) Loop until it goes low.
5) Get current time and calculate the delta...

Offline BANETopic starter

  • Supreme Robot
  • *****
  • Posts: 639
  • Helpful? 4
  • E=roboticsC^2
Re: Axon II with 6 channel RC receiver code
« Reply #4 on: April 12, 2011, 04:31:58 PM »
i should have known webbot would have something for this :D
Quote
pin_pulseIn
TICK_COUNT pin_pulseIn(const IOPin* io, boolean activeHigh)
Measure the duration of an incoming pulse.
This will change the pin to an input and then measure and return the duration of an
incoming pulse.
If the second parameter is TRUE then the duration is how long the pulse was set to high,
otherwise it is how long it was set to low.
On return the pin will be set as an input and the returned value is in microseconds.
So if you want to measure an incoming pulse on B6 that is active high, ie __|-----|___ then you
would write:-
TICK_COUNT us = pin_pulseIn(B6, TRUE);
But if you want to measure an incoming pulse on B6 that is active low, ie ---|___|--- then you
would write:-
TICK_COUNT us = pin_pulseIn(B6, FALSE);

So when the joystick is in center position 1500 us TICK_COUNT should returns the value 1500 right? is it this simple or is there more code?

 

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: Axon II with 6 channel RC receiver code
« Reply #5 on: April 12, 2011, 08:26:59 PM »
I have not tried it, but that is what I believe it should return.  Plus or minus some small delta...

Offline BANETopic starter

  • Supreme Robot
  • *****
  • Posts: 639
  • Helpful? 4
  • E=roboticsC^2
Re: Axon II with 6 channel RC receiver code
« Reply #6 on: April 22, 2011, 05:46:32 PM »
i just tried it and it works good for two channels.  starts screwing up on three or four :P  but thats all i need right now so cheers :)

 


Get Your Ad Here