Show Posts
Pages: [1] 2 3 ... 27
1  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 31, 2014, 02:04:36 am
i just want to say this is a good forum  smiley smiley

Thanks  smiley-cool
Welcome to the Arduino Forum
2  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 31, 2014, 12:57:10 am
... display battery charge indication ...
easy  smiley-wink
 - enable Arduino >> Android communication (see AndroTest V2.0 demo sketch)
 - bring a 4 Volts image of your battery level to Analog Input 0 using a resistive voltage divider
 - monitor A0 value every 1000ms
 - send value to datafield#1
 - if value < voltMin,  send  "** LOW Bat **"  message to datafield#3

void checkLowBat()  {                                            // check Low battery condition
  static long previousMillis = 0;                            
  long currentMillis = millis();
  if(currentMillis - previousMillis > checkLowBatInterval) {     // check every checkLowBatInterval milliseconds
    previousMillis = currentMillis;
    voltage = analogRead(Vpin) * K;                              // K: calculated according resistors values
    if(voltage < voltLimit)    displayStatus = "** LOW Bat **";  // send message to Android device
You can monitor both batteries, using A0 & A1

Other thoughts I had, could there be a WiFi version, would/could I also need a version of the app that includes video feedback ?
Should be possible
Total RC Commander is a sister App that includes Video features through WiFi

See the video in the Exhibition Section

Let me have more info about the video stream you want to display

Did you succeed in changing your BT card bps ??
The command line should be "at+uart=57600,0,0\r\n"

3  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 28, 2014, 09:03:47 am
Hi Vic,

Not sure what is happening here, does seem a power issue
Yes, highly probable
Check your ground connections as suggested by woodygb

When testing the setup using USB power, everything is fine
What is your actual USB 5V source ??   mAh available ??

So this led me to measure the voltages at each point and discovered the voltage drops to 4.03v
No drop when iddle ??
Is your battery pack brand new or used ??

According to Goteck GS-5515MG datasheet (4.8 & 6V):

2200mA at free run, means 5+ Amps at full load
This may be too much for a 2700mAh NiMH battery set
Try a 4000mAh+ battery pack

Any possibility to reduce required torque through better camera balance ??

4  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 27, 2014, 11:47:02 pm
Switching between modes is accomplished by changing pwm values on one channel. Thus when the pwm
value is "A" the apm mode is "manual", when it is "B" the mode goes to "Auto" and so on.
What are the specific values for A & B ??
Can you point me to the wiki part where this is described in details

The objective is to create a third PWM output
 If Button#1 == not pushed   then PWM = A  (manual mode, default)
 If Button#1 == pushed           then PWM = B  (autopilot mode)
Korrect ??
5  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 27, 2014, 11:25:48 am
The apm auto pilot accepts both pwm(default setting) and ppm signals(using a jumper to invoke the mode)
Beyond PWM data, what do you plan to send from BT Commander to APM  ??

How do you switch APM from autopilot to manual mode ??
Please post a link to the Operator's Manual
6  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 27, 2014, 04:18:35 am
Hi kas

Since the vacation season for me is nearly over I started to finish my custom made 4WD chassis using Dagu 75:1 motors and wheels.

The parts that I will use are:
1. USB RoboClaw 2x15A Brushed DC Motor Controller
2. APM2.6 autopilot
3. An arduino (probably the mega2560)
4. 7.2V/8Ah NI-Mh battery
5. You application for setting the modes of the APM2.6, viewing the route using the IP camera and for manual controlling the rover.

Can you help me interface your application with the arduino and the APM2.6?
What I was thinking is have the application send command to the arduino and then the arduino send R/C compatible signals to the APM2.6 autopilot. The Autopilot will send control signal to the motor controller.

My goal is to have a waypoint following rover using the apm2.6 and also be able to control the rover in manual mode using your application.

let my hear your thoughts 

Hi tolisn63

Nice project   smiley-razz

Not too familiar with the ArduPilot Mega   smiley-roll-blue
I suspect APM2.6 accepts only PPM (Pulsed Position Modulation) combined signal
You will need a PWM to PPM converter such as this one (6$ shipped).
Conversion could be made directly by Arduino, but requires interrupts and signal timing may become an issue, depending on other connected sensors

Keep us aware
7  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 26, 2014, 03:44:57 am
from Google Play:
Awesome I use this great app to control my arduino-based tank. The developer seems very willing to provide a support and updates. For example he compiled a special version for me, when I was having some problems with the official release. Thanks
Jakub Topič

Thanks Jakub for this nice feedback, much appreciated   smiley
8  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 25, 2014, 11:06:02 am
Hi Vic,

Only works fully only if powered by USB for both servos and arduino, I have constructed a prototype shield which enables me to power them independently of each other, I can also jump power to servos form arduino uno power input (battery, USB).

If I power them independently, then the servos are erratic or go full 180 degs lock - not ideal as I wont have USB power in the field.
Have tried some similar ways of control of which independent power works ok - example here

I don't see any reason why the two App's would behave differently  smiley-sad-blue smiley-sad-blue
I would have expected better results with separate power, as USB is 5 Volts by nature and servo's need 6 Volts
Are your servo's Analog or digital ??   the solution is probably here

Finally, please post the sketches for the two controllers

9  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 07, 2014, 01:05:33 am
Your binary format printout explains it all:
  // Propeller joydata = (280 << 10) | 260  =  100  01100001  00000100  =  286980    
  // Arduino joydata   = (180 <<  8 ) | 160    =            10110100   10100000   =    46240

All methods are OK using Arduino _long_ integers (32 bits)

16 bit Arduino _unsigned_ integer does overflow when shifted 10 times
as 286980  >  65535 (2^16 -1)

even 16 bit Arduino _signed_ integer does overflow when shifted 8 times
as 46240  >  32767 (2^15 - 1)

I tried it again declaring joydata as an unsigned integer, and I got the same results I got in the above post
Still more room, this is luxury  smiley-wink
10  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 05, 2014, 12:06:21 pm
I revised the code that transfers the x & y data between cores (and it works).

I tried your code and got wrong results

unsigned int joyData;
int joyX, joyY;

void setup()  {
  // twm47099 code
  joyX = 280;    // 280-200 = 80
  joyY = 260;    // 260-200 = 60
  joyData = (joyX<<10) | joyY;                    // encoding
  // --------------------------------
  joyY = (joyData & 511) - 200;                   // decoding
  joyX = (joyData >> 10) - 200;
  Serial.print(joyX);  Serial.print("\t");  Serial.println(joyY);  Serial.println();
  // >> printed result:   -176 60  (not OK) <<

  // kas code
  joyX = 280;    // 280-200 = 80
  joyY = 260;    // 260-200 = 60

  joyData = (joyX-100 <<8) | joyY-100;              // encoding
  // --------------------------------
  joyX = (joyData >>8) -100;                        // decoding
  joyY = (joyData & 0xFF) -100;
  Serial.print(joyX);  Serial.print("\t");  Serial.print(joyY);
  // >> printed result:   80 60  (OK) <<

void loop()  {}

Probably due to data type implementation difference in Arduino and Propeller   smiley-roll-blue smiley-roll-blue
11  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 04, 2014, 12:34:20 am
That was where I found a problem.  When transferring data between cores the Propeller automatically syncs the transfer for 1 variable.  For transferring groups of related data (x & y from the same time) the programmer has to handle it.  When the program printed x & y it was taking x & y from separate sequential data sets.  So I added a couple of global variables 'okwrite' and 'okread' to keep things sync'd.

I have no experience with multicore MCU's, so I may be wrong  smiley-roll-blue
What about combining  X & Y data into a single integer variable before transferring to the main core:
int joyData = joyX << 8  +  joyY
then parse back this value ??

One other thing, I haven't seen any button or joystick errors yet,
You may experience transmission errors when you start sending back data to the Android device
12  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 02, 2014, 04:48:59 am
My suggestion:  Keep . It . Simple   smiley-wink

Start with a program that parses data received from Android and just does that
It's final mission is to display (X,Y) joystick position and report button pushes
For data feedback to Android, just aknowledge button status on datafields phone screen.
You will find it much more confortable not to care about robot, motors and sensors at this development stage

Your PC screen should look pretty much like that:

In a second step, you may add debug facilities to your program
You will then chase communication errors and possibly adjust timing and code to reduce them
 - Joystick errors
 - Buttons errors
 - data frame errors
 - total data frames received

One Joystick (trapped) error out of 17530 received frames, not bad with Bluetooth

This is my Print debug function that reports possible errors:
void printDebug(int nByte)  {
static int buttonErr=0, joyErr=0, frameErr=0;
static long frames=0;

  if(nByte==2)     {                                                                // button data   < STX X ETX >
    if(cmd[1]>64 && cmd[1]<77 && cmd[2]==ETX)  {
      Serial.print("buttonStatus: "); Serial.print(buttonStatus);
      Serial.print("  bin: ");        Serial.println(getButtonStatusString());    
      Serial.print("Button: ");
    }  else { buttonErr++;   Serial.print("** Button error **: "); }

  else if(nByte==7)  {                                                             // Joystick data   < STX  XXX YYY ETX >
    boolean dataOK = cmd[1]>48 && cmd[1]<52 && cmd[2]>47 && cmd[2]<58 && cmd[3]>47 && cmd[3]<58
                  && cmd[4]>48 && cmd[4]<52 && cmd[5]>47 && cmd[5]<58 && cmd[6]>47 && cmd[6]<58
                  && cmd[7]==ETX;
    if(dataOK)           Serial.print("Joystick: ");                              // digits within range
    else                { joyErr++;   Serial.print("** Joystick error **: ");  }

  else         { frameErr++; Serial.print("** data frame error **: "); }          // wrong Byte number
  Serial.print("< ");                                                             // print incoming Bytes
  for(int j =0; j<nByte+1; j++)   { Serial.print(cmd[j]); Serial.print(" "); }
  Serial.print(">  ");  

  Serial.print(buttonErr); Serial.print("-");                                     // print errors status
  Serial.print(joyErr);    Serial.print("-");  
  Serial.print(frameErr);  Serial.print("-");

Finally, adapt a copy of your program to drive the ActivityBot

Two questions --
1. Does the data sent have to include values for all data fields?  Or can some be left out?
No, just send the delimiters:
 - Standard frame:
< STX   Buttons state   0X01   DataField#1   0x04   DataField#2   0x05   DataField#3   ETX >
 - DataField#2 and #3 omited:
< STX   Buttons state   0X01  DataField#1  0x04   0x05  ETX >

2.  When the button status is sent to the android device, is it echoed back to the bot?
It was the case in V4, now fixed in V5
MCU feedback did generate a "onCheckedChanged" Android event that trigged a new button data frame to MCU
In some situation, data could flow back and forth and gererate buttons flickering
Now button info sent from Android to MCU is echoed back (Buttons state) by MCU to Android, that's it

Good luck   smiley-wink

13  Topics / Robotics / ** Joystick BT Commander V5.2 ** on: August 01, 2014, 12:05:17 pm
     Joystick BT Commander V5.2   now available

More info here
14  International / Réalisations et Projets Finis / Re: Robot d'inspection piloté par Androïd on: August 01, 2014, 11:56:34 am
un truc que je trouverais sympa ce serait que tu deporte l'option joystick auto-return sur l'ecran principal
ou que tu propose sur l'ecran principal en cas d'option auto-return = off , un petit bouton (à proximité du joystick) forçant le centrage

implémenté dans la Version 5.2
Merci de tester et de me faire un feedback  smiley-wink
15  Using Arduino / Networking, Protocols, and Devices / ** Joystick Bluetooth Commander V5.2 ** on: August 01, 2014, 10:44:12 am
Joystick Bluetooth Commander Version 5.2  has just been published on Google Play

Change log
new features:
 - Manual return to center Button is displayed when "Auto return to center" is unchecked (thanks Artouste)
 - "automatically flip if device turned upside down" is now an option, to maintain compatibility with
     early Android versions  (thanks joepro)
 - Additional on screen Option button for new devices w/o dedicated Menu button (thanks twm47099)

 - Fixed possible racing conditions at App start up (flickering buttons)
 - Various minor improvements

  Demo sketch:   AndroTest V2.0   (communication protocol unchanged)    see reply #256

  Total RC Commander (with live video display) is also available.    Demo

Please contact me via PM

Enjoy  smiley-wink

Pages: [1] 2 3 ... 27