Attempting to write thermocouple data to SDCard every ?4hrs
msiriwardena
Posts: 301
I am trying to write Data from 3 thermocouples to the SDCard every 3 to 4 hrs every day.
RTC 1307 is also incorporated inti this project to keep real time.
I got all of them to work also to write Data to the SDCard.At present it wites the Data every 2-3 seconds no matter
how I change the Repeat loop in the SDCard.
I have tried to place IF conditions ex. IF Hour== 16 or Hour ==19 and minute ==0 and secs ==0 etc.
I also tried embedded loop and "quit" still I cannot get it right.
I appreciate some Help.
P.S : archive project is attached
Thanks,
Siri.
RTC 1307 is also incorporated inti this project to keep real time.
I got all of them to work also to write Data to the SDCard.At present it wites the Data every 2-3 seconds no matter
how I change the Repeat loop in the SDCard.
I have tried to place IF conditions ex. IF Hour== 16 or Hour ==19 and minute ==0 and secs ==0 etc.
I also tried embedded loop and "quit" still I cannot get it right.
I appreciate some Help.
P.S : archive project is attached
Thanks,
Siri.
Comments
You seem to be depending on Hours, Minutes, and Seconds.... With 32bit integers, you could just have a loop read a wait count of 4 hours entirely in seconds.
You could use the RTC to set the time and date only at power up, and have that converted to UnixTime seconds for running the loop. That would eliminate the need to frequently read the RTC. It may be that your loop to read the RTC is writing every read to your SDcard.
http://en.wikipedia.org/wiki/Unix_time
The only disadvantage is that all your time stamps will be in Unix Time (which is in seconds) unless you convert the time to hours, seconds, and minutes to write to the SDcard.
By using Unix Time, the code becomes a lot cleaner and it works extremely well with a 32bit system.
Now you can do a simple comparison
This would run the code in the if construct when the time was 12:30AM.
Thanks for the help.I have a RTC because I need the Temps logged every 12,6,18 & 24hrs - daily for about a year - to figure out the daily,monthly variations of the Temp in the water in 3 wells.
I tried your solution - it worked except -the temps were recoded for about i min. from the starting hour.- so I skipped the seconds and added a waitcnt hust over one minute
to the loop.I am yesting it right now.
Hope this will solve the issue.
Thanks again,
Siri
I have to ask?
Since you are taking only one measurements every 4 hours which results in less than 8K longs in a year you could save this in the EEPROM. This would alleviate the need for the SD-Card.
Also, using a DS18B20+ is much easier to do than a thermocouple. This only needs a pair of wires and outputs digitally and provides 1/2 degree C accuracy.
Duane J
hour0 takes on integer values from 0 to 5 thru the day and changes every 4 hours, and it is the changeover that triggers the SD logging.
@Duane - I looked at the DS18B20 - this not suitable for the project as the temps are read in well water that about 20 ft deep.
@ Tracy - I will give it try - for learning purpose.
Thanks to all
Siri
If you are using thermocouple you need to seal the measurement end so it doesn't come in contact with water. The dissimilar metals form a little electrochemical battery which can affect the reading. I take the small metal eraser protector on Pentel Mechanical Pencils and fill it with silicone rubber then push the thermocouple into it.
Plastic pen caps would also work well for you as the temperatures are low.
The DS18B20+'s TO-92 package also fits into the Pentel eraser cap to.
BTW, does your thermocouple circuit have "Cold Junction Compensation"? You can't get long term accuracy without it. The solid state sensors don't need it.
Duane J
@ Siri, for the record, here's yet another way to do the timing... It only drops through to the SD card code when hour1 transitions from 5 to 0.
It can be simplified even further if the interval is 1,2, 3 or 6 hours... It does not need Bcd2int conversion, due to the curious mathematical fact that an integer mod those values is the same whether the hour is represented as a straight integer or as BCD.
Siri
Take a look at the reference design for the MAX31855PMB1.
Duane J