Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Stepping motor coding on microchip

  1. Feb 24, 2012 #1
    Hello,
    Trying to code a microchip PIC18C452.
    Desired:
    4 steps per rotations
    pulses per second=1/15
    t wait =15s

    #define #define #define #define
    clrf
    STEP_ONE b’00100000’ STEP_TWO b’00010000’ STEP_THREE b’00001000’ STEP_FOUR b’00000100’
    STEP_NUMBER
    ; PortB<5:2> are used to connect the ; switches
    ; Initialize start of step sequence
    ;*********************************************************************** Initialize here TMR0 module, enable TMR0 interrupt and load a value in TMR0
    ;***********************************************************************
    ;************************************************************************ ; Routine in TMR0 ISR which updates the current sequence for the next steps ;************************************************************************
    org UPDATE_STEP incf
    btfsc clrf movf call movwf return
    OUTPUT_STEP addwf
    retlw retlw retlw retlw
    2000h
    STEP_NUMBER,F STEP_NUMBER,2 STEP_NUMBER STEP_NUMBER,W OUTPUT_STEP PORTB
    PCL,F STEP_ONE STEP_TWO STEP_THREE STEP_FOUR
    ; Increment step number ; If Step number = 4h then clear the count
    ; Load the step number to Working register ; Load the sequence from the table ; to Port B
    ; Add Wreg content to PC and ; return the corresponding sequence in Wreg




    this is what microchip has on their website for name AN822

    If someone could please advise me on how to fill this in, it would be great.
    I have almost no experience but would really love to be able to do this.

    Thank you so much.
     
  2. jcsd
  3. Feb 24, 2012 #2
    you have to crawl before you walk.
    Can you use the pic to make an LED blink?
    simulate a 'stop light'?
    use pulse width modulation combined with a red, a green, and a blue LED to make a color box?
    these exercises may seem like a waste of time, but they're more useful than copy/paste- if all you do is copy/paste code, then you aren't really doing engineering!
    (also, consider using an arduino for prototyping purposes)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Stepping motor coding on microchip
  1. Optimization Code (Replies: 7)

  2. Asme code (Replies: 1)

  3. Motor for a project (Replies: 7)

Loading...