Variable overwriting another variable
Mcadieux
Posts: 5
I'm new to spin so hopefully this isn't something really stupid I am doing wrong. The problem I am having is when I write to one of my variables it is actually overwriting a different variable.
This is my variable definition block:
This is where the temp variable is used:
The problem is instead of the number being assigned to temp it is sent to DOT. This has me stumped.
This is my variable definition block:
VAR long centerPos, servoPos, Dot long temporary, newPos, degMax, degMin byte Cog
This is where the temp variable is used:
PUB setDeg(servo, deg) temporary := (controller.getHighLimit(servo) - controller.getLowLimit(servo)) / DOT[noparse][[/noparse]servo] newPos := (deg * temporary) + centerPos[noparse][[/noparse]servo] servoPos[noparse][[/noparse]servo] := newPos controller.Set(servo, servoPos[noparse][[/noparse]servo])
The problem is instead of the number being assigned to temp it is sent to DOT. This has me stumped.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."
- Bjarne Stroustrup
My guess is your server argument is set to *1*, not *0*.
Always, for cases like this, please attach full code.
VAR
long centerPos[noparse][[/noparse]10], servoPos[noparse][[/noparse]10], Dot[noparse][[/noparse]10]
long temporary, newPos, degMax, degMin
byte Cog 'Holds the cog that the controller was launched into
That may not be what is going on, but I think we need to see more code to know for sure.
Post Edited (Mcadieux) : 2/24/2009 5:48:11 AM GMT
If you want help, you have to post your entire program, not just output.spin. The problem might lie in the code that calls the methods in output.spin.
The MyServo32v3 object is just your standard Servo32v3 object. I deleted cheapfix temporary and made temp back to a local variable and it seems to work fine now. I may have just been doing something stupid last night. Thanks for trying to help, sorry I was brain dead about posting code last night.
Glad you figured it out.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."
- Bjarne Stroustrup