Show Posts
Pages: [1] 2 3 ... 26
1  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)

Quote
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
2  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 05, 2014, 12:06:21 pm
Quote
I revised the code that transfers the x & y data between cores (and it works).

I try your code and got wrong results

Code:
unsigned int joyData;
int joyX, joyY;

void setup()  {
  Serial.begin(57600);
  
  // 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
3  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 04, 2014, 12:34:20 am
Quote
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:
Code:
int joyData = joyX << 8  +  joyY
then parse back this value ??


Quote
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
4  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:
Code:
void printDebug(int nByte)  {
static int buttonErr=0, joyErr=0, frameErr=0;
static long frames=0;

  frames++;
  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("-");
  Serial.println(frames);
}


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



Quote
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:
Code:
< STX   Buttons state   0X01   DataField#1   0x04   DataField#2   0x05   DataField#3   ETX >
 - DataField#2 and #3 omited:
Code:
< STX   Buttons state   0X01  DataField#1  0x04   0x05  ETX >
 


Quote
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



5  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
6  International / Réalisations et Projets Finis / Re: Robot d'inspection piloté par Androïd on: August 01, 2014, 11:56:34 am
Quote
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
7  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)

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



8  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: July 29, 2014, 01:10:29 am
Quote
I'm using a Propeller MCU.  I have C and Forth programs I wrote (using yours as a basis) for the previous protocol.  I've got to make a few changes for the new protocol. 

Tom,

I started learning MCU's using Basic Stamps, I would really appreciate to have AndroTest V2.0 demo sketch
ported to the Propeller environment and offered to the Parallax Community.

Keep us aware of your progress, be sure you will get full support for this task   smiley smiley smiley

9  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: July 28, 2014, 01:08:23 am
Quote
Thanks that worked
Glad to help

Quote
Where did you find that?
I used a new service called "Search Engine"   smiley-wink  smiley-wink  smiley-wink
Try it:
https://www.google.com/search?hl=en&as_q=%22menu+button%22+%22tab+4%22+samsung&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=&gws_rd=ssl#as_qdr=all&hl=en&lr&q=%22menu+button%22+%22galaxy+tab+4%22+youtube

Can you connect now to your Arduino ??



10  Using Arduino / Networking, Protocols, and Devices / Samsung Galaxy Tab 4 ** Menu button ** on: July 27, 2014, 11:59:36 am
Samsung has finally killed the dedicated menu button, replacing it with a task-switching key  smiley-eek-blue

Try pressing and holding this left button for a few seconds
Should bring the Option menu

Let me know if it works  smiley-wink
11  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: July 27, 2014, 12:05:28 am
Hi Tom

Quote
I have BT turned on, but I have not yet paired it to a device. 
Does that make a difference?
No, you should access option screens w/o pairing

Quote
I've downloaded version 5 to my Samsung tablet 4. 
I cannot find a way to get to a settings screen.
Are you talking about this one ??

Let me know
12  Topics / Robotics / Re: Bluetooth robotic dancer on: July 09, 2014, 08:58:59 am
Quote
if i add ur software to my robot it will be nice
https://www.youtube.com/watch?v=uAcljpmfuh0

Hi caymanguy,
Nice bot ,  thanks for sharing  smiley

I also use this App for controlling my own balancing robot, (now with MPU-6050 gyro/acc combo)


You may see the Bluetooth card, vertically plugged on the breadboard


13  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: July 08, 2014, 03:05:40 am
Quote
I can't really get onto google play and download the app from China
can anybody send me the app to my email (xxx-xxx@qq.com)
or send me another link to download
thank you very much!

Hi magicjackho, welcome to the Forum
Check your mail smiley-wink

I sent you V5.2 to be published on Google Play within a few weeks
Should you need support, this is the place

Let me have a screenshot of the Application

@All     ** I NEED screenshots **
this my only way to optimize display layout for your specific device  smiley

Personal advice:
To avoid spamming, I suggest you edit your message and remove your email info   smiley-evil

14  Using Arduino / LEDs and Multiplexing / Re: LED control via Android smartphone on: July 08, 2014, 12:46:03 am
Joystick Bluetooth Commander is now Version 5.1



Code should be updated with new communication protocol
More info here and here

15  Topics / Robotics / Re: Bluetooth robotic dancer on: July 08, 2014, 12:29:12 am
Code has been updated to be compatible with Joystick BT Commander V5.x



More info here and here

Pages: [1] 2 3 ... 26