Cross cog variable communication problem
c2tb34
Posts: 8
Hello.
I'm working on a project that involves servos being controlled by potentiometer RCtime circuits.
As a simple preliminary test, I am trying to control a servo with the Serial Terminal. I have
attached the two spin files that I am working with.
In the code, I am starting the terminalController object in a new cog while passing it the address
of the servoControl object's position variable, tHa. tHa is the high time for the PWM pulse, and ideally
the user should be able to input a new position value through the terminal which is then stored
in long[noparse][[/noparse]address of the position variable]. However, when I execute the code, the servo initially
holds at its neutral value, but as soon as I input a new value through the Serial Terminal, I receive
an odd mix of ASCII characters in the Serial Terminal, and the servo is no longer holding a position.
Any help would be very much appreciated [noparse]:)[/noparse]
I'm working on a project that involves servos being controlled by potentiometer RCtime circuits.
As a simple preliminary test, I am trying to control a servo with the Serial Terminal. I have
attached the two spin files that I am working with.
In the code, I am starting the terminalController object in a new cog while passing it the address
of the servoControl object's position variable, tHa. tHa is the high time for the PWM pulse, and ideally
the user should be able to input a new position value through the terminal which is then stored
in long[noparse][[/noparse]address of the position variable]. However, when I execute the code, the servo initially
holds at its neutral value, but as soon as I input a new value through the Serial Terminal, I receive
an odd mix of ASCII characters in the Serial Terminal, and the servo is no longer holding a position.
Any help would be very much appreciated [noparse]:)[/noparse]
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
high time value for the servo, so the servo should still hold a position after
that value is updated. I'm not sure why the servo quits holding a position
after Debug.getDec is called.
Thank you for the help [noparse]:)[/noparse]
It actually was not a coding error. It was a hardware issue.
Specifically, my poor Prop was browning out during execution.
I have been running it off of a 9 volt battery for as long as I have
had it, and I should have noticed that power LED flickering during
execution... le sigh. I popped in a new 9 volt, and voila! It worked.
Of course, I only tried a new battery after I drove myself near
crazy looking at my code.
I suppose the moral of the story is check your assumptions first.
Thanks for the help everyone!