Main

September 28, 2008

Updates to Matchport AR Missing Tutorial

I was motivated to make some minor updates and clarifications to the MatchPort AR Missing Tutorial because it has already moved into the top ten files downloaded from Skippy Records.  I just received the MatchPort b/g Pro in (what my buddy over at Joel's Garage affectionately refers to as) the "Brown Truck."  I will start to extend the MatchPort AR how-to and getting started guide to include the wireless version later this week.

September 10, 2008

The MatchPort AR Missing Tutorial

MatchPort AR and Demo Kit

I wanted to be able to add an embedded Web server to my projects.

I chose the MatchPort AR because, with the same experience, hardware, and nearly the same software configuration, I would be able to move to a wireless solution with the MatchPort b/g Pro. (The MatchPort b/g uses a different OS.)

I wanted to get up to speed quickly, so I purchased the demo kit, thinking that would include all the software and hardware I would need to understand and learn how to use the MAR in a project of my own. This was more or less the case, but getting up to speed was much slower than expected.

I thought I would be up and running demo apps in an afternoon and off to my first project early the next morning. Instead, I spent hours understanding the paradigm assumed for the MAR, hunting down example code, working out details and trying to understand the MAR's somewhat convoluted documentation.

I hope this tutorial gives the first-time embedded TCP/IP/HTTP server users a fast and straightforward introduction to the MAR. And maybe I can save more experienced users the hassle of tracking down the details of how the MAR can be coaxed into becoming a working embedded network component.

Download The MatchPort AR Missing Tutorial (PDF).

June 04, 2008

Added del.icio.us Electronics Links to Sidebar

March 23, 2008

1-Chip 4-Channel PIC16F886 Data Logger

This project has only a few modifications from the “Single Chip, Four Channel Datalogger” article by Dan Gravatt in the 2008 January Issue of Nuts&Volts (page 42), so I won’t go into much detail.

Below is the schematic.  The changes from Dan’s datalogger are that I used the PIC16F886, which is pin-compatible with the PIC 16F876.  I also used the PIC’s hardware serial I/O channels (pins 17 and 18) and I added an indicator LED that indicates logging in progress and the log interval (pin 22).  The switch sets the mode between logging and writing data over the serial port.

 

1-chip datalogger schematic
 

 

The C data logger code is available here as is a hex file with 1 s log interval. I used the CCS compiler. This makes reading and writing program memory very straight forward with commands like write_program_eeprom( prog_mem_adr, value ) and read_program_eeprom(prog_mem_adr). The 16F886 has 8192 total program flash words. The total time of logging is determined by the delay setting at line 64 of main.c.  Use a frequency counter at the indicator LED to set the desired logging interval. If you don’t add any lines to the code, you can increase the memory used for logging by setting START_ADR to the lowest open memory address. You can get this information with, e.g., the PICKit2 programming application or whatever your favorite PIC programmer provides.

Here’s the completed logger with a LM35 temperature sensor (suspended in the foreground) and a 7805 regulator (on the back left corner of the board) with a 9V battery attached.

1-chip data logger

January 02, 2008

PICKit2 Command Line Setup in CCS Compiler IDE

Microchip recently released a command line application for programming PIC chips with the PICKit2 device programmer . (It is called pk2cmd and there are links near the bottom of the page.)

I wanted to configure this for use with the CCS compiler IDE. After a few minutes of searching on Google for an answer, I didn't find one.  So I set about figuring it out.  Here's my solution:

The CCS Compiler allows a user to add buttons to execute 3rd party applications under the "Options|Tools" menu item.

Open this dialog box and in the dialog box, under "Name" add the name, e.g. PICKit2. Under "Usage" use the drop down menu to select where you want the new button to appear.  I added one for both "Tools Menu" and "Compile > Program Menu."

In the "Command" box, you need something like this: "C:\Program Files\Microchip\PICkit 2 v2\pk2cmd.exe" "-P%D"  "-F%H" "-M" "-h3"

You need to add the path above to your windows "PATH" variable (under "My Computer|Properties|Advanced|Environment Variables"--I had to log out and log in for the changes to take effect.)

The %D parameter is the device name including "PIC", e.g. PIC16F648A.  "-M" indicates that the chip is to be erased before programming; %H is the name of the hex file to program to the PIC chip.  Finally, "-h3" tells the application to wait 3 seconds before exiting.  This is a great feature as the CMD window opened by the application closes immediately when execution completes. Without the delay, you don't get to see any of the output messages.

Be sure to read the Readme file that comes with pk2cmd.  There are additional command options for reading from the device, powering the device, etc just like the GUI interface for the PICKit2.

Hit the "Apply" button.  Be sure to save the profile by hitting the green disk "Save" button to the right of the "Tools" menu, again, under the "Options" menu. If you don't do this step, you won't have any custom buttons when you restart.

I hope this helps.

September 01, 2007

Building an Electrocardiograph I

After the biofeedback experiments a few weeks ago, I started thinking about a more flexible way to measure raw heart rate data.  I am interested in more control of data sampling in order to make signal processing and analysis easier.

Fortuitously, the last issue of Make has a short article on page 157 on the topic of DIY electrocardiographs.  So off we go...

I first decided to go with the instrumentation amplifier built from three 741 op amps as described in the article.  I added the simple resistance-capacitance filter recommended in the article, got some conducting 3M Red Dot electrode pads and hooked the whole think up to the USB Bit Whacker for data collection (see Accelerometer from a few days ago.).

What were the results? Well, a qualified "it worked," but this needs some work.

The amplifier.  We need a gain of about 1000 to get the signal in the range of the A/D capabilities of the UBW (0-5V, 10 bits resolution). And we need high fidelity differential amplification of the inputs. This is called the common-mode rejection ratio (CMMR).  We need a CMMR of 100,000:1 (~100dB).  Here is the schematic:

instrumentation amp schematic


I added the recommended RC amplifier to the output to clean up the signal a little.

Here are some photos of the construction process. The circuit is point-to-point wired on a proto board and the whole think is mounted in a small aluminum case. The basic circuit is only a few components so it didn't take long to build.

instrumentation amplifier construction


The amplifier is powered by two 9v batteries to provide +/-9V for the op amps.  This means the output signal varies from something like -8 to +8 volts. Feeding the A/D of the UBW a signal between 0-5V is going to require some adjustments.  I added two 10K ohm potentiometers for null offset to I1 and I2.  (I now think this was a naive mistake because these have to be set very nearly equal for the amplifier to work.) I also added a 500 ohm gain adjust potentiometer in place of the 200 ohm fixed resister recommended.

testing instumentation amplifier


When I tested the amplifier with DC input signals, I grounded one input and varied the input at the other with a simple voltage divider.  This didn't expose any of the weaknesses of my design decisions. The null offset adjustment worked well. The test showed a gain of 1000 was easy to attain and that the amplifier produced a nice looking linear response.



So I closed up the case and was off to measure my heart beats.

finshed amplifier


Contact pads.  I started with some home-grown copper electrodes.  While I did get a small signal--intermittently--this wasn't going to work. To the Internet to buy the real thing from 3M.



I attached my new amplifier to the UBW analog input channel and modified my Python script (accelerometer.py) from the accelerometer experiment to capture data on one channel every 10 ms.  Here are the results:

heart rate data


And some detail...

detail plt


It is clear that external signals are swamping the desired heart beat signal.  It also may be the case that the amplifier-A/D combination is so poorly matched that there is some distortion of the data.

What to do different:

* Shorten the input leads--they seem to be acting as large antennae to the 60 Hz AC line frequency
* Build a better filter (active)
* Build/buy a more robust instrumentation amplifier
* Use a smarter method to translate the output to the required A/D voltage range
* Best of all, have this experience

August 29, 2007

Accelerometer and USB Bit Whacker

Trying out new sensors for my PIC projects can be tedious with only LEDs or 2-line LCD displays to provide feedback.  When I don't quite know what you are looking for, there can be some fiddling around to get things going. The USB Bit Whacker makes this first prototyping step really easy. With the 18F25xx or 18F45xx USB enabled chips from Microchip and some software created by Brian Schmalz (the USB Bit Whacker software), you can see how your new sensors are going to act with a PIC chip in just a few minutes.

The UBW lets you control pin input and output though the USB port on your computer with a few simple commands.  Using standard USB/Serial drivers on the computer (available from Microchip and elsewhere), you can interact with your UBW through a terminal application or any language the speaks serial. That's all there is to it. I built an 18F4550 board that uses Brian's UBW firmware with a minor modifications. But for real speed, just buy one ready to go from Sparkfun (shown in the photo).

UBW and Accelerometer 

I got a new +/- 2g accelerometer and a UBW from Sparkfun and wanted to see them in action right away. Using my UBW from Sparkfun, I added some header pins and used some jumper wires to hook things up as shown in the photo (this part takes about 2 min if you move slowly). The accelerometer is a 2 axis (x-y) device that offers voltages at the outputs between 0 V and Vcc (roughly) that are proportional to the acceleration along the x and y axes. Since there isn't any difference between the acceleration due to gravitational force and that due to changing speeds, the device can work dynamically to measure motion (acceleration) or pseudo-statically, to measure orientation in a gravitational field.

Plot of Accelerator Voltages


 

(Click for full-size image)

  With a few lines of Python code reading the serial port, I was able to log data from both axes of the accelerometer as I slowly rolled the accelerometer along my desktop. The resulting data is shown in the plot below.  As you can see, I rotated the device through 360 degrees in about 22 seconds, taking a few readings per second.

Links:

* Sparkfun -- Lots of cool stuff here!
* UBW at Sparkfun
* UBW Homepage
* Accelerometer data sheet
* Accelerometer at Sparkfun 
* Python data logger application

May 10, 2007

LiniStepper TestDrive Board Tested

Working toward a CNC machine, I decided to use the LiniStepper as my Stepper motor driver.  It is inexpensive, has a good feature set, is based on the Microchip 16F638A and open source.  I have build two LiniSteppers to date (need 1, maybe 2 more).  To test the stepper drivers, 4 control lines have to be set and a step clock function provided. A simple 555-based oscillator with some DIP switches will do. (You can buy a complete kit from James Newton for $19. That's what I did, but I had a small soldering incident that destroyed the board--hence this project.)

Here's the LinStepper driving a small stepper motor at 12V.

 

Stepper motor test

 

 

And here's a close up of the Stepper Tester.

LiniStepper tester circuit (LiniTester) 

 If you want to build one of your own, here's the schematic and circuit board (600dpi) artwork.  I used a 470 ohm resistor for the LED, 10K ohm resistors for the pull-ups, 2 500K pots for frequency and duty cycle adjustment and a .1 microfarad capacitor for the timing cap.  The 7 pin header matches the layout of the LiniStepper.  The upper 2-pin jumper in the photo is power input to the regulator circuit; the lower 2-pin header is for additional 5V supply (here I am powering the circuit directly from my bench supply).

 

April 29, 2007

Solaroller Tractor Pull Video

FlatTop vs. 2-Cell in a dramatic tractor pull. For more information, see my previous post on Solarollers.

See the drag race between FlatTop and 2-Cell at YouTube.

The advantage in both cases goes to 2-Cell, although FlatTop does a lot better when heading south due to the angle of the Sun and 2-Cell's two solar cells.

April 27, 2007

Solarollers

 


 

These are fun and easy to build.  The solar engine is made from two transistors and a threshold "switch" that allows the two capacitors to be charged by the solar cell.  When the voltage across the capacitors reaches the threshold of the switch, the energy stored in the capacitor is released moving the Roller as current flows to the motor.  This allows the vehicle to move in a wide range of light intensities.

 

Solar Roller and BEAM resources:


April 15, 2007

PIC-based Programmable LED

Alex Weber over at Instructables built a great programmable LED based on the AVR chip.  Since I am tooled for PIC, I thought it would be fun to replicate what he has done. This simple project is fun and it provides a great building block for playing with collective behaviors.

PIC-based Programmable LED 

Download detailed instructions and software LEDRec.c, LEDRec.h, LEDRec.hex for a PIC-based programmable LED.