Go Down

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

fullspool

Not really  ::)
Let's wait for dimension engineering response





This is what they said :


So this uses Arduino's servo library. You likely won't need our libraries. You will set Sabertooth DIPs to RC/microcontroller mode, and connect signals to S1/S2. I'm not sure if everything will run smooth as is- you may have to do some tweaking. I can tell you the Sabertooth tends to works best in this mode using a servo range of 40-140, with 90 being "stop."

kas

Use LIMIT_ANGLE =50  as per woodygb advice


fullspool

#677
Mar 24, 2016, 04:16 am Last Edit: Mar 24, 2016, 04:22 am by fullspool
Use LIMIT_ANGLE =50  as per woodygb advice


I've already did this yesterday and nothing new happened.

Edit :

I do have an update though and finally getting some where . I reset the board,  loaded 1.7 code with limit at 50 , check all connections and now it's kinda working .

Here is what's happening :

1 off, 2 and 3 on, 4 off, 5 on, 6 off
Motors are slowly turning at idle and stick movement is 90 degrees off. So if i turn the phone portrait I can move forward and backward correctly but left and right are backwards .


kas

Quote
stick movement is 90 degrees off
swap pinServo_X  (D9)  and  pinServo_Y  (D10)  wires



woodygb

#679
Mar 24, 2016, 09:46 am Last Edit: Mar 24, 2016, 10:09 am by woodygb
Quote
1 off, 2 and 3 on, 4 off, 5 on, 6 off
Motors are slowly turning at idle and stick movement is 90 degrees off
The Arduino servo library is NOT an exact match for the R/C signal format ....SERVO 90 or OFF/Neutral/Idle is actually equiv to a signal value of 1471 rather than the standard neutral value of 1500 ...hence your getting the motors slowly turning.

Solution ... Turn ON Autocalibrate.

EDIT ...Or I suppose that you could redefine neutral in the Arduino prog as a servo value of 92.8.

fullspool

swap pinServo_X  (D9)  and  pinServo_Y  (D10)  wires



I tried this but it just rotated the stick movement another 90 degrees so left and right movements caused it to go forwards and backwards so I put it back to how I had it .

If I put the DIP to 1 down and the other 5 up my wheels don't turn at center stick movement but the sticks are 45 degrees off and left / right are mirrored again .

Thanks guys ,
Justin

fullspool

The Arduino servo library is NOT an exact match for the R/C signal format ....SERVO 90 or OFF/Neutral/Idle is actually equiv to a signal value of 1471 rather than the standard neutral value of 1500 ...hence your getting the motors slowly turning.

Solution ... Turn ON Autocalibrate.

EDIT ...Or I suppose that you could redefine neutral in the Arduino prog as a servo value of 92.8.
Thank you for the suggestions, I will try this . Where did you get the value of 92.8 ?

Here is a video

https://youtu.be/UtN7EWkzLMs

kas

#682
Mar 24, 2016, 02:03 pm Last Edit: Mar 24, 2016, 02:16 pm by kas
Try inverting one motor power supply polarity


woodygb

#683
Mar 24, 2016, 03:31 pm Last Edit: Mar 24, 2016, 04:05 pm by woodygb
Thank you for the suggestions, I will try this . Where did you get the value of 92.8 ?


Ummm lets check.

Quote
The servo.cpp library contains the "default" us values as "default min is 544, max is 2400" .
..so

The range of 544 to 2400 is  0  to 180 in the servo library  a bit of math gives us the single unit signal value of 10.31.

(90*10.31)+544 = 1471.9 a difference of  28.1 to the 1500 norm.

so we need 28.1/10.31= 2.72 more than servo 90  that would make 1500 neutral = servo 92.72  .

I think .......

Here's a link to much the same conclusion about the servo 90 value it includes a solution.
http://makezine.com/2014/04/23/arduinos-servo-library-angles-microseconds-and-optional-command-parameters/


@Kas ...It would seem that the approach to use is to define the servo attach range... eg.

Quote
myservoA.attach(pinServo_A, 1000, 2000); 
  myservoX.attach(pinServo_X, 1000, 2000); 
  myservoY.attach(pinServo_Y);

kas

Quote
Here's a link to much the same conclusion about the servo 90 value.
http://makezine.com/2014/04/23/arduinos-servo-library-angles-microseconds-and-optional-command-parameters/
Interesting readings
Based on this document, do you suggest to replace

  myservoX.attach(pinServo_X); 
  myservoY.attach(pinServo_Y);
 
by

  myservoX.attach(pinServo_X, 1000, 2000); 
  myservoY.attach(pinServo_Y, 1000, 2000); 



woodygb

#685
Mar 24, 2016, 04:06 pm Last Edit: Mar 24, 2016, 04:16 pm by woodygb Reason: additional info
Kas ..you posted whilst I was editing!!! :)

Yes ...I think it would be best to make the range match standard R/C protocol.

So the changes would be ...

Quote
myservoX.attach(pinServo_X, 1000, 2000); 
  myservoY.attach(pinServo_Y, 1000, 2000); 
and


 
Quote
servo_L = map(servo_L, -100, 100, 1000, 2000);   //         << adjust to change motor direction
  servo_R = map(servo_R, -100, 100, 1000, 2000);
  servo_L = constrain(servo_L, 1000, 2000);
  servo_R = constrain(servo_R, 1000, 2000);
Yes?

kas

Quote
So the changes would be ...

❝myservoX.attach(pinServo_X, 1000, 2000); 
  myservoY.attach(pinServo_Y, 1000, 2000); 
Yes


Quote
and

 ❝servo_L = map(servo_L, -100, 100, 1000, 2000);   //         << adjust to change motor direction
  servo_R = map(servo_R, -100, 100, 1000, 2000);
  servo_L = constrain(servo_L, 1000, 2000);
  servo_R = constrain(servo_R, 1000, 2000);

Yes?
No
The remaining code still "speaks" degrees   ;)


fullspool

Ummm lets check.
..so

The range of 544 to 2400 is  0  to 180 in the servo library  a bit of math gives us the single unit signal value of 10.31.

(90*10.31)+544 = 1471.9 a difference of  28.1 to the 1500 norm.

so we need 28.1/10.31= 2.72 more than servo 90  that would make 1500 neutral = servo 92.72  .

I think .......

Here's a link to much the same conclusion about the servo 90 value it includes a solution.
http://makezine.com/2014/04/23/arduinos-servo-library-angles-microseconds-and-optional-command-parameters/


@Kas ...It would seem that the approach to use is to define the servo attach range... eg.

Ahhh gotcha thank you for taking the time to explain it to me, I just read that blog. I am going to have to read it 5-6 more times for it to fully sink in . I still need to test this and see if it works, I would just have to change :

int servo_L, servo_R = 90;                              // servo's positioning values

to

int servo_L, servo_R = 92.72;                              // servo's positioning values

Is this correct?


@kas I changed the polarity of one motor and its working perfect now. Thank you for the suggestion.

I also adjusted to code to read :

  myservoX.attach(pinServo_X, 1000, 2000); 
  myservoY.attach(pinServo_Y, 1000, 2000); 

It fixed my motors from turning at center stick position however my top speed of the wheel chair is down
drastically compared to before. So It might be best to remove this range and adjust the servo position?



woodygb

#688
Mar 25, 2016, 01:37 am Last Edit: Mar 25, 2016, 01:48 am by woodygb
 
Quote
myservoX.attach(pinServo_X, 1000, 2000); // R/C norm range 
  myservoY.attach(pinServo_Y, 1000, 2000);  
Using the above code solves the problem of the slightly off neutral value of 1472 ... as 1500 is now slap in the middle...half way between 1000 and 2000. .. and 90 degrees is also halfway between 0 and 180 degrees.

So ...
Quote
int servo_L, servo_R = 90;
can stay as it is.

The code mod also does away with the need for the LIMIT_ANGLE as you have defined the range and in doing so have set a NEW number for the servo angle values.

Thus ...
servo_R/L @ 0=1000 , servo_R/L @ 90 = 1500  &  servo_R/L @ 180 = 2000 which matches R/C norm.

This means that can now use the original code.


Quote
servo_L = map(servo_L, -100, 100, 0, 180);   //         << adjust to change motor direction
  servo_R = map(servo_R, -100, 100, 0, 180);
  servo_L = constrain(servo_L, 0, 180);
  servo_R = constrain(servo_R, 0, 180);
I hope that makes sense.

fullspool

Using the above code solves the problem of the slightly off neutral value of 1472 ... as 1500 is now slap in the middle...half way between 1000 and 2000. .. and 90 degrees is also halfway between 0 and 180 degrees.

So ... can stay as it is.

The code mod also does away with the need for the LIMIT_ANGLE as you have defined the range and in doing so have set a NEW number for the servo angle values.

Thus ...
servo_R/L @ 0=1000 , servo_R/L @ 90 = 1500  &  servo_R/L @ 180 = 2000 which matches R/C norm.

This means that can now use the original code.


I hope that makes sense.
I tried making these changes using the same DIP settings and BOT just freaks out, motors start turning, stopping, slowly turning, then back wide open, pauses for a minute and repeats LOL

I tried to revert back to my old code that was working now it's acting silly and unstable, I am really confused now as it worked fine but top speed was alot slower .

I thought maybe I screwed up my sabertooth so I hooked it back up to my radio control and everything worked perfect. I thought I was really making progress now I just screwed it up.

Here was a video from earlier, don't know why it doesn't work now.  :(

https://youtu.be/K78tliDVAWs

I attached the last working code, even though it doesnt work now??

Go Up