Go Down

Topic: Android Bluetooth joystick (Read 361581 times) previous topic - next topic

woodygb

#645
Mar 18, 2016, 10:26 am Last Edit: Mar 18, 2016, 12:33 pm by woodygb
@Kas ..some thoughts.

I think that 0-180 is simply out of the normal radio control pulse range ..
Quote
The pulse nominally ranges from 1.0 ms to 2.0 ms with 1.5 ms always being center off
.. however...
Quote
The servo.cpp library contains the "default" us values as "default min is 544, max is 2400" .
.
As coded the NO Turbo function ( 1/2 write range value ) will be in range ....but out of range in TURBO .



So I think that rather than servo.write ( angle )  the code should use servo.writeMicroseconds(xxxx)....or reduce the angle range from 0-180 to 30-150.

Edit :- The stand alone servo which has a normal swing angle of 120 degrees seems to happily accept this extended range...but the Scorpion XL controller probably has a set acceptable range of 0.74ms to 2.24ms .

The value of 0.74ms to 2.24ms was gleaned from the web as the min/max  range limit for a Spektrum Transmitter/Receiver.

kas

#646
Mar 18, 2016, 11:38 am Last Edit: Mar 18, 2016, 01:13 pm by kas
Quote
I think that 0-180 is simply out of the normal radio control pulse range
 ..As coded the NO Turbo function ( 1/2 write value ) will be in range ....but out of range in TURBO .
Good point  :)


EDIT
Quote
Something has went wrong after version 1.3
V1.3:  (shouldn't work... but it does  :o )     EDIT2  ** see below **
 myservoX.write(servo_L/turbo);
 myservoY.write(servo_R/turbo);

V1.6:  (doesn't work... but it should   :smiley-evil: )
 joyX = joyX/turbo;
 joyY = joyY/turbo;


@fullspool,
please reload V1.6A,
calibrate,
test range by moving Joystick only North/South
let us know the exact normal working range (Datafields display)


woodygb

#647
Mar 18, 2016, 12:23 pm Last Edit: Mar 18, 2016, 01:06 pm by woodygb
Probably not relevant ..but
v1.3 say's

Quote
void motorsControl()  {
  myservoX.write(servo_L/2);
  myservoY.write(servo_R/2);
NOT

Quote
myservoX.write(servo_L/turbo);
  myservoY.write(servo_R/turbo);
This would 1/2 the X, Y mix value or would the code 1/2 the 0-90-180 values ?

kas

Probably not relevant ..but
v1.3 say's

❝void motorsControl()  {
  myservoX.write(servo_L/2);
  myservoY.write(servo_R/2);
NOT
❝myservoX.write(servo_L/turbo);
  myservoY.write(servo_R/turbo);

This would 1/2 the X, Y mix value ?
Sorry, I was comparing with V1.4 :-*

So, the asumption is definitely that the Scorpion ESC doesn't accept the full 0 - 180° range
Let's wait for fullspool results

We WILL make it out  ;)




kas

#649
Mar 18, 2016, 01:26 pm Last Edit: Mar 18, 2016, 01:30 pm by kas
@woodygb

❝void motorsControl()  {
    myservoX.write(servo_L/2);
    myservoY.write(servo_R/2);

was wrong coding
When joystick is iddle
  joyX = joyY = 0
  servo_L = servo_R = 90

Sent command is
  myservoX.write(45);
  myservoY.write(45);
Which is 'backward'  NOT  'stop'
This was probably corrected by calibrating the ESC

I did address this bug in V1.4


fullspool

EDIT
V1.3:  (shouldn't work... but it does  :o )     EDIT2  ** see below **
 myservoX.write(servo_L/turbo);
 myservoY.write(servo_R/turbo);

V1.6:  (doesn't work... but it should   :smiley-evil: )
 joyX = joyX/turbo;
 joyY = joyY/turbo;


@fullspool,
please reload V1.6A,
calibrate,
test range by moving Joystick only North/South
let us know the exact normal working range (Datafields display)

I uploaded the code again and it produced same results, the bot went into full reverse around the 162ish mark in the data fields. Uploaded v1.3, re-calibrated and it worked perfect, LOL im confused.

Thanks for the help guys, I really appreciate it.

Video:
https://youtu.be/7XDa-ClUwrI

kas

#651
Mar 18, 2016, 02:05 pm Last Edit: Mar 18, 2016, 02:47 pm by kas
Quote
the bot went into full reverse around the 162ish mark in the data fields
This one should be OK   ;)


// V1.6B Test, MAX_ANGLE output limit (no turbo)

Please calibrate after loading

EDIT: should work for forward motion, not backward (yet)
EDIT2: modified (forward + backward motion)
Let me know



woodygb

@Kas .

That code may well be a work around to THIS controllers problem but I doubt that it will apply to other makes/models of R/C motor controllers.

Why not just follow standard R/C signal range protocol and restrict the angle and thus the ms value ?



  joyX = joyX/turbo;                                                  // turbo (button #2)
  joyY = joyY/turbo;

  if(joyY >-10))  {  // divide minus 10 by turbo?        // differential steering
    servo_L = (joyY - (3*joyX)/4);
    servo_R = (joyY + (3*joyX)/4);
  }  else  {
    servo_L = (joyY + (3*joyX)/4);
    servo_R = (joyY - (3*joyX)/4);
  }
 
  servo_L = map(servo_L, -100, 100, 30, 150);   //         << adjust to change motor direction
  servo_R = map(servo_R, -100, 100, 30, 150);
  servo_L = constrain(servo_L, 30, 150);
  servo_R = constrain(servo_R, 30, 150);


kas

#653
Mar 18, 2016, 02:58 pm Last Edit: Mar 18, 2016, 04:54 pm by kas
Quote
That code may well be a work around to THIS controllers problem but I doubt that it will apply to other makes/models of R/C motor controllers
Fixed values would restrict range for 0/180 servo's and possibly some calibration-less drivers

    #define    LIMIT_ANGLE    20                            // Max range, adjust to your specific controller/servo

is easy to adjust value for a specific device

fullspool

This one should be OK   ;)


// V1.6B Test, MAX_ANGLE output limit (no turbo)

Please calibrate after loading

EDIT: should work for forward motion, not backward (yet)
EDIT2: modified (forward + backward motion)
Let me know



I tested this code and it works just like v1.3 did with out any issues. I suppose this ESC doesn't like ranges past 160?

woodygb

#655
Mar 18, 2016, 09:18 pm Last Edit: Mar 18, 2016, 09:30 pm by woodygb
This post is only to give my view point.

Web quote..

Quote
The pulse itself most often ranges from 1 ms to 2 ms, with ~1.5 ms being the neutral position.  For servos with larger ranges, you might see pulses between 0.5 and 2.5 ms (neutral will still be around 1.5 ms).
https://github.com/esp8266/Arduino/blob/master/libraries/Servo/src/Servo.h

The Arduino servo angle  0-90-180 equates to 544- ( 1500 ) -2400ms signal range which is a 900 ish swing.

A 1100 - ( 1500 ) - 1900ms signal range ...  a 400 swing ... is the "Norm" for  many R/C Transmitter /Receiver combos including those owned by me.

kas

#656
Mar 18, 2016, 10:50 pm Last Edit: Mar 18, 2016, 10:58 pm by kas
Quote
I tested this code and it works just like v1.3 did with out any issues.
Finally   ;D  ;D  ;D


Quote
I suppose this ESC doesn't like ranges past 160?
Yes, thanks woodygb for this bright idea


// V1.7  added adjustable output limit   (with turbo enabled)

EDIT: Calibration should be made in turbo mode (Button #2 <ON>)



fullspool

Great news , the bot preform perfectly! I do have a question though, how do I get the voltage and Amp display back in the data fields?

Thanks for your guys hard work!

Justin

kas

Quote
I do have a question though, how do I get the voltage and Amp display back in the data fields?
Just change
//    Serial.print(voltage, 2);               Serial.print((char)0x4);         // datafield #1 = battery level
//    Serial.print(milliAmp);                 Serial.print((char)0x5);         // datafield #2 = milli Amps
        Serial.print(servo_L);                  Serial.print((char)0x4);
        Serial.print(servo_R);                  Serial.print((char)0x5);

to
        Serial.print(voltage, 2);                Serial.print((char)0x4);         // datafield #1 = battery level
        Serial.print(milliAmp);                  Serial.print((char)0x5);         // datafield #2 = milli Amps
//    Serial.print(servo_L);                   Serial.print((char)0x4);
//    Serial.print(servo_R);                   Serial.print((char)0x5);

fullspool, I think it's now time to carefully read and understand the code  ::)



fullspool

fullspool, I think it's now time to carefully read and understand the code  ::)

Thank you for all your help , I am doing my best to understand it but it's more advanced then I am at this point . I've read the code multiple times and picking up on a few things.

FYI I put a couple batteries through the bot and it's performing awesome.

Go Up