Accurate ticks generation


Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    May 2010
    Location
    Goldsboro, NC
    Posts
    4

    Default Accurate ticks generation

    Hello everyone
    I am new to picbasic pro and and have a question about the following code.
    I am using this code to drive a stepper motor in a clock. I'm trying to pulse it 26.67 times a second which will pulse the stepper 1600 a min.
    if I use 38 in the pause routine I end up with 26.204 and the clock runs slow and 39 gives me 26.915 and the clock is fast.

    I sure there is a simple way to get the 26.67 but I'm not sure of how to do it.
    Any suggestions would be greatly appreciated.

    output portb.1
    output portb.0
    input portb.2
    output portb.7
    output portb.6

    high 1 'set direction
    high 6 'microstep
    high 7 '" "

    mainloop:
    High 0 'pulse train on pin 0 26.204 cycles a second
    Pause 19
    Low 0
    Pause 19

    if portb.2 = 0 then ' check button
    goto sub1 ' if down go to sub1
    endif



    Goto mainloop


    sub1: low 6 'full step
    low 7 '" "
    High 0 'pulse train on pin 0 to speed up motor to set
    pause 1 'time
    low 0
    pause 1

    if portb.2 = 0 then ' check if button is still down
    goto sub1 ' if not go to mainloop
    endif

    pause 1000
    goto mainloop

    end
    Last edited by Acetronics2; - 23rd May 2010 at 10:47. Reason: Gave a more expressive title to thread

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts