Application Note. C51 Microcontrollers. Driving Unipolar Stepper Motors Using C51/C251. Introduction. Description

Similar documents
8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Tag Tuning/RFID. Application Note. Tag Tuning. Introduction. Antenna Equivalent Circuit

8-bit Microcontroller. Application Note. AVR314: DTMF Generator

Quick Start Guide. CAN Microcontrollers. ATADAPCAN01 - STK501 CAN Extension. Requirements

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

AT89C5131A Starter Kit... Software User Guide

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

8-bit Microcontroller. Application. Note. AVR204: BCD Arithmetics. Features. Introduction. 16-bit Binary to 5-digit BCD Conversion bin2bcd16

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

General Porting Considerations. Memory EEPROM XRAM

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

AVR241: Direct driving of LCD display using general IO. 8-bit Microcontrollers. Application Note. Features. Introduction AVR

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR442: PC Fan Control using ATtiny13. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

AVR120: Characterization and Calibration of the ADC on an AVR. 8-bit Microcontrollers. Application Note. Features. Introduction

USB 2.0 Full-Speed Host/Function Processor AT43USB370. Summary. Features. Overview

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

Step Motor Controller. Application Note. AVR360: Step Motor Controller. Theory of Operation. Features. Introduction

Application Note. Migrating from RS-232 to USB Bridge Specification USB Microcontrollers. Doc Control. References. Abbreviations

8-bit Microcontroller. Application Note. AVR461: Quick Start Guide for the Embedded Internet Toolkit. Introduction. System Requirements

8-bit Microcontroller. Application Note. AVR410: RC5 IR Remote Control Receiver

Application Note. 8-bit Microcontrollers. AVR091: Replacing AT90S2313 by ATtiny2313. Features. Introduction

How To Prevent Power Supply Corruption On An 8Bit Microcontroller From Overheating

Application Note. USB Mass Storage Device Implementation. USB Microcontrollers. References. Abbreviations. Supported Controllers

USB Test Environment ATUSBTEST- SS7400. Summary

2-wire Serial EEPROM AT24C1024. Advance Information

Two-wire Automotive Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 (1) AT24C16 (2)

AVR444: Sensorless control of 3-phase brushless DC motors. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

2-Wire Serial EEPROM AT24C32 AT24C64. 2-Wire, 32K Serial E 2 PROM. Features. Description. Pin Configurations. 32K (4096 x 8) 64K (8192 x 8)

ATF15xx Product Family Conversion. Application Note. ATF15xx Product Family Conversion. Introduction

Application Note. 8-bit Microcontrollers. AVR280: USB Host CDC Demonstration. 1. Introduction

DIP Top View VCC A16 A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 I/O0 I/O1 I/O2 GND A17 A14 A13 A8 A9 A11 A10 I/O7 I/O6 I/O5 I/O4 I/O3. PLCC Top View VCC A17

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

Application Note. 8-bit Microcontrollers. AVR307: Half Duplex UART Using the USI Module

Two-wire Serial EEPROM AT24C1024 (1)

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Table of Contents. Section 1 Introduction Section 2 Getting Started Section 3 Hardware Description

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR313: Interfacing the PC AT Keyboard

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AT86RF230 (2450 MHz band) Radio Transceiver... User Guide

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

All-band AM/FM Receiver and Audio Amplifier IC U2510B

2-wire Serial EEPROM AT24C512

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

8-bit RISC Microcontroller. Application Note. AVR335: Digital Sound Recorder with AVR and DataFlash

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

STK 500, AVRISP, AVRISP

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR435: BLDC/BLAC Motor Control Using a Sinus Modulated PWM Algorithm. 1. Features. 2.

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

AVR318: Dallas 1-Wire master. 8-bit Microcontrollers. Application Note. Features. Introduction

256K (32K x 8) OTP EPROM AT27C256R 256K EPROM. Features. Description. Pin Configurations

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

AVR441: Intelligent BLDC Fan Controller with Temperature Sensor and Serial Interface. 8-bit Microcontrollers. Application Note.

Application Note Microcontrollers. Guidelines to Keep ADC Resolution within Specification. Introduction. ADC Resolution

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

80C51 MCU s. Application Note. Analyzing the Behavior of an Oscillator and Ensuring Good Start-up. Oscillator Fundamentals

AVR447: Sinusoidal driving of three-phase permanent magnet motor using ATmega48/88/ bit Microcontrollers. Application Note.

Table 1 Comparison of DC, Uni-Polar and Bi-polar Stepper Motors

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

AVR068: STK500 Communication Protocol. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

ATF1500AS Device Family. Application Note. In-System Programming of Atmel ATF1500AS Devices on the HP3070. Introduction.

AT91 ARM Thumb Microcontrollers. Application Note. GNU-Based Software Development on AT91SAM Microcontrollers. 1. Introduction. 2.

Application Note. AVR Microcontrollers. AVR493: Sensorless Commutation of Brushless DC Motor (BLDC) using AT90PWM3 and ATAVRMC

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

Application Note. Microcontrollers. AVR480: Anti-Pinch System for Electrical Window

8-bit. Application Note. Microcontrollers. AVR273: USB Mass Storage Implementation. Features. 1. Introduction

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AN235 Application note

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

Transcription:

Driving Unipolar Stepper Motors Using C51/C251 Introduction Stepper motors are commonly used in accurate motion control. They allow to control any motion with high precision by counting the number of steps applied to the motor. Most of systems controlling stepper motors are embedded systems such as printer, scanner or floppy disk drive. This application note describes how to drive a unipolar stepper motor with the Programmable Counter Array of an Atmel C51/C251 microcontroller. C51 Microcontrollers Application Note Description C51/C251 microcontroller output pins cannot directly drive stepper motors. These have to be powered before being applied to the stepper motor. This document explains uses the Programmable Counter Array (PCA) of the microcontroller to generate the control signals to the Power Interface. The Power Interface allows the microcontroller to drive enough current into coils of a stepper motor. There are two advantages to using PCA. First of all, PCA provides greater accuracy than toggling pins in software because the toggle occurs before the interrupt request is serviced. Thus, interrupt response time does not affect the accuracy of the output. Secondly the microcontroller CPU is left free for application task execution while the PCA drives stepper motors. There are two major types of stepper motors: Permanent magnet stepper motors (unipolar stepper motors and bipolar stepper motors) and variable reluctance stepper motors (hybrid stepper motors). Rev. 1

Figure 1. System Configuration C51/C251 Control Signals Powered Control Signals Power Interface Stepper Motor Identification of Stepper Motor Unipolar Stepper Motor There are several types of stepper motors, these cannot be driven in the same way. In this application note, we have chosen to drive a unipolar stepper motor (see Figure 2). For more information you will find schemes to identify the other types of stepper motors. Unipolar stepper motors are characterised by their center-tapped windings. Figure 2. Unipolar Stepper Motors Coils Bipolar Stepper Motor Bipolar stepper motors are designed with separate coils. Figure 3. Bipolar Stepper Motor Coils Variable Reluctance Variable reluctance stepper motor (also called hybrid motors) are characterised by one common lead. 2 C51/C251 Application Note

C51/C251 Application Note Figure 4. Hybrid Stepper Motor Coils Driving Unipolar Stepper Motors One Phase On Mode (Full Step mode) There are three ways to drive unipolar stepper motors (one phase on, two phase on or half step), each one has some advantages and disavantages. Table 1. One Phase On Sequence Step 1a 1b 2a 2b 1 1 0 0 0 2 0 1 0 0 3 0 0 1 0 4 0 0 0 1 3

Figure 5. One Phase Steps In one phase mode, each successive coil is energized in turn. One phase mode produces smooth rotations and the lowest power comsumption of the three modes. Steps are applied in order from one to four. After step four, the sequence is repeated from step one. Applying steps from one to four makes the motor run clockwise, reversing the order of step from four to one will make the motor run counter-clockwise. Figure 6. One Phase On Steps Sequence 4 C51/C251 Application Note

C51/C251 Application Note Two Phases On Mode (Alternate Full step Mode) Table 2. Two Phases On Sequence Step 1a 1b 2a 2b 1 1 0 0 1 2 1 1 0 0 3 0 1 1 0 4 0 0 1 1 Figure 7. Two Phases On Steps In two phase mode, successive pairs of adjacent coils are energised in turn, motion is not as smooth as in one phase mode, power comsumption is more important but it produces greater torque. As in one phase mode, applying the steps in order makes the stepper motor run clockwise and reversing order makes it turn counter-clockwise. 5

Figure 8. Two Phases On Steps Sequence Half Step Mode Table 3. Half Step Sequence Step 1a 1b 2a 2b 1 1 0 0 1 2 1 0 0 0 3 1 1 0 0 4 0 1 0 0 5 0 1 1 0 6 0 0 1 0 7 0 0 1 1 8 0 0 0 1 The half step sequence is a mix of one phase on and two phase on sequences. The main advantage of this mode is to increase by two the nominal number of steps of your stepper motor. By example, an unipolar stepper motor of 24 steps of 15 degrees each "becomes", when we use half step mode, a stepper motor of 48 steps of 7.5 degrees. 6 C51/C251 Application Note

C51/C251 Application Note Figure 9. Half Step Sequence 7

Figure 10. Half Step Sequence Hardware The following schematics shows the power interface between the Atmel C51/C251 and a stepper motor. The four PCA pins must have the following hardware connected. Coils are connected with both center-tapped windings connected to 12V power supply. Figure 11. Power Interface 5V 12V center-tapped winding C51/C251 1K 4N37 1K 1N4007 Stepper Motor Coil TIP121 P1.x/CEXx 100K 2N2222A 5V GND 12V GND X4 In this configuration, the stepper motor is opto-isolated from the microcontroller with a high protection level. The 2N2222A transistor helps to drive enough current in 4N37 led (via 1kΩ resistor). Stepper motor power is given by 12V power supply via TIP121 transistor. Diode on stepper motor coil is used to prevent inductive kicks produced when coil is turned off. 8 C51/C251 Application Note

C51/C251 Application Note Driving Two Stepper Motors with Only One PCA It is possible to drive two stepper motors at the same time with only four PCA channels. For this, we will use the the Two Phase On mode (see Table 2 and Figure 6). In this mode, signals 1 and 2 are respectively opposite waveforms of signals 3 and 4. Thus, it is possible to have the four signals needed for one stepper motor with only two PCA channels and two logical inverters. C51/C251 Control Signals Powered Control Signals Power Interface 1 Control Signals Powered Control Signals Stepper Motor 1 Power Interface 2 Stepper Motor 2 Software The software of this application note (Given in appendix A), written in C language allows to make a motor turn NB_LOOP loops clockwise (or counter-clockwise) direction in half step mode. NB_LOOP and clockwise (or counter-clockwise) are defined in constant variable at the beginning of code, and must be defined before compilation. The user also needs to define (via constant variable) the number of steps of the motor. The unipolar stepper motor will be driven with PCA via Power Interface described in section 3. - The following software initializes CEX0 to CEX3 of Programmable Counter Array in High Speed Output Mode - Timer 0 is configured in 8 bit auto-reload mode - Clock of the PCA is given by overflow of Timer 0. - PCA interrupt vector at address 0x0033h is also used. If speed precision is not very important in the application it is possible to use Fosc/12 or Fosc/4 for PCA clock input, it will leave Timer 0 free for the application itself. 9

The speed of the stepper motor may be calculated with the formula: SPEED = NB STEP 8 * 60 12 Fosc * 0xFFFF * [ 0xFF - TH0 ] SPEED = Speed in rotations per minute NBSTEP = Number of step of the motor, in general written on the stepper motor itself (48, 96, 200..) Fosc = Frequency of the oscillator in Hertz. For example, when using stepper motor with 200 steps and a 12 Mhz oscillator and loading THO with 0xFC, the speed is 12.2 rotations per minute. With the same formula THO is found by: TH0 = 0xFF - 40 * Fosc NB STEP * 0xFFFF * SPEED The table below lists the values of speed for different oscillator frequencies and nominal number of steps of the motor, when using Fosc / 12 and Fosc / 4 as PCA clock input. Rot/Min Fosc (MHz) Nb of Step 210.941 11.0592 96 Fosc / 4 70.314 11.0592 96 Fosc / 12 101.252 11.0592 200 Fosc / 4 33.751 11.0592 200 Fosc / 12 178.705 12 96 Fosc / 4 76.295 12 96 Fosc / 12 109.865 12 200 Fosc / 4 36.622 12 200 Fosc / 12 305.180 16 96 Fosc / 4 101.723 16 96 Fosc / 12 146.487 16 200 Fosc / 4 48.829 16 200 Fosc / 12 Value for other oscillator frequency or number of steps can be found easily by arithmetic operation. For example, at Fosc = 12 MHz and clock input = Fosc / 12, NBSTEP = 96 we found 76.295 rotations per minute. If another motor of 48 steps is used instead, we found now 2*76.295 rotations per minute. Note: Above values are theoretical for high speed rotation, motors are limited by needed torque. Sometimes it will be necessary to start the motor slowly and accelerate it after few seconds. 10 C51/C251 Application Note

C51/C251 Application Note Appendix A: Software MAIN.C /*C************************************************************************************ * NAME : Stepper.c * CREATED_BY : Eric TINLOT * CREATION_DATE : 05/02/01 * PURPOSE : Driving unipolar stepper motor in half step mode using PCA. **************************************************************************************/ /* I N C L U D E S */ #include "89C51RD2.H" /* sfr definition file */ /* D E C L A R A T I O N */ /* M A C R O S */ #define ENABLE_ALL_IT ( EA = 1 ) #define PCA_ON ( CCON = 0x40) #define PCA_OFF ( CCON &= 0xBF) /* D E F I N I T I O N */ #define NB_LOOP 10/* place here the number of loop desired */ /* select rotation direction here */ #define CLOCKWISE #define NB_STEP 48 /* define by stepping motor itself */ #define P_HIGH 0xFF #define P_LOW 0x00 long int nb_it=0; /*F************************************************************************************ * NAME :ccaxh_reload_value * AUTHOR :Eric TINLOT * DATE :05/02/01 * PURPOSE:Load value in PCA register CCAPxH * INPUTS:value for CCAP0H,CCAP1H,CCAP2H,CCAP3H 11

* OUTPUTS:void **************************************************************************************/ void ccapxh_reload_value(char h0, char h1, char h2, char h3) { CCAP0H = h0; CCAP1H = h1; CCAP2H = h2; CCAP3H = h3; } /*F************************************************************************************ * NAME :timer0_init * AUTHOR :Eric TINLOT * DATE :05/02/01 * PURPOSE:init timer 0 for PCA clock * INPUTS :void * OUTPUTS:void **************************************************************************************/ void timer0_init(void) { TH0 = 0xB3; TL0 = 0xB3; TMOD = TMOD 0x02; TCON = TCON 0x10; } /*F************************************************************************************ * NAME :pca_init * AUTHOR :Eric TINLOT * DATE :05/02/01 * PURPOSE:init pca to run in High speed Output * INPUTS :void * OUTPUTS:void **************************************************************************************/ void pca_init(void) { CCAP0L = P_HIGH; CCAP1L = P_HIGH; CCAP2L = P_HIGH; CCAP3L = P_HIGH; #ifdef CLOCKWISE /* pca register initialisation for CLOCKWISE rotation */ ccapxh_reload_value(0x5f,0x00,0x00,0x1f); #else /* COUNTER_CLOCKWISE */ /* pca register initialisation for COUNTER CLOCKWISE rotation */ 12 C51/C251 Application Note

C51/C251 Application Note ccapxh_reload_value(0x1f,0x00,0x00,0x5f); #endif CCAPM0 = 0x4D; /* enable High Speed Output mode on CEX0 - CEX3 */ CCAPM1 = 0x4D; CCAPM2 = 0x4D; CCAPM3 = 0x4D; /* PCA Clock Select */ CMOD = 0x04; /* CMOD = 0x04 -> pca clock = timer0 overflow */ /* CMOD = 0x00 -> pca clock = Fosc/12 */ /* CMOD = 0x02 -> pca clock = Fosc/4 */ CH = 0xFF; CL = 0xFF; EC = 0x01; } /*F************************************************************************************ * NAME :PCA - interrupt program * AUTHOR :Eric TINLOT * DATE:05/02/01 * PURPOSE:identify toggle pin and prepare pca register for next toggle * nb_it variable, enable to count number of loop * INPUTS :void * OUTPUTS:void **************************************************************************************/ PCA() interrupt 6 using 1 /* Int Vector at 000BH, Reg Bank 1 */ { #ifdef CLOCKWISE if (CCF0==1 && CEX0==0) { nb_it++; CCF0 = 0; CCAP0H = 0xFF; } if (CCF1==1 && CEX1==0) { CCF1 = 0; CCAP1H = 0x3F; } if (CCF2==1 && CEX2==0) { CCF2 = 0; CCAP2H = 0x7F; } if (CCF3==1 && CEX3==0) { CCF3 = 0; CCAP3H = 0xBF; } if (CCF0==1 && CEX0==1) { CCF0 = 0; CCAP0H = 0x5F; } if (CCF1==1 && CEX1==1) { CCF1 = 0; CCAP1H = 0x9F; } if (CCF2==1 && CEX2==1) { CCF2 = 0; CCAP2H = 0xDF; } if (CCF3==1 && CEX3==1) { CCF3 = 0; CCAP3H = 0x1F; } #else /* COUNTER_CLOCKWISE */ if (CCF0==1 && CEX0==0) { nb_it++; CCF0 = 0; CCAP0H = 0xBF; } if (CCF1==1 && CEX1==0) { CCF1 = 0; CCAP1H = 0x7F; } if (CCF2==1 && CEX2==0) { CCF2 = 0; CCAP2H = 0x3F; } if (CCF3==1 && CEX3==0) { CCF3 = 0; CCAP3H = 0xFF; } 13

if (CCF0==1 && CEX0==1) { CCF0 = 0; CCAP0H = 0x1F; } if (CCF1==1 && CEX1==1) { CCF1 = 0; CCAP1H = 0xDF; } if (CCF2==1 && CEX2==1) { CCF2 = 0; CCAP2H = 0x9F; } if (CCF3==1 && CEX3==1) { CCF3 = 0; CCAP3H = 0x5F; } #endif } /*F************************************************************************************ * NAME :main * AUTHOR:Eric TINLOT * DATE :05/02/01 * PURPOSE:call init subroutines and run stepper motor for nb_loop * INPUTS :void * OUTPUTS:void **************************************************************************************/ void main(void) { long int tocount; tocount = 2 * (NB_STEP / 8) * NB_LOOP; /* compute number of IT needed for NB LOOP*/ timer0_init(); /* init Timer 0 for pca clock */ pca_init(); /* init pca to run in High speed Output */ ENABLE_ALL_IT; PCA_ON; do{ }while(nb_it<=tocount); /* wait motor turn nb_loop */ PCA_OFF; P1 = P_LOW; /* clear all coils (no comsumption) */ do{ }while(1); /* endless */ } 14 C51/C251 Application Note

Atmel Headquarters Corporate Headquarters 2325 Orchard Parkway San Jose, CA 95131 TEL 1(408) 441-0311 FAX 1(408) 487-2600 Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland TEL (41) 26-426-5555 FAX (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimhatsui East Kowloon Hong Kong TEL (852) 2721-9778 FAX (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan TEL (81) 3-3523-3551 FAX (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131 TEL 1(408) 441-0311 FAX 1(408) 436-4314 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131 TEL 1(408) 441-0311 FAX 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France TEL (33) 2-40-18-18-18 FAX (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France TEL (33) 4-42-53-60-00 FAX (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 TEL 1(719) 576-3300 FAX 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland TEL (44) 1355-803-000 FAX (44) 1355-242-743 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany TEL (49) 71-31-67-0 FAX (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 TEL 1(719) 576-3300 FAX 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France TEL (33) 4-76-58-30-00 FAX (33) 4-76-58-34-80 e-mail literature@atmel.com Web Site http://www.atmel.com Atmel Corporation 2002. Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company s standard warranty which is detailed in Atmel s Terms and Conditions located on the Company s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel s products are not authorized for use as critical components in life support devices or systems. ATMEL is a registered trademark of Atmel. Other terms and product names may be the trademarks of others. Printed on recycled paper. /xm