Go Down

Topic: Modifying R/C receiver output signals? (Read 1 time) previous topic - next topic

Anjanbabu

Recently I got a Turnigy pistol grip radio for my RC cars and boats (http://hobbyking.com/hobbyking/store/__23165__Turnigy_GTX3_AFHDS_2_4ghz_3_Channel_Radio_System.html)
I have a bunch of aeroplane ESCs and I don't really want to/or can afford to buy a car ESC right now. The problem is, the aeroplane ESCs don't work right with the pistol grip radios and they need a "Pistix" adapter, I am thinking of using Arduino to modify the signals coming from the Rx beforre being sent to the aeroplane ESC.
I checked the Rx signal output values with arduino.
These are the approx values I got with the throttle trigger at various positions,
default position=1415
extreme reverse=820
extreme forward=1720
Now, what I think should be happening is that I need to eliminate the reverse range. I tried to do it mechanically, but the internal mechanism doesn't allow such modification, so this has to be done the software way.
I think we need tomodify the throttle signals so as to when the throttle is at it's default position it sends a signal equivalent to 820 instead of 1415.

I'm a total noob, but I wrote this code which apparently doesn't work and now I'm clueless, rather codeless.  XD

Code: [Select]
int val;

void setup()
{
  pinMode(5, INPUT);
}

void loop()
{
  val= digitalRead(0);
  val = map(val,1415,1720,820,1720);
  digitalWrite(9, val);
}
19 year old . junk artist . amateur photographer . curiosity struck . rc modeller . aeroplane admirer . speed fanatic . DIY preacher

PeterH

I may have misunderstood, but as far as I can see you have got a handset which is designed to support forward and reverse and is mechanically designed so that the 'at rest' position is mid travel. This would make sense when used with an ESC which supports forwards and reverse, where the mid position corresponds to stationary.

You have a plane ESC which (obviously) doesn't support reverse and which treats the minimum pulse as stationary and the maximum pulse as full power. This means that when the handset throttle is in the 'at rest' position you are getting half power from the motor; you need to pull the throttle control to the 'full reverse' position to stop the motor.

If that is the problem then it seems to me that the easiest approach would be to mechanically modify the throttle assembly so that it is sprung to the minimum/reverse position instead of the mid position. If it's a decent quality system you may find that it is designed to make this easy just by moving an internal spring - this change is commonly available on twin stick handsets designed to be used for cars or aircraft. A pistol grip handset probably isn't designed to support aircraft use so may not have that easy adjustment designed in, but you may still be able to find a way to modify it so that the trigger is sprung to the 'fully back' position.

If the mechanical approach isn't possible then it would be possible to put a signal modifier between the RC receiver and the ESC to shrink the pulse so that mid position on the input corresponded to minimum pule length on the output, and you could use an Arduino to do that. You would need to read the incoming pulse length, do some simple arithmetic to calculate the required output pulse length, and then use the Servo library to output that pulse. However, I suggest you exhaust all the options to solve the problem mechanically before you try to tackle it electronically.
I only provide help via the forum - please do not contact me for private consultancy.

Anjanbabu

The radio uses a cam mechanism that doesn't allow such mechanical modifications, that's the first thing I tried.

So I've already mentioned I'm an Arduino noob, please get me started on what kind of math calculations are necessary. XD
Also,can this project be done with an ATmega8? That's all I have right now.
19 year old . junk artist . amateur photographer . curiosity struck . rc modeller . aeroplane admirer . speed fanatic . DIY preacher

PeterH


So I've already mentioned I'm an Arduino noob, please get me started on what kind of math calculations are necessary. XD
Also,can this project be done with an ATmega8? That's all I have right now.


You will have to do a bit of experimenting to work out the actual range of signals you get from your transmitter, but let's pretend that the mid position is 2000 uSec and full throttle is 2500 uSec. You'll need to do some testing to work out what range your ESC expects too, but let's pretend that 'no throttle' is 1500 uSec and 'full throttle' is 2500  uSec.

You can use pulseIn() to measure the incoming pulse length in microseconds:

Code: [Select]

unsigned long inputPulseLength = pulseIn(INPUT_PIN, HIGH) ;


You can use the constrain function to deal with any input values which are outside your normal expected range e.g. if the user moves the trigger into 'reverse':

Code: [Select]

inputPulseLength = constrain(inputPulseLength, 2000, 2500);


You can use the map function to convert your input value in the range 2000-2500 to an output value in the range 1500 - 2500:
Code: [Select]

unsigned long outputPulseLength = map(inputPulseLength, 2000, 2500, 1500, 2500);


You can use the Servo library to output the corresponding signal:

Code: [Select]

esc.writeMicroseconds(outputPulseLength);


I've used magic numbers in the code fragments above for simplicity, but in your code you should define constants for these values so they aren't all duplicated throughout your code:

Code: [Select]

const unsigned long MIN_INPUT_LENGTH = 2000;
etc


If this is all you need it to do then it should be easily within the capabilities of any Arduino.
I only provide help via the forum - please do not contact me for private consultancy.

cr0sh

I'm still trying to figure out how you plan to use a pistol grip transmitter for an R/C airplane. Ok - so you have throttle (trigger) and left/right steering (knob), but what about elevator (up/down) and (optionally) aileron control? AFAIK, you don't generally have any way to control those on a pistol-grip transmitter.

If you really wanted to do this properly, you would drop the pistol grip, and stick with a 4 or 5 channel stick controller. No Arduino needed (especially if you get one of the programmable 2.4 GHz models).
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

PeterH


I'm still trying to figure out how you plan to use a pistol grip transmitter for an R/C airplane.


I may have got the wrong end of the stick, but I thought the OP was using a pistol grip 2ch system to control cars/boats but wanted to use an ESC designed for use on aircraft. The aircraft ESC would be designed for a throttle that went 0% - 100% rather than reverse-neutral-forwards.
I only provide help via the forum - please do not contact me for private consultancy.

Anjanbabu


I'm still trying to figure out how you plan to use a pistol grip transmitter for an R/C airplane.

I want to use the pistol grip radio on my cars & boats, I've already got a bunch of aeroplane ESCs with me and I don't want to invest in new ones for a car/boat. I figured about the Pistix adapter that lets me use aeroplane ESC on a pistol grip and then I decided to make a similar adapter myself rather than paying $6 for the Pistix and $20 to ship it to India from the USA.
There, that's the whole story. XD
Also, nobody's made an Instructables on this, so I'm seizing the opportunity. ;)

PeterH, thanks a ton for that elaboration! I'm going to try it very soon.
19 year old . junk artist . amateur photographer . curiosity struck . rc modeller . aeroplane admirer . speed fanatic . DIY preacher

PeterH

Just as food for thought - by the time you've got the Arduino/clone/whatever in there decoding the servo signals you're 90% of the way to producing your own brushed ESC. All you'd need would be an H-bridge circuit capable of supporting the voltage/current range that you require. It's take a bit of work to design/build your own H-bridge driver but the components would not cost a fortune, and this would mean you also get a reverse capability. Maybe consider this as a future option once you have got the "DIY Pistix" working?
I only provide help via the forum - please do not contact me for private consultancy.

lastRites

Yeah I have got something similar brewing XD But higher amp reversible H-Bridges are a pain to design and not really that cost effective when you consider the cheapo ESCs from china. Brushless is a whole different story. The OP is using a brushless motor here I think..

PeterH

I don't do this sort of thing any more but back when I did the standard approach to an ESC was to provide a relatively cheap transistor for the part load situation and just short circuit the whole thing with a relay for full power. The marketing people came up with all sorts of terms to describe the power boost that the relay gave but it was really just a crude hack to avoid the transistor from burning out at full power. Which it did anyway, if you spent to long at part throttle. You could get a solution which is (IMO) quite usable without having to design a complete state-of-the-art ESC.
I only provide help via the forum - please do not contact me for private consultancy.

Anjanbabu

I wrote this code, but getting an error. What's the mistake I'm doing?

Code: [Select]

#include <Servo.h>
Servo esc;
int Rx = 7;
unsigned long Rxpulse;


void Setup()

{
  pinMode (6, INPUT);
  esc.attach (9);
 
}
void loop()
{
 
  Rxpulse = pulseIn(6,HIGH);
  Rxpulse = constrain(Rxpulse, 1426, 1720);
  unsigned long outputPulseLength = map(Rxpulse, 1426, 1720, 819, 1720);
  esc.writeMicroseconds(outputPulseLength);
  const unsigned long MIN_INPUT_LENGTH = 1426;
}


Error--
Code: [Select]
core.a(main.cpp.o): In function `main':
D:\Softwares\arduino-1.0.5-windows\arduino-1.0.5\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'
19 year old . junk artist . amateur photographer . curiosity struck . rc modeller . aeroplane admirer . speed fanatic . DIY preacher

PeterH

The setup() function name should start with a lowercase 's'.
I only provide help via the forum - please do not contact me for private consultancy.

Anjanbabu

Thanks, that worked. Hopefully, the code does the job. 8)
19 year old . junk artist . amateur photographer . curiosity struck . rc modeller . aeroplane admirer . speed fanatic . DIY preacher

Anjanbabu

PeterH, thanks a ton for your help. The code works flawlessly! 8)

For anyone who might need it in future, the Rx signal pulse is almost the same for all surface radios, so the same values should work too. I tried it on two radios to be sure about it and it works. Minor signal issues can be trimmed out.
Quote

#include <Servo.h>   
Servo esc;
unsigned long Rxpulse;


void setup()

{
  pinMode (6, INPUT);
  esc.attach (9);
 
}
void loop()
{
 
  Rxpulse = pulseIn(6,HIGH);
  Rxpulse = constrain(Rxpulse, 1426, 1720);
  unsigned long escPulse = map(Rxpulse, 1426, 1720, 819, 1720);
  esc.writeMicroseconds(escPulse);
  const unsigned long MIN_INPUT_LENGTH = 1426;
}
19 year old . junk artist . amateur photographer . curiosity struck . rc modeller . aeroplane admirer . speed fanatic . DIY preacher

Stingray

Another issue that you might want to worry about is that airplane motors generally have very different requirements from those for cars. Unless you're using an ESC for a huge plane in a very small car, you're going to have problems. Typical hobby grade car motors use a lot more current than typical airplane motors. Also, cars need to respond far more quickly to changes in throttle position than airplanes do. This requires handling large current spikes that an airplane ESC is not designed for. Even if the steady-state current capability is sufficient, the car will probably feel very "dulled."

Brakes are rather useful as well...

Go Up