In 2008 I started a project, and I never finished it for those who visit this site. I had a working project, but never did good documentation. I have finally pulled through with the final product! In this post you should be able to find: both schematics, both programs, and some pictures. What you won’t find is the circuit boards. I made them using the old fashioned way with Ferric Chloride and some Radidio* Shack press on etching strips. (*intentional misspelling)
I cleaned up a little in my junk room/hobby room/office last night, and I found something in my IC bin that I thought was pretty cool. I bought it about 2 years ago, and I never opened it. It’s the Parallax Memsic 2125 Dual-axis accelerometer.
This project is done on the Dragon12-P eval board since that is what I am using in school, but I plan on making a Microchip version as well. [I say this now, but it may be months before I actually have a chance. I have to focus on school again starting tomorrow]. I did it within 12 hours of saying so. Here’s the deal: I used a different approach with the Microchip. It is completely and totally simple compared to Freescale.
The Freescale route used a Capture port. I tried this with Microchip, but it didn’t work. I simply made a function that works just like a Capture. I call the function. If the input is high, it waits until it goes low and then starts the timer from zero. Then it waits until the rising edge and then reads the timer into a variable. Then it waits until the input drops to low, reads the value into another variable. Done!
Last night I was messing around with some stuff just for experimentation’s sake. I might use this in my Datalogger though, so I thought I would explore. I’m using the Pickit 2 to do some experiments on and learn new code. Here’s what I’ve discovered.
Using a potentiometer to trigger events:
In digital inputs, a high (1) is close to 5 volts, and a low (0) is close to ground. That’s all you get. Analog inputs are capable of many intermediate values ranging from either 0 – 255, or more depending on what chip you are using. I’m using the PIC16F690, and it has an 8-bit ADC. In this case ground will return 0×00 (0) and vdd will return 0xff (255).
#fuses intrc_io, nowdt, nobrownout, put
unsigned int adcByte;
setup_adc(adc_clock_internal); //The ADC uses a clock to work
setup_adc_ports(sAN0); //pin 19 ADC0
set_adc_channel(0); //This ADC0 is channel 0
while (1) //stay in this loop until reset
adcByte=read_adc(); //read_adc() return an 8-bit variable
/*I’m using the byte returned as the delay for an LED */