Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:59 09 Nov 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 : HUMID command

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 08:14pm 27 May 2017
Copy link to clipboard 
Print this post

MM.ver 5.0401, PIC MX170I. I have used the HUMID command on previous occasions but have updated to 5.0401 and get the error 'Unknown Command'. Whilst it is still in the manual on page 26 "Measuring Humidity and Temperature" the command no longer appears in the list of commands.
Paul.Edited by palcal 2017-05-29
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
busa
Regular Member

Joined: 12/02/2015
Location: Australia
Posts: 81
Posted: 08:31pm 27 May 2017
Copy link to clipboard 
Print this post

Check out the embedded C modules PDF in the download package. The Humid command is now a Csub. Can be put directly into your program or saved in the library.
Busa
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 08:33pm 27 May 2017
Copy link to clipboard 
Print this post

Hi Paul,
The HUMID command has been removed and put into the "Embedded C Modules" folder, along with the IR SEND command and DISTANCE() function - it's noted in the Change Log for V5.04.01. Not sure why, but I guess Geoff needed the room for the other changes - you can still use them but will need to do the embedded module bit.

Greg
Edit: beaten by Busa :)

Edited by paceman 2017-05-29
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 09:23pm 27 May 2017
Copy link to clipboard 
Print this post

Thanks for that. Maybe it should be mentioned in the Manual on Pg. 26, anyone new to the 'Mite would never find it.
Paul.
"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: 2006
Posted: 09:52pm 27 May 2017
Copy link to clipboard 
Print this post

OK it didn't work.
I placed the Csub at the end of my code. Is the command still the same
ie: HUMID pin, tVar, hVar. also when I copy the Csub to my code do I change the
Csub HUMID integer, float, float to Csub HUMID pin, tVar,hVar.
Sorry for being dumb but I have never used Csubs before.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:36pm 27 May 2017
Copy link to clipboard 
Print this post

Hi Paul,

That's a good question.

I'm assuming the way Geoff's written the PDF that integer, float, float stay like that & the cSub treats them as passed variables 1, 2 & 3 regardless of the names in the definition.

Someone who knows a bit more about cSubs might know, but I'd just expect it's as written, paste it at the end & it will work.

But seems that's not the case..

Phil.

Edit:- Maybe it does need unique variable names.

Edited by Phil23 2017-05-29
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 10:43pm 27 May 2017
Copy link to clipboard 
Print this post

I tried it both ways and neither worked.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
busa
Regular Member

Joined: 12/02/2015
Location: Australia
Posts: 81
Posted: 11:23pm 27 May 2017
Copy link to clipboard 
Print this post

What I did was to copy and paste the Csub to MMEdit and then load it and it alone to the Explore 100. Make sure you dont have any other program loaded by giving the NEW command first and then I used the library save command to save it to the library. After that the Humid commands should work as you previously had them in your program.Edited by busa 2017-05-29
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 11:41pm 27 May 2017
Copy link to clipboard 
Print this post

OK I will try that but the manual says it can be included anywhere in your code.
I already have 3 fonts in the library so I hope it fits.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
busa
Regular Member

Joined: 12/02/2015
Location: Australia
Posts: 81
Posted: 12:08am 28 May 2017
Copy link to clipboard 
Print this post

Yes you can include it in your code but I found it more convenient to save it to the library. That way I don't have to worry about it again as the command will work as it did before in any program that I write in the future. If necessary it can always be deleted at a later time if space becomes a problem.
Hope you can get it working again...
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2461
Posted: 01:34am 28 May 2017
Copy link to clipboard 
Print this post

i believe you will find that only internal commands and user-defined basic subroutines can take a list of parameters without having them enclosed in brackets. since HUMID is no longer internal, it needs the brackets around the parameters. instead try:

do
HUMID(5, temperature, humidity)
PRINT temperature, humidity
loop

(assuming the DHT22 is attached to pin 5)


cheers,
rob :-)Edited by robert.rozee 2017-05-29
 
busa
Regular Member

Joined: 12/02/2015
Location: Australia
Posts: 81
Posted: 01:45am 28 May 2017
Copy link to clipboard 
Print this post



DIM FLOAT temp, humidity
'
'
'
do
HUMID 95, temp, humidity 'sensor attached to pin 95
pause 5000
loop






This is what works for me Edited by busa 2017-05-29
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 02:34am 28 May 2017
Copy link to clipboard 
Print this post

I don't understand this...

  palcal said  have updated to 5.0401 and get the error 'Unknown Command'.

The fact that it is now a CSub was the first entry in the change log.

  palcal said  Maybe it should be mentioned in the Manual on Pg. 26, anyone new to the 'Mite would never find it.

It is there!!! There is a whole paragraph (on page 26). It even tells you where to find the CSub.

  palcal said   OK it didn't work... do I change the Csub HUMID integer, float, float to Csub HUMID pin, tVar,hVar...

  robert.rozee said  since HUMID is no longer internal, it needs the brackets around the parameters.

Both the Hunmd.pdf and the manual (on page 26) have some example code which works fine and does NOT use brackets around the parameters.

Geoff
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2461
Posted: 02:57am 28 May 2017
Copy link to clipboard 
Print this post

right, i think i've found the problem.

forget what i wrote about requiring brackets around the parameters. the problem is that even if you do NOT have OPTION EXPLICIT in your code, a C-function requires that the parameters already have been declared. see the following using the IRSEND command (now also external):


IRSEND 5, A%\1, B%\1
IRSEND 5, C%, D%
End

CSub IRSEND integer, integer, integer
[...]


> run
[2] IRSEND 5, C%, D%
Error: Cannot find C
>


geoff: is this considered a bug? as an aside, the whole way variables are handled when OPTION EXPLICIT is NOT declared is now quite confusing - it would be really good if the '$' and '%' could be added back onto the names held in the variable table.


cheers,
rob :-)Edited by robert.rozee 2017-05-29
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2959
Posted: 05:04am 28 May 2017
Copy link to clipboard 
Print this post

  robert.rozee said   it would be really good if the '$' and '%' could be added back onto the names held in the variable table.


I think this is a great idea IMHO I think it would help avoid issues for several of us.

WW
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 11:10am 28 May 2017
Copy link to clipboard 
Print this post

Sorry I think I was looking in the old Manual. I think I have the code right but still no go. I remember when I bought these DHT22s about 5 years ago the first one didn't work and the next one failed early. One has been working since then but I think the one I am using now is a dud. I will have to get some more.
They were cheap ones from China.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 03:04pm 28 May 2017
Copy link to clipboard 
Print this post

  robert.rozee said  it would be really good if the '$' and '%' could be added back onto the names held in the variable table.

I'm not sure if this is a request for allowing duplicate variable names with different types. This is something that I really do not want to do - consider this code:

DIM tmp AS FLOAT, tmp AS INTEGER
tmp = tmp + 1

What version of tmp is the expression referring to?

Besides, using the same variable name with different types would be a terrible programming practice. You need an object orientated language such as C++ for that to be OK.

Geoff
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2461
Posted: 03:58pm 28 May 2017
Copy link to clipboard 
Print this post

nope, just to make it so that it is NOT possible to have references to a variable using a different name than that which declared or created it.

for example:
Const a$ = "123"
b! = 456
Print a, a$
Print b, b!

> RUN
123 123
456 456
>


the mechanism that disallows concurrent use of 'a', 'a$', 'a!' and 'a%' (a practice of which i don't have a strong opinion either way), has unintentionally created a situation where multiple names that in the syntax of basic are incompatible ('a', 'a$', 'a!' and 'a%') refer to the same variable.

by bringing back the '$', '%' or '!' (or none for a float) into the name when a variable is first created, this confusion is eliminated at a minimal performance cost to the interpreter.

i could also see a strong argument for removing option default from the language as part of requiring that the name goes back to explicitly dictating the type. again, this would remove confusion, while having no material impact on utility.


btw: the behaviour of custom functions not having their arguments automatically converted to the appropriate type (as i showed with IRSEND), is this considered a bug? the behaviour is certainly inconsistent with the rest of the language syntax.


cheers,
rob :-)Edited by robert.rozee 2017-05-30
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2461
Posted: 04:11pm 28 May 2017
Copy link to clipboard 
Print this post

this code also fails, where it (strictly speaking) should not:

Option default integer
c=111
Option default string
d="222"
Print c, d

> RUN
[5] Print c, d
Error: C already declared
>


cheers,
rob :-)
 
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