Reading pulses from a radio control receiver

Using the following code and the attached circuit, I am trying to read the pulses from two different channels on the JR 2.4 GHz receiver. I expected the values to vary from 75 to 225 usec. But I am getting values in the range of 2000 to 2250
Code:
Pulsin 2,1,W0
Sertxd (13,10,"DAY NIGHT ",#W0,13,10)
Pulsin 1,1,W2
Sertxd ("SEARCH ",#W2,13,10)
If W0>200 then goto Night
If W0>150 then goto Day
 

Attachments

goom

Senior Member
I have used the pulsin command many times for various applications, reading from several different receivers (2.4 GHz and 75 MHz). I always get the expected values (roughly 75 to 225 = 0.75ms to 2.25ms) on a -08M, -18X or -14M.
I'm not very familiar with the sertx command, but I think that it may work properly only for byte variables, not word variables. Try outputting b0 and b3 and see the results.
 

MPep

Senior Member
Sertxd only allows outputting of Byte variables, not Word variables!

Scratch that, just tried the below in the simulator:

Code:
#picaxe 14M

Main:
serin 2,N2400,b0,b1
serout 2,N2400,("b0 = ",b0,",  b1 = ",b1,",  #b0 = ",#b0,",  #b1 = ",#b1,10,13) 
serout 2,N2400,("#w0 = ",#w0,"  w0 = ",w0)
goto Main
Try the above code in the simulator. To enter values to print out, try entering "1","4" as an example.
You will see that b0 will be the value that you entered, eg 1. b1 = 4
The #b0 is the ASCII value (in decimal) of 1 => 49. #b1 = 52
The #w0 is the ASCII value for 13361

When it comes to w0 however, it cannot be done.
 
Last edited:
Therefore, if I change the code to the following
Code:
Pulsin 2,1,W0
Sertxd (13,10,"DAY NIGHT ",#b0,13,10)
Pulsin 1,1,W2
Sertxd ("SEARCH ",#b4,13,10)
If W0>200 then goto Night
If W0>150 then goto Day
The sertxd will show between 75 and 225.
Is that correct?
 

hippy

Technical Support
Staff member
Some confusion has crept in; SERTXD will output the word value of a variable when used with #, for example SERTXD( #w0 ).

The first thing to do is to simplify your code, use a simple loop to just see what you are receiving on one channel ...

Do
PulsIn 2, 1, w0
SerTxd( "w0=", #w0, CR, LF )
Loop

It could be that you are reading the gap between the pulse rather than the pulse itself, so you may want to try "PulsIn 2, 0, w0".
 

BeanieBots

Moderator
Based on your figures, I too was thinking that you were measuring the wrong polarity of the pulse. However, I don't see how that is possible unless you have wired the Rx unit signal to PICAXE ground and the Rx ground to PICAXE input. (which also requires totally isolated power supplies to both units).

The 'standard' RC pulse convention is positive going pulse.
Check you have the connections wired the correct way around.
 

Wrenow

Senior Member
Using the following code and the attached circuit, I am trying to read the pulses from two different channels on the JR 2.4 GHz receiver. I expected the values to vary from 75 to 225 usec. But I am getting values in the range of 2000 to 2250
Code:
Pulsin 2,1,W0
Sertxd (13,10,"DAY NIGHT ",#W0,13,10)
Pulsin 1,1,W2
Sertxd ("SEARCH ",#W2,13,10)
If W0>200 then goto Night
If W0>150 then goto Day
One potential issue. Are you using DSM or DSM2. Some of the 2.4gHz systems send the servo commands to the servos simultaneously, not sequentially. If I recall correctly, DSM is sequential, DSM2 is simultaneous.

Of course, I am guessing (and this is only a guess), the second pulsin will only trigger once the first pulsin is completed. So you will be getting every other frame with DSM2. On the other hand, it would not make any difference which order you read the channels.

Cheers,

Wreno
 
Top