data acquisition on arduino

Observations from an outlier

data acquisition on arduino

scanner-cut-300x220-3296942

scanner-cut-300x220-3296942

arduino data acquisition

Arduinos can be used in real products, they just aren’t teaching tools anymore. I cut my teeth on 68HC11 using C and the BUFFALO bootloader, mostly pain and not so much fun. sure the paid tools and IDE’s for this chip were pretty good but the were expensive and not hobby grade. if one wanted to experiment, the (oopic and the basic stamp and pic were pretty easy to use. the oopic was usefull because it was easy to code and download the new binaries. it had events and objects — hiding a lot of the complexities that most students would trip on and in the hobby guy’s price range (free deevelopment tools).

I used java for my climbing telemetry system. The TINI microcontroller never caught on, but was one of this first microcontrollers that I used that had ethernet and ran java byte codes. it was a bit underpowered to do any real work but it was great for getting data from sensors into a network. this was in the days of x10 and home plug, both failures in terms of creating standards for networked devices.

Lego came out with a great learning/hobby product that got good community support. I used the Lego bricks to teach basic maze finding using the java programming language (no big loop, just event handlers when robots bumped into walls). Still not great for real projects because of it’s limited inputs/outputs, but that changed when the Arduino efforts took off. It had great community support early on and was all free and open source tools. But.. it can be a bit buggy when doing complicated things though. I used to think one should never use it for a serious product, but this isn’t true. not at all.

One small job I did was to acquire analog data at high speed. At first I thought this would require a high speed, dedicated card on a PC.. but, it was do-able with an arduino. The application needed to spin a motor and read in data. In order to get the fastest analog sampling all that was required was to add these following lines into my sketch.

// defines for setting and clearing register bits #ifndef cbi #define cbi(sfr, bit) (_sfr_byte(sfr) &= ~_bv(bit)) #endif #ifndef sbi #define sbi(sfr, bit) (_sfr_byte(sfr) |= _bv(bit)) #endif /* init the chip */ void setup() { // set prescale to 16 sbi(adcsra,adps2); cbi(adcsra,adps1) ; cbi(adcsra,adps0) ; // ensure motor ready home(); serial.begin(115200);
}

After setting these registers, I was getting analog read times that were more than fast enough to get about 1000 readings in under 800ms. What did limit the speed was the serial port write operations. The way to make this faster is write these values to an array, and then write them out the USB port after reading.

 // scan while no limit pressed  long go = millis(); while(digitalRead(11) == 1) { Serial.println((String)analogRead(0)); if((millis()-go)>600) { Serial.println("fault"); home(); break; } }

See more on this topic on forums here.