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.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 08:27am 13 Aug 2016
Copy link to clipboard
Print this post
I'm trying to measure Battery voltage
I'm using a voltage divider with PIN 24 measuring the voltage
IF I "PRINT "The Voltage is" PIN(24)" V" THIS WORKS FINE
BUT
I need to multiply the voltage by 2 to get the correct battery voltage
IF I do this
voltage = PIN(24)
voltage = PIN(24) * 2
Print voltage""
the program crashes totally
IF I try Print "Voltage";Str$(voltage,3,2); " V"
It still crashes totally
I've also tried
voltage1 = PIN(24)
voltage = voltage1 * 2
and
voltage1$ = PIN(24)
voltage$ = voltage1$ * 2
Nothing works
what am I doing wrong?
I know it's something really stupid and simple but I just cannot get my head round what it is
I did know this, but if I leave something for a couple of weeks I totally forget and I have to learn from scratch again, it's really annoying and frustrating to me, so it must be pi***ng some of you off me asking so many stupid questions that anyone with a memory that works would remember after learning it.Edited by lew247 2016-08-14
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 10:26am 13 Aug 2016
Copy link to clipboard
Print this post
Sorted it
For some reason this works
[code]SUB BATTERY
Batt2 = Pin(24)
Batt3 = Batt2 * 2
BATT = Batt3
END SUB
[/code]
And then PRINT BATT or PRINT "Battery Voltage";STR$(BATT,3,2);" V" both work
Out of curiousity (if anyone knows) BATT,3,2 what is the 3?
I know the 2 is the number of decimal points to print but not sure what the 3 is
MM_Wombat Senior Member Joined: 12/12/2011 Location: AustraliaPosts: 139
Posted: 11:52am 13 Aug 2016
Copy link to clipboard
Print this post
Page 75 of the Micromite manual.
The first number is the amount of characters before the decimal point, and the second number is, as you know, the number of decimal points.
The spaces have been changed to the "^" character as the forum removes the spaces when I post it.
MMWombatEdited by MM_Wombat 2016-08-14Keep plugging away, it is fun learning
But can be expensive (if you keep blowing things up).