algebra calculations help
OutKastBob
Posts: 2
I am new to the propeller so if i ask/say something newbish just let me know...lol.
I am trying to get the propeller to measure the resistance of a potentiometer using the rctime.spin and that is working fine but it only gives me the delay in cycles which means for me that i need to convert it to resistance which is "ohms := ((tdecay * (1/clkfreq)) / (.693 * .000000011))", the .000000011 being the capacitance of my capacitor. i tried entering this in the code and when i ran it all i kept getting was a result of 0. when i manually run the calculation on a calculator it comes up to the right measured resistance using a DMM. I have ran out of ideas to get this calculation to work and i am gonna reluctantly admit that i need help
I am trying to get the propeller to measure the resistance of a potentiometer using the rctime.spin and that is working fine but it only gives me the delay in cycles which means for me that i need to convert it to resistance which is "ohms := ((tdecay * (1/clkfreq)) / (.693 * .000000011))", the .000000011 being the capacitance of my capacitor. i tried entering this in the code and when i ran it all i kept getting was a result of 0. when i manually run the calculation on a calculator it comes up to the right measured resistance using a DMM. I have ran out of ideas to get this calculation to work and i am gonna reluctantly admit that i need help
Comments
Yes, you're asking something newbish. And that's fine. The Prop only does integer math at runtime (while it's running). Look through the labs for something call pseudoreal numbers. 2/4 = 0 to the Prop so instead use 200/4 which equals 50 but have you program remember it's 100 time larger than the real answer. There are lots of tricks like this to get around the interger math problem.
Duane
This is of course an assumption on my part, because you have not posted any code for the forum to look at. If you will post the code, I'm sure you will get better and more detailed response's.
Cheers
ohms = tdecay * 1.639774367
Now take the number 1.639774367 times 65536 and round it to get 107464
Now use:
ohms := (tdecay * 107464) >> 16
I think that will work up to about 20K Ohms.
Bean