Stepping motor coding on microchip

  • Thread starter Thread starter readytolearn
  • Start date Start date
  • Tags Tags
    Coding Motor
AI Thread Summary
The discussion focuses on coding a PIC18C452 microchip to control a stepper motor with specific parameters, including four steps per rotation and a pulse rate of one per 15 seconds. The user seeks guidance on completing their code, which includes initializing the TMR0 module and updating the step sequence in the interrupt service routine. There is a suggestion to practice basic exercises like blinking an LED or simulating a stoplight to build foundational skills in microcontroller programming. The importance of understanding the code rather than just copying it is emphasized, along with a recommendation to consider using Arduino for prototyping. Overall, the conversation highlights the need for practical experience in coding and microcontroller applications.
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)
 
Posted June 2024 - 15 years after starting this class. I have learned a whole lot. To get to the short course on making your stock car, late model, hobby stock E-mod handle, look at the index below. Read all posts on Roll Center, Jacking effect and Why does car drive straight to the wall when I gas it? Also read You really have two race cars. This will cover 90% of problems you have. Simply put, the car pushes going in and is loose coming out. You do not have enuff downforce on the right...
I'm trying to decide what size and type of galvanized steel I need for 2 cantilever extensions. The cantilever is 5 ft. The space between the two cantilever arms is a 17 ft Gap the center 7 ft of the 17 ft Gap we'll need to Bear approximately 17,000 lb spread evenly from the front of the cantilever to the back of the cantilever over 5 ft. I will put support beams across these cantilever arms to support the load evenly
Thread 'What's the most likely cause for this carbon seal crack?'
We have a molded carbon graphite seal that is used in an inline axial piston, variable displacement hydraulic pump. One of our customers reported that, when using the “A” parts in the past, they only needed to replace them due to normal wear. However, after switching to our parts, the replacement cycle seems to be much shorter due to “broken” or “cracked” failures. This issue was identified after hydraulic fluid leakage was observed. According to their records, the same problem has occurred...

Similar threads

Replies
3
Views
2K
Replies
2
Views
2K
Replies
2
Views
7K
Replies
2
Views
2K
Back
Top