|
Forum Index : Microcontroller and PC projects : HUMID command
| Author | Message | ||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2006 |
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. "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: AustraliaPosts: 81 |
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: AustraliaPosts: 1329 |
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 :) |
||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2006 |
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: AustraliaPosts: 2006 |
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: AustraliaPosts: 1667 |
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. |
||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2006 |
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: AustraliaPosts: 81 |
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. |
||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2006 |
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: AustraliaPosts: 81 |
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 ZealandPosts: 2461 |
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 :-) |
||||
| busa Regular Member Joined: 12/02/2015 Location: AustraliaPosts: 81 |
DIM FLOAT temp, humidity ' ' ' do HUMID 95, temp, humidity 'sensor attached to pin 95 pause 5000 loop This is what works for me |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
I don't understand this... The fact that it is now a CSub was the first entry in the change log. It is there!!! There is a whole paragraph (on page 26). It even tells you where to find the CSub. 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 ZealandPosts: 2461 |
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 :-) |
||||
| WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2959 |
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: AustraliaPosts: 2006 |
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: AustraliaPosts: 3308 |
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 ZealandPosts: 2461 |
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 :-) |
||||
| robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2461 |
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 :-) |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |