Designing a simple "RC" controller

When I used to fly RC helicopter, I can adjust a "curve" on my radio transmitter that relates the motion of the control stick (transmitter) to the motion of the servo at the receiving end. This curve was displayed on a screen and allows user to tune the sensitivity of servo movement at various points. For example, for lower sensitivity, one would have to move the control stick quite a bit for only a little bit of servo movement. This is useful for tasks like hovering where you don't want to overcompensate. For acrobatics, the reverse is true, you want quick response to any input at the control stick.

I want to design a similar device using Arduino, a LCD screen, and a motor (either stepper or servo) for output (analogous to the servo on the RC heli), and some kind of input (analogous to the control stick on the transmitter). For the input, the user shall move a linear rack and pinion system, with the pinion hooked to a rotary encoder.

Ideally, the user can push the rack back and forth, which controls the corresponding linear movement at the output. The user should be able to adjust the movement curve on the screen. Furthermore, there should be multiple curves (or mode) that the user can switch back and forth. Any mode switch would be done only when the servo and the rack are at their initial position (or when the system is in a "mode change" mode).

The input and output are at the same device so we don't have to worry about wireless transmission of signals like that of a real RC application.

Can someone give me a rough overview of what I need and how this can be implemented? Thanks

Are you saying that you have something that drives a rotary encoder which should be connected to an Arduino and the same Arduino would use the data from the encoder to move a servo that is also attached to the Arduino?

If so I suggest you start with a simple program that detects the encoder pulses and uses them to control the servo position without worrying, for the moment, about different modes.

When you have that working you will know a lot of useful stuff to help you with adding the mode behaviour.

...R

Tell us more about your device. It often helps to know what you are really trying to do when you are asking about various things (x-y problem)

You describe an input (rack and pinion with an encoder on the pinion) and an output (stepper or servo).

Without knowing what the motor needs to drive, we can be of little help recommending hardware there.

Want to get started? Pull apart a computer mouse and steal the rotary encoder. Wire it up to your arduino and see if you can get readings from it. Get a simple rc servo for your output motor. run through the sweep tutorial to make sure you have it wired and powered properly. Then combine the 2. Make the encoder drive the position of the servo. Then add a formula that makes the relationship between the encoder signal and the servo a curve rather than linear. Then add a switch that lets you select a curve with different factors.

What you seem to be describing in your requirements in rc helis etc. is commonly known as exponential.

It may be as Robin says, a much better approach to start simpler, get an understanding and a working example and advance from there.

Perhaps a pot or joystick operating a servo would be a good start.

There is some discussion from way back regarding Arduino and it's use to generate ppm signals in vintage rc transmitters over at another site. They start with basics and work through to dual rates and expo and although you say you do not require rc transmission, it may be of interest to see how this expo etc. is built up.

Many pages to read but if you go through it systematically, it will benefit your knowledge I'm sure.

http://www.modelflying.co.uk/forums/postings.asp?th=94809

Robin2: Are you saying that you have something that drives a rotary encoder which should be connected to an Arduino and the same Arduino would use the data from the encoder to move a servo that is also attached to the Arduino?

If so I suggest you start with a simple program that detects the encoder pulses and uses them to control the servo position without worrying, for the moment, about different modes.

When you have that working you will know a lot of useful stuff to help you with adding the mode behaviour.

...R

Yes, the input is a rotary motion (rotary encoder), and the output is a linear motion (I plan to use stepper motor).

I need the input motion to be related to the output as a "curve". For example, if the x-axis of the 2D curve is the input, and the y-axis is the output, and let's say the curve is something like y=x^2, Then, if the encoder moves by 1 unit, then output move by 1 unit, by the time the encoder moves by 2 unit, the output should be by 4 unit...

I need to display this curve on a LCD as well. The actual curve is not going to be a math expression, but the user would need to be able to adjust the curve. Simple way to do this would be adjust the y at discrete number of points along the x axis (using buttons), and the curve merely connects the ys. The movement of the output should approximate the curve. I guess there will be some math I need to do in my code, but I wonder if all of these functionalities is even possible with a single Arduino?

Thanks

joker1283: I need the input motion to be related to the output as a "curve".

Get it working without a curve first and post your program.

...R

I wonder if all of these functionalities is even possible with a single Arduino?

Yes. Assuming you have the appropriate hardware, all you need to do is write the code.

jremington: Yes. Assuming you have the appropriate hardware, all you need to do is write the code.

I will try to get it working without a curve, as Robin recommended. But in the meantime, I'm curious how I should implement the curve, as that would determine whether I need feedback or not, which would determine if I should use a servo or stepper motor.

I wonder if it's possible to implement that "curve" without using any feedback. I want to use the 28-byj48 stepper, and I remember you can only tell a stepper motor how fast to step at any time. So I can control the speed and direction of the stepper. But I am really interested in position, and this position is related to the input position from a rotary encoder.

I'm just trying to brainstorm possible ways how I can code this up. I guess I can use a look up table to represent the "curve," with the entries being position values. Can you give me a rough guideline on the coding part so that the stepper will move in accordance to the curve?

Thanks

joker1283: as that would determine whether I need feedback or not,

The RC control units for model aircraft don't have feedback - that would require data being sent back from the plane to the control unit.

One way to make a curve is with a look-up table. If the joystick value is between X and Y use a value between the Xth position and the Yth position in the table adjusted by the proportion that the joystick value is between X and Y.

To illustrate... Suppose the joystick produces a value of 273 (from the range 0 - 1023). Suppose there are 8 steps in the lookup table. To convert 1023 to 8 you divide by 128. So 273/128 gives 2. Get the values in lookupTable[2] and lookupTable[2 + 1]. Let's pretend they are the value 97 and 121. The lower value is really equivalent to 256 and the higher value is equivalent to 384 - a range of 128. The value 273 is 17 higher than 256, or 17/128ths between the two values. The range between 97 and 121 is 24 and 17/128ths of that is 3. So the output value should be 97 + 3 = 100.

It's actually easier to write in a program than to describe. If you have more steps in the table you will get a smoother curve.

...R

Robin2: The RC control units for model aircraft don't have feedback - that would require data being sent back from the plane to the control unit.

One way to make a curve is with a look-up table. If the joystick value is between X and Y use a value between the Xth position and the Yth position in the table adjusted by the proportion that the joystick value is between X and Y.

To illustrate... Suppose the joystick produces a value of 273 (from the range 0 - 1023). Suppose there are 8 steps in the lookup table. To convert 1023 to 8 you divide by 128. So 273/128 gives 2. Get the values in lookupTable[2] and lookupTable[2 + 1]. Let's pretend they are the value 97 and 121. The lower value is really equivalent to 256 and the higher value is equivalent to 384 - a range of 128. The value 273 is 17 higher than 256, or 17/128ths between the two values. The range between 97 and 121 is 24 and 17/128ths of that is 3. So the output value should be 97 + 3 = 100.

It's actually easier to write in a program than to describe. If you have more steps in the table you will get a smoother curve.

...R

Thanks.

I also want to try this with a servo too. I need to order parts now and I wonder if there are any common, cheap rotary encoders and servos that you know of? For stepper, I'm using the 28byj48 motor, which is cheap and widely available. I wonder if there are common widely available models for rotary encoders and servo too?

Thanks

Servos are servos. If you just want to experiment buy the cheapest one you can find.

I have no experience of rotary encoders. Are you thinking of encoders that turned by hand?

...R

Robin2:
Servos are servos. If you just want to experiment buy the cheapest one you can find.

I have no experience of rotary encoders. Are you thinking of encoders that turned by hand?

…R

I’ll just buy a cheap hobby servo.

I’m learning about servos now. So basically, you control a stepper by specifying the frequency of steps (each control signal corresponds to a “step”, and you can specify how fast it steps, like by changing the delay between each step). So you only get to control the rotational velocity.

But you can control the servo by specifying a position? In another word, the input signal will corresponds to a position and the servo will move there quickly without you having to worry about the velocity?

Thanks

Well not cheap but it ...

https://www.parallax.com/product/900-00360

joker1283: I'm learning about servos now. So basically, you control a stepper by specifying the frequency of steps (each control signal corresponds to a "step", and you can specify how fast it steps, like by changing the delay between each step). So you only get to control the rotational velocity.

But you can control the servo by specifying a position? In another word, the input signal will corresponds to a position and the servo will move there quickly without you having to worry about the velocity?

That all sounds correct. But you seem to have missed the fact that you can control a stepper position by counting steps if you know where the motor was positioned when you started counting.

However if you are only now learning that stuff it seems to me that writing a program for a 'copter is somewhere far in the future.

...R