NXP S12HZ Reference guide

Type
Reference guide
HCS12
Microcontrollers
freescale.com
Cluster (Dashboard)
Using S12HZ256 as a
Single-Chip Solution
Designer Reference Manual
DRM084
Rev. 0
10/2006
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
Freescale Semiconductor 3
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
This product incorporates SuperFlash® technology licensed from SST.
© Freescale Semiconductor, Inc., 2006. All rights reserved.
Cluster (Dashboard) Using S12HZ256
as a Single-Chip Solution
Designer Reference Manual
by: Kenny Lam
8/16-Bit Applications Engineering, APTSPG
Freescale Semiconductor, Inc.
To provide the most up-to-date information, the revision of our documents on the World Wide Web will be
the most current. Your printed copy may be an earlier revision. To verify that you have the latest
information available, refer to:
http://www.freescale.com
The following revision history table summarizes changes contained in this document. For your
convenience, the page number designators have been linked to the appropriate location.
Revision History
Date
Revision
Level
Description
Page
Number(s)
October,
2006
0 Initial release N/A
Revision History
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
4 Freescale Semiconductor
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
Freescale Semiconductor 5
Table of Contents
Chapter 1
Introduction
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 System Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Chapter 2
Benefits and Features of the 9S12HZ256 Controller
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Basic Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.1 User Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.2 Low-Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 3
Stepper Motor Drive Theory
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Stepper Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 Stepper Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 Stepper Motor Micro-Stepping Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5 Stepper Stall Detection (SSD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.6 LCD Driver for LCD Display Panel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.7 LCD2 Panel Initialization and Checking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.8 LCD2 Panel Firmware (API) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Chapter 4
Software Integration
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Micro-Stepping Control Using Internal Timer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.3 Motor Running and LCD2 Panel Display Demonstration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.4 Cluster System Demonstration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Chapter 5
Hardware Schematics
Chapter 6
Bill of Materials
Table of Contents
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
6 Freescale Semiconductor
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
Freescale Semiconductor 7
Chapter 1
Introduction
1.1 Introduction
This manual describes the design of a cluster board (dashboard) using Freescale’s S12HZ256
microcontroller unit (MCU). This is a single-chip design for the whole system.
The traditional cluster board uses a cross coil motor to drive the analog pointers (actuator) which move
either clockwise or counterclockwise to indicate the car speed, engine rotation speed, fuel level, engine
temperature, etc. This technology is well established and widely used throughout the world. However,
when the cross coil motor is being assembled, it requires an alignment process. The cross coil motor
displacement linearity is also a drawback in regards to the displacement accuracy (linearity), as it may
need motor fine tuning during cluster board manufacturing. In view of this, stepper motors can be one
alterative solution in this application. In addition, the Moving Magnet Technology (MMT) is more mature
for stepper motors nowadays.
The following are some advantages in having the magnet of a stepper motor move relative to a stationary
coil set.
1. The stationary drive coils are beneficial to a motor structure, as they can deal effectively with heat
dissipation.
2. There are no “flying” leads since the coils are stationary which leads to improved longevity of the
motor.
3. The weight of the stationary coils does not affect the maximum velocity of the motor.
4. There is no frictional wear out because the moving magnet concept does not make contact with
any of the stationary elements of motor.
For cluster applications in the automotive segment, Freescale offers the S12H family of devices which
can support up to six stepper motors. These devices also include, as a single-chip solution, a 32 x 4
segment LCD driver to show time and mileage updates on a LCD panel. The designers have also
integrated Stepper Stall Detection (SSD) in the new derivative of the S12HZ family. This derivative
supports up to four stepper motors with SSD.
This manual is based on the 9S12HZ256 features for designing a cluster application.
NOTE
This document is written for the user who is familiar with the S12H256
family and CodeWarrior for S12 and cluster applications. All hardware
schematic diagrams and firmware source codes are available as reference
materials.
Introduction
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
8 Freescale Semiconductor
1.2 System Overview
Figure 1-1 provides a pictorial overview of the system.
Figure 1-1. S12HZ256 Dashboard System
Vehicle Speed
CAN Physical
Interface
PWM
Gauge
Drivers
LED
CAN
5V Vcc
PWM
Input
Signal
Cond’n
(as req’d)
LM2902
MC33174
MC33184
TL064
Engine RPM
Engine Temp.
Batt. Voltage
Fuel Level
I/C0
I/C1
ADC5
ADC4
ADC3
ADC2
Vreg
*
Vreg
*
I / O
LCD
DRIVER
MC9S12Hx
16 Bit MCU
Integrated LCD Driver
32x4 (112 QFP package)
Integrated Drive for 4 Stepper Motors
With Motor Stall Detection (MSD)
(16 hi-current PWM outputs)
Easier PCB Routing
Fewer Components
Higher Reliability
Cost Effective
Keys
RS232
SCI
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
Freescale Semiconductor 9
Chapter 2
Benefits and Features of the 9S12HZ256 Controller
2.1 Introduction
As shown in this chapter, the S12HZ family of devices offers an excellent complement of peripherals and
a broad range of memory and packages.
2.2 Basic Features
Some of the S12HZ family benefits are shown below. Features have been broken down by type for your
convenience.
HCS12 Core:
16-bit HCS12 CPU
Upward compatible with M68HC11 instruction set
Interrupt stacking and programmer’s model identical to M68HC11
–20-bit ALU
Instruction queue
Enhanced indexed addressing
Multiplexed external bus interface (MEBI)
Module mapping control (MMC)
Interrupt control (INT)
Debugger and breakpoints (DBG)
Background debug mode (BDM)
Memory:
256K, 128K, 64K Flash EEPROM
2K, 1K byte EEPROM
12K, 6K, 4K byte RAM
CRG:
Low current oscillator
Phase locked loop (PLL)
Reset, clocks
Computer operating properly (COP) watchdog
Real time interrupt
Clock monitor
Benefits and Features of the 9S12HZ256 Controller
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
10 Freescale Semiconductor
Analog-to-digital converter (ADC):
16 channels, 10-bit resolution
External conversion trigger capability
Two 1M bit per second, CAN 2.0 A, B software compatible modules:
Five receive and three transmit buffers
Flexible identifier filter programmable as 2 x 32 bit, 4 x 16 bit, or 8 x 8 bit
Four separate interrupt channels for Rx, Tx, error, and wake-up
Low-pass filter wake-up function
Loop-back for self test operation
Timer:
16-bit main counter with 7-bit prescaler
Eight programmable input capture or output compare channels
Two 8-bit or one 16-bit pulse accumulators
Six PWM channels:
Programmable period and duty cycle
8-bit 6-channel or 16-bit 3-channel
Separate control for each pulse width and duty cycle
Center-aligned or left-aligned outputs
Programmable clock select logic with a wide range of frequencies
Fast emergency shutdown input
Serial interfaces:
Two asynchronous serial communication interfaces (SCI)
Synchronous serial peripheral interface (SPI)
Inter-integrated circuit interface (IIC)
Liquid crystal display driver with variable input voltage:
Configurable for up to 32 frontplanes and 4 backplanes or general purpose input or output
Five modes of operation allow for different display sizes to meet application requirements
Unused frontplane and backplane pins can be used as general purpose input or output
16 high current drivers suited for PWM motor control:
Each PWM channel switchable between two drivers in an H-bridge configuration
Left, right, and center aligned outputs
Support for sine and cosine drive
•Dithering
Output slew rate control
Modes of Operation
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
Freescale Semiconductor 11
Four stepper stall detectors (SSD):
Full step control during return to zero
Voltage selector and integrator/sigma delta converter circuit
16-bit accumulator register
16-bit modulus down counter
112-Pin LQFP and 80-Pin QFP packages:
85 I/O lines with 5-V input and drive capability
5-V A/D converter inputs
Eight key wake up interrupts with digital filtering and programmable rising/falling edge trigger
Operating speed:
Operation at 50 MHz equivalent to 25 MHz bus speed
Development support:
Single-wire background debug™ mode (BDM)
Debugger and on-chip hardware breakpoints
2.3 Modes of Operation
2.3.1 User Modes
User modes include:
Normal and emulation operating modes
Normal single-chip mode
Normal expanded wide mode
Normal expanded narrow mode
Emulation expanded wide mode
Emulation expanded narrow mode
Special operating modes
Special single-chip mode with active background debug mode
Special test mode (Freescale use only)
Special peripheral mode (Freescale use only)
2.3.2 Low-Power Modes
Low-power modes include:
Stop mode
Pseudo stop mode
Wait mode
Benefits and Features of the 9S12HZ256 Controller
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
12 Freescale Semiconductor
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
Freescale Semiconductor 13
Chapter 3
Stepper Motor Drive Theory
3.1 Introduction
The stepper motor (MMT) is an excellent choice for cluster applications. This application employs high
current drives suited for pulse width modulator (PWM) motor control, which supports sine and cosine
drive, using the 9S12HZ256 device. Software running on the 9S12HZ256 device implements:
Micro-stepping to achieve precise linear position
Reduced noise
Vibration during stepper motor running.
3.2 Stepper Motor
In theory, although a micro-stepping controller offers hundreds of intermediate positions between steps,
but it has some drawbacks. It is worth noting that micro-stepping does not generally offer great precision.
This is because of both linearity problems and the effects of static friction.
The utility of micro-stepping is limited by several considerations:
1. The angular precision achievable with micro-stepping will be limited if there is any static friction in
the system.
2. It involves the non-sinusoidal character of the torque versus shaft-angle curves on real motors.
Sometimes, this is attributed to the detent torque on permanent magnet and hybrid motors. But, in
fact both detent torque and the shape of the torque versus angle curves are products of poorly
understood aspects of motor geometry. Specifically the shapes of the teeth on the rotor and stator,
these teeth are almost always rectangular.
3. Problems arise because most applications of micro-stepping involve digital control systems. Thus,
the current through each motor winding is quantized, controlled by a digital-to-analog converter
(PWM). Furthermore, if typical PWM current limiting circuitry is used, the current through each
motor winding is not held perfectly constant, but rather, oscillates around the current control
circuit's set point. As a result, the best a typical micro-stepping controller can do is approximate the
desired currents through each motor winding.
In view of these considerations, note that the drive stepper motor running smoothly in micro-stepping
depends on the motor characteristics. The number of the steps in micro-stepping selection is also based
on the stepper motor. We chose 24 micro-stepping / step in this reference design manual as an example.
Stepper Motor Drive Theory
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
14 Freescale Semiconductor
3.3 Stepper Motor Control
Figure 3-1 shows a 2-phase step motor control signal. This signal switches on and off in turn and is driven
by an H-bridge as shown in Figure 3-2.
Figure 3-1. 2-Phase Step Motor Control Signal
Figure 3-2. H-Bridge
A
/B
CW
CCW
B
/A
A
Store
tri
p
A
/A
Supply
+
-
Phase
A
Stepper Motor Control
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
Freescale Semiconductor 15
As shown in Figure 3-3, phase A and B are driven by a square wave to move the rotor. It can be locked
at a desired position when the phase supply (square wave) stops to alter.
Figure 3-3. Basic Driving Circuit for Two Phase Step Motor
In order to drive a moving stepper motor, the S12H family offers a simple instruction to control step
movement. The example below, uses motor channel 0 to control the stepper motor moving forward. The
phase supply sequences are as follows:
Phase A B
01
00
10
void eat_time(int time) //eat time
{
while(time--!=0){}
}
void step_move() //step move
{
MCDC0H &=~0x80; //channel 0 (A = 0, /A = 1) Step 0
MCDC1H |=0x80; //channel 1 (B = 1, /B = 0)
eat_time(0x2000); //delay
MCDC0H &=~0x80; //channel 0 (A = 0, /A = 1) Step 1
MCDC1H &=~0x80; //channel 1 (B = 0, /B = 1)
eat_time(0x2000); //delay
MCDC0H |=0x80; //channel 0 (A = 1, /A = 0) Step 2
MCDC1H &=~0x80; //channel 1 (B = 0, /B = 1)
eat_time(0x2000); //delay
MCDC0H |=0x80; //channel 0 (A = 1, /A = 0) Step 3
MCDC1H |=0x80; //channel 1 (B = 1, /B = 0)
eat_time(0x2000); //delay
}
A
Gnd
Vdd
+
-
Phase A
Vdd
Gnd
Phase B
Rotate
Stepper Motor Drive Theory
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
16 Freescale Semiconductor
Please refer to the firmware project (1. StepMove) for more detailed information. See Figure 3-4.
Figure 3-4. StepMove Screen
Stepper Motor Micro-Stepping Control
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
Freescale Semiconductor 17
3.4 Stepper Motor Micro-Stepping Control
The utility of micro-stepping is limited by at least three considerations.
1. Motor static friction
2. Non-sinusoidal character of the torque versus shaft-angle, each motor
3. Winding is quantized, controlled by a digital-to-analog converter (PWM)
The most common control algorithm is adopted to use sinusoidal current to drive micro-stepping. One
complete sinusoidal wave is equivalent to four steps in a 2-phase motor.
Phase A is driven by a PWM as sinusoidal to move the rotor. It can also be locked at a desired position
when the phase supply stops to alter. The stepper motor can be held by the supply current from the driver
as static holding torque.
Phase A and B are driven by a sinusoidal wave to move the rotor. It can be locked at a desired position
when the phase supply (sinusoidal wave) stops to alter.
To drive stepper motor moving, the S12H family can use a simple look-up table to implement a sinusoidal
signal to drive micro-stepping movement.
Refer to Figure 3-5 and Figure 3-6.
Figure 3-5. Micro-Stepping Sinusoidal Control
A
/B
CW
CCW
B
/A
A
S
t
Stepper Motor Drive Theory
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
18 Freescale Semiconductor
Figure 3-6. Micro-Stepping Sinusoidal Control with PWM
Please refer to the firmware project (2. MicroStepMove) for more detailed information. See Figure 3-7.
Figure 3-7. MicroStepMove Screen
Suppl
y
A
/
PWM
PWM
+
-
Phase
PWM
/PWM
Phase
B
Store trip
Stepper Stall Detection (SSD)
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
Freescale Semiconductor 19
3.5 Stepper Stall Detection (SSD)
This module provides a built-in circuit to detect the induced voltage on the non-driven coil of a stepper
motor. The back EMF can be measured by an internal ADC module, which can integrate the induced
voltage on the non-driven coil, and store its results to a16-bit accumulator register. The internal 16-bit
modulus down counter can be used to monitor the blanking time and the integration time. The value in
the 16-bit accumulator represents the change in linked flux. It can be compared to a stored threshold to
distinguish whether the motor reaches the home position. Values above the threshold indicate a moving
motor, in which case the pointer can be advanced another full step in the same direction and integration
repeated. Values below the threshold indicate a stalled motor, home position is reached.
See Figure 3-8.
Figure 3-8. Stepper Stall Detection Flowchart
Advanced Motor Pointer
Initialized SSD
Start Blinking
No
End of Start Blinking
Yes
Start Integration
End of Integration
No
Yes
No
Stall Detection
Disabled SSD
Stepper Motor Drive Theory
Cluster (Dashboard) Using S12HZ256 as a Single-Chip Solution Designer Reference Manual, Rev. 0
20 Freescale Semiconductor
Please refer to the firmware project (3. StepperStallDetection) for more detailed information. See
Figure 3-9.
Figure 3-9. StepperStallDetection Screen
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40

NXP S12HZ Reference guide

Type
Reference guide

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI