Thursday, February 21, 2013

Surfacing

It's been a while since I posted.  A long time.  Not for a lack of work, just been spending more time on the projects and less on pictures and writeup.  I plan to continue to document my projects, but more via youtube video than here.

I've been spending a bit of time working on a few projects:
  • A Tandy Color Computer retro project, developing a bus interface to mimic both ROM and a few of the more common and useful peripherals, particularly the floppy disk interface.  I have the basic circuit design done, and I'm waiting on a small batch of boards to be fabricated.  My proof of concept links the CoCo 3 to the Altera DE-2 FPGA board, but the real unit has a 32K EEPROM and a connector to interface with an Arduino Mega board, using a CPLD to handle signaling glue.  The intent is to have the board support EEPROM programming from the Arduino, the CoCo accessing the ROM by itself, or the CoCo talkign to both the Arduino and the EEPROM.
  • I've been learning more about FPGAs and CPLDs and Verilog generally.  Lots of fun.
  • The industrial control project I started has evolved a lot.  I'm currently working on a custom PLC that's programmable via an Android tablet.  We're getting near final testing and tweaks, so more video on that soon.
  • The TinyG tablet app has taken a back seat, in part because I've been waiting for the communications protocols to firm up before I rewrote that part of the app.  It looks like a new release is happening soon, and so I expect I'll pick that up again.
That's pretty much it, but then again, that's about all I have time for at the moment.  Subscribe to me at http://www.youtube.com/user/Greyhound716/videos if you want to know when I post more stuff.

Monday, September 24, 2012

Operator Commands

Well, after a very focused dev session, I was able to add the support all of the command DB elements, allow manipulation of the individual command elements (like deleting them), and feeding them to the TinyG incrementally.  It's not perfect, but it's working pretty well.  Next up is to enhance the communications protocol between the Arduino and the tablet so that it does more than passes the info on to the TinyG.  More specifically, I want to be able to send it relay commands in JSON format as well as to enable a download mode that will open up a file for writing on the Arduino.  Once I get that done I'll do another demo.

Code isn't up on github yet, but I expect to get it up there before the project is done.  Need to think about how this code will mix with the other TinyG app before I put it up there.


Sunday, September 23, 2012

TinyG Operator Progress

I've made substantial progress on the Android - Arduino link over the past couple of weeks.  I posted this video to demo some of the new work.  Still on the docket is to construct actual gcode based on the input, and to store that in the system.

I'm using a database backend to store the programs and commands.  It turns out that's easier than manipulating raw files.  I'm also using the same service abstraction I used for TinyG for Android that allows selection of either network or USB host mode interaction.  So that means that I should be able to roll this USB Accessory mode capability into the core program without a lot of pain.

I've started to think about refactoring the existing TinyG for Android code.  Instead of having a separate app with the USB support, I'm probably going to make a multi-ADK release.  So this means that folks who can use the advanced features will automatically download one app with all the code, and the ones who can only use a subset of a capabilities will get another.  It should make some of the handling a little less tortured.

Thursday, September 6, 2012

Resources

I've been asked to put some of the resources I use for my projects all in one place.  Here are a few of my favorite things.  I regularly try to do video demos of my projects, and so for that take a look at my youtube channel.  Also, you can look at sites like hackaday for ideas, or even your local Buffalo Lab makerspace.

Arduino:

The main Arduino site itself is obvious, but I also like Sparkfun and Adafruit as both sources of ideas and for things like shields.  If you are going to use the USB Shield or the Mega ADK board, the Circuits@Home site is very useful as well.  Also, don't forget about the "examples" that are available within the Arduino IDE itself.

If you are planning to skip the Arduino IDE and "sketch" system completely and build code like your forefathers, you need to understand the underlying chipset and have a working toolchain.  It is very instructive to write a simple C program, have it be compiled to assembly, and to try to discern what that code does.  You get extra points if you grok relocatable code and understand what a linker does.  When you finally have object code to upload to the device, you need to choose how to do that last step.  Fortunately, the Arduino hardware has a built in method of flashing the firmware via the USB port.  You can get an AVR programmer if you want to be hard core, or you have a board that doesn't have the secondary bootloader.

When I'm doing electronic design work, I usually pull parts from places like Jameco and Digikey.  there are others, but between these two you can find almost anything.

Random tip: Always be aware of what voltage logic you're using.  For example, most Arduino boards are 5v, which means they output 5v as a "1" and they have a fairly high voltage threshold for inputs to be considered a "1" (I think something like 2.7v).  If you're trying to interface with a device that is based on 3.3v logic or even lower, you can get odd results or even damage your devices.  There are ways to do level shifting using options as simple as a voltage divider.

There are some standard ways to do things like light an LED from an output pin or "debounce" a switch that is attached to an input.  Understand how these simple circuits work.

Android:

The developer site is a great resource, as is all of the free code on Github (including my stuff).  If you need help, a google search usually turns something up on stack overflow.

Hope that helps some.  Let me know if I missed anything useful.

Sunday, August 26, 2012

Updates to TinyG for Android and a hardware controller

I'm working on a new project that should lead to several big improvements to TinyG for Android.  The project overall is to build a simple "operator" control for an existing CNC system, which would be able to send a stored program to a TinyG when the "go" button is pressed.  For this to work correctly, the unit will need to be able to home the CNC system on reset.  It will also need to be able to handle a few additional control inputs/outputs, since in addition to the "standard" gcode-based axes and spindle controls, the unit requires the actuation of some relays.

The Android app comes into play as a programming and control pendant for the operator unit.  The idea here is to have the Android device be able to train/build a new program by providing step-by-step line, arc, and relay controls, and then to have these programs be able to be stored on the Android device and uploaded to the operator system as needed.  During the program mode, the operator control would act like a passthrough.

There are two reusable components that will come out of this project that are of general interest.  The first is the program builder.  The second and in some ways the most important is that I will be implementing the operator control as an Android Accessory.  This will require a shim device between the TinyG and the Android devices (unlike the current Host mode), but has the potential to open the application up to many more Android devices.  While my first cut will only support Android 3.1 and up, a compatibility library should allow support to even earlier devices.

I'm planning to use the Arduino ADK board as the core of the operator control.  It is in effect an integrated Arduino Mega 2560 and a USB shield.  The Arduino programming environment is kind of clunky, but I expect that it will be sufficient for this project.  I probably could have used an Arduino UNO for this project, but the Mega's additional hardware serial ports and additional IOs make it an attractive option.  I'll be combining the ADK board with at least a microSD card breakout to store the programs.  The relay integration is TBD.  Depending on the switching voltages, I may use a relay shield or a standalone relay module.

At the moment I'm just sketching out the design and gathering materials.  I will be documenting progress as I go, including some photos.

In other news, I picked up a Xilinx CPLD development board, and I'm looking forward to learning a bit more about Verilog and CPLD/FPGA programming.  Given the TinyG project, it will probably need to wait for a while.  Lots of fun toys!

Saturday, August 11, 2012

Fun with Old Computers






One of the benefits of getting older is that you can afford the state of the art tech of your childhood.  In my case, I suddenly got the desire to tinker with the 8-bit goodness that is the Tandy Color Computer line that was sold in Radio Shack in the 80's.  I had a Color Computer 2 with standard BASIC.  It had 16k of memory, and used a cassette interface for storage.  It was the first computer I ever owned, and the second one I learned to program.  The first machine I ever "programmed" was an Apple IIe clone in my elementary school.  Of course, programming at the time typically meant copying BASIC programs from magazines like Family Computing.

This go around, I was able to pick up at 128k Color Computer 3 (as well as an original and a coco 2 for good measure!) off Ebay.  This model has composite video output as well as analog RGB out (think CGA!).  Unfortunately, old analog RGB monitors are surprisingly expensive, and so it's composite for now.  I have a Cunning Plan however.  There seem to be some inexpensive conversion devices out there (like this), and if I get sufficiently interested I might pick one up.

My first goal was simply to play a few old games.  In particular, I wanted to play my favorite game at the time, Dungeons of Daggorath.  Unfortunately, my original cartridge was long gone.  While many of these games are still under copyright, you can often find ROM images around the net.  Fortunately for me, this particular game has a very generous developer (Douglas Morgan) who has licensed the game to anyone who wants it.  He even offers the source code!

So now I have the ROM image, and my next challenge is how to get the data into the computer.  Fortunately, I have some raw materials to work with - an old 8k EEPROM, and an ancient cartridge for Personal Finance.  I carefully removed the old ROM from the cartridge, and soldered a socket connecter in the same place.  Unfortunately, the ROMs used at the time were a 24-pin 2364 variant, and the "modern" device I had was a 28-pin 27C64 with a completely different pinout.  With a little searching, I was able to find a pin mapping, and I was able to build an ugly but serviceable wiring harness.

The next step was how to program the EEPROM.  I had an Arduino UNO handy; problem was, it didn't have enough pins to directly address all of the ROM pins.  A little discrete logic to build a 18 bit shift register and I was in business.  I decided to directly wire the data lines so that I could read the chip (8 pins), used clock and serial out (2 more pins) and still needed 3 more output pins for CE, OE, and WE.  I ended up putting OE and WE pins on the shift register, and leaving CE direct.  One output pin left over!
 
I wrote a simple Arduino sketch to initialize and to read bytes from the serial line and follow the relevant chip timing to push the bits out.  I them wrote a simple Processing sketch to download a binary ROM image to the UNO.  The Arduino sketch is below if you're interested in doing something similar, though it's pretty simple code.










 After that, it was just a matter of popping in the chip, plugging in the "cartridge," and turning it on:


















The Arduino sketch:

const int addrOut = 11;
const int clock = 12;
const int chip_enable = 13;
const int ready = 0; // ANALOG
int value;

void setup() {
  for (int i=2; i <= 13; i++) {
    pinMode(i, OUTPUT);
  }
 
  randomSeed(millis());
 
  digitalWrite(clock, LOW);
  digitalWrite(chip_enable, HIGH); // invert logic
 
  Serial.begin(9600);
}

unsigned int loadAddr(unsigned int addr, boolean WE, boolean OE) {
  unsigned int d = addr;
 
  d &= 0x1fff;
  if (WE)
    d |= 0x8000;
  if (OE)
    d |= 0x4000;
 
  shiftOut(addrOut, clock, MSBFIRST, (d & 0xff00) >> 8);
  shiftOut(addrOut, clock, MSBFIRST, (d & 0x00ff));
}

void readEeprom() {
  unsigned int addr = 0;
  byte value;
  int pcount;
 
  for (int i=2; i < 10; i++) {
    pinMode(i, INPUT);
  }
 
  pcount = 0;
  while (addr <= 0x1fff) {
    value = 0;
    if (pcount == 0) {
      Serial.print("\nAddress: ");
      Serial.print(addr, 16);
      Serial.print(" : ");
    }
    loadAddr(addr, true, false);
    digitalWrite(chip_enable, LOW);
    for (int i=0; i < 8; i++) {
      value |= (digitalRead(i+2) << i);
    }
    
    Serial.print(value, 16);
    addr++;
    pcount = (pcount+1) % 16;
    digitalWrite(chip_enable, HIGH);
  }
}
void chipClear() {
  loadAddr(0, true, true);
  digitalWrite(chip_enable, LOW);
  loadAddr(0, false, true);
  delay(10);
  loadAddr(0, true, true);
  digitalWrite(chip_enable, HIGH);
}

void writeByte(unsigned int addr, byte b) {
  for (int i=2; i < 10; i++) {
    pinMode(i, OUTPUT);
  }
  loadAddr(addr, false, true);
  digitalWrite(chip_enable, LOW);
  for (int i=0; i < 8; i++) {
    if (b & (1 << i))
      digitalWrite(i+2, HIGH);
    else
      digitalWrite(i+2, LOW);
  }
  digitalWrite(chip_enable, HIGH);
  loadAddr(addr, true, true);
}

void loop() {
  while ((value = Serial.read()) == -1);
  if (value == 'w') {
    for (int i=0; i < 8*1024; i++) {
      while (Serial.available() == 0);
      value = Serial.read();
      writeByte(i, value);
      Serial.write(value);
    }
  } else {
    Serial.println("got something else!");
  }
}


Thursday, July 12, 2012

Social Work Android App



I've been working with some folks at the University at Buffalo School of Social Work to develop a feed reader that's tailored to the needs of social work professionals.  The app itself is built using a nice Android library called FeedGoal, and with a little tweaking we're adding channels that the school will manage to relate to various activities within the school and the disciplines.  Still a work in progress, but the app is up on Google Play for testing.

I'm also working on my todo list of bug fixes and enhancements for TinyG for Android.  In particular, I'd like to do a couple of behind the scenes things to make it more robust in the face of various status changes by moving the persistent objects into their own fragment.  I don't know if that's going to work, but we'll see.  I'm also planning to make it preserve the download filename between screen changes and app restarts, integrating a simplified file browser instead of using the openintents model, improving the throughput of the downloads, and a few other things.