Removed PiJenaSrc; Added motorPiJena submodule

This commit is contained in:
kpetersn
2019-04-08 14:14:10 -05:00
parent d8488c49db
commit f1c366b80a
11 changed files with 5 additions and 1333 deletions
+3
View File
@@ -37,3 +37,6 @@
[submodule "modules/motorMicronix"]
path = modules/motorMicronix
url = https://github.com/epics-motor/motorMicronix.git
[submodule "modules/motorPiJena"]
path = modules/motorPiJena
url = https://github.com/epics-motor/motorPiJena.git
+1
View File
@@ -18,6 +18,7 @@ SUBMODULES += motorMicroMo
SUBMODULES += motorMicronix
SUBMODULES += motorNPoint
SUBMODULES += motorOriel
SUBMODULES += motorPiJena
# Allow sites to add extra submodules
-include Makefile.local
Submodule modules/motorPiJena added at 423a983d0c
-3
View File
@@ -48,9 +48,6 @@ ThorLabsSrc_DEPEND_DIRS = MotorSrc
DIRS += SmartMotorSrc
SmartMotorSrc_DEPEND_DIRS = MotorSrc
DIRS += PiJenaSrc
PiJenaSrc_DEPEND_DIRS = MotorSrc
DIRS += AerotechSrc
AerotechSrc_DEPEND_DIRS = MotorSrc
-20
View File
@@ -1,20 +0,0 @@
# Makefile
TOP = ../..
include $(TOP)/configure/CONFIG
# Both the following line, and a line in the *.dbd file,
# must be uncommented to use diagnostic debugging messages.
USR_CXXFLAGS += -DDEBUG
DBD += devPIJena.dbd
LIBRARY_IOC = PIJena
# piezosystem jena motor controller support
SRCS += devPIJEDS.cc drvPIJEDS.cc PIJEDS_Register.cc
PIJena_LIBS += motor asyn
PIJena_LIBS += $(EPICS_BASE_IOC_LIBS)
include $(TOP)/configure/RULES
-65
View File
@@ -1,65 +0,0 @@
/*
FILENAME... PIJEDS_Register.cc
USAGE... Register piezosystem jena motor device driver shell commands.
*/
/*****************************************************************
COPYRIGHT NOTIFICATION
*****************************************************************
(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO
This software was developed under a United States Government license
described on the COPYRIGHT_UniversityOfChicago file included as part
of this distribution.
**********************************************************************/
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <iocsh.h>
#include "motor.h"
#include "drvPIJEDS.h"
#include "epicsExport.h"
extern "C"
{
// Pi Setup arguments
static const iocshArg setupArg0 = {"Max. controller count", iocshArgInt};
static const iocshArg setupArg1 = {"Polling rate", iocshArgInt};
// Pi Config arguments
static const iocshArg configArg0 = {"Card being configured", iocshArgInt};
static const iocshArg configArg1 = {"asyn port name", iocshArgString};
static const iocshArg configArg2 = {"asyn address (GPIB)", iocshArgInt};
static const iocshArg * const PIJEDSSetupArgs[2] = {&setupArg0, &setupArg1};
static const iocshArg * const PIJEDSConfigArgs[3] = {&configArg0, &configArg1,
&configArg2};
static const iocshFuncDef setupPIJEDS = {"PIJEDSSetup", 2, PIJEDSSetupArgs};
static const iocshFuncDef configPIJEDS = {"PIJEDSConfig", 3, PIJEDSConfigArgs};
static void setupPIJEDSCallFunc(const iocshArgBuf *args)
{
PIJEDSSetup(args[0].ival, args[1].ival);
}
static void configPIJEDSCallFunc(const iocshArgBuf *args)
{
PIJEDSConfig(args[0].ival, args[1].sval, args[2].ival);
}
static void PIJEDSmotorRegister(void)
{
iocshRegister(&setupPIJEDS, setupPIJEDSCallFunc);
iocshRegister(&configPIJEDS, configPIJEDSCallFunc);
}
epicsExportRegistrar(PIJEDSmotorRegister);
} // extern "C"
-129
View File
@@ -1,129 +0,0 @@
Digital Piezo Controller
piezosystem jena
www.piezojena.com
Model: EDS
Tested Version: EDS2, DSM V1.959
RS232: <Programmable>
9600,8,1,N (See setup warning below)
RX EOL: '/r' (13) <cr>
TX FRAMING: '/023'<ascii text>/r/n'/021'
Position Resolution: 0.001 micrometers (um)
=================== serial.cmd =============================
# Piezosystem Jena EDS motor controller/driver setup parameters:
# (1) maximum number of controllers in system
# (2) maximum drives per controller
# (3) motor task polling rate (min=1Hz, max=60Hz)
#drvPIJEDSdebug=1
PIJEDSSetup(1, 2, 60)
# Piezosystem Jena EDS controller/driver configuration parameters:
# (1) controller being configured
# (2) asyn port name (string)
# (3) asyn address (GPIB)
PIJEDSConfig(0, "serial1", 0)
================== motor.substitutions ==================
{P, N, M, DTYP, C, S, DESC, EGU, DIR, VELO,VBAS, ACCL, BDST, BVEL, BACC, MRES, PREC, DHLM, DLLM, INIT}
{xxx:, 9, "m$(N)", "PIJEDS", 0, 0, "motor $(N)", um, Pos, 2., 0, .2, 0, 0, .2, .001, 5, 100, 0, ""}
{xxx:, 10, "m$(N)", "PIJEDS", 0, 1, "motor $(N)", um, Pos, 2., 0, .2, 0, 0, .2, .001, 5, 100, 0, ""}
=================== CONTROLLER SETUP =================
BAUD RATE: 115200 BAUD must be lowered to 9600 to work
with the IP-OCTAL card (VxWorks IOC's).
***WARNING***
The 9600 baud setting does NOT work after the EDS2 is power cycled.
Re-entering the 9600 baud setting is required.
Use Controller's Screen to access motion parameters (PID, notch filter)
PID parameters are not implemented in EPICS device driver because
the other motion calibration settings are not available from EPICS.
============= COMMANDS SYNTAX ==================================
<command>,<axis>,[<arg>]</r>
Where axis = 0, 1, ...,5
* Reply from motion commands '/023/021' (framing characters only)
* Single command per line
Query Reply: <command>,<axis>,<return value>
*** WARNING *** Printing the EDS responses (during debugging)
lockup the vxWorks terminal session (using cu) because
of the framing characters.
=================== MOTION =================
ENABLE/DISABLE Servo - ClosedLoop/OpenLoop
cl,<axis>,[1/0]
MOVE Absolute (set displacement)
set,<axis>,<0 to xxx.xxx>
MOVE Relative
<none>
GO HOME
<none>
SET VELOCITY (slew rate)
sr,<axis>,<xxx.x>
Units: 0.001 ... 500.0 V/ms
STOP MOTION
<none>
=================== STATUS =================
READ Version Info
\r
Return:
READ Commanded position
<none>
READ Feedback position
mess,<axis>
Response: 0 to xxx.xxx um
READ Velocity (programmed)
sr,<axis>
Units: 0.001 ... 500.0 V/ms
ON-TARGET:
<none>
SERVO ENABLE
stat,<axis>
16bit register - bit 7
================== IMPLEMENTATION NOTES ==========================
DRIVER SUPPORT EXCEPTIONS:
NO Relative Motion
NO JOG command
NO DONE indicator
NO Homing
NO Limit Switches
SET_STATUS:
DONE: No DONE indicator so the 'no motion' test is used
to set the DONE status.
No Motion Test: Reference position is not available so
the 'no motion' test was widen to a hard coded
tolerance value based on the MAXIMUM RESOLUTION.
This was needed because of encoder jitter.
-314
View File
@@ -1,314 +0,0 @@
/*
FILENAME... devPIJEDS.cc
USAGE... Motor record device level support for Physik Instrumente (PI)
GmbH & Co. E-516 motor controller.
*/
/*
* Original Author: Joe Sullivan
* Date: 6/07
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log:
* -----------------
* .01 01/29/06 jps - copied from devPIE710.cc
*/
#include <string.h>
#include <errlog.h>
#include "motorRecord.h"
#include "motor.h"
#include "motordevCom.h"
#include "drvPIJEDS.h"
#include "epicsExport.h"
extern struct driver_table PIJEDS_access;
/* ----------------Create the dsets for devPIJEDS----------------- */
static struct driver_table *drvtabptr;
static long PIJEDS_init(int);
static long PIJEDS_init_record(void *);
static long PIJEDS_start_trans(struct motorRecord *);
static RTN_STATUS PIJEDS_build_trans(motor_cmnd, double *, struct motorRecord *);
static RTN_STATUS PIJEDS_end_trans(struct motorRecord *);
struct motor_dset devPIJEDS =
{
{8, NULL, (DEVSUPFUN) PIJEDS_init, (DEVSUPFUN) PIJEDS_init_record, NULL},
motor_update_values,
PIJEDS_start_trans,
PIJEDS_build_trans,
PIJEDS_end_trans
};
extern "C" {epicsExportAddress(dset,devPIJEDS);}
/* --------------------------- program data --------------------- */
/* This table is used to define the command types */
/* WARNING! this must match "motor_cmnd" in motor.h */
static msg_types PIJEDS_table[] = {
MOTION, /* MOVE_ABS */
MOTION, /* MOVE_REL */
MOTION, /* HOME_FOR */
MOTION, /* HOME_REV */
IMMEDIATE, /* LOAD_POS */
IMMEDIATE, /* SET_VEL_BASE */
IMMEDIATE, /* SET_VELOCITY */
IMMEDIATE, /* SET_ACCEL */
IMMEDIATE, /* GO */
IMMEDIATE, /* SET_ENC_RATIO */
INFO, /* GET_INFO */
MOVE_TERM, /* STOP_AXIS */
VELOCITY, /* JOG */
IMMEDIATE, /* SET_PGAIN */
IMMEDIATE, /* SET_IGAIN */
IMMEDIATE, /* SET_DGAIN */
IMMEDIATE, /* ENABLE_TORQUE */
IMMEDIATE, /* DISABL_TORQUE */
IMMEDIATE, /* PRIMITIVE */
IMMEDIATE, /* SET_HIGH_LIMIT */
IMMEDIATE, /* SET_LOW_LIMIT */
VELOCITY /* JOG_VELOCITY */
};
static struct board_stat **PIJEDS_cards;
/* --------------------------- program data --------------------- */
/* initialize device support for PIJEDS stepper motor */
static long PIJEDS_init(int after)
{
long rtnval;
if (!after)
{
drvtabptr = &PIJEDS_access;
(drvtabptr->init)();
}
rtnval = motor_init_com(after, *drvtabptr->cardcnt_ptr, drvtabptr, &PIJEDS_cards);
return(rtnval);
}
/* initialize a record instance */
static long PIJEDS_init_record(void *arg)
{
struct motorRecord *mr = (struct motorRecord *) arg;
/* Disable change of direction testing in record support */
/* This is a closed-loop device */
mr->ntm = menuYesNoNO;
return(motor_init_record_com(mr, *drvtabptr->cardcnt_ptr, drvtabptr, PIJEDS_cards));
}
/* start building a transaction */
static long PIJEDS_start_trans(struct motorRecord *mr)
{
motor_start_trans_com(mr, PIJEDS_cards);
return(OK);
}
/* end building a transaction */
static RTN_STATUS PIJEDS_end_trans(struct motorRecord *mr)
{
motor_end_trans_com(mr, drvtabptr);
return(OK);
}
/* add a part to the transaction */
static RTN_STATUS PIJEDS_build_trans(motor_cmnd command, double *parms, struct motorRecord *mr)
{
struct motor_trans *trans = (struct motor_trans *) mr->dpvt;
struct mess_node *motor_call;
struct controller *brdptr;
struct PIJEDScontroller *cntrl;
char buff[110];
int card, maxdigits;
unsigned int size;
double dval, cntrl_units, res;
RTN_STATUS rtnval;
bool send;
send = true; /* Default to send motor command. */
rtnval = OK;
buff[0] = '\0';
/* Protect against NULL pointer with WRTITE_MSG(GO/STOP_AXIS/GET_INFO, NULL). */
dval = (parms == NULL) ? 0.0 : *parms;
rtnval = (RTN_STATUS) motor_start_trans_com(mr, PIJEDS_cards);
motor_call = &(trans->motor_call);
card = motor_call->card;
motor_call->type = PIJEDS_table[command];
brdptr = (*trans->tabptr->card_array)[card];
if (brdptr == NULL)
return(rtnval = ERROR);
cntrl = (struct PIJEDScontroller *) brdptr->DevicePrivate;
res = cntrl->drive_resolution[motor_call->signal];
cntrl_units = dval;
maxdigits = EDS_MAX_RES;
if (PIJEDS_table[command] > motor_call->type)
motor_call->type = PIJEDS_table[command];
if (trans->state != BUILD_STATE)
return(rtnval = ERROR);
if (command == PRIMITIVE && mr->init != NULL && strlen(mr->init) != 0)
strcat(motor_call->message, mr->init);
switch (command)
{
case MOVE_ABS:
case MOVE_REL:
case HOME_FOR:
case HOME_REV:
case JOG:
if (strlen(mr->prem) != 0)
{
strcat(motor_call->message, mr->prem);
rtnval = motor_end_trans_com(mr, drvtabptr);
rtnval = (RTN_STATUS) motor_start_trans_com(mr, PIJEDS_cards);
motor_call->type = PIJEDS_table[command];
}
if (strlen(mr->post) != 0)
motor_call->postmsgptr = (char *) &mr->post;
break;
default:
break;
}
switch (command)
{
case MOVE_ABS:
sprintf(buff, "set,#,%.*f", maxdigits, (cntrl_units * res));
break;
case MOVE_REL:
send = false;
break;
case HOME_FOR:
case HOME_REV:
send = false;
break;
case LOAD_POS:
send = false;
break;
case SET_VEL_BASE:
send = false; /* DC motor; not base velocity. */
break;
case SET_VELOCITY:
sprintf(buff, "sr,#,%.*f", maxdigits, (cntrl_units * res));
break;
case ENABLE_TORQUE:
strcpy(buff, "cl,#,1");
break;
case DISABL_TORQUE:
strcpy(buff, "cl,#,0");
break;
case SET_ACCEL:
/* The PIJEDS does not support acceleration commands. */
send = false;
break;
case GO:
/* The PIJEDS starts moving immediately on move commands
* Must send a command for driver expects a response */
strcpy(buff, "stat,#");
break;
case PRIMITIVE:
case GET_INFO:
/* These commands are not actually done by sending a message, but
rather they will indirectly cause the driver to read the status
of all motors */
send=false;
break;
case STOP_AXIS:
/* No stop command available - use move relative 0 */
send = false;
break;
case JOG_VELOCITY:
case JOG:
sprintf(buff, "sr,#,%.*f", maxdigits, (cntrl_units * res));
break;
case SET_PGAIN:
send = false;
break;
case SET_IGAIN:
send = false;
break;
case SET_DGAIN:
send = false;
break;
case SET_HIGH_LIMIT:
case SET_LOW_LIMIT:
case SET_ENC_RATIO:
trans->state = IDLE_STATE; /* No command sent to the controller. */
send = false;
break;
default:
send = false;
rtnval = ERROR;
}
size = strlen(buff);
if (send == false)
return(rtnval);
else if (size > sizeof(buff) || (strlen(motor_call->message) + size) > MAX_MSG_SIZE)
errlogMessage("PIJEDS_build_trans(): buffer overflow.\n");
else
{
strcat(motor_call->message, buff);
rtnval = motor_end_trans_com(mr, drvtabptr);
}
return(rtnval);
}
-7
View File
@@ -1,7 +0,0 @@
# Piezosystem jena motor controllers
device(motor,VME_IO,devPIJEDS,"PIJEDS")
driver(drvPIJEDS)
registrar(PIJEDSmotorRegister)
variable(drvPIJEDSdebug)
-710
View File
@@ -1,710 +0,0 @@
/*
FILENAME... drvPIJEDS.cc
USAGE... Motor record driver level support for piezosystem jena
GmbH & Co. E-516 motor controller.
/*
* Original Author: Joe Sullivan
* Date: 6/07
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log:
* -----------------
* .01 03/26/07 jps - copied from drvPIC710.cc tested on PI VER "DSP V3.11,MCU V5"
*/
/*
DESIGN LIMITATIONS...
1 - Like all controllers, the PIJEDS must be powered-on when EPICS is first
booted up.
*/
#include <string.h>
#include <math.h>
#include <epicsThread.h>
#include <drvSup.h>
#include <stdlib.h>
#include <errlog.h>
#include "motorRecord.h"
#include "motor.h"
#include "drvPIJEDS.h"
#include "epicsExport.h"
#define GET_IDENT ""
#define BUFF_SIZE 100 /* Maximum length of string to/from PIJEDS */
/*----------------debugging-----------------*/
volatile int drvPIJEDSdebug = 0;
extern "C" {epicsExportAddress(int, drvPIJEDSdebug);}
static inline void Debug(int level, const char *format, ...) {
#ifdef DEBUG
if (level < drvPIJEDSdebug) {
va_list pVar;
va_start(pVar, format);
vprintf(format, pVar);
va_end(pVar);
}
#endif
}
/* --- Local data. --- */
int PIJEDS_num_cards = 0;
static char *PIJEDS_axis[] = {"0", "1", "2", "3", "4", "5"};
/* Command Information - used by set_status() */
#define EDS_CMNDS_MAX 3
#define EDS_POS 0
#define EDS_STATUS 1
#define EDS_SLEW 2
#define READ_POS "mess,#" /* Read position command */
#define READ_STATUS "stat,#" /* Read Motor Status */
#define READ_SLEW "sr,#" /* Read Slew Velocity V/ms */
static char *EDS_CMNDS[] = {READ_POS, READ_STATUS, READ_SLEW};
/* See fillCmndInfo() */
static struct cmndInfo_struct {
char sendStr[10]; /* Command String */
char searchStr[3]; /* Partial command string to check reply */
int dataIndex; /* Index into reply for data */
} cmndInfo[EDS_CMNDS_MAX];
static unsigned long fdbk_tolerance; /* Divisor to shift position - for DONE */
/* Local data required for every driver; see "motordrvComCode.h" */
#include "motordrvComCode.h"
/*----------------functions-----------------*/
static int recv_mess(int, char *, int);
static RTN_STATUS send_mess(int, char const *, char *);
static int set_status(int, int);
static long report(int);
static long init();
static int motor_init();
static void fillCmndInfo();
static void query_done(int, int, struct mess_node *);
/*----------------functions-----------------*/
struct driver_table PIJEDS_access =
{
motor_init,
motor_send,
motor_free,
motor_card_info,
motor_axis_info,
&mess_queue,
&queue_lock,
&free_list,
&freelist_lock,
&motor_sem,
&motor_state,
&total_cards,
&any_motor_in_motion,
send_mess,
recv_mess,
set_status,
query_done,
NULL,
&initialized,
PIJEDS_axis
};
struct drvPIJEDS_drvet
{
long number;
long (*report) (int);
long (*init) (void);
} drvPIJEDS = {2, report, init};
extern "C" {epicsExportAddress(drvet, drvPIJEDS);}
static struct thread_args targs = {SCAN_RATE, &PIJEDS_access, 0.0};
/*********************************************************
* Print out driver status report
*********************************************************/
static long report(int level)
{
int card;
if (PIJEDS_num_cards <=0)
printf(" No PIJEDS controllers configured.\n");
else
{
for (card = 0; card < PIJEDS_num_cards; card++)
{
struct controller *brdptr = motor_state[card];
if (brdptr == NULL)
printf(" PIJEDS controller %d connection failed.\n", card);
else
{
struct PIJEDScontroller *cntrl;
cntrl = (struct PIJEDScontroller *) brdptr->DevicePrivate;
printf(" PIJEDS controller #%d, port=%s, id: %s \n", card,
cntrl->asyn_port, brdptr->ident);
}
}
}
return(OK);
}
static long init()
{
/*
* We cannot call motor_init() here, because that function can do GPIB I/O,
* and hence requires that the drvGPIB have already been initialized.
* That cannot be guaranteed, so we need to call motor_init from device
* support
*/
/* Check for setup */
if (PIJEDS_num_cards <= 0)
{
Debug(1, "init(): PIJEDS driver disabled. PIJEDSSetup() missing from startup script.\n");
}
return((long) 0);
}
static void query_done(int card, int axis, struct mess_node *nodeptr)
{
}
/********************************************************************************
* *
* FUNCTION NAME: set_status *
* *
* LOGIC: *
* Initialize. *
* Send "Moving Status" query. *
* Read response. *
* IF normal response to query. *
* Set communication status to NORMAL. *
* ELSE *
* IF communication status is NORMAL. *
* Set communication status to RETRY. *
* NORMAL EXIT. *
* ELSE *
* Set communication status error. *
* ERROR EXIT. *
* ENDIF *
* ENDIF *
* *
* IF "Moving Status" indicates any motion (i.e. status != 0). *
* Clear "Done Moving" status bit. *
* ELSE *
* Set "Done Moving" status bit. *
* ENDIF *
* *
* *
********************************************************************************/
static int set_status(int card, int signal)
{
struct PIJEDScontroller *cntrl;
struct mess_node *nodeptr;
struct mess_info *motor_info;
struct motorRecord *mr;
/* Message parsing variables */
struct cmndInfo_struct *pInfo;
char buff[BUFF_SIZE];
char *pdata;
int rtn_state;
EDS_Status_Reg statusReg;
epicsInt32 motorData;
unsigned long posDelta;
bool plusdir, ls_active, plusLS, minusLS;
bool readOK;
msta_field status;
cntrl = (struct PIJEDScontroller *) motor_state[card]->DevicePrivate;
motor_info = &(motor_state[card]->motor_info[signal]);
nodeptr = motor_info->motor_motion;
if (nodeptr != NULL)
mr = (struct motorRecord *) nodeptr->mrecord;
else
mr = NULL;
status.All = motor_info->status.All;
recv_mess(card, buff, FLUSH);
readOK = false;
// Read controller status word
pInfo = &cmndInfo[EDS_STATUS];
send_mess(card, pInfo->sendStr, PIJEDS_axis[signal]);
if (recv_mess(card, buff, 1) && (pdata=strstr(buff,pInfo->searchStr)))
{
// sscanf(pdata+pInfo->dataIndex, "%d", (int *)&statusReg.All);
statusReg.All = atoi(pdata+pInfo->dataIndex);
Debug(2, "set_status(): statusStr: %s, statusReg=0x%x\n", pdata, statusReg.All);
// Read motor position
pInfo = &cmndInfo[EDS_POS];
send_mess(card, pInfo->sendStr, PIJEDS_axis[signal]);
if (recv_mess(card, buff, 1) && (pdata=strstr(buff,pInfo->searchStr)))
{
motorData = NINT(atof(pdata+pInfo->dataIndex) / cntrl->drive_resolution[signal]);
Debug(2, "set_status(): posString: %s, posData=%d\n", pdata, motorData);
readOK = true;
}
else
Debug(1, "set_status(): posString: ERROR!\n");
}
else
Debug(1, "set_status(): statusString: ERROR!\n");
if (readOK)
{
cntrl->status = NORMAL;
status.Bits.CNTRL_COMM_ERR = 0;
}
else
{
if (cntrl->status == NORMAL)
{
cntrl->status = RETRY;
rtn_state = OK;
goto exit;
}
else
{
cntrl->status = COMM_ERR;
status.Bits.CNTRL_COMM_ERR = 1;
status.Bits.RA_PROBLEM = 1;
rtn_state = 1;
goto exit;
}
}
/* No direct DONE status on the EDS controller
* DONE is derived from delta position test */
status.Bits.RA_DONE = 0;
status.Bits.RA_HOME = status.Bits.RA_DONE;
status.Bits.EA_POSITION = (statusReg.Bits.closeLoop) ? 1 : 0; /* Torgue disabled flag */
/* No Limit switches */
ls_active = plusLS = minusLS = false;
// When comparing feedback position - allow for sloppyness
posDelta = abs(motorData-motor_info->position);
Debug(5, "set_status(): deltaPos: %ld\n", posDelta);
/* Reference position is not available so
* widen the 'no motion' test because of encoder
* jitter. */
// if (motorData == motor_info->position)
if (posDelta < fdbk_tolerance)
{
if (motor_info->no_motion_count)
{
status.Bits.RA_DONE = 1;
status.Bits.RA_HOME = status.Bits.RA_DONE;
}
if (nodeptr != 0) /* Increment counter only if motor is moving. */
motor_info->no_motion_count++;
}
else
{
status.Bits.RA_DIRECTION = (motorData >= motor_info->position) ? 1 : 0;
motor_info->no_motion_count = 0;
}
motor_info->position = motor_info->encoder_position = motorData;
plusdir = (status.Bits.RA_DIRECTION) ? true : false;
/* Set limit switch error indicators. */
if (plusLS == true)
{
status.Bits.RA_PLUS_LS = 1;
if (plusdir == true)
ls_active = true;
}
else
status.Bits.RA_PLUS_LS = 0;
if (minusLS == true)
{
status.Bits.RA_MINUS_LS = 1;
if (plusdir == false)
ls_active = true;
}
else
status.Bits.RA_MINUS_LS = 0;
/* encoder status */
status.Bits.EA_SLIP = 0;
status.Bits.EA_SLIP_STALL = 0;
status.Bits.EA_HOME = 0;
status.Bits.RA_PROBLEM = 0;
/* Parse motor velocity? */
/* NEEDS WORK */
motor_info->velocity = 0;
// if (!status.Bits.RA_DIRECTION)
// motor_info->velocity *= -1;
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
/* Test for post-move string. */
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
nodeptr->postmsgptr != 0)
{
strcpy(buff, nodeptr->postmsgptr);
send_mess(card, buff, (char*) NULL);
nodeptr->postmsgptr = NULL;
}
exit:
motor_info->status.All = status.All;
return(rtn_state);
}
/*****************************************************/
/* send a message to the PIJEDS board */
/* send_mess() */
/*****************************************************/
static RTN_STATUS send_mess(int card, char const *com, char *name)
{
char local_buff[MAX_MSG_SIZE];
char *pbuff;
struct PIJEDScontroller *cntrl;
int comsize, namesize;
size_t nwrite;
comsize = (com == NULL) ? 0 : strlen(com);
namesize = (name == NULL) ? 0 : strlen(name);
if ((comsize + namesize) > MAX_MSG_SIZE)
{
errlogMessage("drvPIJEDS.cc:send_mess(); message size violation.\n");
return(ERROR);
}
// Allow empty message strings - returns version info */
// else if (comsize == 0) /* Normal exit on empty input message. */
// return(OK);
if (!motor_state[card])
{
errlogPrintf("drvPIJEDS.cc:send_mess() - invalid card #%d\n", card);
return(ERROR);
}
local_buff[0] = (char) NULL; /* Terminate local buffer. */
if (name == NULL)
strcat(local_buff, com); /* Make a local copy of the string. */
else
{
strcpy(local_buff, com);
pbuff = strchr(local_buff, '#');
if (pbuff != NULL)
*pbuff = *name;
else
Debug(1, "send_mess(): NAME ERROR: message = %s\n", local_buff);
}
Debug(3, "send_mess(): message = %s\n", local_buff);
cntrl = (struct PIJEDScontroller *) motor_state[card]->DevicePrivate;
pasynOctetSyncIO->write(cntrl->pasynUser, local_buff, strlen(local_buff),
COMM_TIMEOUT, &nwrite);
return(OK);
}
/*****************************************************/
/* receive a message from the PIJEDS board */
/* recv_mess() */
/*****************************************************/
static int recv_mess(int card, char *com, int flag)
{
struct PIJEDScontroller *cntrl;
size_t nread = 0;
asynStatus status = asynError;
int eomReason;
/* Check that card exists */
if (!motor_state[card])
return(ERROR);
cntrl = (struct PIJEDScontroller *) motor_state[card]->DevicePrivate;
if (flag == FLUSH)
pasynOctetSyncIO->flush(cntrl->pasynUser);
else
status = pasynOctetSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE,
COMM_TIMEOUT, &nread, &eomReason);
if ((status != asynSuccess) || (nread <= 0))
{
com[0] = '\0';
nread = 0;
}
Debug(3, "recv_mess(): message = \"%s\"\n", com);
return(nread);
}
/*****************************************************/
/* Setup system configuration */
/* PIJEDSSetup() */
/*****************************************************/
RTN_STATUS
PIJEDSSetup(int num_cards, /* maximum number of controllers in system. */
int scan_rate) /* polling rate - 1/60 sec units. */
{
int itera;
if (num_cards < 1 || num_cards > PIJEDS_NUM_CARDS)
PIJEDS_num_cards = PIJEDS_NUM_CARDS;
else
PIJEDS_num_cards = num_cards;
/* Set motor polling task rate */
if (scan_rate >= 1 && scan_rate <= 60)
targs.motor_scan_rate = scan_rate;
else
targs.motor_scan_rate = SCAN_RATE;
/*
* Allocate space for motor_state structures. Note this must be done
* before PIJEDSConfig is called, so it cannot be done in motor_init()
* This means that we must allocate space for a card without knowing
* if it really exists, which is not a serious problem
*/
motor_state = (struct controller **) malloc(PIJEDS_num_cards *
sizeof(struct controller *));
for (itera = 0; itera < PIJEDS_num_cards; itera++)
motor_state[itera] = (struct controller *) NULL;
return(OK);
}
/*****************************************************/
/* Configure a controller */
/* PIJEDSConfig() */
/*****************************************************/
RTN_STATUS
PIJEDSConfig(int card, /* card being configured */
const char *name, /* asyn port name */
int addr) /* asyn address (GPIB) */
{
struct PIJEDScontroller *cntrl;
if (card < 0 || card >= PIJEDS_num_cards)
return(ERROR);
motor_state[card] = (struct controller *) malloc(sizeof(struct controller));
motor_state[card]->DevicePrivate = malloc(sizeof(struct PIJEDScontroller));
cntrl = (struct PIJEDScontroller *) motor_state[card]->DevicePrivate;
strcpy(cntrl->asyn_port, name);
cntrl->asyn_address = addr;
return(OK);
}
/*****************************************************/
/* initialize all software and hardware */
/* This is called from the initialization routine in */
/* device support. */
/* motor_init() */
/*****************************************************/
static int motor_init()
{
struct controller *brdptr;
struct PIJEDScontroller *cntrl;
int card_index, motor_index;
char buff[BUFF_SIZE], *pbuff;
int total_axis;
int status;
int version;
bool online;
asynStatus success_rtn;
static const char output_terminator[] = EDS_OUT_EOS;
static const char input_terminator[] = EDS_IN_ETX;
initialized = true; /* Indicate that driver is initialized. */
/* Check for setup */
if (PIJEDS_num_cards <= 0)
return(ERROR);
/* Fill out EDS command string information - used by set_status() */
fillCmndInfo();
for (card_index = 0; card_index < PIJEDS_num_cards; card_index++)
{
if (!motor_state[card_index])
continue;
brdptr = motor_state[card_index];
brdptr->ident[0] = (char) NULL; /* No controller identification message. */
brdptr->cmnd_response = true;
total_cards = card_index + 1;
cntrl = (struct PIJEDScontroller *) brdptr->DevicePrivate;
status = version = 0;
/* Initialize communications channel */
success_rtn = pasynOctetSyncIO->connect(cntrl->asyn_port, 0,
&cntrl->pasynUser, NULL);
if (success_rtn == asynSuccess)
{
int retry = 0;
pasynOctetSyncIO->setOutputEos(cntrl->pasynUser, output_terminator,
strlen(output_terminator));
pasynOctetSyncIO->setInputEos(cntrl->pasynUser, input_terminator,
strlen(input_terminator));
/* Send a message to the board, see if it exists */
/* flush any junk at input port - should not be any data available */
pasynOctetSyncIO->flush(cntrl->pasynUser);
/* Assure that Controller is ONLINE */
do
{
online = false;
/* Set Controller to ONLINE mode */
send_mess(card_index, GET_IDENT, (char*) NULL);
if ((status = recv_mess(card_index, buff, 1)))
online = (strstr(buff,"DSM")) ? true : false;
else
retry++;
} while (online == false && retry < 3);
}
if (success_rtn == asynSuccess && online == true)
{
/* Parse out EDS revision (3 decimal places) and convert to int */
if ((pbuff = strchr(buff, 'V')))
version = NINT(atof(pbuff+1) * 1000);
else
version = 0;
strcpy(brdptr->ident, buff);
brdptr->localaddr = (char *) NULL;
brdptr->motor_in_motion = 0;
/* Check for supported EDS versions */
if (version >= 1959)
cntrl->versionSupport = true;
else
cntrl->versionSupport = false;
/* Determine # of axes. Request stage name. See if it responds */
for (total_axis = 0; total_axis < EDS_MAX_MOTORS; total_axis++)
{
send_mess(card_index, READ_POS, PIJEDS_axis[total_axis]);
status = recv_mess(card_index, buff, 1);
if (strstr(buff,"not present"))
break;
}
brdptr->total_axis = total_axis;
/* fdbk_tolerance = 10^^(MAX_RES - 1) */
/* Used in set_status() to calculate DONE/NO_MOTION */
fdbk_tolerance = (unsigned long)pow(10.0,(double)(EDS_MAX_RES-1));
for (motor_index = 0; motor_index < total_axis; motor_index++)
{
struct mess_info *motor_info = &brdptr->motor_info[motor_index];
motor_info->status.All = 0;
motor_info->no_motion_count = 0;
motor_info->encoder_position = 0;
motor_info->position = 0;
brdptr->motor_info[motor_index].motor_motion = NULL;
/* PIJEDS has DC motor support only */
motor_info->encoder_present = YES;
motor_info->status.Bits.EA_PRESENT = 1;
motor_info->pid_present = NO;
motor_info->status.Bits.GAIN_SUPPORT = 1;
cntrl->drive_resolution[motor_index] = 1.0/pow(10.0,(double)EDS_MAX_RES);
set_status(card_index, motor_index); /* Read status of each motor */
}
}
else
motor_state[card_index] = (struct controller *) NULL;
}
any_motor_in_motion = 0;
mess_queue.head = (struct mess_node *) NULL;
mess_queue.tail = (struct mess_node *) NULL;
free_list.head = (struct mess_node *) NULL;
free_list.tail = (struct mess_node *) NULL;
epicsThreadCreate((char *) "PIJEDS_motor", epicsThreadPriorityMedium,
epicsThreadGetStackSize(epicsThreadStackMedium),
(EPICSTHREADFUNC) motor_task, (void *) &targs);
return(OK);
}
static void fillCmndInfo()
{
int index;
struct cmndInfo_struct *pInfo = cmndInfo;
char **pCmndStr = EDS_CMNDS;
for (index = 0; index < EDS_CMNDS_MAX; index++, pInfo++, pCmndStr++)
{
strcpy(pInfo->sendStr,*pCmndStr); /* Command String */
strncpy(pInfo->searchStr,*pCmndStr,2); /* Partial Cmnd to check reply */
pInfo->dataIndex = strlen(*pCmndStr) + 1; /* Index to reply data */
}
}
-85
View File
@@ -1,85 +0,0 @@
/* File: drvPIJEDS.h */
/* Device Driver Support definitions for motor */
/*
* Original Author: Ron Sluiter
* Current Author: Joe Sullivan
* Date: 09/20/2005
*
* Modification Log:
* -----------------
* .00 09/13/2006 jps copied from drvPIC838.h
*/
#ifndef INCdrvPIJEDSh
#define INCdrvPIJEDSh 1
#include "motordrvCom.h"
#include "asynDriver.h"
#include "asynDriver.h"
#include "asynOctetSyncIO.h"
#define COMM_TIMEOUT 2 /* Timeout in seconds. */
#define EDS_MAX_RES 3 /* Position resolution (significant digits) */
#define EDS_OUT_EOS "\r" /* Command End-Of-Line = CR (0x13) */
#define EDS_IN_STX "\023" /* Reply Start (frame character) */
#define EDS_IN_ETX "\021" /* Reply End (framing Character) */
#define EDS_VERSION 1959 /* Driver tested against EDS DSM V1.959 */
#define EDS_MAX_MOTORS 6 /* maximum motors per controller */
#define PIJEDS_NUM_CARDS 10 /* Maximum number of support controllers */
struct PIJEDScontroller
{
asynUser *pasynUser; /* asynUser structure */
int asyn_address; /* Use for GPIB or other address with asyn */
CommStatus status; /* Controller communication status. */
double drive_resolution[EDS_MAX_MOTORS];
bool versionSupport; /* Track supported Versions - include in Report */
char asyn_port[80]; /* asyn port name */
};
/* Types of position feedback */
#define EDS_FDBK_NONE 0
#define EDS_FDBK_STRAIN 1
#define EDS_FDBK_CAPACITIVE 2 /* Typical */
#define EDS_FDBK_INDUCTIVE 3
/* Controller Status Word */
typedef union
{
epicsUInt16 All;
struct
{
#ifdef MSB_First
unsigned int nabyte :8; /* 8-15 */
unsigned int closeLoop :1; /* 7 - Closed Loop Mode */
unsigned int piezoDecontrol :1; /* 6 - Piezo Voltage Decontroled */
unsigned int na5 :1; /* 5 - NA. */
unsigned int openLoop :1; /* 4 - Open Loop Mode */
unsigned int na3 :1; /* 3 NA */
unsigned int fdbkType :2; /* 1&2 - Feedback Type - EDS_FDBK_nnnnn */
unsigned int motorExist :1; /* 0 - Motor plugged into controller */
#else
unsigned int motorExist :1; /* 0 - Motor plugged into controller */
unsigned int fdbkType :2; /* 1&2 - Feedback Type - EDS_FDBK_nnnnn */
unsigned int na3 :1; /* 3 NA */
unsigned int openLoop :1; /* 4 - Open Loop Mode */
unsigned int na5 :1; /* 5 - NA. */
unsigned int piezoDecontrol :1; /* 6 - Piezo Voltage Decontroled */
unsigned int closeLoop :1; /* 7 - Closed Loop Mode */
unsigned int nabyte :8; /* 8-15 */
#endif
} Bits;
} EDS_Status_Reg;
/* Function prototypes. */
extern RTN_STATUS PIJEDSSetup(int, int);
extern RTN_STATUS PIJEDSConfig(int, const char *, int);
#endif /* INCdrvPIJEDSh */