Friday, August 26, 2011

Android ProgressDialog reappears and won't go away

You'd think it'd be easy to create a progress dialog in your android app, but as far as I can tell, it's completely broken.  Any number of things will cause it to reappear or never go away.  Here's an apparently-ignored bug report:
http://code.google.com/p/android/issues/detail?id=11953

Tuesday, August 16, 2011

GWS S125 1T servo

Acroname sells the "R298-1T-SERVO", which is actually a GWS S125 1T/2BB.  It's different from most servos in that you can tell it to set any angle from 0-360 degrees, whereas most ordinary servos only move 90-180 degrees.

It has a 25-tooth spline, which should make it compatible with futaba arms.

Pololu sells it under the correct part number.

Tuesday, August 09, 2011

Arduino pro mini + bluesmirf + FTDI basic


Tonight I got my Ubuntu Lucid machine to program a 3.3v Arduino Pro Mini using a 3.3v FTDI Basic USB->TTL serial interface, and then got them both to talk to a BlueSmirf bluetooth->TTL serial board.

To get the bluetooth board to work, I wired it to the USB board so that I could talk to it from both ends: its serial lines and over bluetooth.  (See photo)


I ran minicom and connected to /dev/ttyUSB0, talking to the USB board and thus to the serial lines on the bluesmirf.  This bluesmirf was set up to communicate at 57600 baud, which I had to find by trial and error.  Once I got the right baud rate, typing "$$$" got me a "CMD" prompt as the manual suggests.  I switched it over, so now it uses 115200 baud.

On the bluetooth side, I used these instructions to talk to the bluesmirf over bluetooth from my glaptop:


Once I ran this: sudo rfcomm connect 0 00:06:66:04:B1:C2 1

I thought it was going to let me type to the bluetooth device, but really it's just creating /dev/rfcomm0 and then doing nothing. So with that command running in another window, I ran minicom and pointed it at /dev/rfcomm0, at which point I was able to type and see it in the other minicom window (pointed at /dev/ttyUSB0), and vice versa.

So that's how I knew the bluesmirf board was working.

To get the arduino running on my lucid machine, I had to apt-get install gcc-avr and avr-libc, make sure my JAVA_HOME was set right (because I have sun-java6-jre installed): export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre

Then I downloaded the 64-bit linux install from here: http://arduino.cc/en/Main/Software and unpacked it into a folder in my home directory.  Then I cd'ed into it and ran ./arduino.  I tried the http://arduino.cc/en/Tutorial/Blink example, and it worked great.

Next, I wired the arduino to the bluesmirf as shown here:


I left the bluesmirf TX unconnected to the arduino RX so that it wouldn't interfere when I programmed the arduino.  I used the "arduino" IDE to compile the following program, which just dumps some stuff over the serial port any time the reset button is hit.  The only change from the stock arduino "ASCII table" example is the change to 115200 baud, and pulling pin 13 high to assert the CTS hardware flow control line on the bluesmirf.  (I could also just as easily have run a wire from VCC to that line):

/*
  ASCII table
 
 Prints out byte values in all possible formats:  
 * as raw binary values
 * as ASCII-encoded decimal, hex, octal, and binary values
 
 For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII
 
 The circuit:  No external hardware needed.
 
 created 2006
 by Nicholas Zambetti 
 modified 18 Jan 2009
 by Tom Igoe
 
 This example code is in the public domain.

  
 
 */
void setup() 
  Serial.begin(115200); 
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  
  // prints title with ending line break 
  Serial.println("ASCII Table ~ Character Map"); 

// first visible ASCIIcharacter '!' is number 33:
int thisByte = 33; 
// you can also write ASCII characters in single quotes.
// for example. '!' is the same as 33, so you could also use this:
//int thisByte = '!';  

void loop() 
  // prints value unaltered, i.e. the raw binary version of the 
  // byte. The serial monitor interprets all bytes as 
  // ASCII, so 33, the first number,  will show up as '!' 
  Serial.write(thisByte);    

  Serial.print(", dec: "); 
  // prints value as string as an ASCII-encoded decimal (base 10).
  // Decimal is the  default format for Serial.print() and Serial.println(),
  // so no modifier is needed:
  Serial.print(thisByte);      
  // But you can declare the modifier for decimal if you want to.
  //this also works if you uncomment it:

  // Serial.print(thisByte, DEC);  


  Serial.print(", hex: "); 
  // prints value as string in hexadecimal (base 16):
  Serial.print(thisByte, HEX);     

  Serial.print(", oct: "); 
  // prints value as string in octal (base 8);
  Serial.print(thisByte, OCT);     

  Serial.print(", bin: "); 
  // prints value as string in binary (base 2) 
  // also prints ending line break:
  Serial.println(thisByte, BIN);   

  // if printed last visible character '~' or 126, stop: 
  if(thisByte == 126) {     // you could also use if (thisByte == '~') {
    // This loop loops forever and does nothing
    while(true) { 
      continue; 
    } 
  } 
  // go on to the next character
  thisByte++;  
}


Once I flashed the arduino, I connected from my laptop to the bluesmirf over bluetooth, hit the reset button, and saw the table as expected in the minicom window connected to /dev/rfcomm0.  First try, even. :)