Stepping motor coding on microchip

  • Thread starter Thread starter readytolearn
  • Start date Start date
  • Tags Tags
    Coding Motor
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
readytolearn
Messages
7
Reaction score
0
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.
 
Physics news on Phys.org
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)