Voltage Measurement
plau45
Posts: 109
I know how to measure voltage and I also than changed it into the -100 to 100 range, but I need to figure out how to alter the equation ud = 200*(udV-2.5)/5 so that it would scale from 0 to 1800. I went ahead and multiplied the whole thing and got a scaling from -1800 to 1800 but can't seem to center at 900. I have gotten it to 900 but when I moved my joystick it only changes the measurement by at most 2 numbers. When I use the scale from -1800 to 1800 I get it so I start at 0 and can go all the way to either 1800 or -1800 with the joystick. I need to figure this out so that I can move my servo both ways just not one. I may figure it out before you guys get back to me. Thanks.
Comments
Also if you post your code by placing it between code tags [noparse] [/noparse] it will show up correctly in the forum.
If "ud = 200*(udV - 2.5) / 5" is used for a range of -100 to 100 then you'd use "ud = 360 * udV" to scale it to 0 to 1800.
Is that what you need?
I hope I didn't misinterpret your question.
Actually I should have asked, what is the voltage range you get from the joysticks? Is it 0 to 5v?
Also be sure you have fully charged batteries. I almost went crazy a couple of times (at least twice a year) when I try to debug servo programs where the servo only moves a small amount and stops. It is usually because my batteries run low and the program works well without power to the servos, but when the servo is hooked up, the current draw, is too much and the prop resets. Using new batteries debugs it fine.
Tom
Am I missing some subtlety of C?
How is "ud = 1800 * udV / 5" different than "ud = 360 * udV"?
Don't the two equations give the same output?
It seems like one would be better off combining the multiplication and division terms together to make the calculations in the Propeller faster.
Duane,
Your'e right. I was just showing it as a proportion. When I actually use it in C I would use one constant that was equal to calculated value of the other constants as you have done (unless it wasn't time critical and I was illustrating generally how to do something).
Tom