Shop OBEX P1 Docs P2 Docs Learn Events
Cross cog variable communication problem — Parallax Forums

Cross cog variable communication problem

c2tb34c2tb34 Posts: 8
edited 2010-03-28 08:39 in Propeller 1
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]

Comments

  • SRLMSRLM Posts: 5,045
    edited 2010-03-28 02:43
    You should test it by replacing the long[noparse][[/noparse]posAddress]:=... with a series of test values, and make sure that it works at that level. I suspect that part of the problem may be the order of operations. + is evaluated before *.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Powered by enthusiasm
  • c2tb34c2tb34 Posts: 8
    edited 2010-03-28 03:42
    I will test that as soon as I can. However, 30_000 is the lower bound of the
    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]
  • mparkmpark Posts: 1,305
    edited 2010-03-28 06:44
    Maybe you need a bigger stack?
  • c2tb34c2tb34 Posts: 8
    edited 2010-03-28 08:39
    Well, problem solved smile.gif

    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!
Sign In or Register to comment.