Shop OBEX P1 Docs P2 Docs Learn Events
Counter — Parallax Forums

Counter

argmafiaargmafia Posts: 30
edited 2006-03-03 19:13 in BASIC Stamp
Is there a way to integrate a real time/counter program to perform a function every necessary time needed??

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-03 18:54
    Can you give more details?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • argmafiaargmafia Posts: 30
    edited 2006-03-03 19:02
    we have a program and we are operating three stepper motors·independently.· Each stepper motor has to be turned ON at different times, for example stepper motor 1 turns every·8 hours, stepper motor 2 turns every 6 hours, and stepper 3 turns ever·4 hours.· The reason we are having a problem is because these times are variables inputted by the user using the keypad.· Our initial plan was to use the PAUSE command, but realized that it would affect the other two stepper motors.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-03 19:13
    Here's an idea that you may be able to apply: You do only one PAUSE,·at a small increment that can drive the others.·By·using the modulus operator·you can update each independently.

    Main:
    · DO
    ··· PAUSE 100
    ····motor1 = motor1·+ 1·// M1Count······ ' update motor "clock"
    ····IF (motor1 = 0) THEN················ ' update motor on roll-over
    ······' update motor 1
    ··· ENDIF
    ····motor2 = motor2 + 1 // M2Count
    ····IF (motor2 = 0) THEN
    ······' update motor·2
    ··· ENDIF
    ··· motor3 = motor3 + 1·// M3Count
    ····IF (motor3 = 0) THEN
    ······' update motor·3
    ··· ENDIF
    · LOOP

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.