00001 #ifndef __CPHIDGETSTEPPER
00002 #define __CPHIDGETSTEPPER
00003 #include "cphidget.h"
00004
00011 DPHANDLE(Stepper)
00012 CHDRSTANDARD(Stepper)
00013
00014
00020 CHDRGET(Stepper,InputCount,int *count)
00027 CHDRGETINDEX(Stepper,InputState,int *inputState)
00034 CHDREVENTINDEX(Stepper,InputChange,int inputState)
00035
00041 CHDRGET(Stepper,MotorCount,int *count)
00042
00049 CHDRGETINDEX(Stepper,Acceleration,double *acceleration)
00056 CHDRSETINDEX(Stepper,Acceleration,double acceleration)
00063 CHDRGETINDEX(Stepper,AccelerationMax,double *max)
00070 CHDRGETINDEX(Stepper,AccelerationMin,double *min)
00071
00078 CHDRGETINDEX(Stepper,VelocityLimit,double *limit)
00085 CHDRSETINDEX(Stepper,VelocityLimit,double limit)
00092 CHDRGETINDEX(Stepper,Velocity,double *velocity)
00099 CHDRGETINDEX(Stepper,VelocityMax,double *max)
00106 CHDRGETINDEX(Stepper,VelocityMin,double *min)
00113 CHDREVENTINDEX(Stepper,VelocityChange,double velocity)
00114
00121 CHDRGETINDEX(Stepper,TargetPosition,__int64 *position)
00128 CHDRSETINDEX(Stepper,TargetPosition,__int64 position)
00135 CHDRGETINDEX(Stepper,CurrentPosition,__int64 *position)
00142 CHDRSETINDEX(Stepper,CurrentPosition,__int64 position)
00149 CHDRGETINDEX(Stepper,PositionMax,__int64 *max)
00156 CHDRGETINDEX(Stepper,PositionMin,__int64 *min)
00163 CHDREVENTINDEX(Stepper,PositionChange,__int64 position)
00164
00171 CHDRGETINDEX(Stepper,CurrentLimit,double *limit)
00178 CHDRSETINDEX(Stepper,CurrentLimit,double limit)
00185 CHDRGETINDEX(Stepper,Current,double *current)
00192 CHDRGETINDEX(Stepper,CurrentMax,double *max)
00199 CHDRGETINDEX(Stepper,CurrentMin,double *min)
00206 CHDREVENTINDEX(Stepper,CurrentChange,double current)
00207
00214 CHDRGETINDEX(Stepper,Engaged,int *engagedState)
00221 CHDRSETINDEX(Stepper,Engaged,int engagedState)
00228 CHDRGETINDEX(Stepper,Stopped,int *stoppedState)
00229
00230 #ifndef EXTERNALPROTO
00231
00232 #define STEPPER_MAXSTEPPERS 8
00233 #define STEPPER_MAXINPUTS 8
00234
00235 #define BIPOLAR_STEPPER_CURRENT_SENSE_GAIN 8.5
00236 #define BIPOLAR_STEPPER_CURRENT_LIMIT_Rs 0.150
00237
00238
00239 #define MOTOR_DONE_STEPPER 0x10
00240 #define MOTOR_DISABLED_STEPPER 0x20
00241
00242
00243 #define STEPPER_POSITION_PACKET 0x00
00244 #define STEPPER_VEL_ACCEL_PACKET 0x10
00245 #define STEPPER_RESET_PACKET 0x20
00246
00247 struct _CPhidgetStepper{
00248 CPhidget phid;
00249
00250 int (CCONV *fptrPositionChange)(CPhidgetStepperHandle, void *, int, __int64);
00251 int (CCONV *fptrPositionChange32)(CPhidgetStepperHandle, void *, int, int);
00252 int (CCONV *fptrVelocityChange)(CPhidgetStepperHandle, void *, int, double);
00253 int (CCONV *fptrCurrentChange)(CPhidgetStepperHandle, void *, int, double);
00254 int (CCONV *fptrInputChange)(CPhidgetStepperHandle, void *, int, int);
00255
00256 void *fptrPositionChangeptr;
00257 void *fptrPositionChange32ptr;
00258 void *fptrInputChangeptr;
00259 void *fptrCurrentChangeptr;
00260 void *fptrVelocityChangeptr;
00261
00262
00263 unsigned char inputState[STEPPER_MAXINPUTS];
00264 __int64 motorPositionEcho[STEPPER_MAXSTEPPERS];
00265 double motorSpeedEcho[STEPPER_MAXSTEPPERS];
00266 double motorSensedCurrent[STEPPER_MAXSTEPPERS];
00267 unsigned char motorEngagedStateEcho[STEPPER_MAXSTEPPERS];
00268 unsigned char motorStoppedState[STEPPER_MAXSTEPPERS];
00269 int packetCounterEcho[STEPPER_MAXSTEPPERS];
00270
00271
00272 __int64 motorPosition[STEPPER_MAXSTEPPERS];
00273 __int64 motorPositionReset[STEPPER_MAXSTEPPERS];
00274 double motorAcceleration[STEPPER_MAXSTEPPERS];
00275 double motorSpeed[STEPPER_MAXSTEPPERS];
00276 double motorCurrentLimit[STEPPER_MAXSTEPPERS];
00277 unsigned char motorEngagedState[STEPPER_MAXSTEPPERS];
00278 int packetCounter[STEPPER_MAXSTEPPERS];
00279
00280 double motorSpeedMax, motorSpeedMin;
00281 double accelerationMax, accelerationMin;
00282 __int64 motorPositionMax, motorPositionMin;
00283 double currentMax, currentMin;
00284 int microSteps;
00285
00286 unsigned char outputPacket[MAX_OUT_PACKET_SIZE];
00287 unsigned int outputPacketLen;
00288 } typedef CPhidgetStepperInfo;
00289 #endif
00290
00293 #endif
00294