Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 507 → Rev 508

/programy/C/avr/LX200/stepper.h
0,0 → 1,103
/*
* Copyright (C) 2004 Darren Hutchinson (dbh@gbdt.com.au)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
* License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*
* $Id: stepper.h,v 1.7 2004/04/05 06:42:15 dbh Exp $
*/
 
#ifndef _STEPPER_H_
#define _STEPPER_H_
 
/* Define the encoding used to hold the exictation values for each
* stepper coil.
*/
#define _EX_ENTRY(c1, c2) (((c1) << 4) | (c2))
#define _GET_C1(e) ((e) >> 4)
#define _GET_C2(e) ((e) & 0xf)
 
#define EX_0 0x0 // Inactive
#define EX_P_0_2 0x1 // +0.2 active
#define EX_P_0_4 0x2 // +0.4 active
#define EX_P_0_67 0x3 // +0.67 active
#define EX_P_1 0x4 // +Active
 
#define EX_M_0_2 0x9 // -0.2 active
#define EX_M_0_4 0xa // -0.4 active
#define EX_M_0_67 0xb // -0.67 active
#define EX_M_1 0xc // -Active
 
/* Define the struture used to pass excitation information from
* the stepper module to the excitation module
*/
struct excitation_s
{
uint8_t excitation;
uint8_t useRelay;
};
 
extern struct excitation_s raExcitation;
extern struct excitation_s decExcitation;
 
/* Define a structure to hold the current "state" for each axis. This
* allows up to use the same code for both axis, so I don't feel
* tempted to skimp on the features
*/
struct stepState_s
{
// Input (from the combiner)
int8_t reqSpeed; // Rate requested
 
// Output (to the driver)
struct excitation_s *pExcite;
 
// Configuration
uint16_t backlash; // #steps to counteract backlash
uint8_t finPos; // Finish movement in positive direction
uint8_t finNeg; // Finish movement in negative direction
 
// Machine state
uint8_t stepCtr; // Current step in cycle
int8_t curSpeed; // Current rate (when moving after spin)
void *pState; // State pointer
uint16_t count; // Counter used in states
 
uint8_t *pTable; // Current step table
 
// Support function state
uint8_t clkDivRatio; // Current clock div
uint8_t divCtr; // Clock division counter
};
 
/* These are held in stepper.c */
extern struct stepState_s raState;
extern struct stepState_s decState;
extern int8_t trackingRate;
extern uint8_t transRatio;
 
/* Prototypes */
void stepperInit(void);
void setRaSpeed(int8_t speed);
void setDecSpeed(int8_t speed);
 
void setupRateTable(uint8_t transRatio);
void setTrackRate(int8_t rate);
 
/* DEBUG: Uses half step instread of microstep if true */
extern uint8_t doHalfStep;
 
#endif /* _STEPPER_H_ */