Shop OBEX P1 Docs P2 Docs Learn Events
“servo control with a pot” question — Parallax Forums

“servo control with a pot” question

GrampsGramps Posts: 117
edited 2010-04-21 23:52 in Learn with BlocklyProp
I’m working on “servo control with a pot” on page 158 WAM. The demo moves the servo about 45 degrees when the pot is moved 90 degrees. How do you match them so they both move together from 0 to 90?

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-04-20 23:33
    time VAR Word
    
    DO
      HIGH 7
      PAUSE 10
      RCTIME 7, 1, time
    
    [color=green]  time = time */ 185 ' Scale by 0.724 (X 256 for */).
      time = time + 500 ' Offset by 500.[/color]
    
      PULSOUT 14, time ' Send pulse to servo.
    LOOP
    

    Given: PULSOUT 14, time··
    time is the position
    ··time·is the result of·the RCTIME operation

    Try different values in the two math operations (scaling and offset determinations)
  • GrampsGramps Posts: 117
    edited 2010-04-21 03:34
    Thank you!
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-04-21 18:13
    Add a line with a·DEBUG to kick out the RCTIME value, so that you can see what's going on there, too.
  • GrampsGramps Posts: 117
    edited 2010-04-21 23:52
    Ok, thanks again, I was on the right track but didn't see results till I pushed the 185 number way up to 550.
    Now if i could just understand what's happening[noparse]:)[/noparse]
    It will sink in one day.............
Sign In or Register to comment.