Thursday, December 12, 2013

The Future of Avionics.


In the last two weeks a couple articles have hit my in box, showing me why the avionics market is about to make a huge change. The current system of all-in-one boxes is not gonna work, and we need to accept that. It is time to go component with the avionics.



The electronics in the boxes have a life. They don't really wear out, unless you believe in the smoke theory of electronics. The other parts do wear out, knobs, displays, and other mechanical parts. The manufacturers aren't making some of the components any more (chips, knobs, etc). J. Mac McClellan who writes a great blog for the EAA pointed out that the Garmin radios are starting to go obsolete. So 10 or 15 years ago, you spent $20,000 updating the panel in your airplane, and now you need a new radio. There are no slide in replacements, so do you glue on something for now, until you can afford a whole nuther panel?

Another company was mentioned in the Canard Squadron email I get where they are using Android tablets and phones for a PFD. The company is called Talos Avionics. The product is a-efis, and can be bought today! No nothing certified, but probably good enough for daily use, with steam gauges as backups. Sure why you can't use certified instruments as backups to your non-certified panel? Well, the non-certified panel is more functional.

Another project I am working on is based on the STMF429 discovery board. This board has a display, CPU, gyros and accelerometers, and costs under $25. Have a look at the picture on page 9, and how detailed the graphics are. Why couldn't a small AI or better device be built for about $100 using this technology. It would be aviation throw away ($100 hamburger range). Right now any hole in the panel will cost at least $500 to get filled. The 6 pack that IFR pilots rely on costs a minimum of $3000, could we take that cost down to under $1000, I think so.

I've been talking about doing engine monitor on Android for about 3 years, what is so hard about it. (I've had a few distractions...). There are challenges, certainly, but giving people a full time job to do this stuff, and it should be quick and easy.

Prove me wrong, until then, it is time to change the world. 




Friday, October 18, 2013

Some Vendors

A while ago, it was my son's birthday, and I thought I'd get him one of the JXD 7300's. I thought it would be better than the JXD 5110, it is bigger and I thought it would be more useful. I waited too long to order it from China, so I looked for a US vendor. I had no luck finding a US vendor. I thought I might be OK getting it express shipped. 

I ordered it on a Thursday, and paid the extra $30 for 3-5 day shipping. The device arrived 15 days later. The correspondence with the company was challenging. On Sunday they sent me a note:

Since the value for your order is a little expensive, to protect the safe of your paypal account,

we want to confirm some info from you, hope your kindly understanding.
1st,  Could you pls confirm your shipping address whether correct or not

Well I appreciate that they are worried for my safety, but $144 isn't that much, I have spent way more than that on Paypal before. I also realize it is already tomorrow in China, so my Thursday order was really Friday early morning, and the Sunday correspondence was really Monday, but follow along. I did tell them that it was me, and that I thought my Paypal account was verified. I responded on Sunday, which I am sure they got on Tuesday. Their response Monday at 2AM my time was:

May I know when do you expect to receive the parcel? then I will arrange a shipment, since normally we will ship the order within 3-7 working days.

Ok, shouldn't they expect that if I paid for 3 day shipping I might want it really soon? What is there about 3-7 working days before they ship it? Holy cow, it seems really obvious now I am not going to get the thing in time. So I decide to look for a new vendor, maybe someone in the US. I look, and there is a vendor in New Jersey who has 10 of them listed on Ebay. I decide to order the one from ebay, and try to work something out with this Chinese vendor.  

I sent the following message:

I expect to receive the device by Thursday 10/10/2013.

The response I got was:

Hi friend,
Thanks for your email.
I will ask the warehouse to ship it by Thursday, pls wait patiently.
Hope your understanding in advance.

Best regards,

This is almost comical. I want it by Thursday, so they will ship it by Thursday? Maybe they know it is yesterday here in the US, so they can ship it and it will arrive Tomorrow? By now, I've had enough, since this won't make it even the week of my son's birthday, so I am ok with cancelling the order. Remember the first message, they weren't even sure it was me, they ought to be cool with me cancelling the order. I send a note back:

I wanted it at my house on Thursday!

Can we just Cancel this order?

Wow, that seems pretty clear. I am asking, not telling, but I have things arranged, and I no longer want the unit from them. Their response is:

Hi friend,
Even though we ship it yesterday, it is impossible to arrive you in one day. It will usually will take 3-7 working days via DHL.
We will urge the warehouse to ship it in 1 day, is it OK?
Looking forward to your reply.
Best regards,

Did they ship it yesterday? Am I in a time warp? I realize they are adjusting days, and this message I got on Wednesday, I know I don't want it. I did send them a note, that I thought was pretty clear:

If you are going to ship it anyway, then it doesn't matter.

It will be late, and I will just give your company a bad review.
I'd rather you not ship it, refund my money and we both
go away disappointed.

Is this clearer? "I would rather they not ship it and refund my money". I felt that was pretty clear. They did send one more note:

Hi friend,
Thanks for your email.
We will ship it today, pls wait for a while patiently.

It arrived 9 days later. Unbelievable, did they expect me to say good things about them? What do you think, did I miss something? I've bought most of my Arduino stuff from China, and I expect those things to arrive at my house 2-3weeks after I pay for the item. This took 2 weeks using express mail! I don't get it. 

I'll share the vendors name, if you ask. 

Sunday, October 6, 2013

Starting With Android Studio

Over the summer, well at GoogleIO, Google introduced a new way to develop apps for Android, called Android Studio. Android Studio is based on IntelliJ instead of Eclipse. I've been using Eclipse for 7 years, so this change might be a challenge.

The install was really straight forward. Everything is on developer.android.com. The link about halfway down the page will have the various install packages, one for Windows, one for Mac and another for Linux. The only thing these packages don't include is the JDK.

I had a JDK6 installed on my Linux box, and was able to install without any issues. I adjusted my PATH environment variable in the bashrc file, and everything worked the second start (the first start complained about double something being created). Start.sh seems generic, but that is what they use.

Once it came up, there was the tip of the day, and then a warning that there is a new update. There wasn't anything obvious about the update, and how to get the update. I clicked on the "more info" button, and it said to go to help->Check for updates in the menu. I clicked that, and it offered "get updates and restart". The studio GUI went away for about 2 minutes, and gave me status of what is happening. Applying patch was the longest part.

Once it comes up, it starts with a prebuilt app called "My First App". Not sure what it is, but it is a place to start.

The developers page has a link to some tips. These tips offer easier ways to do some editing, and navigation using control keys like emacs and other editors.

The layout editor give an easy start, but isn't intuitive. I added a button, and it looked like it was attached top and center. When I re-sized the button, it jumped to the upper left. The proper way to re-size the button was to change the text and font. I'll have to play with that a little more, so I can figure out how to align buttons and such (assuming I have an app with many buttons).

Most of the default devices are Nexus, and generic low resolution ones. I don't think a 5.4" screen will likely come in 480x854 pixels. I created a Galaxy NoteII with a 5.5" screen at 1280x720 pixels, since that is a phone I use. It doesn't reall matter, since whatever you create will just change presentation on the different devices.

At the top of the edit area, are tabs for the editable stuff, and at the bottom are the tabs for the view. The view can be changed between "Design" and "Text". Design is the drag and drop part. Text is the place where the XML and Java are edited for the project. The java code is where the callbacks and such go. The XML is where the properties of the display is set. While much of the screen layout can be adjusted in the drag-n-drop section, sometimes certain tweaks require editing the XML.

Building is easy, pressing the build menu, and selecting make project will create a set of executables that can be used to build an APK file. The APK file must be signed with a given key. Either a self signed key, or an official key from a register can be used. To self sign an app for testing, you can use the Keytool.

Once your app is running in the emulator (and maybe on a device), the adb tool can be displayed. Selecting on the Android in the bottom part of the frame, or selecting run->debug from the top menu, will enable debugging.

This is a powerful tool. Android Studio has many options, and will take some getting used to. It may not happen the first time you use the tool, or the second time, but it will be a good tool to use.

Give it a shot!



Sunday, September 22, 2013

Samsung isn't Great


I was all excited about the Samsung infrastructure, but I see some big cracks. I've got the Galaxy NoteII and the Galaxy Note 10.1. My wife also has the Galaxy NoteII. Don't get me wrong, Samsung builds great hardware.

Samsung software is not so great! They go a real strong 90% of what someone needs. I think as long as you stay in the Samsung family, things get along. Once outside, well, that is when the trouble starts. I've never signed up for any of the Samsung services, since I was already signed up for the Google services that meet my needs.

Things like Peel, gosh what a great little app for knowing what is happening on the TV networks. Easy to program and easy to get all setup. They sent out an update (I didn't think it needed it, but I took the update, and then the IR didn't work so well on one TV. I reset up that TV, and then it worked again, but why did the update break things???

The other feature of the Notes, are the pens. Wow, how cool is that. There have been no updates to the SNote software since I got the units, and the software is almost there. The text recognition is wonderful, no training, and it was recognizing my chicken scratches almost perfect. My problem is with the text boxes. Why can't the text boxes be more automatic. They come up small, and aren't easy to resize, and don't always put spaces between words. That makes the software, close to unusable.

I use the SNotes to take written notes, and don't bother to convert to text. That removes the search capability. I say I'll get to converting the written text to either a blog post or a wiki entry for my work documents. But that will add work, and may not help long term.

I feel Samsung pollutes the systems with crapware too. The AllShareCast dongle app is probably really useful if you have an AllShareCast dongle, but I don't. Why can't they make that an optional app instead of requiring it on all devices. ChatOn, SamsungLink and SamsungPushService all seem benign, but I need to keep those things up to date, in case there are exploits in the current version. (If you want a laugh, look in the playstore for reviews of SamsungLink). Why don't they make their services compelling, rather than same or worse than what I have today.

So now Samsung releases Gear. What a bad joke! It only works with the newest Samsung devices (for now??). The NoteIII and the newest Note 10.1. Dang you mean I need to update all my hardware to use a watch that might work for a day? I don't think so. This silly watch can't be very useful, since it has a tiny screen, and can't really talk to the outside world without a tablet or phone. Battery life of 25hours, well, hmmm... I better not spend the night at a friends house unless I brought a charger. And why not a wireless charger?

Now Samsung wants to start a whole new infrastructure. They want people to look at Tizen as a replacement for Android. Cool! their apps are so good, why not have me looking at devices based on Tizen, they will be better than...a sharp stick in the eye, I guess. (where is that sarcasm tag??)

No, I think my next device will NOT be Samsung. They don't have to do much to fix things in the next year, they only need to make what they have usable. Going for the next big thing is great, if they did it great. They haven't done anything great so far, and I don't seem 'em going that way. They will continue to do things that look like they could do things great, and will continue to disappoint. Unless they actually do great things, they will start being another mediocre phone company.

Samsung will need to support current devices, and make improvements. The Note line is clearly different than any other phone/tablet available, and they can build on that by fixing the software! Samsung has a reputation of crapifying phones, and if they quit doing that going forward that would help their reputation. By removing the crap, they may have an incentive to make their apps compelling, and people will want them, and actually install them. Today, all the owners of Samsung devices are forced to have the crap preloaded, and all we want to do is remove it!

It is up to you Samsung!

Sunday, August 4, 2013

The Mask is Off By One

A common software mistake, off by one errors happen occasionally. Indexing starting at 0 instead of one, you got ten things, so the last on is 9, not 10. What about hardware, you go pins, and they are numbered, or sometimes labeled. Dang it, wouldn't you know it, the labels on the board were off by one.

If you look at those labels, you can see the ground and 3.3V labels and that is where I am connected. Trouble is, if you look on the board this shield plugs into, the labels are off by one.

Starting with the pin labeled 5.0V on the shield, that is connected to RESET on the MEGA128 board that I am using. The next pin, is labeled  3.3V, but the traces in front of it are connected to the 5V. The next pin, labeled GND but the trace in front of it is really 3.3V. See these two pictures.

I believe I may have cooked my chip. All I could get out of the code was a 0. Over and over again. I should check the other writing to make sure I am connected to the proper pins. 


I have a spare MAX31855, so I am not totally dead in the water yet. I want to connect it to the right voltage, incase it does a shutdown on over voltage, and not leak smoke only. (I never saw any smoke).

Unsoldering the chip may be possible as well.

I really am trying, I just kept fiddling with the software, until tonight when I checked the voltage. (trust me the software is monkey see monkey do. I am using the SPI library included with the Arduino code.

I am an idiot. The 50, 51, 52 ... pins at the end start with 2 ground pins. I didn't count. So it is completely wired wrong. I need to take another whack at that part before I get around to calling my chip bad.

I am blaming it on being out of hardware practice. Can you take 5 years off from something and pick it up in a weekend.

Ever be so dumb yourself?

I re-did the connections. I am, using the ICSP header for both the SCLK and MISO. I've got it connected to 3.3V and it seems to be outputting data. 0 with nothing connected and some random data when the thermocouple is connected.

I've found the Adafruit libraries for the MAX31855, and want to try them, but am out of time for tonight. I'll get to looking at them another evening when I have more time. 

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

Thursday, May 23, 2013

I guess I might be committed to Samsung (for now)

I finally got my tablet, maybe two weeks ago. It was off of eBay again. This time the experience was amazing. It showed up when promised, and with some extras. 

I got a Samsung 16GB Galaxy Note 10.1. It is WiFi only, and I am ok with that for now. Once in a while I would like it connected while I am away from WiFi connections, but mostly I get by. I have the NoteII, and can mostly do what I need to on that. The Note II can act as a hotspot, but I am on an old contract with T-Mobile, and they will charge an extra $20/month if I do that. I've asked about switching to their monthly plan, since that has hotspot included. The guy at the store was vague, about the savings, and I was in a hurry, so I went home, and wished I had more time.

Overall the tablet experience is great! The Samsung will allow running many apps in separate windows, and you can see them all. It is clunky, with the touch interface, and forces click to type, rather than hover (I am an old X windows user, I still rely on hover to type to be efficient). It is probably the most useful feature that Samsung added over the stock android. Touch wiz is fine, no specific complaints. 

Surprises in the software included Peel a TV controller, super easy to setup. PS Touch a fancy media editor. FlipBoard a news reader. When I first logged in, the apps all synced up with my phone! It was good and bad. My kids had a bunch of games so the games are mostly on both my phone and the tablet. I keep saying I'll clean them up, but so far I really havn't (I've had the angry birds making noises in meetings!).

I mostly won't setup a Samsung account. I see nothing for me compared to the Google version of the same services. When I got the phone, it came with a DropBox account, so I signed up, but I only use the Google Drive. 

The screen is readable in sunlight. Unless the sun is pointing right at the screen, you can see it all the time. It has enough bezel so holding the device, you aren't pressing buttons. 

It came without swype or any of the drag around keyboards. I thought that was going to be bad, but with the 10 in screen in landscape, the stock keyboard is mostly usable.  I did get a bluetooth keyboard for it. It makes a nice cover. The one I got is aluminium, and will snap to the front or back. Snapping it on the back is nice when it isn't needed in meeting and such. It is super lightweight, so light that you can't stand the 10in tablet in portrait mode, since the tablet will tip it over. It isn't as good as a laptop, since the screen will pop out if you wiggle around.

Battery life is pretty amazing. A couple days on a charge is really good. The proprietary connector is a pain. I did order an OTG dongle, but that hasn't arrived yet. It is kind of big, so I probably won't use it much.  

The UI is pretty standard. Nothing special there, other than the window controls. I am getting to like Google Now, so I am ok with letting Google read my mail and such.

I've also been Listening to +AndroidCentral, +AllAboutAndroid and +ThisWeekInGoogle podcasts from Google IO. Lots of good stuff coming making the whole Android experience richer. I see only good things coming up.

Write Soon 




Tuesday, April 23, 2013

EBay is Trustable

So much for that tablet. The one I ordered never showed up. The seller had pictures of the Blackberry Tablet on that auction, and when I sent questions to the seller, I got no response. After two weeks, I gave up, and filed a claim on ebay buyer protection program. After a week, they got me my money back.

So I started shopping again. Sunday there was a Galaxy Note 10.1 listed. The price was really good, not the same as the Galaxy Tab, but I thought what the heck. The Note is the tablet I really wanted, so I got it. It was a whole different experience. The seller contacted me after coming back from the post office telling me about their experience. It should show up tomorrow.

I've also started a new blog. The Flying and Technology blog will be more about education related to the technology and flying. Opinions will slip in, just like this blog.

I am not really keeping up on any building of this or any other projects. I've been fixing my pool, and working hard at my real job.

Life is good, lets  keep things that way

Tuesday, April 2, 2013

I Ordered a New Tablet.


I wasted a bunch of time shopping on eBay last week. I finally decided it is time to get a mainstream tablet. I mostly want it for work, but think it would be good for doing ADS-B in on the cheap!

I ordered a new Samsung Galaxy Tab 2 10.1. I didn't get the note, it cost too much. The Galaxy Tab 10.1 is still a dual code 1.6GHz device, and ought to be enough power for now, and is less than a year old. It has everything I want; bluetooth, GPS, WiFI and a big screen. I think I'll have to buy an OTG adapter since it uses a proprietary USB connector (just like the iPad).

How can I do ADS-B for under $100 with this? Well, the SDR folks have been working overtime. One guy at least, Martin. He has the RTL2832u dongle talking to the Android devices. It was only a matter of time, since both the Android stuff and the rtl2832 SDR software are all open sourced. It doesn't do ADS-B decoding out of the box, but what the heck, that is only a little more software.

The FAA while  threatening to charge for the charts, still gives them away. It doesn't really matter, for me using old charts on this, since it will probably be just a toy for now. If I were to ever fly with this relying on the tablet for navigation, then I would want the most current charts. If needed, I would pay for them.

I think I could do the development of the ADS-B decoding, and try to use someones mapping software to get the data to display on the screen. If nothing else, decode the TIS-B and FIS-B data.

Yea, I know Garmin and FreeFlight and everyone seems to think anything under $5000 is the a cheap price for ADS-B, but here I am suggesting a $300 tablet, and a $20 receiver it all I need for ADS-B (plus some cables, and software). Imagine if this would run on a $79 Android tablet, then the whole mess is under $100!. That ought to shock those other guys. Sure they are doing it the hard way, separate receivers and all the work to get "certified" ADS-B receivers, but trust me, you don't need to have a receiver "certified".

Since it is GA in the USA, I am convinced the UAT frequencies are the right ones. The FAA will put the same data out on both the 1090MHz ES, and the 974MHz
UAT frequencies. 


Can we make it happen? Want to help? Lets do it!!

Let me know if I forgot something...

Saturday, February 16, 2013

Open Pilot has the Answer

I found some videos from the open pilot group who have their code ported to the STM Discovery F3 board. There is a Quad Copter flying using one. There is a demo showing stuff on the screen. Progress is happening.

I was thinking, if I just use the existing open pilot stuff, then I only have to get the code working on the Android, so I only have to do half the work. Then I don't have to come up with a communication protocol either, since open pilot already has one. Hack a Day of course came to the rescue yesterday also. There is a link to using App Inventor to connect an Android to an Arduino. It seems to make everything easier.

I was thinking, I don't have an Android SDK on Linux, but I mostly use Linux for surfing and developing, it might be time to get it. Yesterday the Android Central podcast suggested getting the SDK has gotten even easier recently. I'll give it a shot and let you know. It is also supposed to be easier to develop on. The Linux ADT bundle is about 400MB zipped, not too bad. The instructions seem reasonable, unzip and run. Maybe when I get done with this post, I try it.

Looks like I'll have some experiences that I've been through be broadcast on Airplane Geeks podcast this week.  That will be fun, talking about my mentors, and opportunities I have given other folks. It was a little more challenging than I thought, trying to stay coherent reading the text. It might be something I'll look into in the future.




Friday, January 25, 2013

Regrouping...


Last night, I tried to get the STM examples working using the Mentor CodeBench. It didn't work, or wasn't straightforward. I had make files pointing every direction, and finally got it to compile. It never linked, too many h files that didn't have matching libraries.

I want to re-do the whole example directory. I think I can, and still make it work. The CodeBench doesn't have discovery f3 header files, so the the 8 leds aren't quite mapped out. I may be able to copy one of the header files from the STM examples to the STM directory, and make it all work.

This guy recommends building my own linker script. I am thinking that would be a good idea. Maybe that will be the trick.

I've worked with BSP's before, but they were the whole tool chain for the board by the manufacturer. I wish people would give up on proprietary compilers and such. Unless they are building code that is orders of magnitude more efficient, there is no point. Just build for GCC and we all will be better off.


Stuff 
The CodeBench manual link

I went to a seminar on building presentations. It had a bunch of good ideas. I am going to try to engage all the readers to be more active in my project using those techniques. Prepare to be engaged!

Another Rant
I don't know what is going on. TimeWarner cable said they upgraded my speed over Christmas. Well, maybe, but it seems everything I do on this laptop is as slow as molasses! It used to be faster, and sometimes I can download movies well (ooo, if you haven't seen Speed and Angels, Hulu has it on their basic service for free. It is a pre-quel to top gun)

Tuesday, January 22, 2013

more stm discovery f3 links


STM has a repository of sample code for the discovery board. I need that for finding out how to make calls. I am more of a monkey see, monkey do kind of programmer. I'll use the manual if I have a question about a call, or can't find and example. I find it faster to find some code that mostly does what I need, and adapt it (reuse!). Most of the ST site is full of javascript pop ups that probably work on other browsers, but on Mandriva running Linux, the popups get lost, and make navigation complex (probably windows would be similar, but I am not going to try to find out. The manual is a PDF file, which is fine, I can download that and have a copy any time I need it. Some of the confusion too is all the devices that you can get data for.

The example code includes code for the on chip peripherals, not so much for the off chip items like the accelerometer, compass and gyro. I'll still have to dig for that.

Then of course, yesterday hack-a-day had a template for setting up discovery board projeccts.  I'll have to look at it now, since I have a link to it. He has something similar to code bench but for gcc-arm-embedded toolchain. That is good. I should be able to follow some of that work and get some ideas.

On my facebook post, I suggested I was building an autopilot. This can be the hub of various peripherals, including the autopilot. Unless one gets a direct route, the heading might not matter, but the IMU should allow guidance point to point, as good or better than the GPS. 


News on the JXD S5110 front...

My son has tuned in to the whole retro gaming with game pad buttons. He is probably playing the game as much, or more than he was before (that is good and bad). I spent some time with it also, when he wasn't around. The OTG port was just sitting there, and I finally got around to plugging a mouse into the port. It worked! so if he gets bored with the retro games, he can plug a mouse into it, and use it like a touch screen. The usability is going up! I won't show him the HDMI port, or he'll probably want to play all his games on the big screen.

More people are following, so tell your friends!

good luck

Saturday, January 19, 2013

Discovery Board is Working

Last week, I got the compiler compiling code. This week I got the discovery board talking OpenOCD. Life is good, now I just gotta figure out a protocol for sending data back up the USB port.

The engine monitor is on the back burner again. I want to build an IMU, since I have this board. If I can build an IMU, I should be able to build a little glass cockpit type display, similar to the Dynon or other EFIS app for the Android. The discovery board doesn't have any pressure sensors, but has a 3 axis gyro, a compass, 3D accelerometer, and a bunch of LEDs.

Using the gyro's, compass and accelerometers I should be able to build an accurate atitude indicator, a turn coordinator, a directional gyro indicator. If I can add pressure sensors, I should be able to build the whole "6-pack" from a standard instrument panel.

The secret to OpenOCD was at this site. Don't build the ftdi stuff, unless you have the ftdi dongle. If you are talking to the Discovery board, all you need is "stlink" that has been in OpenOCD since version 6.1.

The open pilot site has some resources for the discovery f3. There is a quad copter built using one.

Life is funny sometimes. Telnet, something I rely on, it is just there on all systems, old DOS (with some network kit), windows, all the unix systems I've used, mac and linux. For some reason, it isn't part of the default installation of Mandriva linux. How does one do anything without telnet. A simple urpmi and I have it, but weird!!

Anyway, I don't know if I added a link to this page, but it has a very high level set of instructions for building and loading software on the board, including using OpenOCD. He does:

openocd -f /usr/local/share/openocd/scripts/board/stm32f3discovery.cfg &
telnet localhost 4444
reset halt

flash erase_sectors 0 0 127
flash write a.out 0x8000000
 

To make that work, you really need to use the '&' to put open OCD in the background or use another terminal to do the telnet. Then you need to use different commands (maybe he had another version):

openocd -f /usr/local/share/openocd/scripts/board/stm32f3discovery.cfg &
telnet localhost 4444
reset halt

flash erase_sector 0 0 127
flash write_image imu.elf 

I havn't figured out what offset to write the image yet. There is another version of write:

flash write_bank bank_id filename offset
        Write binary data from file to flash bank, starting at specified
        byte offset from the beginning of the bank.

I think that will be something to play with in the future. The test_image shows it at 0x0800000, which may have been a typo from the initial site.

test_image imu.elf
address 0x08000000 length 0x000004cc
address 0x080004cc length 0x00000028
verified 1268 bytes in 0.000318s (3893.966 KiB/s)
The darn GDB doesn't work though. It was built expecting libncurses.so.4, and I only have that version in /usr/lib64.  I'll probably have to build that too, now. The demo code only increments a value by 5. Probably keeps the CPU pretty busy! Good way to test the debugger once I get that running.




 
The JXD S5110...

Well, it lived a hard life. It isn't dead, but well on the way. Today it was dropped, and the screen broke. This seems to have rendered the touch screen completely useless. I cannot figure out how to make the touch screen usable. The emulated games to work though. They mostly relied on the buttons around the screen, and they still work! The buttons emulate certain screen inputs, so you can unlock the device, and navigate the icons to select the games. It is funny, you know it is android, and you want to touch it, but that doesn't work. The joystick on the side does most of the driving, and the select button selects things. If someone made a good bumper for it, I'd probably buy another one.

Keep building

Sunday, January 13, 2013

Android Christmas


For Christmas, my older son wanted a phone. Without any influence, other than he couldn't have a Galazy Note or an S3, he wanted a Motorola Backflip, or any Galaxy phone. (I think he knew that I wouldn't buy him anything from Apple). We weren't going to pay for an unlimited plan, so I thought it reasonable to get an unlocked phone, and a pay as you go plan. Our older son and daughter went halfs on an unlocked Motorola Backflip. At first I thought this a great idea, but the backflip is so attached to ATT, that we can't load too many useful third party apps on it. I let him use my myTouch 4g until I can get this worked out a little more.

My other son got a JXD S5110 android gaming device. If you have never seen one of these, they are pretty cool. It looks just like an older PSP, with all the same buttons, but without the CD drive in the back. There is a circular Android logo on the back, that makes it look like a PSP. It has a large screen and a ton of software loaded on it (emulators mostly, Mame, N64, GB, etc). It has Ice Cream Sandwich, but you have to load the play store on it.

99% of everything I've loaded on it works. He plays temple run, cut the rope, and NinJump mostly. It has a multitouch resistive screen, and works amazingly well. You have to push, but overall, it impressive how well it works. One thing that doesn't work is Youtube. I can't tell you why.

The JXD X5110 is fragile. He dropped it the first day, and broke the WiFi switch. Why it has a physical switch, I can't tell you, since it is also software controlled. The back comes off of the device easily, so I soldered across the WiFi switch, so we don't have to deal with that. Over the next week, he has dropped it a couple more times, and knocked the power switch loose, and both of the top buttons. The power switch is about the size of a grain of rice, and the left/right buttons are larger push buttons. I was able to re-solder them on. I am guessing they probably flow soldered them with solder paste (RoHS and all). I used plain old 60/40 lead solder and a 15 watt iron. Nothing to it, maybe like 20 minutes total time (it took a little time to find the power button, since it is about the same size as the screws).

I don't know if I mentioned it, but my wife and I both got Galaxy Note 2's a couple weeks before Christmas. That was a good choice, I really like the device, and with the big screen, it makes everything else seem tiny. I haven't done any programming for it yet, but I want to try, especially for the side by side two apps at a time work. I've got podkicker on that, and been listening to the GoogleIO podcasts from last summer. I mostly listen to +All About Android and +Android Central podcasts for insite into future and device considerations. 

I've done a little work to get a development environment setup for the STM Discovery F3 boards I have. I tried really hard to build GNU toolchain from scratch, but eventually gave up and got the Code Sourcery from Mentor Graphics. It is all setup, but havn't built anything to install yet. I am tempted to use the Discovery boards for the processor for the engine monitor, instead of the Arduino. It'd just be nice to move on from 8bitters finally.

I also was working on pinewood derby, and plastic models, and all. Not much time for watching TV, but I want to play with the SDR again. I've kind of let all that go since last summer.

keep in touch.