Okay, now to make sense of the data given the resolution… So, lets give this another shot and replace millis() with micros() in the above code.īingo! Now this time is going by so fast that two sensor readings never get logged to the same time reading. So then I checked the Arduino Uno hardware page (the version I’m using) to check if it is a 16Mhz version, and it is indeed. the value returned is always a multiple of four). Duemilanove and Nano), this function has a resolution of four microseconds (i.e. So, is there a way to get more resolution in the time function so each time stamp is associated with only one sensor reading? Turns out there is! The micros() function outputs in, you guessed it, microseconds- sort of. The millis() function outputs milliseconds of time elapsed, and as you can see above, I’m getting some readings at the same ms! Which means this is printing faster than 1000Hz. print the results to the serial monitor:Īnd here’s a section of the initial output: initialize serial communications at 9600 bps: Int sensorValue = 0 // value read from the photocell I’ve found that CoolTerm is the easiest way to do this, and it’s available in Mac, Windows, and Linux versions (yes, I’m still a PC).Ĭonst int analogInPin = A0 // Analog pin that the photocell is attached to While you can see data scroll in the serial monitor screen of Arduino, you can’t save it to a file directly from there. So I tried just using a photocell hooked up like one of the FSRs here, then I tried a speed test to see just how fast I could get data to print. I really need to log data very quickly and am having some issues getting above 200 Hz, so I thought I would simplify things and get back to basics to try to find the maximum speed I can write to a file. I don’t want to write to an SD card, because I want to be able to run repetitive experiments and graph the data in real time (through Processing) or close to real time (in Excel). The objective is to basically use the Arduino as a data acquisition board and avoid using a more expense NI DAQ with LabVIEW or MATLAB. I’ve been working on a robotics project for a while* that requires me to log data from various analog sensors, and I’ve been doing it all with an Arduino so far.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |