Monday, July 15, 2013

Chips Are Getting Smaller

I started building with integrated circuits in about 1976. Radio Shack started carrying the 7400 series chips sometime around then. In school I had learned about half and full adders, so I knew what AND, OR and NOT gates were. I imagine they were a couple bucks each back then, but I wanted to build something. I quickly soldered up a half adder using these chips on a piece of Formica, dead bug style.

Over the years I built many projects hand soldering huge boards of chips. In high school, me and three other guys (Scott and Steve) built Don Lancasters TV Typewriter II. We etched the board our selves, but without plated through holes, ended up soldering sockets on both sides of the board (Steve pulled his hair out troubleshooting the thing, eventually removing about half the sockets, soldering the chips in, on both sides). I built many expander boards for the various computers I've had in the last 40 years.



Tonight I soldered in the MAX31855KASA chip I got as a sample a couple months ago. Fun, cool, challenging. I cleaned the heck out of the soldering iron, had to refile the tip to get it sharp enough, and it happened. The first time, I got 4 of 8 pins, the second time I got 6 of 8, and finally with some heat, I got the other two. It doesn't look pretty, but it works, and no shorts. Mass production will require solderflow, if I am to use these chips.



Yesterday and today, I did some research. Yes, the Arduino supports SPI. There is a nice SPI reference library as well. The MAX31855 only does serial out, so I connected the pins like:

   44  - IO44  - Chip Select of the 31855
   50  - MISO  - Serial out of the 31855
   52  - SCK - Serial clock input of the 31855

I used my standard color coding, that I have been doing for over 30 years:
   Blue - Ground
   Red - Vcc
   White - Signal

Then the rainbow ribbon cable is:
   Red - T+ Thermocouple +
   Orange - T- Thermocouple minus

The results look a little messy:
   

I am a little nervous that the chip is at one end of the board and the SPI is at the other end, but that is the layout of this proto board. There is only one thermocouple input in this chip, so that also disapoints me, but who knows, working in eagle, and maybe it won't matter. 

I tested the K-thermocouple that I have using a soldering iron and my vold meter. It is hard to read the voltage in the meter, but it looks like 15mv:



I haven't written the code yet, but I'd like to as soon as I can. Maybe tomorrow. 


Sunday, July 14, 2013

Amarino - Again

So I switched back to Amarino. Nothing wrong with the Andruino, in fact long term I'll probably base things off of that, I just need a GUI on the Android now, and Andruino doesn't let me do that. Code that I write for Amarino will be portable for the most part, so I should be able to write a gage module and use it for both environments.

So I rewound... I didn't go to the trouble of connecting the old PC hard disk to the new computer. I thought I would learn more if I did it the hard way. So far I think I have. Amarino isn't very flexible. The code must be hard coded for your bluetooth cards address. Finding the numeric address was a challenge. Initially when the pairing starts it displays the address, but then it changes to the name of the device. I looked in settings, thinking it might list the address there. It turns out the Amarino app has the address in the connect dialog. It took a little while, but I have it.

When I installed the ADK, it defaulted all my targets to 4.2.2. That works great on the emulator, but none of my devices are that advanced. I only have 4.1.2 on them, and some older phones have 2.3.3 or something. (If you aren't familiar with Android, the 2.x OS was pre-tablet version, but you can find some off brand tablets running 2.x, then the 3.x OS was for the early tablets, and Google quickly came up with an OS to satisfy their needs, and it only ran on tablets. The 4.x and above OS is the unified phone/tablet OS that is very current, and is more distributed, so most situations only need a new app, not a whole new OS to get almost all the latest features). The different OS targets APIs are also numbered (IE 4.1.2 is API 16, 2.3.3 is API API 10, sort of like Java versions). 

I installed the 4.0, 4.1 and 2.3 APIs so I can test things out on all my devices. This is done in the Android SDK manager app. Just a few clicks, to select what do download, and press install packages and the ADK is app updated! I didn't download the MIPs or Intel versions, thinking it would save time, and I don't really need them. The older tablets I gave the kids are MIPs based tablets, I may get a version another day for them, if I decide the app is suitable for older tablets (probably, I am not doing anything too complicated, but I don't think those devices have bluetooth).

Loading a bunch of new devices still didn't let me change targets. I had to restart Eclipse. Now I have a large collection of usable APIs. It still can't find my phone, only the emulators. It turns out I needed some new Samsung USB driver for it. I am not sure if Samsung is pushing the boundaries, or if they are being evil requiring a new driver. I'll look into that another day. I installed the app, but now touchwiz keeps crashing. I am rebooting the device, hoping whatever mess I created will get fixed.

Uh oh, now what? Well rebooting didn't fix anything, touchwiz keeps crashing. The phone is useless right now. At least the GUI. It isn't anything malicious, like a virius, just my dopey version of SensorGraph. I can use the notification bar to get to email, and that works (if there is a notification to select). Now when I exit email to go back to the home screen, when touchwiz crashes, I end up back at the email program.

Ooof, sitting here thinking about things, I think I know what I did. The SensorGraph came with an Icon defined in the original package. When I started putting the package together, it couldn't find that icon, so I created a 0byte file for it. I am guessing touchwiz is trying to draw a zero byte icon, and is getting a null pointer exception. I'll change the app to use some other icon, and then download that. It is just touchwiz, so that makes as much sense as anything.

Yes, that fixed that trouble, but now SensorGraph quit at startup. I thought it was because Amarino wasn't running. I started Amarino and connected to the board, then SensorGraph, but it still crashes. The LogCat was enabled, and I see a runtime exception, no class found at.abraxas.amarino.Amarino. It almost sounds like I don't have the amarino libs installed on the phone? Hmmm...

"With great power..." I had the amarino libs included in the build, but not in the deploy. Under the project->properties->buildpath->order and export, I had to check the box to export the amarino libraries. Now it works! Well it is connected, and well, 1 active connection. It says "hello world, sensor graph". I still need to upload the sensor graph software to the arduino. I had already loaded the code to the arduino library. Here is a screen shot of the stock MeetAndroid sketch output on the phone (random noise on analog pin 5)
Then I went and changed the sketch to read the input from the LM34 that was on the board at pin 15
It started at ambient temperatures, then I put my sweaty fingers on it, and you can see where it jumped up.

Now on to redoing my GUI work.






Tuesday, July 9, 2013

I Am Having Fun Now

Okey doke, I am just trying things, and well, it is working. Kinda silly, but at the same time, my juices are starting flowing. The bluetooth is pretty reliable, once I figure out the switches, and such. I've tweaked the Arduino code, and have it doing something interesting.

First the bluetooth, I have the iTead Studio v2.1 bluetooth shield, which seems to be obsolete. There are two switches on the board, voltage selection, and serial port selection. The voltage selection seems to work in either 3.3V or 5V on the Arduino Mega that I am using. The input MUST be set to FT232 for uploading sketches, and in the "To Board" setting to communicate with the Android. Handy to know.

Just as a datapoint, the phone (Samsung Galaxy Note II) seems to pair with the Arduino shield better than the tablet (Samsung Galaxy Note 10.1). I don't know why. The tablet works well once connected, it is just sometimes it is finicky.

I tweaked the sketch to read from the LM34 that I have on the prototyping board from before. This is connected to the A15 pin on the Mega. I have the get data read the value and convert the voltage into something like a temprature. It is running probably 20 degrees warmer than reality if I assume the analog reference is 5V or 10 degrees cool if I assume 3.3V. All I did was put a 1K bias resistor on it, which may be too much, the datasheet shows 50-75ohm. Probably that 3.3V is fine.

 Here is my tweaked code:

/*
 PROJECT: Andruino 0.1 Alpha
 PROGRAMMER: Hazim Bitar (techbitar at gmail dot com)
 DATE: July1, 2013
 FILE: Andruino.ino
 LICENSE: Public domain
*/

#define START_CMD_CHAR '*'
#define END_CMD_CHAR '#'
#define DIV_CMD_CHAR '|'
#define CMD_DIGITALWRITE 10
#define CMD_ANALOGWRITE 11
#define CMD_TEXT 12
#define CMD_READ_ARDUINO 13
#define MAX_COMMAND 20  // max command number code. used for error checking.
#define MIN_COMMAND 10  // minimum command number code. used for error checking. 
#define IN_STRING_LENGHT 40
#define MAX_ANALOGWRITE 255
#define PIN_HIGH 3
#define PIN_LOW 2

String inText;

void setup() {
  Serial.begin(9600);
  Serial.println("Andruino 0.1 Alpha by Tommyb (2013).");
  Serial.flush();
}

void loop()
{
  Serial.flush();
  int ard_command = 0;
  int pin_num = 0;
  int pin_value = 0;
  int temp = 0;    // temprature
  float a15 = 0;  // analog pin 15 input.
  float maxAnalog = 1024;
  float trueTemp = 0.0;

  char get_char = ' ';  //read serial

  // wait for incoming data
  if (Serial.available() < 1) return; // if serial empty, return to loop().

  // parse incoming command start flag 
  get_char = Serial.read();
  if (get_char != START_CMD_CHAR) return; // if no command start flag, return to loop().

  // parse incoming command type
  ard_command = Serial.parseInt(); // read the command
  
  // parse incoming pin# and value  
  pin_num = Serial.parseInt(); // read the pin
  pin_value = Serial.parseInt();  // read the value

  // 1) GET TEXT COMMAND FROM ANDRUINO
  if (ard_command == CMD_TEXT){   
    inText =""; //clears variable for new input   
    while (Serial.available())  {
      char c = Serial.read();  //gets one byte from serial buffer
      delay(5);
      if (c == END_CMD_CHAR) { // if we the complete string has been read
        // add your code here
        break;
      }              
      else {
        if (c !=  DIV_CMD_CHAR) {
          inText += c; 
          delay(5);
        }
      }
    }
  }

  // 2) GET digitalWrite DATA FROM ANDRUINO
  if (ard_command == CMD_DIGITALWRITE){  
    if (pin_value == PIN_LOW) pin_value = LOW;
    else if (pin_value == PIN_HIGH) pin_value = HIGH;
    else return; // error in pin value. return. 
    set_digitalwrite( pin_num,  pin_value);  // Uncomment this function if you wish to use 
    return;  // return from start of loop()
  }

  // 3) GET analogWrite DATA FROM ANDRUINO
  if (ard_command == CMD_ANALOGWRITE) {  
    analogWrite(  pin_num, pin_value ); 
    // add your code here
    return;  // Done. return to loop();
  }

  // 4) SEND DATA TO ANDRUINO
  if (ard_command == CMD_READ_ARDUINO) { 
    // char send_to_android[] = "Place your text here." ;
    // Serial.println(send_to_android);   // Example: Sending text
    a15 = analogRead(A15);
    // Serial.print(" Analog 15 = "); 
    // Serial.print(a15);  // Example: Read and send Analog pin value to Arduino
    trueTemp = maxAnalog;
    trueTemp = (a15 / trueTemp); 
    Serial.print("  Temp = ");
    Serial.println(trueTemp*330.0);
    return;  // Done. return to loop();
  }
}

// 2a) select the requested pin# for DigitalWrite action
void set_digitalwrite(int pin_num, int pin_value)
{
  switch (pin_num) {
  case 13:
    pinMode(13, OUTPUT);
    digitalWrite(13, pin_value);  
    // add your code here      
    break;
  case 12:
    pinMode(12, OUTPUT);
    digitalWrite(12, pin_value);   
    // add your code here       
    break;
  case 11:
    pinMode(11, OUTPUT);
    digitalWrite(11, pin_value);         
    // add your code here 
    break;
  case 10:
    pinMode(10, OUTPUT);
    digitalWrite(10, pin_value);         
    // add your code here 
    break;
  case 9:
    pinMode(9, OUTPUT);
    digitalWrite(9, pin_value);         
    // add your code here 
    break;
  case 8:
    pinMode(8, OUTPUT);
    digitalWrite(8, pin_value);         
    // add your code here 
    break;
  case 7:
    pinMode(7, OUTPUT);
    digitalWrite(7, pin_value);         
    // add your code here 
    break;
  case 6:
    pinMode(6, OUTPUT);
    digitalWrite(6, pin_value);         
    // add your code here 
    break;
  case 5:
    pinMode(5, OUTPUT);
    digitalWrite(5, pin_value); 
    // add your code here       
    break;
  case 4:
    pinMode(4, OUTPUT);
    digitalWrite(4, pin_value);         
    // add your code here 
    break;
  case 3:
    pinMode(3, OUTPUT);
    digitalWrite(3, pin_value);         
    // add your code here 
    break;
  case 2:
    pinMode(2, OUTPUT);
    digitalWrite(2, pin_value); 
    // add your code here       
    break;      
    // default: 
    // if nothing else matches, do the default
    // default is optional
  } 
}





Whatcha think, any thing I ought to be fiddling with?


Monday, July 8, 2013

I am doing a crummy job...

I am not keeping up with this, I am not documenting what works and what doesn't, and I just ignore all the readers.

Sorry

I'll be very humble in this post. Lots has changed. I bought a new desktop computer. This thing seems really good. It has two USB ports in the front of it, so I think that will help with things. Certainly the arduino plugs in nicely. I have the tablet, and a new phone. They are both Samsung Android devices. This is good, they both share nicely, so I can probably have some success.

Looking back, and trying to get things where I was, well, I am not having any luck.  I reinstalled the Arduino IDE, and looking back at my notes, I guess I missed some setups. The IDE won't let me talk to the board. The driver says successfully installed, but everytime I plug in, I get uh-ah sound from windows. This is Windows7, and I am following the instructions on the Arduino install page.

It seems the Arduino page isn't up to snuff. I went right to the FTDI page for the instructions on how to install the Windows 7 x64 device drivers (I don't think the 64 bit Intel drivers are included with Arduino at this time).  Yes, the instructions appear to make you do the same update driver twice, but yes you need to!

Even wanting to go back to where I was, I don't find any of my software, although it is probably on my old computer. How could you have duplicated, or improved my work? I need to do better than that. I am trying to be more open, and I hope you can understand.

This time the board is a Mega128, and the board is on Com3.  I was able to test this by trying the "Burn Bootloader" option in the tools menu of the IDE and watching the Rx/Tx LEDs blink.

I may go back in grab all the files off that old computer, and then try again, or I may start from scratch?

There seems to be a new Arduino to Android project on Hackaday again. It is using bluetooth, so I will give it a go.

I'll try to keep motivated, and put up code this time.

The Bluetooth device is called linvor 00:11:04:15:10:87, and the login is 1234.  I believe the bluetooth shield is still on 9600 baud.  I keep getting the error:

   avrdude: stk500_getsync(): not in sync: resp=0x00

with the shields on. With the shields off, it works fine. Maybe I need to turn off the bluetooth shield while I am uploading code? There is a switch, one side labeled "to board" the other labeled "to ft232". I can upload the code, with the switch on the "to ft232" side, and get no errors. I can also get serial data from the board to my phone using the serial monitor, without changing the switch. I don't receive anything from the phone though.

This is the code that is included from the Arduino to Android project


/*
 PROJECT: Andruino 0.1 Alpha
 PROGRAMMER: Hazim Bitar (techbitar at gmail dot com)
 DATE: July1, 2013
 FILE: Andruino.ino
 LICENSE: Public domain
*/

#define START_CMD_CHAR '*'
#define END_CMD_CHAR '#'
#define DIV_CMD_CHAR '|'
#define CMD_DIGITALWRITE 10
#define CMD_ANALOGWRITE 11
#define CMD_TEXT 12
#define CMD_READ_ARDUINO 13
#define MAX_COMMAND 20  // max command number code. used for error checking.
#define MIN_COMMAND 10  // minimum command number code. used for error checking. 
#define IN_STRING_LENGHT 40
#define MAX_ANALOGWRITE 255
#define PIN_HIGH 3
#define PIN_LOW 2

String inText;

void setup() {
  Serial.begin(9600);
  Serial.println("Andruino 0.1 Alpha by TechBitar (2013).");
  Serial.flush();
}

void loop()
{
  Serial.flush();
  int ard_command = 0;
  int pin_num = 0;
  int pin_value = 0;

  char get_char = ' ';  //read serial

  // wait for incoming data
  if (Serial.available() < 1) return; // if serial empty, return to loop().

  // parse incoming command start flag 
  get_char = Serial.read();
  if (get_char != START_CMD_CHAR) return; // if no command start flag, return to loop().

  // parse incoming command type
  ard_command = Serial.parseInt(); // read the command
  
  // parse incoming pin# and value  
  pin_num = Serial.parseInt(); // read the pin
  pin_value = Serial.parseInt();  // read the value

  // 1) GET TEXT COMMAND FROM ANDRUINO
  if (ard_command == CMD_TEXT){   
    inText =""; //clears variable for new input   
    while (Serial.available())  {
      char c = Serial.read();  //gets one byte from serial buffer
      delay(5);
      if (c == END_CMD_CHAR) { // if we the complete string has been read
        // add your code here
        break;
      }              
      else {
        if (c !=  DIV_CMD_CHAR) {
          inText += c; 
          delay(5);
        }
      }
    }
  }

  // 2) GET digitalWrite DATA FROM ANDRUINO
  if (ard_command == CMD_DIGITALWRITE){  
    if (pin_value == PIN_LOW) pin_value = LOW;
    else if (pin_value == PIN_HIGH) pin_value = HIGH;
    else return; // error in pin value. return. 
    set_digitalwrite( pin_num,  pin_value);  // Uncomment this function if you wish to use 
    return;  // return from start of loop()
  }

  // 3) GET analogWrite DATA FROM ANDRUINO
  if (ard_command == CMD_ANALOGWRITE) {  
    analogWrite(  pin_num, pin_value ); 
    // add your code here
    return;  // Done. return to loop();
  }

  // 4) SEND DATA TO ANDRUINO
  if (ard_command == CMD_READ_ARDUINO) { 
    // char send_to_android[] = "Place your text here." ;
    // Serial.println(send_to_android);   // Example: Sending text
    Serial.print(" Analog 0 = "); 
    Serial.println(analogRead(A0));  // Example: Read and send Analog pin value to Arduino
    return;  // Done. return to loop();
  }
}

// 2a) select the requested pin# for DigitalWrite action
void set_digitalwrite(int pin_num, int pin_value)
{
  switch (pin_num) {
  case 13:
    pinMode(13, OUTPUT);
    digitalWrite(13, pin_value);  
    // add your code here      
    break;
  case 12:
    pinMode(12, OUTPUT);
    digitalWrite(12, pin_value);   
    // add your code here       
    break;
  case 11:
    pinMode(11, OUTPUT);
    digitalWrite(11, pin_value);         
    // add your code here 
    break;
  case 10:
    pinMode(10, OUTPUT);
    digitalWrite(10, pin_value);         
    // add your code here 
    break;
  case 9:
    pinMode(9, OUTPUT);
    digitalWrite(9, pin_value);         
    // add your code here 
    break;
  case 8:
    pinMode(8, OUTPUT);
    digitalWrite(8, pin_value);         
    // add your code here 
    break;
  case 7:
    pinMode(7, OUTPUT);
    digitalWrite(7, pin_value);         
    // add your code here 
    break;
  case 6:
    pinMode(6, OUTPUT);
    digitalWrite(6, pin_value);         
    // add your code here 
    break;
  case 5:
    pinMode(5, OUTPUT);
    digitalWrite(5, pin_value); 
    // add your code here       
    break;
  case 4:
    pinMode(4, OUTPUT);
    digitalWrite(4, pin_value);         
    // add your code here 
    break;
  case 3:
    pinMode(3, OUTPUT);
    digitalWrite(3, pin_value);         
    // add your code here 
    break;
  case 2:
    pinMode(2, OUTPUT);
    digitalWrite(2, pin_value); 
    // add your code here       
    break;      
    // default: 
    // if nothing else matches, do the default
    // default is optional
  } 
}






To do more testing, I probably need to add some LED's or something.

That is all for tonight, it is getting late.




tom