the idea behind it is the following:
have one stepper-driver-board, where 4 (bipolar) steppers can be attached. it can be connected to the arduino board and it is possible to have several of those stepper-driver-boards attached serially.
Therefore I used for each board 4 L293D and 2 74HCT595:
I wrote as well a SW-library for it:
header file:
/*
MasterVerwalter.h - Hardware Stepper Library
Copyright (c) 2008 Jan Winter jwinter@gmx.net. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define MAX_NUMBER_OF_PANELS 12
#define MAX_NUMBER_OF_MOTORS 12
//movement types of the motor:
#define INVERSE 0
#define WAIT 1
#define ONCE 2
#define ENDLESS 3
#define POSITION 4
#define RECHTS 1
#define LINKS -1
#ifndef PanelArray_h
#define PanelArray_h
#include "WConstants.h"
class Motor
{
public:
Motor(void); //constructor
int step(int); //gets the next step position of this motor
int release(void); //releases the motor
void SetStepsToMove(int, int, int, int); //
int getSpeed(void);
int getStepsFinished(void);
private:
/**
@brief the actual index of the movement vector
*/
int _StepIndex;
/**
@brief number of steps to step
*/
int _NumberOfStepsToMove;
/**
@brief number of stepped steps
*/
int _NumberOfStepsMoved;
/**
@brief whether the movement is inverted or not after reaching the step limit
*/
int _Inversion;
/**
@brief Movement mode
@param INVERSE, WAIT, ONCE, ENDLESS
*/
int _MovementMode;
/**
@brief Speed
@param 1 = max, 2 = half, 3 = third
*/
int _Speed;
/**
@brief Direction
@param left, right
*/
int _Direction;
};
class MasterVerwalter
{
public:
MasterVerwalter(unsigned short, unsigned short, unsigned short, unsigned short); //constructor
int clock(int); //a step will be applied by each clock cycle
void init(int, int, int, int, int); //initialize each motor
private:
void writeBits(unsigned short); //writes the bits to the latches
void latchData(void); //gives out the data
int _MotorStates[MAX_NUMBER_OF_MOTORS]; //keeps track of the current motor state
Motor motor[MAX_NUMBER_OF_MOTORS]; //motor classes
unsigned short _NumberOfMotors;
unsigned short _PinData;
unsigned short _PinShift;
unsigned short _PinStore;
unsigned short _ClockCounter;
};
#endif
cpp-file:
have to post it later, didn't fit in this post
one could use it with arduino in such a way:
//MasterVerwalter Objektname(int PinData, int PinShift, int PinStore, int NumberOfMotors)
MasterVerwalter master(PINDATA,PINSHIFT,PINSTORE,4);
//Objektname.init(int MotorNumber, int StepsToMove, int MovementMode, int Speed, int Direction)
master.init(1,100,ONCE,4,LINKS);
for(int i = 0; i < 100; i++){
master.clock(1);
}
in the constructor one tells, which pins have been used for connecting the board to the arduino,
the init method tells which motor will be used in what kind of a manner (for example here: motor 1, 100 steps, once, every fourth cycle, to the left)
.clock() moves the motors...
one can choose between several movement methods:
...
more later have to go
how can I upload images?