Android Bluetooth joystick

kas:
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

woodygb:
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

Try inverting one motor power supply polarity

fullspool:
Thank you for the suggestions, I will try this . Where did you get the value of 92.8 ?

Ummm lets check.

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.

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

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

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);

Kas ..you posted whilst I was editing!!! :slight_smile:

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

So the changes would be ...

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

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?

So the changes would be ...

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

Yes

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 :wink:

woodygb:
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?

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 ...

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.

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.

woodygb:
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. :frowning:

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

AndroTest_Servo_fullspool_V1.8.ino (9.23 KB)

Have you perhaps still got the Sabertooth in mix mode?

The SLOW problem that you previously encountered was simply the result of the change to myservo.

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

and retaining

#define LIMIT_ANGLE 50 // Max range

Making it ZERO would have given back the full speed range.

woodygb:
Have you perhaps still got the Sabertooth in mix mode?

The SLOW problem that you previously encountered was simply the result of the change to myservo.

and retaining

Making it ZERO would have given back the full speed range.

I was using 1 off, 2/3 on, 4 off, 5 on, 6 off >????

I checked your V1.8, it should work as before ::slight_smile:

  • double check bot for wrong or loose connections
  • make sure all grounds are connected
  • disconnect battery(ies) for 5 minutes and try again

I was using 1 off, 2/3 on, 4 off, 5 on, 6 off

What is the purpose of switch 3 ??
If not used, keep it OFF just in case

EDIT
from your message #677:

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 .

What was the problem at that time ??

To muddy the waters even more ...
You tried at least once with dip switch 6 ON.
Which should have been ..... according to the instruction pdf ...Autocalibration mode.
I wonder if the Sabertooth did actually Autocalibrate and if it has possibly RETAINED the now erroneous setting ?

Woody and kas first off I want to apologize for the time you guys wasted to help me chase a problem that didn't need to exist . Somehow I manage to place a lead from the 5V pin from uno into my breadboard positive bus bar . I suppose the 5V from uno and the 6v battery both being tied into the positive bus bar was causing my hc05 to freak out ?

@Woody, I set the limit angle to 0 and now I have full range and with the wiring correction it's working great .

@kas do you have a suggestion for amp sensor for these wheel chair motors ?

Somehow I manage to place a lead from the 5V pin from uno into my breadboard positive bus bar . I suppose the 5V from uno and the 6v battery both being tied into the positive bus bar was causing my hc05 to freak out ?

:o :o
Happy guy, you didn't fry your BT card

@kas do you have a suggestion for amp sensor for these wheel chair motors ?

It's now time for you to describe your electrical setup, a drawing or a photo will help.
Woody is the expert for wheel chairs, most of them appear to be powered by two 12Volts batteries, please confirm

Remember you don't need a specific battery for the Arduino supply, as it can be powered from 12 volts (NOT 24V :smiling_imp: ).

Any need for battery Voltage monitoring ??

Wheelchairs are indeed 24v .

I use these sensors on my Robot Wars bot and use them in conjunction with a Roboteq and some script.

http://www.ebay.co.uk/itm/111689533182?_trksid=p2060353.m1438.l2649&var=410695568918&ssPageName=STRK%3AMEBIDX%3AIT

Pick the 100 amp bi-directional.

NOTE:- The analog voltage output from the sensor is a nice 0-5v and a standard R/C servo plug fits straight on the pins ... the Arduino headers will solder on directly ... BUT the POS & NEG pins of the sensors are reversed compared to a Futaba R/C servo plug so you'll need to lift the tags and swap wires to get a colour polarity match.

.

kas:
:o :o
Happy guy, you didn't fry your BT card

It's now time for you to describe your electrical setup, a drawing or a photo will help.
Woody is the expert for wheel chairs, most of them appear to be powered by two 12Volts batteries, please confirm

Remember you don't need a specific battery for the Arduino supply, as it can be powered from 12 volts (NOT 24V :smiling_imp: ).

Any need for battery Voltage monitoring ??

Yes it is a 24 v system , I am power over a 6v battery for simply sake for now as I have everything mounted to a tray so it makes it easier to run back and forth from the garage to the computer . The sabertooth also has a BEC but I haven't used it yet .

The larger bot will need voltage monitoring and amps, I am building this one as a TUG so it can help me move things around the house easier.

Will a simply voltage divider work like on the smaller BOT ?

@woody , thank you for the link . I will order that now. Do you have a gear reduction drive on your BOTS?

Thanks guys

Will a simply voltage divider work like on the smaller BOT ?

Yes, let me have a proposal for the resistors values and the checkBat() formula :wink:

The bot has a single stage gear reduction of 6-1 ...the most that can be obtained in one stage...two stages would be better to give 15 or 20-1 ratio....but I haven't got the space with this design.

I'd not use the built in BEC .... instead I recommend a UBEC or SBEC.

E.G.

http://www.ebay.co.uk/itm/Turnigy-5A-8-40v-switching-BEC-SBEC-UBEC-Plane-Heli-UK-Seller-Fast-Dispatch-/131194157989?hash=item1e8bc7fba5:g:0AMAAOxyOlhS-7Ri