Stepper Motor controller with HC11Stepper Motor controller with HC11 - 2
Description: PID-Control with 68HC11. STEPPER CONTROL. 68HC11 read encoder. High accuracy RPM-measurement with 68HC11. The encoder is connected to PORTA PA0 and PA1. The board must be in BOOTSTRAP MODE (tested with Loggyboard).
The circuit utilizes a 68HC11 microcontroller for implementing a PID control system, specifically designed for stepper motor control and encoder interfacing. The 68HC11 is programmed to read input from an encoder connected to PORTA pins PA0 and PA1, which allows for high-precision RPM measurements. The system is configured to operate in bootstrap mode, which facilitates the loading of the program into the microcontroller from an external source, such as a Loggyboard.
The provided assembly code snippet outlines the initialization and operational routines of the microcontroller. Key components of the circuit include:
1. **Memory Mapping**: The encoder interface and necessary registers are mapped to specific memory addresses. For instance, PORTA is assigned to $1000, PORTD to $1008, and various control registers such as SPCR, BAUD, and SCSR are mapped to subsequent addresses.
2. **Initialization**: The stack pointer is initialized, and the RS232 interface is set up for serial communication. The encoder count is initialized to zero, and an error flag is cleared to ensure a clean start.
3. **Main Loop**: The main loop of the program consists of a real-time interrupt routine that executes every 0.5 milliseconds. During each iteration, the encoder is read, and the current state of the encoder is compared with the last recorded state to determine the direction of rotation (increment or decrement).
4. **Encoder Handling**: The encoder reading routine isolates the relevant bits from PORTA to determine the state of the encoder. If the current state differs from the last recorded state, the encoder count is adjusted accordingly. This adjustment is crucial for accurately tracking the motor's position and speed.
5. **Error Handling**: The code includes error detection mechanisms that set an error flag if an unexpected encoder state is encountered. This ensures robust operation by preventing incorrect readings from affecting the control algorithm.
6. **Masking Logic**: The masking logic is implemented to ensure that only valid state transitions are considered. The expected values are masked to prevent erroneous increments or decrements, thereby enhancing the reliability of the encoder readings.
Overall, this circuit design showcases an effective integration of a microcontroller with an encoder for precise motor control applications, leveraging the capabilities of the 68HC11 for both processing and communication tasks.PID-Control with 68HC11. STEPPER CONTROL. 68HC11 read encoder. High accuracy RPM-measurement with 68HC11 The encoder is connected to PORTA PA0 and PA1
The board must be in BOOTSTRAB MODE (tested with Loggyboard)
********** listing from encoder.ass **************
$ZEROPAGE.INC
PORTA EQU $1000
PORTD EQU $1008
DDRD EQU $1009
TOC3 EQU $101A
TFLG1 EQU $1023
SPCR EQU $1028
BAUD EQU $102B
SCCR1 EQU $102C
SCCR2 EQU $102D
SCSR EQU $102E
SCDR EQU $102F
BIT5 EQU 00100000B
BIT6 EQU 01000000B
ORG $B600
LDS #200 Load Stackpointer
JSR RS_INIT RS232 INIT
LDD #0
STD ENC_COUNT set to zero
clr ERRORFLAG
JSR SET__MASK init MASK ENC_PLUS and ENC_MINUS
***********************************************************************
LOOP JSR REALTIME loop time 0,5 msec
JSR ENCODER
* ------------------
LDX PTR_SERIAL
JSR X
* ------------------
jmp LOOP
*------------------------------------------
REALTIME LDAA #BIT5 wait for Real Time Interrupt
WAIT_REAL2 BITA TFLG1
BEQ WAIT_REAL2
STAA TFLG1
* ----------------------
SetToc3 LDD TOC3
ADDD #1000 0,5 msec
STD TOC3
* --------------------
RTS
***************************************************
SET__MASK LDAA PORTA
ANDA #00000011B
STAA ENC_LAST
bra SET_MASK2
********************************************
ENCODER LDX ENC_COUNT
LDAA PORTA
ANDA #00000011B isolate input bits
CMPA ENC_LAST
BEQ ENCODER_EXIT if equal then exit
STAA ENC_LAST save value for next cycle
CMPA ENC_PLUS Increment or decrement ? BEQ ENCODERPLUS
CMPA ENC_MINUS
BEQ ENCODERMINUS
LDAA #1 if error
STAA ERRORFLAG
ENCODER_EXIT RTS
ENCODERMINUS DEX
BRA SAVE_ENC_COUNT
ENCODERPLUS INX
SAVE_ENC_COUNT STX ENC_COUNT
SET_MASK2 LDAA ENC_LAST The mask are only the next expected value
BEQ MASK_01
CMPA #00000011B
BEQ MASK_01
MASK_10 EORA #00000010B
STAA ENC_PLUS
LDAA ENC_LAST
EORA #00000001B
STAA ENC_MINUS
RTS
MASK_01 EORA #00000001B
STAA ENC_PLUS
LDAA ENC_LAST
EORA #00000010B
STAA ENC_MINUS
RTS
*****************************************************
$SERIAL.INC
Many of today's appliances feature displays and buttons. Instead of relying on motors and gears, numerous household items now incorporate embedded microcontrollers. This exploration focuses on how to experiment with microcontrollers at home.
Microcontrollers serve as the central processing units for...
A stepper motor controller based on schematics available on the Arduino website. Initially, a two-pin configuration was attempted for a bipolar stepper motor, but it did not function as expected, especially with the library provided on the site. The circuit...
A pulse motor, commonly known as a stepper motor, is defined as a motor that changes its excitation state according to input pulse signals, allowing it to move forward at a specific angle or distance. If the excitation state remains...
In a traditional microstepping motor controller, multiple parallel outputs from a microcontroller are utilized, which are then converted to analog signals using a Digital-to-Analog Converter (DAC) and sent through a power amplifier to drive the motor coils. This method is...
The circuit illustrated in the schematic diagram below allows for the visualization of the direction and shaft rotation of a stepper motor on an LED display. Instead of employing a digital rotation encoder as an input, this circuit utilizes a...
For this week's assignment, a chip design was provided, and the task was to incorporate a button and an LED (light-emitting diode). The objective was to fabricate the chip and program it to interact with the light and button. Given...
Assistance is required to modify a light dimmer circuit connected to a PIC12C508 microcontroller. This circuit is designed for the...
The light dimmer circuit utilizing the PIC12C508 microcontroller serves to control the brightness of a light source through pulse width modulation...
A Darlington connection-type transistor is utilized for driving the coil. In this configuration, two stages of transistors are connected in series, resulting in a high current gain, where the "hfe" of the Darlington transistor is the product of the "hfe"...
This circuit utilizes four IRF510 power FETs driven by a CMOS counter to produce the required two-phase drive quadrature. While integrated circuits (ICs) can perform this function, this method is beneficial for experimenters as it employs widely available components. The...
We use cookies to enhance your experience, analyze traffic, and (if you allow) serve personalized ads.
By clicking Accept All, you agree to our use of cookies.
Learn more