Math and variables
ghost13
Posts: 133
Hi,
I have the Basic Stamp 1. I'm trying to use exponents and powers. How do I do this?
Also, what's wrong with the following? I took it right out of the serial LCD manual.
And what's wrong with this line?
oddSign is created like this:
baseRead is created like this:
Do I have to do
And in addition, this line says it expects a variable:
Am I creating variables incorrectly? I just want a simple integer. This is how I tried to create my variable:
THANKS!!!
Post Edited (ghost13) : 5/26/2007 9:33:17 PM GMT
I have the Basic Stamp 1. I'm trying to use exponents and powers. How do I do this?
Also, what's wrong with the following? I took it right out of the serial LCD manual.
SEROUT 3, 84, [noparse][[/noparse]22, 12, 17]
And what's wrong with this line?
baseRead = oddSign
oddSign is created like this:
SYMBOL oddSign = BIT0
baseRead is created like this:
SYMBOL baseRead = W0
Do I have to do
LET baseRead = oddSign
And in addition, this line says it expects a variable:
IF (oddSign-baseRead)>=3235 THEN HIGH PIN7
Am I creating variables incorrectly? I just want a simple integer. This is how I tried to create my variable:
SYMBOL reading = W0
THANKS!!!
Post Edited (ghost13) : 5/26/2007 9:33:17 PM GMT
Comments
1) The 84 is the Baud value for a BS2 and sets 9600 Baud, no parity, true. The BS1 can't handle 9600 Baud. The highest speed is 2400.
At 2400 Baud, the statement would be: SEROUT 3,T2400,(22, 12, 17)
Note that parentheses are used with the BS1 SEROUT statement.
2/3) The LET is optional. Whether the statement is valid or not depends on the definition of baseRead and oddSign.
4) The "fancy" syntax with the statement following the THEN is only allowed for the BS2 and only if you've specified PBASIC 2.5
using the PBASIC directive. Use IF <condition> THEN <address>. For the BS1, <condition> is more restricted than for the BS2.
The PBASIC manual has the syntax in it as well as examples for the BS1 and BS2.
5) The BS1 has 6 - 16bit predefined variables (W0-W5) which can also be accessed as 12 - 8bit variables (B0-B11). The SYMBOL
statement allows aliases to be defined for these predefined names. In your case, you could use "SYMBOL baseRead = W0".
6) None of the Stamps really support powers and exponents although the BS2 models can do integer square roots and there have been
some routines written for the BS2 for natural logs and exponents (see: www.emesystems.com).
Post Edited (Mike Green) : 5/26/2007 9:46:49 PM GMT
First, how do I divide by something like 0.009? I'm trying to convert the ADC reading to pressure. Then, how do I use exponents/powers?
Thanks!
What about needing to use exponents?
What about needing to use exponents? I don't know ... They're not all they're cracked up to be.
Really, why do you think you need them? (You might, but I don't know what you're trying to do).
I looked at the website and I got dividing by 0.009 to work [noparse]:)[/noparse]
Now I just need exponents [noparse]:([/noparse]
Thanks!
The attached graph has altitude in feet from 0 to 10000 on the left y axis, and pressure in mb on the right y axis, both as functions of the millivolt output of an MXP4115 analog sensor. Even though it has an exponent, the exponent is small and the graph is not strongly curved.
So the message is, Excel is your friend to simplify the problem enough for the BS1, and if that is not possible, ageed, offload the task to the computer that can handle it easily.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Regardless, however, I'm out of memory :-(
Am I not programming well? Or is the BS1 just too limited. The code is attached.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Also the support for the chip is quite good.
Suman Sadhu
Thanks,
Mightor
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
| What the world needs is more geniuses with humility, there are so few of us left.