Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:20 24 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : using HC-12

     Page 3 of 3    
Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 06:38am 30 Dec 2018
Copy link to clipboard 
Print this post

Yes always the same length, a 3 figure number
RM$ = Str$(RainM,3)


edit..Also from the manual
  Quote   Using VAR RESTORE without a previous save will have no effect and
will not generate an error

but it does as I showed above.
Edited by palcal 2018-12-31
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9516
Posted: 07:09am 30 Dec 2018
Copy link to clipboard 
Print this post

On The VAR RESTORE issue, I have no idea at this point. I will download and try your code out in the next few days, to see if I also get the same error.

On the RTC code, you could take your three-byte string, and dump it to the memory a-byte-at-a-time method:


SUB SAVETORTC(DTA$)
Local X 'A local X variable, perhaps totally seperate from a global X
For X=1 to 3 'Step through the three-byte date data, and save it to the RTC RAM
RTC SETREG 50+X,ASC(MID$(DTA$(X,1)) 'Put data into RTC register
Next
END SUB


This should take your three byte string, and put each of the bytes into the RTC RAM starting at address 51 decimal. Change the "50+X" part of the for loop, to suit the start address in decimal, where you want to store the data in the RTC RAM.

Untested, but it should work.

Reading back would just be:


FUNCTION READRTC(DTA$)
Local D$,X,BYTE
For X=1 to 3
RTC GETREG 50+X,BYTE
DTA$=DTA$+CHR$(BYTE)
Next
END FUNCTION


You would ask for the data with the command READRTC (DTA$)
DTA$ should then return with the value of the three bytes in DTA$ as previously saved.

I have not tested any of this yet, I am just writing code as I see it in my head. It should work OK though. Others will no doubt point out how drunk I am, if I have got it totally wrong!
Smoke makes things work. When the smoke gets out, it stops!
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 07:17am 30 Dec 2018
Copy link to clipboard 
Print this post

Thank Grogs, you don't need my code to test the VAR RESTORE I got out some other MMs and wrote a snippet of code and they all give the error. I was looking for an older MM.VER but don't have one.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9516
Posted: 07:23am 30 Dec 2018
Copy link to clipboard 
Print this post

I have older MMBASIC's if you want one. PM me.
Smoke makes things work. When the smoke gets out, it stops!
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1636
Posted: 07:44am 30 Dec 2018
Copy link to clipboard 
Print this post

Sorry, I forgot to say that I did un-comment the VAR SAV and VAR RESTORE and that was supposed to be the point of my post (sigh). Yes I didn't expect any temperature or proper time with those lines commented out.

Bill
Keep safe. Live long and prosper.
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 07:57am 30 Dec 2018
Copy link to clipboard 
Print this post

Bill, then you had no problem with VAR RESTORE, what MM.VER are you running.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1636
Posted: 08:19am 30 Dec 2018
Copy link to clipboard 
Print this post

Version 5.05.1. I could try the latest version but the chip I used is on a bread board covered with a bird's nest of jumpers.

Bill
Keep safe. Live long and prosper.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10090
Posted: 08:28am 30 Dec 2018
Copy link to clipboard 
Print this post

Var save/restore seems to work fine as long as strings are dimensioned before the restore command as required in the manual. Tested on the latest release on MM2.


Dim a$
VAR restore
Print a$
a$="Hello at "+Time$
VAR save a$
end
Edited by matherp 2018-12-31
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 08:41am 30 Dec 2018
Copy link to clipboard 
Print this post

I'm using 5.04.01 will re flash the chip tomorrow.

Edit....OK I couldn't wait, re flashed with 5.05.01 and no problems.
VER 5.04.01 must have had a bug.
@Grogster
I compared the humidity reading with a wet and dry thermometer, the DHT22 was continually reading about 94%Edited by palcal 2019-01-01
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 03:03am 09 Jan 2019
Copy link to clipboard 
Print this post

  palcal said  Does anyone have a source for genuine DHT22 I have bought many and they either fail or are not accurate. The temperature seems OK but the one I am using now the humidity reads about 20% high.


I just bought another 2, one is 3% high (I can live with that) but the other one is 10% high. I don't know how many of these I have used, but never been happy, I've thrown most of them out. The two HTU21D's I am using are just about spot on, but the DHT22's are so easy to use. I am using a Wet & Dry thermometer for comparison.
@ TassieJim
I know you have used them and seem to be happy, where did you get them from?
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2409
Posted: 04:16am 09 Jan 2019
Copy link to clipboard 
Print this post

would it be practical to build your own wet/dry bulb sensor system?

see:
https://meathaccp.wisc.edu/assets/Wet_Bulb.pdf
and
http://naitc-api.usu.edu/media/uploads/2017/01/10/Eggology_wetbulbthermometer_relativehumidity_1.pdf

i'm thinking of a sealed DS18B20 sensor for the wet side:
https://www.ebay.com/itm/323375966391
use a large cotton shoelace as the wick, and construct some sort of water reservoir system (perhaps with a small electric pump controlled by the micromite).

is there a simple formula for converting wet and dry temperatures to RH? my sole knowledge of the subject is someone at work 10+ years ago getting me to help him hook up a couple of DS18B20 sensors to serial ports on his desktop PC and seeing one of the sensors sitting near a bowl of water. as i recall, he was happy with the results he got.


cheers,
rob :-)
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 04:52am 09 Jan 2019
Copy link to clipboard 
Print this post

The only way I have ever done it is with a Pschrometric Chart. The wet dry bulb would have been available before Hygrometers so I guess some one worked it out.
But that way of doing it is a bit messy. I will use the HTU21d's but since they won't work with MY Nucleo L4 I thought I could use a DHT22 with it.
I scrapped the L4 for my project and am using an E-28.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 375
Posted: 01:56pm 11 Jan 2019
Copy link to clipboard 
Print this post

I did build a RH meter some years ago for my sauna. It was based on wet and dry temperature measurements using MCP9801 temperature sensors and a PIC16F887. Cotton wick from a water reservoar for the wet temperature. The sensors encapsulated in epoxy.
Temperatures and RH are displayed on 7-seg LED displays.
The equations used for calculating RH were obtained from an article by Linear Technology:
https://www.analog.com/media/en/technical-documentation/lt-journal-article/LTJournal-V21N4-07-di-LTC2991-LeoChen.pdf.

I did not measure the atmospheric pressure; just kept it constant at "normal" pressure. (For sauna RH I did not need the 7th decimal!)

The biggest problem was to calculate EXP(x). Remember that I spent a lot of time with that.


I installed the whole unit with PIC and display inside the sauna. Thought that it would be interesting to see how long it would survive. According to my documents it was installed in 2012. Still going strong without any problems. (Normally I do not heat to much higher than 80 degC.)

Initially I used only distilled water for the wet temperature probe, but after I run out of stock 2-3 years ago, I use normal tap water. No idea how that effects the accuracy...but still OK for sauna RH.

Hope that Palcal can have use for the equations in the article.
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 08:43pm 11 Jan 2019
Copy link to clipboard 
Print this post

  Pluto said  (Normally I do not heat to much higher than 80 degC.)

YIKES!!!! 176° F!!!!!

The US Department of Agriculture has custody of samples of the Smallpox virus in a laboratory on Plum Island which is just east of Orient Point Long Island. They store it in a residential horizontal chest type freezer at -5°F (-20°C). They have an automatic backup generator. They also have a propane gas fired oven set to 138°F (59°C) right next to the freezer.

If they ever have a power failure and a generator failure and run out of dry ice they have a procedure to move the virus samples to the oven. They have determined that no virus and very few bacteria can exist for more than 30 minutes at 138°.

Do you really hang out in that sauna at 176°F??????? YIKES!!!!

Paul in NY
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4006
Posted: 09:43pm 11 Jan 2019
Copy link to clipboard 
Print this post

Fortunately extremophiles seem not to be harmful to humans (but can cope with scary temperatures).

John
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 375
Posted: 01:26pm 12 Jan 2019
Copy link to clipboard 
Print this post

80 degC is a quite modest sauna temperature. The real sauna men prefer 100-120 degC.
Lower temp and higher humidity is more suitable for me. In order to get some contrast, we run from sauna into the backyard to roll in the snow.
What does not kill you will make you stronger!

Fred
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 09:50pm 12 Jan 2019
Copy link to clipboard 
Print this post

Hi Fred,

What does not kill you will make you stronger ... but what do you do if it does kill you?

60 years ago I dated a girl on my first visit to Sodonkyla, about 500 miles north of Helsinki. She tried to get me to do the run out of the sauna and roll in the snow trick. My heritage is from Kracow, 750 miles south of Helsinki. I was not prepared for that suggestion. I was reasonably sure that she had gone round the bend. I did not try it. I don't intend trying it now. I think there is a distinct possibility that all of you guys might have gone round the bend.

Shuddddeerrrrrr!!!

Pavel Artur Jan Waclaw Lepkowski in NY
 
     Page 3 of 3    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025