Stepping motor coding on microchip

  • Thread starter Thread starter readytolearn
  • Start date Start date
  • Tags Tags
    Coding Motor
Click For Summary
SUMMARY

The discussion focuses on coding a PIC18C452 microchip to control a stepping motor with a specific sequence of steps and timing parameters. The user aims to achieve 4 steps per rotation with a pulse rate of 1 pulse per 15 seconds and a wait time of 15 seconds. Key code components include the initialization of the TMR0 module and the use of specific bit patterns for each step. The user seeks guidance on completing the code and emphasizes the importance of hands-on exercises over mere code copying.

PREREQUISITES
  • Understanding of PIC18C452 microcontroller architecture
  • Familiarity with assembly language programming for microcontrollers
  • Knowledge of timer interrupts, specifically TMR0 in PIC microcontrollers
  • Basic concepts of pulse width modulation (PWM) for LED control
NEXT STEPS
  • Study the Microchip AN822 application note for detailed guidance on motor control
  • Learn about TMR0 configuration and interrupt handling in PIC microcontrollers
  • Explore assembly language programming techniques for PIC microcontrollers
  • Experiment with Arduino for prototyping LED control using PWM
USEFUL FOR

This discussion is beneficial for embedded systems developers, hobbyists working with PIC microcontrollers, and anyone interested in motor control and LED applications using assembly language programming.

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.
 
Engineering 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)
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 2 ·
Replies
2
Views
3K