Shop OBEX P1 Docs P2 Docs Learn Events
Delay in program execution — Parallax Forums

Delay in program execution

J LudwigJ Ludwig Posts: 19
edited 2010-08-18 22:24 in Propeller 1
I am using a single accelerometer axis from a Sparkfun 5DOF module connected to an MCP3208 A/D using the code from the Propeller software v1.2.6. There is an RC servo connected to the prop using the ASM code from the DAT section of Single_Servo_Assembly by Gavin Garner. The goal is to have the arm on the servo stay level when the 5DOF is tilted. It works but there is around a 55 second delay from the time I load it until it starts working. (In another version I have a Parallax 2-line serial LCD attached to monitor values. The delay is the same but then after several operations, the LCD backlight shuts off and the text on the screen disappears - but the servo continues to work.) I suspect it is a stack issue but haven't found a solution. Any thoughts on what causes the delay?
Thanks, Jim

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2010-08-18 21:13
    J Ludwig wrote: »
    Any thoughts on what causes the delay?

    Your assembler code is running before you setup your position variable (it defaults to 0 as a global). Therefore the initial waitcnt target calculation results in a cycle count which you just missed, i.e. you have to wait for the counter to wrap once (53.6sec @80MHz).

    Quick fix, setup position with some safe default value (=> 13) before starting the PASM cog.
  • J LudwigJ Ludwig Posts: 19
    edited 2010-08-18 22:24
    kuroneko, thank you very much. I set position := 130_000 (servo center value) before I started the assembly program and that solved the delay issue. Corrected code attached.
    Jim
Sign In or Register to comment.