Silicon Laboratories Stepper Machine User Manual Page 22

  • Download
  • Add to my manuals
  • Print
  • Page
    / 36
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 21
AN155
22 Rev. 1.1
APPENDIX E - CODE LISTING
//-----------------------------------------------------------------------------
// Stepper.c
//-----------------------------------------------------------------------------
// Copyright 2003 Silicon Laboroatories Inc.
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <c8051f300.h> // include SFR declarations
//-----------------------------------------------------------------------------
// defines and typedefs
//-----------------------------------------------------------------------------
#define SYSCLK 24500000 // SYSCLK frequency in Hz
#define BAUDRATE 57600 // Baud rate of UART in bps
#define READ_BUFFER_SIZE 16 // change UART receive buffer size here
#define WRITE_BUFFER_SIZE 16 // change UART receive buffer size here
#define ON 0 // LED is active low
#define OFF 1
#define ACCELERATE 3 // motor states
#define SLEWING 2
#define DECELERATE 1
#define DONE 0
#define INIT_TZERO 80 // Tzero used at start-up and with
// manual mode, change value here for
// different stepper motors
typedef union // union used for writing to TL0 & TH0
{
struct
{
unsigned char hi;
unsigned char lo;
} b;
unsigned int w;
}udblbyte;
//-----------------------------------------------------------------------------
// Global CONSTANTS
//-----------------------------------------------------------------------------
//
// half step stepper motor step pattern
// transistors are in order B-,B+,A-,A+
//
// 0x01 = 0001
// 0x05 = 0101
// 0x04 = 0100
// 0x06 = 0110
// 0x02 = 0010
// 0x0A = 1010
// 0x08 = 1000
// 0x09 = 1001
const unsigned char code StepPattern[8]=
{0x01,0x05,0x04,0x06,0x02,0x0A,0x08,0x09};
//
Page view 21
1 2 ... 17 18 19 20 21 22 23 24 25 26 27 ... 35 36

Comments to this Manuals

No comments