“Lab” Upgrades

For the longest time my home electronics projects have been done on a 60″ x 30″ folding table in one of our spare bedrooms.  My growing collection of project boxes, spare parts, and equipment finally started to put stress on my furniture – particularly my table.

The old lab table.

The old bowing table in its “clean” state.

I spent embarrassingly too long fretting over whether to buy a desk or build it.  If I bought something, what should I get?  Do I need an “electronics” workbench?  If I build it, what should I build it out of?  I probably spent five months going back and forth – all the while piling more junk on my table.

Spurred on by my better half (and Ministry of Finance), I swallowed my “I can build this” pride and just bought something.  I went with a Kennedy bench by BenchPro.  Specifically, I got a KF3696 which has the rounded front Formica top.  At 8′ x 3′ and well over 100 pounds, it is substantial.  It has a very sturdy feel which is exactly what I wanted.  I went with a cloudy gray top and black frame.  I like the looks very much.  I also went with the adjustable legs and set the height at 36″.

New bench.

The bench in its new home.

I couldn’t be more pleased with the ordering & delivery.  I got a quote from BenchDepot over email and called to confirm the order.  The bench came on a 9′ palette delivered to my home by the freight company.

While switching out the table for the bench, I took the opportunity to clean things up a bit and get organized. All of my project and spare parts boxes now fit neatly under the left half of the bench.  Power strips and what not are neatly along the back (both on top and bottom of the bench).

More space, better organization.

More space, better organization.

I have a few additions left that are on their way – a 4′ x 2′ dissipative rubber mat for the left half of the bench for example.  That hasn’t prevented taking the new configuration for a few test drives.  My daughter used the “new lab” to do one of her science experiments (a homemade accelerometer).

IMG_2099

Homemade accelerometer.

So far, so good.

UPDATE: The rubber mat arrived from All-spec.  I really dig this over the previous setup.  Very sturdy and is great to work on.

photo

 

Ancient History

Found a link to one of the many “big huge awesome” projects that we started in ACM@UIUC back in the day. I’m pretty sure this page is the only thing that actually came out of this project. :) I think (hope?) that I’ve gotten a little better at completing things (retro pc project and this blog not withstanding).

These big huge unfinished projects were not really failures. Many of the people who worked on projects like these at ACM@UIUC are now veterans of the startup scene or leaders behind the scenes at the hot tech shops around. I look back at these projects as ambitious and a great learning experience.

A Simple Remote-Controlled Arduino Tank

A little while ago my son was showing some interest in robotics. His birthday was coming up and we were having trouble deciding between a beginner robot kit focused more on construction or lots of bits and pieces.

The kit we looked at was the Elenco OWI ATR – All Terrain Robot:

The alternative was to build a robot based around Arduino. There are many robotics kits out there but I liked the idea of investing in Arduino as the basis for exploring robotics. I figured we would get the Arduino Uno, a few shields to control motors and sensors and whatnot, throw some wheels on it, and blammo, have a robot.

Then the shopping set in. There is a multitude of places to buy a multitude of robot stuff. I was tempted by RobotShop’s DFRobotShop Rover. Arduino compatible, everything we need to get started. And it was on sale at the time I was looking.

In the end, we bought our son the OWI ATR kit mentioned above for his birthday and I ordered a bunch of bits and pieces instead of the RobotShop Rover to build something more advanced with him. He really enjoyed the OWI ATR kit – he likes to build with his hands so it was the right balance of technology and construction.

For the Arduino robot project, I decided to start with a simple remote controlled tank. I really had no specific plan though I had searched around a bit on YouTube and such to see that others had managed to throw something together. I ordered everything from Amazon though not everything was fulfilled by Amazon so I paid shipping for a few things. Otherwise, I tried to spend as little as possible.

For the mechanicals, I used cheap Tamiya plastic bits. The instructions on these are not the most verbose but my son and I managed to stumble through without any damage to ourselves or the parts.

For the brains behind the operation, I went with a fairly stock setup with an Arduino Uno and a Motor Shield from DFRobot.

Additionally, I wanted to use a wireless PS3 controller for the remote control. I picked up a used Logitech wireless PS2 controller from my local Gamestop (since closed). You can find them on Amazon as well.

I allowed myself a bit of luxury by buying jumper wires.

A battery pack to hold four AA batteries seemed like enough power.

Assembly of the chassis was straightforward…

Tank Chassis

Assembled tank chassis with motors.

After building the chassis, the motor, and doing a quick test with the battery pack connected directly to the motors, I moved on to attaching the Uno and motor shield, I had some 1.5 inch nylon standoffs with screws that I used to mount the Arduino complex to the chassis. I did another quick test controlling the motors using the Arduino + Motor Shield.

Mounted Uno and Motor Shield

Mounted Arduino Uno and Motor Shield

//Arduino PWM Speed Control for DFRobot Motor Shield
//

int E1 = 6;
int M1 = 7;
int E2 = 5;
int M2 = 4;

void setup()
{
    pinMode(M1, OUTPUT);
    pinMode(M2, OUTPUT);
}

void loop()
{
  int value;
  for(value = 0 ; value <= 255; value+=5)
  {
    digitalWrite(M1,HIGH);
    digitalWrite(M2, HIGH);
    analogWrite(E1, value);   //PWM Speed Control
    analogWrite(E2, value);   //PWM Speed Control
    delay(30);
  }
}

Finally, I tore apart the wireless dongle for the PS2 controller, soldered on some jumper pigtails and connected it to the Arduino. Using PS2X from Bill Porter, I got basic remote control working pretty quickly.

Wireless PS2 Controller Dongle

Wireless controller dongle hanging off the back of the tank.

// Glue together PS2X controller code with DFRobot Motor Shield code
//
#include <PS2X_lib.h>  //for v1.6

PS2X ps2x; // create PS2 Controller Class

//right now, the library does NOT support hot pluggable controllers, meaning
//you must always either restart your Arduino after you conect the controller,
//or call config_gamepad(pins) again after connecting the controller.
int error = 0;
byte type = 0;
byte vibrate = 0;

//Arduino PWM Speed Control for DFRobot Motor Shield (default pins)
int E1 = 6;
int M1 = 7;
int E2 = 5;
int M2 = 4;
int lmotor = 0;
int rmotor = 0;

void setup()
{
  Serial.begin(57600);

  // set pin modes for DFRobot Motor Shield
  pinMode(M1, OUTPUT);
  pinMode(M2, OUTPUT);

  error = ps2x.config_gamepad(13,11,10,12, true, true);   //setup pins and settings:  GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error

  if(error == 0)
  {
    Serial.println("Found Controller, configured successful");
    Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;");
    Serial.println("holding L1 or R1 will print out the analog stick values.");
    Serial.println("Go to www.billporter.info for updates and to report bugs.");
   }
   else if(error == 1)
   {
     Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips");
   }
   else if(error == 2)
   {
     Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips");
   }
   else if(error == 3)
   {
     Serial.println("Controller refusing to enter Pressures mode, may not support it. ");
   }

   type = ps2x.readType();
   if (type != 1)
   {
     Serial.println("warning: DualShock Controller Not Found!");
   }
}

void loop()
{
 if(error == 1) //skip loop if no controller found
  return;
 if (type == 1)
 {
    ps2x.read_gamepad(false, vibrate);          //read controller and set large motor to spin at 'vibrate' speed

   lmotor = 0;
   if (ps2x.Button(PSB_L1))
     lmotor = 255;
   if (ps2x.Button(PSB_L2))
     lmotor = -255;

   rmotor = 0;
   if (ps2x.Button(PSB_R1))
     rmotor = 255;
   if (ps2x.Button(PSB_R2))
     rmotor = -255;

 }
 else
 {
   lmotor = 0;
   rmotor = 0;
 }

 // update motors
   if (lmotor < 0)
   {
    digitalWrite(M1, LOW);
    analogWrite(E1, -lmotor);   //PWM Speed Control
   }
   else
   {
    digitalWrite(M1, HIGH);
    analogWrite(E1, lmotor);   //PWM Speed Control
   }

   if (rmotor < 0)
   {
    digitalWrite(M2, LOW);
    analogWrite(E2, -rmotor);   //PWM Speed Control
   }
   else
   {
    digitalWrite(M2, HIGH);
    analogWrite(E2, rmotor);   //PWM Speed Control
   }

 delay(30);
}

Overall, the little tank worked pretty well and we had fun building it. I think the four AA batteries aren’t really enough to power the system as I couldn’t drive both motors in opposite directions simultaneously (or there is a bug in my code which is equally possible).

Assembled Tank

Assembled tank with battery pack.

Since we built this, I’ve used the Arduino for a number of projects (yet to be posted) and picked up an Ultrasonic sensor that we’ve yet to put into use on the tank. That’ll have to be a future post.

Updated: A Mostly Complete Parts List

Here’s the items I used with links to Amazon (based on looking at my order history).

From Breadboard to Protoboard

The time has come to clear some space on my breadboard so I can continue to build out the remainder of the system. I’ve collected a few prototype boards from Futurlec by tossing a few in each order over a few months. I bought a few different flavors of boards (PROTO777, PRBRDLG, and EXPBRD) to see which worked best for my random projects.

Step one was to create a few more bundles of jumper wires to use. I don’t buy jumper wire kits, instead I keep a roll of CAT5 cable and cut off lengths I need, strip off the casing, and make my own jumpers. I’ve gone through about 40 feet of cable so far on the retro pc project. Fry’s usually has 25, 50, and 100′ bulk cat5 bundles in their networking aisles for reasonable prices (definitely cheaper than the jumper kits in the components aisle ).

Another bundle of jumpers.

Next, I took a few boards and laid out sockets for all of the components that are currently on the breadboard. I taped them to the board temporarily with labels for what each part was. This let me get an idea of how many boards I would need, what parts should be located near each other, etc…

Examples of placement.

And then the soldering begins…

Debugging stuck bits

I’ve been blocked on making progress on the retro pc project due to bad reads from the ROM. The seemingly simple snippet of boot code should light an led wired to to the i/o ports (any port).

section .text
resb 0x7F0
org 0x7F0

start:
mov al, 0x1

again:
out 0x10, al
jmp again

When assembled, this turns into the following x86 bits:

00007f0: b0 01 e6 10 eb fc

Unfortunately, when I tried to boot the bundle of wires on the breadboard, I got the following while looking at AD[0:7] on the 8088.

00007f0: b0 01 e2 10 ...

Hmm… that isn’t going to work very well at all. Looking at this more closely, bit 2 (the third bit) is zero when it should be one. What could be causing this bit to be zero instead of one?

  1. It’s possible that the bits in the ROM are simply incorrect and the circuit is reading what is there. If that is the case the fix is easy, burn a new EPROM.
  2. Since this is the low 8 bits of address lines, it is multiplexed with the 8-bits of data. To demultiplex the address and data lines, a 74LS245 is used to control the direction of these 8 lines. It is possible that the ’245 is driving the troublesome bit to zero even when it should be passing data from the ROM (or RAM) to the 8088. If this is the case, the ’245 is likely bad.
  3. The RAM and ROM are both connected to the ’245 and some glue logic to ensure only the RAM or ROM is enabled at any given moment. If the glue logic is wrong, both could be driving the ’245 at the same time which would be bad.
  4. Finally, there is an 8-bit latch attached to the ’245 to hold the data written to any 8088 i/o port whose bit 0 is connected to an led. Since this is used as output only, it is bad wiring if this is driving the ’245.

Debugging the stuck bit is a matter of incrementally testing the potential issues above. Testing the values in the EPROM was easy, I just plopped the EPROM in the USB programmer, read the bits back out and dumped them. They all looked correct.

Testing a bad ’245 was easiest by replacing it with a different one since I had plenty of backups. I tried two different replacements which behaved similar to the first. Seems likely that it would be a circuit problem not something wrong with the chip itself.

Next, I decided to verify the EPROM was working properly in-circuit by disconnecting the wire connecting the EPROM D2 bit to the ’245 and monitored the 8-bit outputs of the EPROM. The value read as expected (E6 was E6, not E2). While the EPROM was disconnected, I used another channel of the LogicPort to monitor the B3 (pin 16) of the ’245 to validate the fact that it was continually driven low — this would confirm that the EPROM was not the issue. Yup pin 16 was stuck low.

So someone else connected to pin 16 of the ’245 must be driving it low. I disconnected the RAM’s output data bit 2 at the ’245 and repeated the test. Still driven low. Wha? That implies that the 8-bit output port is driving the ’245 low? That would be odd. I followed pin 16 to the output port latch … and it was connected to the bit 2 output (Q2) instead of the bit 2 input. Whoops.

The funny thing is that the first thing I did when I saw the “E2″ value is that I double and triple checked all of the connections between the 8088, ’245, ’373 address latches, memory glue logic, RAM, and EPROM. I ignored the ‘output port’ many times in the process.

In the end, I managed to get a good boot sequence and I feel pretty confident that the breadboard 8088 is running!

x86 boot sequence that lights an led. You can see the code coming from the ROM and the write to the IO port in the sequence.

Using Ultrascope for Rigol DS1052E

I’ve become more and more annoyed at having to export images from my Rigol scope to a flash drive plugged into the device. I’d much prefer to capture signals and images directly from my Macbook. Unfortunately, the PC software that comes with the Rigol — Ultrascope — does not run on Mac OS X. Boo. Over the last couple nights, I’ve played with the idea of writing a Cocoa app to pull data from the scope. USBTMC + Cocoa seems like a pretty good path to go.

I also run Windows 7 x64 in Parallels on the Macbook. This works great for a handful of geek related Windows-only tools I use such as the Logicport application as well as the software for my GQ eeprom programmer. I could never get Ultrascope to run properly under Windows 7 x64 on my Thinkpad laptop though so I’ve generally ignored it since shortly after I got the Rigol scope.

Tonight I had to try again while debugging the latest evolution of my retro pc project. I really wanted to capture some waveforms and decided to give it another go.  A post on the rigol_scope Yahoo group had some helpful pointers on getting things to work. After following those directions, things work!

Ultrascope is kind of crappy software in general but it allows me to leave the flash drive plugged into my Xbox 360. :)

Sometimes it is a bad part… sometimes.

I’ve spent the last few weeks working on my retro pc project. The first step with the 8284 seemed to go well but the trouble began when I tried wiring up the 8088. I wasn’t getting anything remotely close to the expected boot sequence. According to the datasheet and
The 8088 Project Book
a few clocks after dropping RESET back to zero, the 8088 should raise ALE after placing 0xFFFF0 on the address lines.

No such luck.

I tried debugging to the best of my limited abilities and could not seem to get the 8088 to behave. I dropped by EEVblog forums to get some help. Turns out those older CPUs were / are pretty sensitive to the clock levels and the 8284 was not producing a valid clock. After a bit more debugging I decided to punt and order a new 8284 — this time from arcadecomponents.com. After the new 8284 arrived, I dropped it in as a replacement for the 8284 from Jameco I previously used. Success! Good looking CLOCK, READY, and RESET signals from the 8284. But still no good ALE, address lines, or boot sequence from the 8088. Tonight I decided to move the 8088 from one breadboard to another and rewire the 8088.

Breadboarded 8088 (on the left) and 8284.

I’m not sure whether it was using the different breadboard or just the rewiring but I was able to get a good boot sequence. Joy! A shot of the signals via an Intronix LogicPort.

8088 Reset Sequence

The 8088 post-reset sequence!

Next stop… adding some address decoders, a ROM, and some SRAM.

Starting a Retro PC using The 8088 Project Book

Several months ago, I purchased a copy of Robert Grossblatt’s classic The 8088 Project Book in hopes of building a retro 8088 computer. My plan was to scavenge the parts from craigslist, ebay, and a couple Seattle area used computer junk stores. My adventures locally didn’t result in many parts though I did have much fun finding all those old ISA cards. I did manage to buy quite a few intel parts (8259s, 8255s, etc…) and a bunch of 74xx TTL parts from a gentleman in the area who was clearing out old stuff. But I still didn’t have an 8088 and a couple other necessary support parts. My queries to craigslist resulted in offers to sell me old 8088 PCs for crazy prices. Eventually, I gave up on finding the parts locally and started adding the remaining pieces to various digikey and futurlec purchases. This past weekend the final piece – the 8284 – arrived which is good because it is pretty important being that it drives the clock for the entire system.

Saturday afternoon I gathered all the various parts, my handy breadboard, and started building the clock driving circuit — the first thing in the book beyond the power supply. There isn’t much to the circuit – a couple caps, resistors, a 14Mhz crystal, etc… However, it didn’t take long to figure out that I was a 4.7uF cap short and couldn’t manage to fake one with the parts I did have on hand.

I was going to place yet another futurlec order but I gave up tonight and stopped by Radio Shack and got the missing cap, wired up everything again, and … nothing. Noise on the 8284′s CLK output. Boo. Double checked everything with the meter and still nothing.

Clock driver circuit.

After a moment I noticed that the bench supply showed no current on its meter. Aha! I’ve never had a proper current limiting bench supply before — turns out it limits the current. Further, when you turn the current limit down to zero, the 8284 doesn’t seem to want to function. Duh. Turn the current limit up to non-zero and … bam! Functioning clock circuit.

Mmm... current & voltage!

CLK and PCLK from the 8284

Next stop is to actually hook up the 8088!

MSP430 LaunchPad arrived today

I ordered one of the $4.30 LaunchPad eval kits from TI a few weeks ago. It was immediately on backorder but to TI’s credit, when they had them, they shipped them quick — overnight FedEx from what I can tell. Nice.

I’ve only downloaded the tools – Code Composer Studio and IAR Embedded Workbench – which I’ve never used before. Should be interesting. I’ll check all this out once I work through my current (and ongoing) PIC32 composite video problems.

Exploring the PIC32 … and failing

I purchased Lucio Di Jasio’s book Programming 32-bit Microcontrollers in C (Exploring the PIC32) a while ago and love it. However, I’ve been struggling over the last few nights to get the composite video stuff to work on my PIC32 Starter Kit + IO Expansion board. The simple resistor DAC seems to be working fine but the output on the TV looks to have an extra pixel or two per line. A vertical line shifts right every line and then resets about every 8 lines or so.

I need to do more debugging with a scope attached to see what is up but it isn’t turning out to be turnkey — I suspect this is something to do with my setup and not the book or code itself.