![]() |
Forum Index : Microcontroller and PC projects : Roll your own data logger - CMM2
Author | Message | ||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
Good morning / evening -- depending on which side of the water you are on. Firstly, I am in love with CMM2. There, I said it. Secondly, as a teacher adviser in Wales, the CMM2 is ideally placed to play a big role in our new curriculum -- so I blogged about it: https://stem.wales/roll-your-own-data-logger-with-maximite-2.html Finally, for that blog, I built and coded a simple data logger in less than 1 hour. The code is below. MMBasic gurus -- any tweaks? What I'd really like is a "speedo" type dial, but am unsure where to start..... ' Basic light meter functionality - not calibrated CLS open "light.txt" for output as #1 ' Defaults to opening from SD Card close #1 ' Open / Close to make sure the file exists - quick and dirty SETPIN 7,AIN 'Uses pin number 7 for Analogue Input (AIN) Do open "light.txt" for append as #1 light = Pin(7) ' reads pin 7 box 0,0,400,20,2,,rgb(black) ' draws a light meter scale box 0,0,light*100,20,2,,rgb(red) ' displays the current value teXT 450,5, format$(light*1000,"%0.0f"), "R" 'prints the current value print #1,TIME$, format$(light*1000,"%0.0f") 'outputs to file the time and light value text_log$="Logged at " + Time$ ' on screen output text 550,5, text_log$ close #1 ' as we pause for 1 min, close file in case of crash pause 60000 ' Wait 1 minute or 60000 miliseconds Loop while INKEY$<>chr$(27) ' Exit if ESC is pressed cls ' keeps screen tidy on exit Entropy is not what it used to be |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Hi and welcome. (I have a sister in Wales. She was planning to come and visit in April but Covid put a stop to those plans!) I would use a SETTICK interrupt instead of the PAUSE 60000 That allows you to do all sorts of other things while you wait. Draw a chart of the light over time perhaps. ' Basic light meter functionality - not calibrated CLS OPEN "light.txt" FOR output AS #1 ' Defaults to opening from SD Card CLOSE #1 ' Open / Close to make sure the file exists - quick and dirty SETPIN 7,AIN 'Uses pin number 7 for Analogue Input (AIN) SETTICK 60000, myLight ' run myLight sub every 60 seconds DO ' do other things while you wait LOOP WHILE INKEY$<>CHR$(27) ' Exit if ESC is pressed CLS ' keeps screen tidy on exit END SUB myLight OPEN "light.txt" FOR append AS #1 light = PIN(7) ' reads pin 7 BOX 0,0,400,20,2,,RGB(BLACK) ' draws a light meter scale BOX 0,0,light*100,20,2,,RGB(RED) ' displays the current value TEXT 450,5, format$(light*1000,"%0.0f"), "R" 'prints the current value PRINT #1,TIME$, format$(light*1000,"%0.0f") 'outputs to file the time and light value text_log$="Logged at " + TIME$ ' on screen output TEXT 550,5, text_log$ CLOSE #1 ' as we pause for 1 min, close file in case of crash END SUB Jim VK7JH MMedit |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
Love it! typo on the web page - just under the heading "The potential of creating your own logger", there's a left paren matched with a right bracket (aka square bracket). John |
||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
![]() Cheers - good eyes -- fixed. Nim Entropy is not what it used to be |
||||
Sasquatch![]() Guru ![]() Joined: 08/05/2020 Location: United StatesPosts: 377 |
Check out the latest version of "Lunar Lander" in this thread: https://www.thebackshed.com/forum/ViewTopic.php?TID=12303&PID=152030#152030#152030 Andrew has done some very nice circular "speedo" type gauges. -Carl |
||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
![]() I'm in the Cardiff area -- very urban - not the pretty part unfortunatley. Love the SETTICK feedback -- one to investigate for version II. Cheers Nim Entropy is not what it used to be |
||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
Perfect - code "borrowed"..... Nim Entropy is not what it used to be |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
back in 1984, I did two modules for a teacher friend. They used something called a "VELA"(?) He wanted an adaptor to shine a tungsten bulb through an inserted test tube them measure the light from it in RGB. It was a cow trimming to get even near a flat response. Got hold of some very good filters but we were fighting the emissions of the tungsten - strong in the red and tails of to hardly anything in the blue. Then the response of the ORP12s... But it was good enough in the end. |
||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
VELA / Data Harvest are the "big boys" in education data loggers -- expensive and slick and Iirc you are wedded to their sensors. FWIW: https://www.retro-kit.co.uk/VELA/ Another "roll your own" project is to make a colorimiter -- white LED emitter shining through a small cuvette and an LDR sensor --> to measure how much light passes through. Basic high school stuff but the colorimiters cost £200+ and are black box again. I think I'll 3D print some kit and this will be my next project. Nim Entropy is not what it used to be |
||||
Andrew_G Guru ![]() Joined: 18/10/2016 Location: AustraliaPosts: 871 |
Hi Nim, Welcome. I'm sure you will get a lot of support from Shedders for helping your young people to learn and explore. The "gauges" in Lunar Lander are intentionally pretty basic (no pun). Here are is a much better one. In that thread I raised a couple of issues with the ARC statement. One is that you can't apply an aspect ratio (like you can in CIRCLE). I have experimented with Panky's code above and you can multiply his SIN components by your aspect ratio and get a circle on your monitor. I abandoned it because in LL the non-circle looks better and it was getting more complex than I wanted. If you read the manual for "MM+" ie Micromite Plus there are several standard gauges that are not (yet) part of the CMM2. Keep up the good work, Andrew {Edit: I'd meant to say how much I love Wales - I spent 3 years in Manchester in the mid-seventies and Wales was a day trip for us Aussies} Edited 2020-08-12 08:57 by Andrew_G |
||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
Andrew - good morning (for me). Wales is beautiful -- sadly I live in the urban areas near Cardiff. That said, the beautiful parts are a 30minute drive away. A "day trip" for me is "Barrybados" (Google it ![]() Manchester / Liverpool - which technically a day trip would be seen as a "big drive" for us!! Thanks for the heads up -- will check your post and the MM+ manual. Have just coded up gauges using the Lander example -- quite easy in retrospect -- and certainly easy enough for beginners to understand (will be teaching to 10-14 yr olds). Cheers Nim Entropy is not what it used to be |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |