Author Topic: 6 channel rc controller algorithm  (Read 2425 times)

0 Members and 1 Guest are viewing this topic.

Offline sfiberTopic starter

  • Regular Contributor
  • *
  • Posts: 107
  • Country: tr
6 channel rc controller algorithm
« on: June 26, 2014, 09:07:28 am »
hi my friends,I couldnt developed algorithm about pwm peak values.as you know when you move joystick of 6 channel rc controller it controls servos but when you pull your hands from joystick it doesnt move to middle position like joystick.If you want to make your servo to middle position you have to pull joystick opposite side.can anyone help me     about algorithm.

I use stm32f4.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10481
  • Country: nz
Re: 6 channel rc controller algorithm
« Reply #1 on: June 26, 2014, 09:13:01 am »
A RC controller has a spring which returns to center.


It sounds like your issue is to do with relative vs absolute position.

Relative position means the new servo position is calculated from it's current position.

Absolute position means the position is a mirror.  70% joystick = 70% servo position.
« Last Edit: June 26, 2014, 09:19:45 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline sfiberTopic starter

  • Regular Contributor
  • *
  • Posts: 107
  • Country: tr
Re: 6 channel rc controller algorithm
« Reply #2 on: June 26, 2014, 09:20:58 am »
A RC controller has a spring which returns to center.


It sounds like your issue is to do with relative vs absolute position.

Relative position means the new servo position is calculated from it's current position.

Absolute position means the position is a mirror.  70% joystick = 70% servo position.


but servos dont move like joystick,they stays them peak values.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10481
  • Country: nz
Re: 6 channel rc controller algorithm
« Reply #3 on: June 26, 2014, 10:13:51 am »
im not sure what you mean by peak values?
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: 6 channel rc controller algorithm
« Reply #4 on: June 26, 2014, 11:24:22 am »
Quote
when you pull your hands from joystick it doesnt move to middle position like joystick.

That's one hell of a sentence to understand, :)

I think what you want to achieve - there is a high likelihood that I am wrong on this - is what people call incremental PID.

A simpler way to achieve that is to calculate the pwm on the delta of two variables: joystick's current position, and joystick's decayed position.

Something like this may work:

Code: [Select]
  js_cur = joystick_read(); //read joystick's current position
  js_dcy+= (js_cur - js_dcy) * alpha; //revise js_decay to approach js_cur, alpha determines the speed of decay
  js_pwm = f(js_cur - js_dcy); //generate pwm based on the difference between js_cur and js_dcy

Right after you have moved the joystick, js_pwm takes the highest value. After that, js_dcy starts to approaching js_cur and the pwm value starts to decline until the js_cur/js_dcy are sufficiently close.

Essentially it is an auto-centering algorithm.

You will need to figure out how to handle the negative values when generating pwm.
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf