RC servo command inputs to 28X1

Helidesigner

New Member
Hello, I'm new to microcontrollers and to the PICAXE forum. I'm working on a programable mixing unit for an RC helicopter. I'm having trouble getting PWM inputs into the 28X1. I am able to drive servos per the instructions that came with the servo upgrade kit. I looked at code posted at DIYRC (the straight thru subroutine) but it does not seem to work. I think I'm connecting the ground and signal wire to the proper input. If I periodically attach and detach the input the servo centers and then moves respectively. It does not do that if I touch any other input. I have read through various threads but can not find exactly the answer I'm looking for. I have picked up on something about timing of the pulse widths. What do I have to do to read in the channels from a Futaba reciever?

Thanks in advance,
Helidesigner
 

BeanieBots

Moderator
Welcome to the forum.
Start simple.
For a basic feedthrough try this.

do
pulsin 1,b0
pulsout 1,b0
loop

The pulsin will wait for each pulse and hence the pulsout will automatically be at the correct frame rate.
You need to connect the 0v of the radio reciever to the 0v of the PICAXE and the signal wire of the desired channel to input 1 (leg 3).

Once you have that working you can then look at adding extra channels and doing the mixing. Also have a look at the servopos command which needs to be used for rapid servo position updates.

I'm a little concerned about delays you might experience (and safety issues). In a helicopter these will be much more noticeable than anything land based.

Out of curiousity, which helicopter and what's you flying level?
 

Helidesigner

New Member
I am using the pulsin and pulsout commands. I am connecting the 0V wire (black) and signal wire (white) to the appropriately labled two pin input on the lower left side of the board (three pin servo outputs are on the upper right side). If the code is as simple as you show then I have something else fundamentally wrong. Am I connecting the input wires correctly?

Regarding delays, once I do get it working can I connect a resonator to increase the update rate?
 

BeanieBots

Moderator
Your connections sound OK.
It may be that you have assigned/used the wrong input/output pins.

You say that you have had the servo working OK using the servo command so we can assume that side of things is OK.
That leaves the input.

Try this:-

do
pulsin 1,b0
debug
loop

You should see a value for b0 in the debug window which represents the pulse length comming from your radio.
If the value of b0 is zero, then your PICAXE is not seeing the pulses.
This could be for a number of reasons.
1. Wrong pin being tested.
2. Insufficient voltage change comming from radio.

If you have another PICAXE available, you could use that to supply servo pulses to your 28X1 input as a test.

What voltage is your radio running at?
What voltage is your PICAXE running at?

If the PICAXE supply is higher than the radio, it might not see the pulses.
Try running them from the same supply.

I don't suppose you have access to a 'scope?
If yes, have a look at the waveform comming from your radio.
What are the max and min voltage values?

The dalay issue:-
This realates to how your receiver decodes the signals, the order in which you read them and whatever processing you do.
Traditional RC equipment sends all the channel pulses serialy at frame rate of 20mS. It doesn't make any difference how fast your PICAXE runs, the frame rate remains the same. If you don't read the pulses in correct order, you can only hope to process alternate pulses at the absolute best.

Newer radios, in particular the latest 2.4Ghz systems send all channels at the same time. That means no matter how fast your PICAXE, you must wait for the next frame before the next channel can be read. Again, that results in a maximum of alternate frames for your mixer.
The very reason for the new method is to eliminate the 20mS delay.

A PICAXE mixer on the old system would at best run at a 20mS rate.
With the new system, it would run at best of a 40mS rate.
(slower if you mix more than 2 channels).
Hope you see the issue. Ask if it's still not clear.

If your mixer is for lights and/or something like undercarriage, then a small delay will not be a problem.
If it is for flight controls, then you WILL notice the delay.
As I'm sure you are aware, flying an RC heli is no simple task, don't make it harder!
For flight controls, it is better to do the mixing at the transmitter straight off the sticks.
 
Last edited:

Wrenow

Senior Member
BB pretty much covered the bases.

One other thing. If you are using the AXE024 3 servo board, you can use some of the servo outs on the "servo side" as inputs from the radio. The 330R resistor does no real harm. Assuming, of course, you are not running over 5.5v on the radio RX (then you would want to disconnect the red wire).

Also, remember that several of the pins on the non-servo side (colour sensor connector) are the exact same pins on the Picaxe as the servo side (with, I seem to recall the addition of one, a different order, etc., but without resistors).

Point being, if you are taking a, say, pulsin on 1 on the colour sensor side to read the radio, you are not going to be able to send a pulsout on 1 as well for this application - it is the same pin1.

Cheers,

Wreno
 

Helidesigner

New Member
Beaniebots, thanks for the suggestions. I tried your code (I had to add a 1 to the pulse in command) and also ran the debug. No steady input signal. If I lightly connnect and disconnect the servo input to the input pins the servo chatters and I see random inputs on the debug screen. It does not do this if I touch any other inputs. So it looks like I have designated the right input and output and have to connections correct, and no signal is being read by the PICAXE board.

I do not understand how to get higher voltage into the board. The board runs on 4.5V, my RC receiver runs on 5.6V, but I am only connecting the black (0V) and white (signal) wires to the board. The measured voltage of the PWM input signal is nominally between 0.15V and 0.30V. Should I be conecting the red + voltage wire to the board somewhere?
 

BeanieBots

Moderator
Your pin assignment is correct and your connections (in theory) are correct.
0.15v & 0.3v is most deffinitely WRONG!

If those are the voltages comming from your Rx unit, it's either faulty or connected to an output or even a short.
Those voltages would not drive anything, be it a servo or PICAXE input.

It almost sounds like you are seeing the output of an open collector device with no pull-up fitted.
Does it (the Rx unit) work with just a servo connected?
If yes, what are the voltages then?
 

goom

Senior Member
The output from the reciever is basically a low duty cycle square wave. "Neutral" will have a nominal pulse width of 1.5ms every 20ms. The average voltage will be 1.5/20x4.4 =0.34V. If Helidesigner is simply measuring the output with a DC voltmeter, the .15V to 0.3V is not too surprising since the meter is probably reading a rough average. I would expect something like this as the transmitter stick is moved between maximum and minimum.
 

Helidesigner

New Member
I did use a DC volt meter and the range of voltages was as I moved the stick. An RC servo plugged into the reciver works normally with the transmitter. So I am still confused. Should I connect the red pos voltage and white signal wires to the input pins? There are only two input pins.
 

Wrenow

Senior Member
DO NOT connect the red wire. Does nothing for upi and could damage the picaxe, since it is qa higher voltage than spec.

I had some iffy readings on the first channel read, but next channel read was OK. When I went to the AXE 024, it all straightened up, so I am suspecting, among other things, a supply voltage noise issue. And, you might want to tie all of your inputs low so they don't float.

Cheers,

Wreno
 

goom

Senior Member
Try this:
1. Disconnect power from the AXE024 board (this is IMPORTANT).
2. Connect your first receiver channel to the three pins furthest from the programming connector. This will provide power and ground to the board, and also connect the signal from the receiver to Input4.
3. Program the -08M with:
restart:
pulsin 4,1,W0
pulsout 2,W0
goto restart
4. Connect your servo to the middle set of three pins.
The servo should now move as if it were connected directly to the servo.

You can now connect your second receiver channel to the remaining 3 pins which will input the signal into Input1. Reprogram with something like:
restart:
pulsin 4,1,W0
pulsin 1,1,W1
'Do your mixing calculations here, e.g. W2=W0+W1/2
pulsout 2,W2
goto restart
 

goom

Senior Member
I see that my post and Wreno's crossed, and may add confusion.
In my sugestion, the red wires can be (must be) connected since this is the board's power souce. With a 5.6V power supply to the receiver, the onboard diode will safely drop the voltage to a safe level.
If you do power the board with a separate supply, as Wreno said, DO NOT connect the red wires (just black and white). This may be a good idea if you have electical noise issues, but I have used a common supply many times without problems.
 
Top