Event-triggered datalogger
Pascal P
Posts: 26
Hello,
I am building·a datalogger to timestamp events that occur at non regular intervals.
I guess another way to describe this application·would be to call it a portable punchclock, i.e. a·small device·with·one button. Everytime the button is pressed, the time at which the button is pressed is stored in·an EEPROM and a running total of the number of times the button has been pressed so far is displayed on a small LCD. Then,·at the end of the day, this datalogger is plugged in a computer·and·all the timestamps are turned into·a·.csv·file for analysis. I am using a Stamp BS2 to do that.
I've gone through·postings, appnotes, and·tech documentation and all the datalogger application I've seen·always seem to·be set to·record data at fixed intervals (e.g. every minutes).
So my question is: Has·anyone ever come accross an application like the one I'm building? I.e. a datalogger with non-regular intervals.
I'm enjoying·working on this·but if it's already out there, I would love it if I didn't have to re-invent the wheel.·Thank you for letting me know if you've come across·an application similar to the one I describe.
Cheers,
Pascal·
I am building·a datalogger to timestamp events that occur at non regular intervals.
I guess another way to describe this application·would be to call it a portable punchclock, i.e. a·small device·with·one button. Everytime the button is pressed, the time at which the button is pressed is stored in·an EEPROM and a running total of the number of times the button has been pressed so far is displayed on a small LCD. Then,·at the end of the day, this datalogger is plugged in a computer·and·all the timestamps are turned into·a·.csv·file for analysis. I am using a Stamp BS2 to do that.
I've gone through·postings, appnotes, and·tech documentation and all the datalogger application I've seen·always seem to·be set to·record data at fixed intervals (e.g. every minutes).
So my question is: Has·anyone ever come accross an application like the one I'm building? I.e. a datalogger with non-regular intervals.
I'm enjoying·working on this·but if it's already out there, I would love it if I didn't have to re-invent the wheel.·Thank you for letting me know if you've come across·an application similar to the one I describe.
Cheers,
Pascal·
Comments
DO UNTIL IN8 = 1
LOOP
Will hold program execution until a button (in this case on pin 8) is pressed.
If you have a real time clock chip with nonvolatile RAM, that is a good place to store the log pointer.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 3/5/2009 4:36:18 PM GMT
Cheers, Pascal
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Yes it will be a portable device. Plus we'll have a few of them in use outdoor and instead of having to bring them all back to a computer, I could just walk around with a memory stick and dump the data of each logger into the one stick and bring the stick back to the computer. I guess the only thing is to make sure each transfer doesn't overwrite the previous one but files are placed in the remaining empty part of the memory stick.
Just to confirm, is this the memory stick datalogger you're refering to: http://www.parallax.com/Portals/0/Downloads/docs/prod/comm/MemoryStickDataloggerV1.1.pdf ?
Cheers, Pascal
Be aware that the memory stick data logger uses several Stamp pins and needs solid 5 volt power, so your field interface would need a plug for that. Transfer of a large amount of data takes time (which seems longer if you have to be standing there in the rain or hot sun!)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Cheers,
Pascal
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
What I am trying to do is I guess an hybrid between a tally counter and a punch clock. Hopefully this mixture will turn out alright [noparse]:)[/noparse]
Thank you again for your input on this.
Cheers, Pascal.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Cheers, Pascal.
·· Now, the answer to your question is actually covered in·both of the programs I wrote for the datalogger.· The Demo in particular waits for the memory stick to be present before contuing on with the program.· It sends a command to the datalogger to see if it is ready.· This is easily done by sending a CR (ASCII 13) to the device and waiting to see if it replies with a prompt ">" symbol.· If you check the firmware spec you can see that different messages are returned when a drive is present as when·not.· We can simply check the first character to make this determination.
·· As a side note...your program should also make sure the drive is done being written to and has closed the file before you remove the memory stick.· Failure to observe this precaution could cause the data on the memory stick to become corrupted and/or lost.· I hope this helps.· Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Hopefully my next post will be to announce the rest of the program is working [noparse]:)[/noparse] Thanks again for your help.
Cheers, Pascal.
Hello.·I just want to thank you all for your help. My little·time logger is working. It stores in a .csv file the time at which a button is pressed and download the file on a memory stick. It's basic and could use some improvement I'm sure but it's a huge leap for me since I didn't know what a microcontroller was 4 months ago.
In the spirit of sharing please find below the completed code.
Cheers,
Pascal
·
Several years ago I was involved in a field study where we needed·a data logger to monitor the change of state·of a switch that would be·opened or closed.· The unit was battery·operated, and needed to last for about 4 months.· If you find the need to extend your battery life on your portable data logger, here is a possible hardware·solution that monitors a switch using only 160uA of quiescent current.· If·a Switch is opened or closed the circuit creates a pulse that powers up the BS2.· In my data logger, the BS2 also managed power to other connected devices.· When the BS2 was powered up it woke up an external RTC that otherwise would run in trickle charge mode.··The BS2 would read the time from the RTC and then the BS2 would shutdown the·RTC·back into a trickle charge mode.· Next the BS2 would turn on an external memory·where the time/date, and switch position were logged.· Following that, the BS2 would·power down the memory, and eventually the BS2·would power itself·off.· Another "switch event" would start the cycle all over again.
·
Attached is a schematic of the 160uA·quiescent current·switch monitor I used in my data logger.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Neat! I was thinking along similar lines the other day: use a microcontroller I/O pin hooked up to a transistor which is on the power line. It's as if the BS2 was pulling itself up by shoestrings: it uses it's output into the input, which is to the output,... Glad to know that it is a valid approach.
And I think you also helped me with the RTC because I read about the trickle charge mode but I didn't know how to use it. Right now, I have to re-enter the "real" time in the RTC everytime I reset or turn on the unit but I was hoping the RTC could be powered separately and I would only have to set the time once. Is that what power trickle allows?
Cheers,
Pascal
I had to double check.... I used a DS1302 for the timekeeping chip. Vcc1 (Pin8) was connected to the main power via a current limiting resistor and capacitor combination. Vcc2 (Pin1) was connected to one of the Stamp I/O's. The actual "trickle charge" feature of the DS1302 was not implemented, other than the availability of Vcc1 and Vcc2 and how the chip treats those two pins.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I also use a DS1302. I will rewire and have Vcc2 connected to a small battery that will only power the timekeeping chip when everything else is sleeping.· I really appreciate your help on this.
Now that my prototype is working, I'd like to create a new version in which I replace the development board by the BS2 alone to save room. I ultimately would like this device to be hand held (e.g. the LCD strapped to the forearm and the switch attached to a glove) so that all the electronics·that is currently is in the big box (shown in the attached picture) ends up inside the enclosure where the LCD is. Would you have some recommendations on how to proceed on this?··
Take care,
Pascal
Vcc1 connects to your battery for low power mode of the DS1302.... Vcc2 is when you want to wake it up.
As far as size, our units fit into something about the size of a wrist watch but we didn't have an LCD to contend with.
We used a pre-programmed BS2-interpreter chip with just the bare essentials. i.e. just memory, and Xtal ... no brownout, serial interface, or regulator. Unit was powered with a 3V lithium battery.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
For the BS2-interpreter, how do you go about pre-programming it? (that's where it's obvious I'm really new to this business, apologies if my questions are really dumb).
Is it done by Parallax, or there is way for me to do it myself?
Cheers,
Pascal
The BS2-Interpreter is programmed by Parallax and can be found here. You say that you are new at this, but are you new to electronics? That particular BS2-Interpreter was in surface mount, but a 28-pin DIP version also exists.
When we were in the design phase we used the DIP version, and then found a local board house to fabricate and populate the boards for us with the surface mount components.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
To make a long story short, I think I may qualify as novice-intermediate in electronics. I'm a mechanical engineer and I had some basic training in electronics so I understand the basic concepts and components but I never had to apply it. So when I came up with the idea of this counter I bought the What's A Microcontroller? course from Parallax, went through the book (excellent by the way), then bought the components (RTC, EEPROM, Memory Stick Datalogger, LCD), wired everything on the development board and assembled the code that I posted. I'm still amazed that I managed to do it. I chose Parallax because I had found an article saying the Parallax development kit was the most user friendly and best for beginners and I am glad I went down that road, you guys have a really good product.
Now, I vaguely remember how to make PCB from a junior high course and I've found a freeware that looks pretty good (http://www.expresspcb.com/) but there is still (at least) one thing I don't understand: If I get just the BS2-Interpreter in DIP version along with an 2kb EEPROM and a voltage regulator which seems to the bare minimum I need, how will I transfer the code I wrote? Can I use the development board to transfer my code? I'm not even sure where it goes, i.e. in the 2kb EEPROM? or in the interpreter itself? Right now, I'm bit lost and I'm not sure how to proceed.
Cheers,
Pascal
Please refer to this schematic:
www.parallax.com/Portals/0/Downloads/docs/prod/schem/BS2revJSchematic.pdf
The schematic has the circuitry for the serial communication to the PC built in to the BS2-Module
and requires a 4-pin (SOUT,SIN,ATN,VSS) programming connector. Optionally you can move the serial communication circuitry into the program connector itself. This would require a 5-pin connector(TX,RX,RST,VSS,VDD) to make the proper connections.
All components can be purchased individually through Parallax.
ExpressPCB is fine for PCB's but I don't think that they will populate the boards for you. Depending on how many units you want to have made this may or may not be a viable option.
Your program is loaded into the EEPROM and is programmed through the serial connector to the PC in combination with the BS2-interpreter chip.
First, I would do all of your debugging and make sure that everything works with the BS2 module. You may find that the BS2 module's size is just right for your application. In my data logger, we needed something about 1 square inch, so a re-work was necessary in order to get things to fit.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Space is not that crucial at this point so I think I'll stick with the BS2 module for the next version.
And thanks for the tip about debugging every first with the module and ExpressPCB.
One last question and I will leave you alone:
Cost-wise, a BS2 module is about $50 while a BS2-chip is $12, and the EEPROM, Resonator, Brown-Out Detector, & Voltage Regulator about $1 each.
Am I correct that down the road if I assemble the microcontroller part of the device using the individual components instead of using a pre-assembled BC2 module, I could expect the cost to about $15 instead of $50? Or am I missing something here?
Cheers,
Pascal
That is correct and what is intended for commercial or at least production of an application. The BASIC Stamp Module itself is really a development tool. Production applications should utilize the components on the target board to reduce cost. In my applications before coming to Parallax I was able to keep the cost of the controller below $15.00 by integrating the Interpreter, Resonator and EEPROM onto my main board which also meant no additional regulator was required. Further cost savings were realized by using the USB2SER development tool for programming the boards. This meant not having to include RS-232 circuitry. Schematics for this are available in the Completed Projects Forum under the sticky thread. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Cheers, Pascal.