Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 254 → Rev 255

/cvi/instr/uSMC/8SMC1-USBhF User Manual.pdf
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: instr/uSMC/USMCDLL.h
===================================================================
--- instr/uSMC/USMCDLL.h (nonexistent)
+++ instr/uSMC/USMCDLL.h (revision 255)
@@ -0,0 +1,273 @@
+// USMCDLL.h - header file with declorations of USMCDLL.dll functions and used structures
+// -SD
+// Note::C++
+// Use functions with reference arguments as in sample
+// Note.C
+// Use functions with address of operator in invoke expression: func(var1, &struct);
+// (For Rev. 24) Will work correctly with firmware version 24.03 or better
+
+#pragma once
+
+#include <windows.h>
+
+// Please use the USMCDLL.lib to easely import functions from dll with "dllimport" (In Microsoft Visual Studio)
+#ifdef USMCDLL_EXPORTS
+#define USMCDLL_API __declspec(dllexport)
+#else
+#define USMCDLL_API __declspec(dllimport)
+#endif
+
+// Structure representing connected devices
+typedef struct USMC_Devices_st{
+ DWORD NOD; // Number of the devices ready to work
+
+ char **Serial; // Array of 16 byte ASCII strings
+ char **Version; // Array of 4 byte ASCII strings
+} USMC_Devices; // Structure representing connected devices
+
+// Structure representing some of divice parameters
+typedef struct USMC_Parameters_st{
+ float AccelT; // Acceleration time (in ms)
+ float DecelT; // Deceleration time (in ms)
+ float PTimeout; // Time (in ms) after which current will be reduced to 60% of normal
+ float BTimeout1; // Time (in ms) after which speed of step motor rotation will be equal to the one specified at
+ // BTO1P field (see below). (This parameter is used when controlling step motor using buttons)
+ float BTimeout2; //
+ float BTimeout3; //
+ float BTimeout4; //
+ float BTimeoutR; // Time (in ms) after which reset command will be performed
+ float BTimeoutD; // This field is reserved for future use
+ float MinP; // Speed (steps/sec) while performing reset operation. (This parameter is used when controlling
+ // step motor using buttons)
+ float BTO1P; // Speed (steps/sec) after BTIMEOUT 1 time have passed. (This parameter is used when controlling
+ // step motor using buttons)
+ float BTO2P; //
+ float BTO3P; //
+ float BTO4P; //
+ WORD MaxLoft; // Value in full steps that will be used performing backlash operation
+ DWORD StartPos; // Current Position Saved to FLASH (see Test MicroSMC.cpp)
+ WORD RTDelta; // Revolution distance – number of full steps per one full revolution
+ WORD RTMinError; // Number of full steps missed to raise the error flag
+ float MaxTemp; // Maximum allowed temperature (Celsius)
+ BYTE SynOUTP; // Duration of the output synchronization pulse
+ float LoftPeriod; // Speed of the last phase of the backlash operation.
+ float EncMult; // Should be <Encoder Steps per Evolution> / <SM Steps per Evolution> and should be integer multiplied by 0.25
+
+ BYTE Reserved[16]; // <Unused> File padding
+
+} USMC_Parameters;
+
+// Structure representing start function parameters
+typedef struct USMC_StartParameters_st{
+ BYTE SDivisor; // Step is divided by this factor (1,2,4,8)
+ BOOL DefDir; // Direction for backlash operation (relative)
+ BOOL LoftEn; // Enable automatic backlash operation (works if slow start/stop mode is off)
+ BOOL SlStart; // If TRUE slow start/stop mode enabled.
+ BOOL WSyncIN; // If TRUE controller will wait for input synchronization signal to start
+ BOOL SyncOUTR; // If TRUE output synchronization counter will be reset
+ BOOL ForceLoft; // If TRUE and destination position is equal to the current position backlash operation will be performed.
+ BYTE Reserved[4]; // <Unused> File padding
+} USMC_StartParameters;
+
+// Structure representing some of divice parameters
+typedef struct USMC_Mode_st{
+ BOOL PMode; // Turn off buttons (TRUE - buttons disabled)
+ BOOL PReg; // Current reduction regime (TRUE - regime is on)
+ BOOL ResetD; // Turn power off and make a whole step (TRUE - apply)
+ BOOL EMReset; // Quick power off
+ BOOL Tr1T; // Trailer 1 TRUE state (TRUE : +3/+5Â; FALSE : 0Â)
+ BOOL Tr2T; // Trailer 2 TRUE state (TRUE : +3/+5Â; FALSE : 0Â)
+ BOOL RotTrT; // Rotary Transducer TRUE state (TRUE : +3/+5Â; FALSE : 0Â)
+ BOOL TrSwap; // If TRUE, Trailers are treated to be swapped
+ BOOL Tr1En; // If TRUE Trailer 1 Operation Enabled
+ BOOL Tr2En; // If TRUE Trailer 2 Operation Enabled
+ BOOL RotTeEn; // If TRUE Rotary Transducer Operation Enabled
+ BOOL RotTrOp; // Rotary Transducer Operation Select (stop on error for TRUE)
+ BOOL Butt1T; // Button 1 TRUE state (TRUE : +3/+5Â; FALSE : 0Â)
+ BOOL Butt2T; // Button 2 TRUE state (TRUE : +3/+5Â; FALSE : 0Â)
+ BOOL ResetRT; // Reset Rotary Transducer Check Positions (need one full revolution before it can detect error)
+ BOOL SyncOUTEn; // If TRUE output syncronization enabled
+ BOOL SyncOUTR; // If TRUE output synchronization counter will be reset
+ BOOL SyncINOp; // Synchronization input mode:
+ // True - Step motor will move one time to the destination position
+ // False - Step motor will move multiple times by steps equal to the value destination position
+ DWORD SyncCount; // Number of steps after which synchronization output sygnal occures
+ BOOL SyncInvert; // Set to TRUE to invert output synchronization signal
+
+ BOOL EncoderEn; // Enable Encoder on pins {SYNCIN,ROTTR} - disables Synchronization input and Rotary Transducer
+ BOOL EncoderInv; // Invert Encoder Counter Direction
+ BOOL ResBEnc; // Reset <Encoder Position> and <SM Position in Encoder units> to 0
+ BOOL ResEnc; // Reset <SM Position in Encoder units> to <Encoder Position>
+
+ BYTE Reserved[8]; // <Unused> File padding
+
+} USMC_Mode;
+
+// Structure representing divice state
+typedef struct USMC_State_st{
+ int CurPos; // Current position (in microsteps)
+ float Temp; // Current temperature of the driver
+ BYTE SDivisor; // Step is divided by this factor
+ BOOL Loft; // Indicates backlash status
+ BOOL FullPower; // If TRUE then full power.
+ BOOL CW_CCW; // Current direction. Relatively!
+ BOOL Power; // If TRUE then Step Motor is ON.
+ BOOL FullSpeed; // If TRUE then full speed. Valid in "Slow Start" mode only.
+ BOOL AReset; // TRUE After Device reset, FALSE after "Set Position".
+ BOOL RUN; // Indicates if step motor is rotating
+ BOOL SyncIN; // Logical state directly from input synchronization PIN
+ BOOL SyncOUT; // Logical state directly from output synchronization PIN
+ BOOL RotTr; // Indicates current rotary transducer press state
+ BOOL RotTrErr; // Indicates rotary transducer error flag
+ BOOL EmReset; // Indicates state of emergency disable button (local control)
+ BOOL Trailer1; // Indicates trailer 1 logical state.
+ BOOL Trailer2; // Indicates trailer 2 logical state.
+ float Voltage; // Input power source voltage (6-39V) -=24 version 0nly=-
+
+ BYTE Reserved[8]; // <Unused> File padding
+} USMC_State;
+
+// New For Firmware Version 2.4.1.0 (0x2410)
+typedef struct USMC_EncoderState_st{
+ int EncoderPos; // Current position measured by encoder
+ int ECurPos; // Current position (in Encoder Steps) - Synchronized with request call
+
+ BYTE Reserved[8]; // <Unused> File padding
+} USMC_EncoderState;
+
+// ~New For Firmware Version 2.4.1.0 (0x2410)
+
+typedef struct USMC_Info_st{
+ char serial[17];
+ DWORD dwVersion;
+ char DevName[32];
+ int CurPos, DestPos;
+ float Speed;
+ BOOL ErrState;
+
+ BYTE Reserved[16]; // <Unused> File padding
+} USMC_Info;
+
+
+#ifdef __cplusplus // C++
+extern "C" {
+//
+// The USMC_Init function initializes driver and returns devices information
+//
+USMCDLL_API DWORD USMC_Init( USMC_Devices &Str); // OUT - Array of structures describing all divices (may be NULL) MUST NOT be deleted
+
+//
+// The USMC_GetState function returns structure representing current state of device
+//
+USMCDLL_API DWORD USMC_GetState( DWORD Device, // IN - Device number
+ USMC_State &Str // OUT - Structure representing divice state
+ );
+//
+// The USMC_SaveParametersToFlash function saves current parameters of controller in static memory
+// so thay can be loaded at start up time
+//
+USMCDLL_API DWORD USMC_SaveParametersToFlash( DWORD Device // IN - Device number
+ );
+//
+// The USMC_SetCurrentPosition function sets current position of controller
+//
+USMCDLL_API DWORD USMC_SetCurrentPosition( DWORD Device, // IN - Device number
+ int Position // IN - New position
+ );
+//
+// The USMC_GetMode function returns USMC_Mode structure last sent to device
+//
+USMCDLL_API DWORD USMC_GetMode( DWORD Device, // IN - Device number
+ USMC_Mode &Str // OUT - Structure representing some of divice parameters
+ );
+//
+// The USMC_SetMode function sets some of device parameters
+//
+USMCDLL_API DWORD USMC_SetMode( DWORD Device, // IN - Device number
+ USMC_Mode &Str // IN/OUT Structure representing some of divice parameters
+ );
+//
+// The USMC_GetParameters function returns USMC_Parameters structure last sent to device
+//
+USMCDLL_API DWORD USMC_GetParameters( DWORD Device, // IN - Device number
+ USMC_Parameters &Str // OUT - Structure representing some of divice parameters
+ );
+//
+// The USMC_SetParameters function sets some of divice parameters
+//
+USMCDLL_API DWORD USMC_SetParameters( DWORD Device, // IN - Device number
+ USMC_Parameters &Str // IN/OUT Structure representing some of divice parameters
+ );
+//
+// The USMC_GetStartParameters function returns USMC_StartParameters structure last sent to device
+//
+USMCDLL_API DWORD USMC_GetStartParameters( DWORD Device, // IN - Device number
+ USMC_StartParameters &Str // OUT - Structure representing start function parameters
+ );
+//
+// The USMC_Start function sets start parameters and starts motion
+//
+USMCDLL_API DWORD USMC_Start( DWORD Device, // IN - Device number
+ int DestPos, // IN - Destination position
+ float &Speed, // IN/OUT - Speed of rotation
+ USMC_StartParameters &Str // IN/OUT - Structure representing start function parameters
+ );
+//
+// The USMC_Stop function stops device
+//
+USMCDLL_API DWORD USMC_Stop( DWORD Device // IN - Device number
+ );
+//
+// The USMC_GetLastErr function return string representing last error
+//
+USMCDLL_API void USMC_GetLastErr( char *str, // OUT - String buffer
+ size_t len // IN - Lenght of that string buffer in bytes
+ );
+
+//
+// The USMC_GetDllVersion function returnes version values of USMCDLL.dll
+//
+USMCDLL_API void USMC_GetDllVersion( DWORD &dwHighVersion, // OUT - High Version Value
+ DWORD &dwLowVersion); // OUT - Low Version Value
+
+//
+// The USMC_Close function closes virtual driver window "microsmc.exe"
+//
+USMCDLL_API DWORD USMC_Close( void );
+
+//
+// The USMC_RestoreCurPos function checks AReset bit and if it is TRUE
+// restores previous CurPos value
+//
+USMCDLL_API DWORD USMC_RestoreCurPos(DWORD Device // IN - Device number
+ );
+
+// New For Firmware Version 2.4.1.0 (0x2410)
+
+//
+// The USMC_GetEncoderState function returns structure representing current position of encoder
+//
+USMCDLL_API DWORD USMC_GetEncoderState( DWORD Device, // IN - Device number
+ USMC_EncoderState &Str // IN/OUT Structure containing encoder state
+ );
+
+// ~New For Firmware Version 2.4.1.0 (0x2410)
+
+} // extern "C"
+#else // C
+DWORD USMC_Init( USMC_Devices *Str );
+DWORD USMC_GetState( DWORD Device, USMC_State *Str );
+DWORD USMC_SaveParametersToFlash( DWORD Device );
+DWORD USMC_SetCurrentPosition( DWORD Device, int Position );
+DWORD USMC_GetMode( DWORD Device, USMC_Mode *Str );
+DWORD USMC_SetMode( DWORD Device, USMC_Mode *Str );
+DWORD USMC_GetParameters( DWORD Device, USMC_Parameters *Str );
+DWORD USMC_SetParameters( DWORD Device, USMC_Parameters *Str );
+DWORD USMC_GetStartParameters( DWORD Device, USMC_StartParameters *Str );
+DWORD USMC_Start( DWORD Device, int DestPos, float *Speed, USMC_StartParameters *Str);
+DWORD USMC_Stop( DWORD Device );
+void USMC_GetLastErr( char *str, size_t len );
+DWORD USMC_Close( void );
+DWORD USMC_GetEncoderState( DWORD Device, USMC_EncoderState *Str);
+#endif // C/C++
+
Index: instr/uSMC/msvc/USMCDLL.lib
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/instr/uSMC/msvc/USMCDLL.lib
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: instr/uSMC/msvc64/USMCDLL.lib
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/instr/uSMC/msvc64/USMCDLL.lib
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: instr/uSMC/uSMC.c
===================================================================
--- instr/uSMC/uSMC.c (nonexistent)
+++ instr/uSMC/uSMC.c (revision 255)
@@ -0,0 +1,761 @@
+#include "uSMC.h"
+
+#ifdef uSMC_MAIN
+//# include "uSMC_ui.h"
+#endif /* uSMC_MAIN */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifndef _WINDOWS
+# include "libusmc.h"
+# include <getopt.h>
+# define Delay(x) usleep((int)(x*1000000))
+#else
+# include "USMCDLL.H"
+# include <utility.h>
+# include <ansi_c.h>
+/*
+# define ERR(s, c) if(opterr) fprintf(stderr,"%s %c\n",s,c);
+int opterr = 1;
+int optind = 1;
+int optopt;
+char *optarg;
+
+int getopt(int argc, char **argv, char *opts){
+ static int sp = 1;
+ int c;
+ char *cp;
+
+ if(sp == 1)
+ if(optind >= argc ||
+ argv[optind][0] != '-' || argv[optind][1] == '\0')
+ return(EOF);
+ else if(strcmp(argv[optind], "--") == NULL) {
+ optind++;
+ return(EOF);
+ }
+ optopt = c = argv[optind][sp];
+ if(c == ':' || (cp=strchr(opts, c)) == NULL) {
+ ERR(": illegal option -- ", c);
+ if(argv[optind][++sp] == '\0') {
+ optind++;
+ sp = 1;
+ }
+ return('?');
+ }
+ if(*++cp == ':') {
+ if(argv[optind][sp+1] != '\0')
+ optarg = &argv[optind++][sp+1];
+ else if(++optind >= argc) {
+ ERR(": option requires an argument -- ", c);
+ sp = 1;
+ return('?');
+ } else
+ optarg = argv[optind++];
+ sp = 1;
+ } else {
+ if(argv[optind][++sp] == '\0') {
+ sp = 1;
+ optind++;
+ }
+ optarg = NULL;
+ }
+ return(c);
+}
+*/
+#endif /* _WINDOWS */
+
+// Function that prints information about device state to console
+void PrintDState(USMC_State *State) {
+ printf( "The state is:\n" );
+ printf( "- Current Position in microsteps - %d\n", State->CurPos );
+ printf( "- Temperature - %.2f\xf8\x43\n", State->Temp );
+ printf( "- Step Divisor - %d\n", State->SDivisor);
+ printf( "- Loft State - %s\n", State->Loft?"Indefinite":"Fixed" );
+ printf( "- Power - %s\n", State->Power?(State->FullPower?"Full":"Half"):"Off" );
+ if(State->RUN)
+ printf( "- Step Motor is Running in %s Direction %s\n",
+ State->CW_CCW?"CCW":"CW", ((State->SDivisor==1) && State->FullSpeed)?"at Full Speed":"" );
+ else
+ printf( "- Step Motor is Not Running\n" );
+ printf( "- Device %s\n", State->AReset?"is After Reset":"Position Already Set" );
+ printf( "- Input Synchronization Logical Pin State - %s\n", State->SyncIN?"TRUE":"FALSE" );
+ printf( "- Output Synchronization Logical Pin State - %s\n", State->SyncOUT?"TRUE":"FALSE" );
+ printf( "- Rotary Transducer Logical Pin State - %s\n", State->RotTr?"TRUE":"FALSE" );
+ printf( "- Rotary Transducer Error Flag - %s\n", State->RotTrErr?"Error":"Clear" );
+ printf( "- Emergency Disable Button - %s\n", State->EmReset?"Pushed":"Unpushed" );
+ printf( "- Trailer 1 Press State - %s\n", State->Trailer1?"Pushed":"Unpushed" );
+ printf( "- Trailer 2 Press State - %s\n", State->Trailer2?"Pushed":"Unpushed" );
+ if( State->Voltage == 0.0f )
+ printf( "- Input Voltage - Low\n");
+ else
+ printf( "- Input Voltage - %.1fV\n", State->Voltage);
+}
+
+// Function that prints information about device start parameters to console
+void PrintDStartParameters(int DPos, float Speed, const USMC_StartParameters *SP ) {
+ printf( "Destination position - %d\n", DPos);
+ printf( "Speed - %.2ftacts/s\n", Speed );
+ printf( "Steps Divisor - %d\n", SP->SDivisor );
+ if(SP->SDivisor == 1) {
+ printf( "Slow start/stop mode - %s\n", SP->SlStart?"Enabled":"Disabled" );
+ } else if(SP->LoftEn) {
+ printf( "Automatic backlash operation - Enabled\n" );
+ printf( "Automatic backlash operation direction - %s\n", SP->DefDir?"CCW":"CW" );
+ printf( "Force automatic backlash operation - %s\n", SP->ForceLoft?"TRUE":"FALSE" );
+ } else {
+ printf( "Automatic backlash operation - Disabled\n" );
+ }
+ if(SP->WSyncIN)
+ printf( "Controller will wait for input synchronization signal to start\n" );
+ else
+ printf( "Input synchronization signal ignored \n" );
+ printf( "Output synchronization counter will %sbe reset\n", SP->SyncOUTR?"":"not " );
+}
+
+// Function that prints information about device parameters to console
+void PrintDParameters(USMC_Parameters *Parameters) {
+ printf( "The parameters are:\n" );
+ printf( "Full acceleration time - %.0f ms\n", (double) Parameters->AccelT );
+ printf( "Full deceleration time - %.0f ms\n", (double) Parameters->DecelT );
+ printf( "Power reduction timeout - %.0f ms\n", (double) Parameters->PTimeout );
+ printf( "Button speedup timeout 1 - %.0f ms\n", (double) Parameters->BTimeout1 );
+ printf( "Button speed after timeout 1 - %.2f steps/s\n", (double) Parameters->BTO1P );
+ printf( "Button speedup timeout 2 - %.0f ms\n", (double) Parameters->BTimeout2 );
+ printf( "Button speed after timeout 2 - %.2f steps/s\n", (double) Parameters->BTO2P );
+ printf( "Button speedup timeout 3 - %.0f ms\n", (double) Parameters->BTimeout3 );
+ printf( "Button speed after timeout 3 - %.2f steps/s\n", (double) Parameters->BTO3P );
+ printf( "Button speedup timeout 4 - %.0f ms\n", (double) Parameters->BTimeout4 );
+ printf( "Button speed after timeout 4 - %.2f steps/s\n", (double) Parameters->BTO4P );
+ printf( "Button reset timeout - %.0f ms\n", (double) Parameters->BTimeoutR );
+ printf( "Button reset operation speed - %.2f steps/s\n", (double) Parameters->MinP );
+ printf( "Backlash operation distance - %d steps\n", (int)Parameters->MaxLoft );
+ printf( "Revolution distance - %d steps\n", (int)Parameters->RTDelta );
+ printf( "Minimal revolution distance error - %d steps\n", (int)Parameters->RTMinError );
+ printf( "Power off temperature - %.2f\xf8\x43\n", (double)Parameters->MaxTemp );
+ printf( "Duration of the output synchronization pulse - ");
+ if(Parameters->SynOUTP == 0)
+ printf( "minimal\n");
+ else
+ printf( "%.1f * [Tact Period]\n", Parameters->SynOUTP - 0.5);
+ printf( "Speed of the last phase of the backlash operation - ");
+ if(Parameters->LoftPeriod == 0.0f)
+ printf( "normal\n" );
+ else
+ printf( "%.2f steps/s\n", (double)Parameters->LoftPeriod );
+ printf( "<Angular Encoder Step> Equals <Angular Step Motor Step>/<%.2f>\n", Parameters->EncMult);
+}
+
+// Function that prints information about device "mode" parameters to console
+void PrintDMode(USMC_Mode *Mode) {
+ printf( "Mode parameters:\n" );
+ printf( "Buttons - ");
+ if(Mode->PMode) {
+ printf( "Disabled\n" );
+ } else {
+ printf( "Enabled\nButton 1 TRUE state - %s\n", Mode->Butt1T?"+3/+5 V":"0 V(GND)" );
+ printf( "Button 2 TRUE state - %s\n", Mode->Butt2T?"+3/+5 V":"0 V(GND)" );
+ }
+ printf( "Current reduction regime - %s\n", Mode->PReg?"Used":"Not Used" );
+
+ if(Mode->ResetD)
+ printf( "Power - %s\n", Mode->EMReset?"Emerjency Off":"Off" );
+ else
+ printf( "Power - On\n" );
+ if(Mode->Tr1En || Mode->Tr2En)
+ printf( "Trailers are - %s\n", Mode->TrSwap?"Swapped":"Direct" );
+
+ printf( "Trailer 1 - ");
+ if(Mode->Tr1En)
+ printf( "Enabled\nTrailer 1 TRUE state - %s\n", Mode->Tr1T?"+3/+5 V":"0 V(GND)" );
+ else
+ printf( "Disabled\n");
+ printf( "Trailer 2 - ");
+ if(Mode->Tr2En)
+ printf( "Enabled\nTrailer 2 TRUE state - %s\n", Mode->Tr2T?"+3/+5 V":"0 V(GND)" );
+ else
+ printf( "Disabled\n");
+
+ if(Mode->EncoderEn) {
+ printf( "Encoder - Enabled\n");
+ printf( "Encoder Position Counter is %s\n", Mode->EncoderInv?"Inverted":"Direct");
+ printf( "Rotary Transducer and Input Syncronisation are\n"
+ " Disabled Because of Encoder\n");
+ } else {
+ printf( "Encoder - Disabled\n");
+ printf( "Rotary Transducer - ");
+ if(Mode->RotTeEn) {
+ printf( "Enabled\nRotary Transducer TRUE state - %s\n", Mode->RotTrT?"+3/+5 V":"0 V(GND)" );
+ printf( "Rotary Transducer Operation - %s\n", Mode->RotTrOp?"Stop on error":"Check and ignore error" );
+ printf( "Reset Rotary Transducer Check Positions - %s\n", Mode->ResetRT?"Initiated":"No, why?");
+ } else {
+ printf("Disabled\n");
+ }
+ printf("Synchronization input mode:\n");
+ if(Mode->SyncINOp)
+ printf("Step motor will move one time to the destination position\n");
+ else
+ printf("Step motor will move multiple times by [destination position]\n");
+ }
+ printf( "Output Syncronization - ");
+ if(Mode->SyncOUTEn) {
+ printf( "Enabled\nReset Output Synchronization Counter - %s\n", Mode->SyncOUTR?"Initiated":"No, why?" );
+ printf( "Number of steps after which synchronization output sygnal occures - %u\n", Mode->SyncCount );
+ } else {
+ printf("Disabled\n");
+ }
+ printf("Synchronization Output is ");
+ if(Mode->SyncInvert)
+ printf("INVERTED\n");
+ else
+ printf("NORMAL\n");
+}
+
+// Function that prints Encoder state information
+void PrintEncState(USMC_EncoderState *EnState, USMC_Parameters *up) {
+/*
+|Type |Name |Description
+|--------|-----------|-------------------------------------------------------------------------
+|Int |EncoderPos |Current position measured by encoder
+|Int |ECurPos |Current position (in Encoder Steps) - Synchronized with request call
+|--------|-----------|-------------------------------------------------------------------------
+*/
+ printf( "The encoder state is:\n" );
+ printf( "- Current Position in microsteps - %.2f\n", EnState->ECurPos/up->EncMult );
+ printf( "- Encoder Position in microsteps - %.2f\n\n", EnState->EncoderPos/up->EncMult );
+ printf( "- Current Position in \"Half of Encoder Step\"s - %d\n", EnState->ECurPos );
+ printf( "- Encoder Position in \"Half of Encoder Step\"s - %d\n", EnState->EncoderPos );
+}
+
+// Function that prints last error information
+void PrintError(void) {
+ char er[101];
+ USMC_GetLastErr(er,100);
+ er[100] = '\0';
+ printf("\n%s",er);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+static int ierr;
+static float Speed=15000.0f;
+
+#define MAXNODES 4
+static USMC_Devices Devices;
+static USMC_StartParameters DStartPar[MAXNODES];
+static USMC_Parameters DPar[MAXNODES];
+static USMC_State DState[MAXNODES];
+static USMC_EncoderState DEncState[MAXNODES];
+static USMC_Mode DMode[MAXNODES];
+
+#define ERRLEN 128
+static char errstr[ERRLEN];
+
+void uSMC_PrintDevices(void) {
+ /*
+ |Type |Name |Description
+ |--------|-----------|-------------------------------------------------------------------------
+ |DWORD |NOD |Number of devices connected to computer
+ |char ** |Serial |Array of pointers to 16–byte ASCII strings of length – NOD
+ |char ** |Version |Array of pointers to 4–byte ASCII strings of length – NOD
+ |--------|-----------|-------------------------------------------------------------------------
+ */
+ int i;
+ for (i=0; i<Devices.NOD; i++) {
+ printf("Device - %d,\tSerial Number - %.16s,\tVersion - %.4s\n",i+1,Devices.Serial[i],Devices.Version[i]);
+ }
+}
+
+int uSMC_SetParameters(int node, int stageType) {
+ /*
+ |Type |Name |Description
+ |--------|-----------|-------------------------------------------------------------------------
+ |float |AccelT |Acceleration time (in ms)
+ |float |DecelT |Deceleration time (in ms)
+ |float |PTimeout |Time (in ms) after which current will be reduced to 60% of normal
+ |float |BTimeout1 |Time (in ms) after which speed of step motor rotation will be equal to the one specified at
+ | | |BTO1P field in this structure
+ |float |BTimeout2 |Time (in ms) after which speed of step motor rotation will be equal to the one specified at
+ | | |BTO2P field in this structure
+ |float |BTimeout3 |Time (in ms) after which speed of step motor rotation will be equal to the one specified at
+ | | |BTO3P field in this structure
+ |float |BTimeout4 |Time (in ms) after which speed of step motor rotation will be equal to the one specified at
+ | | |BTO4P field in this structure
+ |float |BTimeoutR |Time (in ms) after which reset command will be performed (see 5.4.7 at page 53)
+ |float |BTimeoutD |This field is reserved for future use
+ |float |MinP |Speed (steps/sec) while performing reset operation
+ |float |BTO1P |Speed (steps/sec) after BTIMEOUT1 time has passed (see 5.4.8 at page 54)
+ |float |BTO2P |Speed (steps/sec) after BTIMEOUT2 time has passed (see 5.4.8 at page 54)
+ |float |BTO3P |Speed (steps/sec) after BTIMEOUT3 time has passed (see 5.4.8 at page 54)
+ |float |BTO4P |Speed (steps/sec) after BTIMEOUT4 time has passed (see 5.4.8 at page 54)
+ |WORD |MaxLoft |Value in full steps that will be used performing backlash operation
+ |DWORD |StartPos |Current Position saved to FLASH. Refer to test.cpp for implementing this functionality.
+ | | |Should be set to 0 for correct reloading of current position in SMCVieW program
+ |WORD |RTDelta |Revolution distance – number of full steps per one full revolution
+ |WORD |RTMinError |Number of full steps missed to raise the error flag
+ |float |MaxTemp |Maximum allowed temperature (centigrade degrees)
+ |BYTE |SynOUTP |Duration of the output synchronization pulse ( see 5.4.13 at page 58)
+ |float |LoftPeriod |Speed (steps/sec) of the last phase of the backlash operation
+ |float |EncMult |Encoder step multiplier. Should be <Encoder Steps per Revolution> / <SM Steps per Revolution>
+ | | |and should be integer multiplied by 0.25
+ |--------|-----------|-------------------------------------------------------------------------
+ */
+ int saveToFlash;
+ int Dev;
+
+ saveToFlash=0;
+ Dev=node-1;
+ if (ierr=USMC_GetParameters(Dev,&DPar[Dev])) return ierr;
+ switch (stageType) {
+ case -1:
+ saveToFlash=1;
+// DPar[Dev].StartPos = 0;
+ case 1:
+ // Linear stage
+ DPar[Dev].AccelT = 200.0f;
+ DPar[Dev].DecelT = 200.0f;
+ DPar[Dev].PTimeout = 1.0f;
+ DPar[Dev].BTimeout1 = 500.0f;
+ DPar[Dev].BTimeout2 = 500.0f;
+ DPar[Dev].BTimeout3 = 500.0f;
+ DPar[Dev].BTimeout4 = 500.0f;
+ DPar[Dev].BTimeoutR = 500.0f;
+ DPar[Dev].MinP = 60.0f;
+ DPar[Dev].BTO1P = 10.0f;
+ DPar[Dev].BTO2P = 20.0f;
+ DPar[Dev].BTO3P = 30.0f;
+ DPar[Dev].BTO4P = 60.0f;
+ DPar[Dev].MaxLoft = 32;
+ DPar[Dev].RTDelta = 200;
+ DPar[Dev].RTMinError = 15;
+ DPar[Dev].MaxTemp = 70.0f;
+ DPar[Dev].SynOUTP = 1;
+ DPar[Dev].LoftPeriod = 50.0f;
+ DPar[Dev].EncMult = 1.0f;
+ break;
+ case -2:
+ saveToFlash=1;
+ case 2:
+// Rotation stage
+ DPar[Dev].MaxTemp = 70.0f;
+ DPar[Dev].AccelT = 200.0f;
+ DPar[Dev].DecelT = 200.0f;
+ DPar[Dev].BTimeout1 = 500.0f;
+ DPar[Dev].BTimeout2 = 500.0f;
+ DPar[Dev].BTimeout3 = 500.0f;
+ DPar[Dev].BTimeout4 = 500.0f;
+ DPar[Dev].BTO1P = 100.0f;
+ DPar[Dev].BTO2P = 200.0f;
+ DPar[Dev].BTO3P = 300.0f;
+ DPar[Dev].BTO4P = 600.0f;
+ DPar[Dev].MinP = 500.0f;
+ DPar[Dev].BTimeoutR = 500.0f;
+ DPar[Dev].LoftPeriod = 500.0f;
+ DPar[Dev].RTDelta = 200;
+ DPar[Dev].RTMinError = 15;
+ DPar[Dev].EncMult = 2.5f;
+ DPar[Dev].MaxLoft = 32;
+ DPar[Dev].PTimeout = 100.0f;
+ DPar[Dev].SynOUTP = 1;
+ break;
+ }
+ if (ierr=USMC_SetParameters(Dev,&DPar[Dev])) return ierr;
+ if (saveToFlash) {
+ if(ierr=USMC_SaveParametersToFlash(Dev)) return ierr;
+ PrintDParameters(&DPar[Dev]);
+ printf("\nThese Parameters were Saved to Flash");
+ }
+ return FALSE;
+}
+
+int uSMC_RevertStartPosition(int node) {
+ int Dev;
+
+ Dev=node-1;
+ if (ierr=USMC_GetParameters(Dev,&DPar[Dev])) return ierr;
+ DPar[Dev].StartPos = 0;
+ if (ierr=USMC_SetParameters(Dev,&DPar[Dev])) return ierr;
+ if(ierr=USMC_SaveParametersToFlash(Dev)) return ierr;
+ printf("\nStart Position is Reset to 0\n");
+ return FALSE;
+}
+
+int _VI_FUNC uSMC_PowerOn (int node) {
+ int Dev;
+
+ Dev=node-1;
+ if (ierr=USMC_GetMode(Dev,&DMode[Dev])) return ierr;
+ DMode[Dev].ResetD = FALSE;
+ if (ierr=USMC_SetMode(Dev,&DMode[Dev])) return ierr;
+ return FALSE;
+}
+
+int uSMC_PowerOffSave(int node,int saveToFlash) {
+ int Dev=node-1;
+ if (saveToFlash) {
+ if (ierr=USMC_GetParameters(Dev,&DPar[Dev])) return ierr;
+ }
+ if (ierr=USMC_GetMode(Dev,&DMode[Dev])) return ierr;
+ DMode[Dev].ResetD = TRUE;
+ if (ierr=USMC_SetMode(Dev,&DMode[Dev])) return ierr;
+ do {
+ Sleep(50);
+ if (ierr=USMC_GetState(Dev,&DState[Dev])) return ierr;
+ } while(DState[Dev].Power == TRUE);
+ if (saveToFlash) {
+ DPar[Dev].StartPos = DState[Dev].CurPos;
+ if (ierr=USMC_SetParameters(Dev,&DPar[Dev])) return ierr;
+ if (ierr=USMC_SaveParametersToFlash(Dev)) return ierr;
+ }
+ return FALSE;
+}
+
+int _VI_FUNC uSMC_PowerOff (int node) {
+ if (ierr=uSMC_PowerOffSave(node,0)) return ierr;
+ return FALSE;
+}
+
+int _VI_FUNC uSMC_Open (void) {
+ int i;
+ if (ierr=USMC_Init(&Devices)) return ierr;
+ uSMC_PrintDevices();
+ return FALSE;
+}
+
+int _VI_FUNC uSMC_FindSerial (char serial[])
+{
+ int i;
+ for (i=0; i<Devices.NOD; i++)
+ if (!strncmp (Devices.Serial[i], serial, 16)) return i;
+ return -1;
+}
+
+int _VI_FUNC uSMC_Reset (int node) {
+ return FALSE;
+}
+
+int _VI_FUNC uSMC_Init (int node, int type) {
+ /*
+ |Type |Name |Masked|Saved|Description
+ |--------|-----------|------|-----|------------------------------------------------------------
+ |BOOL |PMode |– |YES |Turn off buttons (TRUE - buttons disabled)
+ |BOOL |PReg |– |YES |Current reduction regime (TRUE - regime is on)
+ |BOOL |ResetD |– |YES |Turn power off and make a whole step (TRUE - apply)
+ |BOOL |EMReset |– |– |Quick power off (see 5.4.6 at page 53)
+ |BOOL |Tr1T |– |YES |Limit switch 1 TRUE state (TRUE : +3/+5?; FALSE : 0?)
+ |BOOL |Tr2T |– |YES |Limit switch 2 TRUE state (TRUE : +3/+5?; FALSE : 0?)
+ |BOOL |RotTrT |– |YES |Rotary Transducer TRUE state (TRUE : +3/+5?; FALSE : 0?)
+ |BOOL |TrSwap |– |YES |If TRUE, Limit switches are treated to be swapped
+ |BOOL |Tr1En |– |YES |If TRUE Limit switch 1 Operation Enabled
+ |BOOL |Tr2En |– |YES |If TRUE Limit switch 2 Operation Enabled
+ |BOOL |RotTeEn |– |YES |If TRUE Rotary Transducer Operation Enabled
+ |BOOL |RotTrOp |– |YES |Rotary Transducer Operation Select (stop on error if TRUE)
+ |BOOL |Butt1T |– |YES |Button 1 TRUE state (TRUE : +3/+5?; FALSE : 0?)
+ |BOOL |Butt2T |– |YES |Button 2 TRUE state (TRUE : +3/+5?; FALSE : 0?)
+ |BOOL |ResetRT |YES |– |Reset Rotary Transducer Check Positions (need one full revolution
+ | | | | |before it can detect error)
+ |BOOL |SyncOUTEn |– |YES |If TRUE output synchronization enabled
+ |BOOL |SyncOUTR |YES |– |If TRUE output synchronization counter will be reset
+ |BOOL |SyncINOp |– |YES |Synchronization input mode:
+ | | | | |- TRUE - Step motor will move one time to the DestPos
+ | | | | |- FALSE - Step motor will move multiple times by DestPos microsteps as distance
+ |DWORD |SyncCount |– |YES |Number of steps after which synchronization output signal occurs
+ |BOOL |SyncInvert |– |YES |Set this bit to TRUE to invert output synchronization polarity
+ |BOOL |EncoderEn |– |YES |Enable Encoder on pins {SYNCIN,ROTTR} - disables Synchronization input and Rotary Transducer
+ |BOOL |EncoderInv |– |YES |Invert Encoder Counter Direction BOOL ResBEnc YES – Reset <EncoderPos> and <ECurPos> to 0
+ |BOOL |ResEnc |YES |– |Reset <ECurPos> to <EncoderPos>
+ |--------|-----------|-------------------------------------------------------------------------
+ Masked –> These Boolean values will be automatically cleared by USMC_GetMode (to FALSE)
+ */
+ int Dev;
+
+ Dev=node-1;
+// if (ierr=uSMC_PowerOff(node)) return ierr;
+ if (ierr=uSMC_SetParameters(node,type)) return ierr;
+ switch (type) {
+ case -1:
+ case 1:
+ if (ierr=USMC_GetMode(Dev,&DMode[Dev])) return ierr;
+ DMode[Dev].Tr1T = FALSE;
+ DMode[Dev].Tr2T = FALSE;
+ DMode[Dev].Tr1En = TRUE;
+ DMode[Dev].Tr2En = TRUE;
+ DMode[Dev].TrSwap = FALSE;
+ DMode[Dev].EncoderEn = FALSE;
+ if (ierr=USMC_SetMode(Dev,&DMode[Dev])) return ierr;
+ break;
+ }
+ if (ierr=uSMC_PowerOn(node)) return ierr;
+ return FALSE;
+}
+
+int _VI_FUNC uSMC_ReferenceMove (int node) {
+ int Dev;
+ float tmpSpeed;
+
+ Dev=node-1;
+ tmpSpeed=Speed;
+ if (ierr=USMC_GetMode(Dev,&DMode[Dev])) return ierr;
+ DMode[Dev].Tr1T = FALSE;
+ DMode[Dev].Tr2T = FALSE;
+ DMode[Dev].Tr1En = TRUE;
+ DMode[Dev].Tr2En = TRUE;
+ DMode[Dev].TrSwap = FALSE;
+ DMode[Dev].EncoderEn = FALSE;
+ if (ierr=USMC_SetMode(Dev,&DMode[Dev])) return ierr;
+ Speed=10000.0f;
+ if (ierr=USMC_SetCurrentPosition(Dev,0)) return ierr;
+ if (ierr=uSMC_MoveTo(node,-500000)) return ierr;
+ if (ierr=uSMC_MoveFor(node,5000)) return ierr;
+ Speed=500.0f;
+ if (ierr=uSMC_MoveTo(node,-500000)) return ierr;
+ Speed=tmpSpeed;
+ if (ierr=uSMC_MoveFor(node,5000)) return ierr;
+ if (ierr=USMC_SetCurrentPosition(Dev,0)) return ierr;
+ return FALSE;
+}
+
+int _VI_FUNC uSMC_MoveFor (int node, int dist) {
+ int CurPos;
+ if (ierr=uSMC_GetPosition(node,&CurPos)) return ierr;
+ if (ierr=uSMC_MoveTo(node,CurPos+dist)) return ierr;
+ return FALSE;
+}
+
+int _VI_FUNC uSMC_MoveTo (int node, int dest) {
+ /*
+ |Type |Name |Description
+ |--------|-----------|-------------------------------------------------------------------------
+ |BYTE |SDivisor |Step is divided by this factor (1,2,4,8)
+ |BOOL |DefDir |Direction for backlash operation (relative) (see 5.4.15 at page 60)
+ |BOOL |LoftEn |Enable automatic backlash operation (works if slow start/stop mode is off)
+ |BOOL |SlStart |If TRUE slow start/stop mode enabled
+ |BOOL |WSyncIN |If TRUE controller will wait for input synchronization signal to start
+ |BOOL |SyncOUTR |If TRUE output synchronization counter will be reset
+ |BOOL |ForceLoft |If TRUE and destination position is equal to the current position
+ | | |backlash operation will be performed
+ |--------|-----------|-------------------------------------------------------------------------
+ */
+ int Dev;
+ time_t tcur,tprev;
+
+ Dev=node-1;
+ if (ierr=USMC_GetStartParameters(Dev,&DStartPar[Dev])) return ierr;
+ DStartPar[Dev].SDivisor=8;
+ DStartPar[Dev].SlStart=TRUE;
+ DStartPar[Dev].LoftEn=FALSE;
+ DStartPar[Dev].WSyncIN=FALSE;
+ if (ierr=USMC_Start(Dev,dest,&Speed,&DStartPar[Dev])) return ierr;
+ tprev=time(NULL)+1;
+ do {
+ Delay(0.01);
+ if (ierr=USMC_GetState(Dev,&DState[Dev])) return ierr;
+ tcur=time(NULL);
+ if (tcur > tprev) {
+ printf("%d CurPos %d L%d R%d Rot%d %s %s\n",node,
+ DState[Dev].CurPos,DState[Dev].Trailer1,DState[Dev].Trailer2, DState[Dev].RotTr,
+ DState[Dev].RUN?"Run":"Stopped",DState[Dev].Power?"On":"Off" );
+ tprev= tcur;
+ }
+ } while (DState[Dev].RUN);
+ return FALSE;
+}
+
+int _VI_FUNC uSMC_GetPosition (int node, int *pos) {
+ /*
+ |Type |Name |Description
+ |--------|-----------|-------------------------------------------------------------------------
+ |int |CurPos
+ |float |Temp |Current temperature of the power driver
+ |BYTE |SDivisor |Step is divided by this factor
+ |BOOL |Loft |Indicates backlash status
+ |BOOL |FullPower |Full power if TRUE
+ |BOOL |CW_CCW |Current direction of rotation (relatively to some direction – dependent on
+ | | |step motor circuits connection and on its construction)
+ |BOOL |Power |If TRUE then Step Motor power is ON
+ |BOOL |FullSpeed |If TRUE then full speed. Valid in "Slow Start" mode only
+ |BOOL |AReset |TRUE After Device reset, FALSE after "Set Position"
+ |BOOL |RUN |TRUE if step motor is rotating
+ |BOOL |SyncIN |Logical state directly from input synchronization PIN (pulses treated as positive)
+ |BOOL |SyncOUT |Logical state directly from output synchronization PIN (pulses are positive)
+ |BOOL |RotTr |Indicates current rotary transducer logical press state
+ |BOOL |RotTrErr |Indicates rotary transducer error flag (reset by USMC_SetMode function with ResetRT bit – TRUE)
+ |BOOL |EmReset |Indicates state of emergency disable button (TRUE – Step motor power off)
+ |BOOL |Trailer1 |Indicates Limit switch 1 logical press state
+ |BOOL |Trailer2 |Indicates Limit switch 2 logical press state
+ |float |Voltage |Power supply voltage (Volts)
+ |--------|-----------|-------------------------------------------------------------------------
+ */
+ int Dev;
+
+ Dev=node-1;
+ if (ierr=USMC_GetState(Dev,&DState[Dev])) return ierr;
+ *pos=DState[Dev].CurPos;
+ return FALSE;
+}
+
+void _VI_FUNC uSMC_Close (void) {
+ USMC_Close();
+}
+
+//******************************
+
+#ifdef uSMC_MAIN
+#define uSMC_SERIAL_X "0000000000004925"
+#define uSMC_SERIAL_Y "0000000000006030"
+#define uSMC_SERIAL_Z "0000000000002894"
+# ifdef _WINDOWS
+int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPSTR lpszCmdLine, int nCmdShow) {
+
+ const char serials[3][16]={uSMC_SERIAL_X,uSMC_SERIAL_Y,uSMC_SERIAL_Z};
+
+ int i;
+ int DestPos[3],CurPos[3];
+ int nodes[3];
+// float Speed=2000.0f;
+
+ if (InitCVIRTE (hInstance, 0, 0) == 0) return -1; /* out of memory */
+
+ uSMC_Open();
+ for (i=0;i<3;i++) {
+ nodes[i]=uSMC_FindSerial(serials[i])+1;
+ uSMC_Init(nodes[i],1);
+ uSMC_GetPosition(nodes[i],&CurPos[i]);
+ }
+ printf("nodes x,y,z: %2d, %2d, %2d\n",nodes[0],nodes[1],nodes[2]);
+ printf("Current position: %2d, %2d, %2d\n",CurPos[0],CurPos[1],CurPos[2]);
+// uSMC_ReferenceMove(node);
+
+ getchar();
+ DestPos[0]=32000;
+ DestPos[1]=125000;
+ DestPos[2]=300000;
+ for (i=0;i<3;i++) {
+ uSMC_MoveTo(nodes[i],DestPos[i]);
+ uSMC_GetPosition(nodes[i],&CurPos[i]);
+ }
+ printf("Current position: %2d, %2d, %2d\n",CurPos[0],CurPos[1],CurPos[2]);
+
+ for (i=0;i<3;i++) uSMC_PowerOff(nodes[i]);
+ getchar();
+ uSMC_Close();
+ return 0;
+}
+
+# else
+
+int main (int argc, char **argv) {
+ int i,j,k;
+ int node=0,opt,value=0;
+ int EOldPos=-1;
+ if ( USMC_Init ( &devices ) ) abort();
+
+
+ while ((opt = getopt(argc, argv, "i:av:f:l:udn:m:s:v:g:h:r:p:")) != -1) {
+ switch (opt) {
+ case 'i':
+ usmc_Init (node, atoi(optarg));
+
+ break;
+ case 'a':
+ printdevices(devices);
+ for (i=0; i<devices.NOD; i++) {
+
+ USMC_GetState(i,&DState[i]);
+ printf("%d CurPos %d L%d R%d %s %s\t",i,
+ DState[i].CurPos,DState[i].Trailer1,DState[i].Trailer2,
+ DState[i].RUN?"Run":"Stopped",DState[i].Power?"On":"Off" );
+ USMC_GetParameters(i,&DPar[i]);
+ USMC_GetEncoderState(i,&DEncState[i]);
+ printf("node %d ECurPos 0x%0x %f EncoderPos =0x%04x %f\n",i,
+ DEncState[i].ECurPos, (((DEncState[i].ECurPos)>>5)&0x8FFFFF)/DPar[i].EncMult,
+ DEncState[i].EncoderPos,((DEncState[i].EncoderPos >> 5)&0x8FFFFF)/DPar[i].EncMult);
+
+ }
+ break;
+
+ case 'l':
+ printf("usmc_MoveTo Loop\n");
+ for (i=0; i<5; i++) {
+ int xpos=i*1000+10000;
+ usmc_MoveTo (1, xpos);
+ for (j=0; j<5; j++) {
+ int ypos=j*1000+10000;
+ usmc_MoveTo (2, ypos);
+ for (k=0; k<50; k++) {
+ int zpos=k*1000+10000;
+ usmc_MoveTo (3, zpos);
+ printf("x=%d y=%d z=%d\n",xpos,ypos,zpos);
+ Delay(atof(optarg));
+
+ }
+ }
+ }
+ break;
+ case 'n':
+ node = atoi(optarg);
+ break;
+ case 's':
+ usmc_speed = atoi(optarg);
+ break;
+ case 'p':
+ usmc_PowerOnOff(node,atoi(optarg));
+ break;
+ case 'm':
+ usmc_MoveTo (node, atoi(optarg));
+ printf("usmc_MoveTo node=%d pos=%d \n",node,atoi(optarg));
+
+ break;
+ case 'v':
+ value=atoi(optarg);
+ break;
+ /*
+ case 'f':
+ MIKRO_Set (node,optarg,value);
+ printf("MIKRO_Set node %d cmd=%s val=%d\n",node,optarg, value);
+ break;
+ case 'g':
+ MIKRO_Get (node,optarg,&i);
+ printf("MIKRO_Get node %d cmd=%s val=%d\n",node,optarg, i);
+
+ break;
+
+
+ */
+
+ case 'r':
+ printf("usmc_Reset node=%d mode=%d\n",node, atoi(optarg));
+ usmc_Reset (node, atoi(optarg));
+ break;
+
+ case 'h':
+ printf("usmc_ReferenceMove node=%d mode=%d\n",node, atoi(optarg));
+ usmc_ReferenceMove (node, atoi(optarg));
+ break;
+
+ case 'u':
+ usmc_RelMove(node, 1000);
+ break;
+ case 'd':
+ usmc_RelMove(node, -1000);
+ break;
+
+
+ default: /* '?' */
+ help();
+
+ break;
+ }
+ }
+ if (argc==1) help();
+
+
+ USMC_Close ();
+ return 0;
+}
+
+# endif /* _WINDOWS */
+#endif /* _uSMC_MAIN */
Index: instr/uSMC/uSMC.cws
===================================================================
--- instr/uSMC/uSMC.cws (nonexistent)
+++ instr/uSMC/uSMC.cws (revision 255)
@@ -0,0 +1,301 @@
+[Workspace Header]
+Version = 1302
+Pathname = "/c/home/cvi/instr/uSMC/uSMC.cws"
+CVI Dir = "/c/program files/national instruments/cvi2013"
+CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
+CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013"
+CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
+IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
+IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
+VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
+VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
+Number of Projects = 2
+Active Project = 1
+Project 0001 = "/c/home/cvi/instr/K617/K617.prj"
+Project 0002 = "/c/home/cvi/instr/PROLOGIX/prologix.prj"
+Drag Bar Left = 212
+Window Top = 47
+Window Left = 315
+Window Bottom = 972
+Window Right = 1658
+Maximized = False
+Maximized Children = True
+Max32 Number Of Errors = 20
+Track Include File Dependencies = True
+Prompt For Missing Includes = True
+Stop On First Error File = False
+Bring Up Err Win At Start = True
+Bring Up Err Win For Errors = False
+Save Changes Before Running = "Always"
+Save Changes Before Compiling = "Always"
+Hide Windows = False
+Break At First Statement = False
+Sort Type = "File Name"
+Number of Opened Files = 2
+Window Confinement Region Enabled = True
+MainColumnWidth = 195
+FileDateColumnWidth = 70
+FileSizeColumnWidth = 70
+
+[Project Header 0001]
+Version = 1302
+Don't Update DistKit = False
+Platform Code = 4
+Build Configuration = "Debug"
+Warn User If Debugging Release = 1
+Batch Build Release = False
+Batch Build Debug = False
+
+[Project Header 0002]
+Version = 1302
+Don't Update DistKit = False
+Platform Code = 4
+Build Configuration = "Debug"
+Warn User If Debugging Release = 1
+Batch Build Release = False
+Batch Build Debug = False
+
+[File 0001]
+Path = "/c/home/cvi/instr/K617/K617.fp"
+File Type = "Function Panel"
+Disk Date = 3500219966
+In Projects = "1,"
+Window Top = 33
+Window Left = 10
+Window Height = 400
+Window Width = 400
+
+[File 0002]
+Path = "/c/home/cvi/instr/PROLOGIX/prologix.fp"
+File Type = "Function Panel"
+Disk Date = 3500214502
+In Projects = "1,2,"
+
+[File 0003]
+Path = "/c/home/cvi/instr/PROLOGIX/prologix.c"
+File Type = "CSource"
+Disk Date = 3500234235
+In Projects = "2,"
+Window Top = 157
+Window Left = 74
+Window Z-Order = 2
+Source Window State = "1,0,0,0,0,0,0,0,0,80,0,0,0,0,0,23,83,0,120,30,323,683,1,0,"
+
+[File 0004]
+Path = "/c/home/cvi/instr/PROLOGIX/prologix.h"
+File Type = "Include"
+Disk Date = 3500215296
+In Projects = "2,"
+Window Top = 33
+Window Left = 10
+Source Window State = "1,0,0,0,0,0,0,0,0,80,0,0,0,0,0,23,13,0,0,0,323,683,1,0,"
+
+[File 0005]
+Path = "/c/home/cvi/instr/K617/K617.c"
+File Type = "CSource"
+Disk Date = 3566382177
+In Projects = "1,"
+Window Top = 95
+Window Left = 42
+Window Z-Order = 1
+Source Window State = "1,0,0,0,0,0,0,0,0,136,0,0,0,0,0,53,94,0,285,25,323,683,1,0,"
+
+[File 0006]
+Path = "/c/home/cvi/instr/K617/K617.h"
+File Type = "Include"
+Disk Date = 3500226164
+In Projects = "1,"
+Window Top = 126
+Window Left = 58
+Source Window State = "1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,349,683,1,0,"
+
+[File 0007]
+Path = "/c/home/cvi/instr/PROLOGIX/prologix_ui.uir"
+File Type = "User Interface Resource"
+Disk Date = 3500215705
+In Projects = "2,"
+Window Top = 64
+Window Left = 26
+Window Height = 323
+Window Width = 683
+
+[Tab Order]
+Tab 0001 = "/c/home/cvi/instr/K617/K617.c"
+Tab 0002 = "/c/home/cvi/instr/PROLOGIX/prologix.c"
+
+[Default Build Config 0001 Debug]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Default Build Config 0001 Release]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Default Build Config 0001 Debug64]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Default Build Config 0001 Release64]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Build Dependencies 0001]
+Number of Dependencies = 0
+
+[Build Options 0001]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Execution Trace = "Disabled"
+Profile = "Disabled"
+Debugging Level = "Standard"
+Break On Library Errors = True
+Break On First Chance Exceptions = False
+
+[Execution Target 0001]
+Execution Target Address = "Local desktop computer"
+Execution Target Port = 0
+Execution Target Type = 0
+
+[SCC Options 0001]
+Use global settings = True
+SCC Provider = ""
+SCC Project = ""
+Local Path = ""
+Auxiliary Path = ""
+Perform Same Action For .h File As For .uir File = "Ask"
+Perform Same Action For .cds File As For .prj File = "Ask"
+Username = ""
+Comment = ""
+Use Default Username = False
+Use Default Comment = False
+Suppress CVI Error Messages = False
+Always show confirmation dialog = True
+
+[DLL Debugging Support 0001]
+External Process Path = ""
+
+[Command Line Args 0001]
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+
+[Default Build Config 0002 Debug]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Default Build Config 0002 Release]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Default Build Config 0002 Debug64]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Default Build Config 0002 Release64]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Batch Build = False
+Profile = "Disabled"
+Debugging Level = "Standard"
+Execution Trace = "Disabled"
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+External Process Path = ""
+
+[Build Dependencies 0002]
+Number of Dependencies = 0
+
+[Build Options 0002]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Execution Trace = "Disabled"
+Profile = "Disabled"
+Debugging Level = "Standard"
+Break On Library Errors = True
+Break On First Chance Exceptions = False
+
+[Execution Target 0002]
+Execution Target Address = "Local desktop computer"
+Execution Target Port = 0
+Execution Target Type = 0
+
+[SCC Options 0002]
+Use global settings = True
+SCC Provider = ""
+SCC Project = ""
+Local Path = ""
+Auxiliary Path = ""
+Perform Same Action For .h File As For .uir File = "Ask"
+Perform Same Action For .cds File As For .prj File = "Ask"
+Username = ""
+Comment = ""
+Use Default Username = False
+Use Default Comment = False
+Suppress CVI Error Messages = False
+Always show confirmation dialog = True
+
+[DLL Debugging Support 0002]
+External Process Path = ""
+
+[Command Line Args 0002]
+Command Line Args = ""
+Working Directory = ""
+Environment Options = ""
+
Index: instr/uSMC/uSMC.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/instr/uSMC/uSMC.exe
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: instr/uSMC/uSMC.fp
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/instr/uSMC/uSMC.fp
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: instr/uSMC/uSMC.h
===================================================================
--- instr/uSMC/uSMC.h (nonexistent)
+++ instr/uSMC/uSMC.h (revision 255)
@@ -0,0 +1,62 @@
+//==============================================================================
+//
+// Title: MIKRO.h
+// Purpose: Header file for MVP stage driver.
+//
+// Created on: 29.11.2014 at 20:51:03 by Samo Korpar.
+// Copyright: . All Rights Reserved.
+//
+//==============================================================================
+
+#ifndef __uSMC_H__
+#define __uSMC_H__
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+//==============================================================================
+// Include files
+
+#include <cvidef.h>
+#include <ivi.h>
+
+//==============================================================================
+// Constants
+
+//==============================================================================
+// Types
+
+//==============================================================================
+// External variables
+
+//==============================================================================
+// Global functions
+
+int _VI_FUNC uSMC_Open (void);
+
+int _VI_FUNC uSMC_FindSerial (char serial[]);
+
+int _VI_FUNC uSMC_Reset (int node);
+
+int _VI_FUNC uSMC_Init (int node, int type);
+
+int _VI_FUNC uSMC_PowerOn (int node);
+
+int _VI_FUNC uSMC_PowerOff (int node);
+
+int _VI_FUNC uSMC_ReferenceMove (int node);
+
+int _VI_FUNC uSMC_MoveFor (int node, int dist);
+
+int _VI_FUNC uSMC_MoveTo (int node, int dest);
+
+int _VI_FUNC uSMC_GetPosition (int node, int *pos);
+
+void _VI_FUNC uSMC_Close (void);
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* ndef __uSMC_H__ */
Index: instr/uSMC/uSMC.prj
===================================================================
--- instr/uSMC/uSMC.prj (nonexistent)
+++ instr/uSMC/uSMC.prj (revision 255)
@@ -0,0 +1,543 @@
+[Project Header]
+Version = 1302
+Pathname = "/c/home/cvi/instr/uSMC/uSMC.prj"
+Project Label = "uSMC"
+CVI Dir = "/c/program files/national instruments/cvi2013"
+CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
+CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013"
+CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
+IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
+VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
+IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
+VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
+Number of Files = 8
+Target Type = "Executable"
+Flags = 16
+Copied From Locked InstrDrv Directory = False
+Copied from VXIPNP Directory = False
+Locked InstrDrv Name = ""
+Don't Display Deploy InstrDrv Dialog = False
+
+[Folders]
+Instrument Files Folder Not Added Yet = True
+Folder 0 = "Source Files"
+FolderEx 0 = "Source Files"
+Folder 1 = "User Interface Files"
+FolderEx 1 = "User Interface Files"
+Folder 2 = "Library Files"
+FolderEx 2 = "Library Files"
+Folder 3 = "Include Files"
+FolderEx 3 = "Include Files"
+
+[File 0001]
+File Type = "CSource"
+Res Id = 1
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "Test MicroSMC.c"
+Path = "/c/home/cvi/instr/uSMC/Test MicroSMC.c"
+Exclude = True
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+Folder Id = 0
+
+[File 0002]
+File Type = "CSource"
+Res Id = 2
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "uSMC.c"
+Path = "/c/home/cvi/instr/uSMC/uSMC.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+Folder Id = 0
+
+[File 0003]
+File Type = "CSource"
+Res Id = 3
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "uSMCctrl.c"
+Path = "/c/home/cvi/instr/uSMC/uSMCctrl.c"
+Exclude = True
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+Folder Id = 0
+
+[File 0004]
+File Type = "User Interface Resource"
+Res Id = 4
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "uSMC_ui.uir"
+Path = "/c/home/cvi/instr/uSMC/uSMC_ui.uir"
+Exclude = False
+Project Flags = 0
+Folder = "User Interface Files"
+Folder Id = 1
+
+[File 0005]
+File Type = "Library"
+Res Id = 5
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "USMCDLL.lib"
+Path = "/c/home/cvi/instr/uSMC/USMCDLL.lib"
+Exclude = False
+Project Flags = 0
+Folder = "Library Files"
+Folder Id = 2
+
+[File 0006]
+File Type = "Include"
+Res Id = 6
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "uSMC.h"
+Path = "/c/home/cvi/instr/uSMC/uSMC.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+Folder Id = 3
+
+[File 0007]
+File Type = "Include"
+Res Id = 7
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "uSMCctrl.h"
+Path = "/c/home/cvi/instr/uSMC/uSMCctrl.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+Folder Id = 3
+
+[File 0008]
+File Type = "Include"
+Res Id = 8
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "USMCDLL.h"
+Path = "/c/home/cvi/instr/uSMC/USMCDLL.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+Folder Id = 3
+
+[Custom Build Configs]
+Num Custom Build Configs = 0
+
+[Default Build Config Debug]
+Config Name = "Debug"
+Is 64-Bit = False
+Is Release = False
+Default Calling Convention = "cdecl"
+Optimization Level = "No optimizations"
+Require Prototypes = True
+Show Warning IDs in Build Output = False
+Selected Warning Level = "None"
+Warning List None = "4,9,84,105,106,107,108,109,110,111"
+Warning List Common = ""
+Warning List Extended = ""
+Warning List All = ""
+Warning Mode = 0
+Enable Unreferenced Identifiers Warning = False
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Assignment In Conditional Warning = False
+Uninitialized Locals Compile Warning = "Aggressive"
+Require Return Values = True
+Enable C99 Extensions = False
+Enable OpenMP Extensions = False
+Stack Size = 250000
+Stack Reserve = 1048576
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DuSMC_MAIN"
+Sign = False
+Sign Store = ""
+Sign Certificate = ""
+Sign Timestamp URL = ""
+Sign URL = ""
+Manifest Embed = False
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Runtime Support = "Full Runtime Support"
+Runtime Binding = "Shared"
+Embed Project .UIRs = False
+Generate Map File = False
+Embed Timestamp = True
+Create Console Application = False
+Using LoadExternalModule = True
+DLL Exports = "Include File Symbols"
+Register ActiveX Server = False
+Numeric File Version = "1,0,0,0"
+Numeric Prod Version = "1,0,0,0"
+Comments = ""
+Comments Ex = ""
+Company Name = ""
+Company Name Ex = "%company"
+File Description = "usmc_ctrl_dbg (Debug x86)"
+File Description Ex = "%application (%rel_dbg %arch)"
+File Version = "1.0"
+File Version Ex = "%f1.%f2"
+Internal Name = "usmc_ctrl_dbg"
+Internal Name Ex = "%basename"
+Legal Copyright = "Copyright © 2017"
+Legal Copyright Ex = "Copyright © %company %Y"
+Legal Trademarks = ""
+Legal Trademarks Ex = ""
+Original Filename = "usmc_ctrl_dbg.exe"
+Original Filename Ex = "%filename"
+Private Build = ""
+Private Build Ex = ""
+Product Name = " usmc_ctrl_dbg"
+Product Name Ex = "%company %application"
+Product Version = "1.0"
+Product Version Ex = "%p1.%p2"
+Special Build = ""
+Special Build Ex = ""
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+
+[Default Build Config Release]
+Config Name = "Release"
+Is 64-Bit = False
+Is Release = True
+Default Calling Convention = "cdecl"
+Optimization Level = "No optimizations"
+Require Prototypes = True
+Show Warning IDs in Build Output = False
+Selected Warning Level = "None"
+Warning List None = "4,9,84,105,106,107,108,109,110,111"
+Warning List Common = ""
+Warning List Extended = ""
+Warning List All = ""
+Warning Mode = 0
+Enable Unreferenced Identifiers Warning = False
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Assignment In Conditional Warning = False
+Uninitialized Locals Compile Warning = "Aggressive"
+Require Return Values = True
+Enable C99 Extensions = False
+Enable OpenMP Extensions = False
+Stack Size = 250000
+Stack Reserve = 1048576
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DuSMC_MAIN"
+Sign = False
+Sign Store = ""
+Sign Certificate = ""
+Sign Timestamp URL = ""
+Sign URL = ""
+Manifest Embed = False
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Runtime Support = "Full Runtime Support"
+Runtime Binding = "Shared"
+Embed Project .UIRs = False
+Generate Map File = False
+Embed Timestamp = True
+Create Console Application = False
+Using LoadExternalModule = True
+DLL Exports = "Include File Symbols"
+Register ActiveX Server = False
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+
+[Default Build Config Debug64]
+Config Name = "Debug64"
+Is 64-Bit = True
+Is Release = False
+Default Calling Convention = "cdecl"
+Optimization Level = "No optimizations"
+Require Prototypes = True
+Show Warning IDs in Build Output = False
+Selected Warning Level = "None"
+Warning List None = "4,9,84,105,106,107,108,109,110,111"
+Warning List Common = ""
+Warning List Extended = ""
+Warning List All = ""
+Warning Mode = 0
+Enable Unreferenced Identifiers Warning = False
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Assignment In Conditional Warning = False
+Uninitialized Locals Compile Warning = "Aggressive"
+Require Return Values = True
+Enable C99 Extensions = False
+Enable OpenMP Extensions = False
+Stack Size = 250000
+Stack Reserve = 1048576
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DuSMC_MAIN"
+Sign = False
+Sign Store = ""
+Sign Certificate = ""
+Sign Timestamp URL = ""
+Sign URL = ""
+Manifest Embed = False
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Runtime Support = "Full Runtime Support"
+Runtime Binding = "Shared"
+Embed Project .UIRs = False
+Generate Map File = False
+Embed Timestamp = True
+Create Console Application = False
+Using LoadExternalModule = True
+DLL Exports = "Include File Symbols"
+Register ActiveX Server = False
+Numeric File Version = "1,0,0,0"
+Numeric Prod Version = "1,0,0,0"
+Comments = ""
+Comments Ex = ""
+Company Name = ""
+Company Name Ex = "%company"
+File Description = "uSMC (Debug x64)"
+File Description Ex = "%application (%rel_dbg %arch)"
+File Version = "1.0"
+File Version Ex = "%f1.%f2"
+Internal Name = "uSMC"
+Internal Name Ex = "%basename"
+Legal Copyright = "Copyright © 2017"
+Legal Copyright Ex = "Copyright © %company %Y"
+Legal Trademarks = ""
+Legal Trademarks Ex = ""
+Original Filename = "uSMC.exe"
+Original Filename Ex = "%filename"
+Private Build = ""
+Private Build Ex = ""
+Product Name = " uSMC"
+Product Name Ex = "%company %application"
+Product Version = "1.0"
+Product Version Ex = "%p1.%p2"
+Special Build = ""
+Special Build Ex = ""
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+
+[Default Build Config Release64]
+Config Name = "Release64"
+Is 64-Bit = True
+Is Release = True
+Default Calling Convention = "cdecl"
+Optimization Level = "No optimizations"
+Require Prototypes = True
+Show Warning IDs in Build Output = False
+Selected Warning Level = "None"
+Warning List None = "4,9,84,105,106,107,108,109,110,111"
+Warning List Common = ""
+Warning List Extended = ""
+Warning List All = ""
+Warning Mode = 0
+Enable Unreferenced Identifiers Warning = False
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Assignment In Conditional Warning = False
+Uninitialized Locals Compile Warning = "Aggressive"
+Require Return Values = True
+Enable C99 Extensions = False
+Enable OpenMP Extensions = False
+Stack Size = 250000
+Stack Reserve = 1048576
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DuSMC_MAIN"
+Sign = False
+Sign Store = ""
+Sign Certificate = ""
+Sign Timestamp URL = ""
+Sign URL = ""
+Manifest Embed = False
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Runtime Support = "Full Runtime Support"
+Runtime Binding = "Shared"
+Embed Project .UIRs = False
+Generate Map File = False
+Embed Timestamp = True
+Create Console Application = False
+Using LoadExternalModule = True
+DLL Exports = "Include File Symbols"
+Register ActiveX Server = False
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+
+[Compiler Options]
+Default Calling Convention = "cdecl"
+Require Prototypes = True
+Require Return Values = True
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Unreferenced Identifiers Warning = False
+Enable Assignment In Conditional Warning = False
+O Option Compatible With 5.0 = False
+Enable C99 Extensions = False
+Uninitialized Locals Compile Warning = "Aggressive"
+Precompile Prefix Header = False
+Prefix Header File = ""
+
+[Run Options]
+Stack Size = 250000
+Stack Commit = 4096
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+
+[Compiler Defines]
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DuSMC_MAIN"
+
+[Include Paths]
+Include Path 1 Is Rel = True
+Include Path 1 Rel To = "CVI"
+Include Path 1 Rel To Override = "CVI"
+Include Path 1 Rel Path = "instr/CAENV462"
+Include Path 1 = "/c/program files/national instruments/cvi2013/instr/CAENV462"
+Include Path 2 Is Rel = True
+Include Path 2 Rel To = "CVI"
+Include Path 2 Rel To Override = "CVI"
+Include Path 2 Rel Path = "instr/CAENV830"
+Include Path 2 = "/c/program files/national instruments/cvi2013/instr/CAENV830"
+Include Path 3 Is Rel = True
+Include Path 3 Rel To = "Project"
+Include Path 3 Rel Path = "../CAENV288"
+Include Path 3 = "/c/home/cvi/instr/CAENV288"
+Include Path 4 Is Rel = True
+Include Path 4 Rel To = "CVI"
+Include Path 4 Rel To Override = "CVI"
+Include Path 4 Rel Path = "instr/CAENV814"
+Include Path 4 = "/c/program files/national instruments/cvi2013/instr/CAENV814"
+
+[Create Executable]
+Executable File_Debug Is Rel = True
+Executable File_Debug Rel To = "Project"
+Executable File_Debug Rel Path = "usmc_ctrl_dbg.exe"
+Executable File_Debug = "/c/home/cvi/instr/uSMC/usmc_ctrl_dbg.exe"
+Executable File_Release Is Rel = True
+Executable File_Release Rel To = "Project"
+Executable File_Release Rel Path = "usmc_ctrl.exe"
+Executable File_Release = "/c/home/cvi/instr/uSMC/usmc_ctrl.exe"
+Executable File_Debug64 Is Rel = True
+Executable File_Debug64 Rel To = "Project"
+Executable File_Debug64 Rel Path = "uSMC.exe"
+Executable File_Debug64 = "/c/home/cvi/instr/uSMC/uSMC.exe"
+Executable File_Release64 Is Rel = True
+Executable File_Release64 Rel To = "Project"
+Executable File_Release64 Rel Path = "uSMC.exe"
+Executable File_Release64 = "/c/home/cvi/instr/uSMC/uSMC.exe"
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+DLL Exports = "Include File Symbols"
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+Type Lib Guid = ""
+Runtime Support = "Full Runtime Support"
+Instrument Driver Support Only = False
+Embed Project .UIRs = False
+Generate Map File = False
+
+[External Compiler Support]
+UIR Callbacks File Option = 0
+Using LoadExternalModule = False
+Create Project Symbols File = True
+UIR Callbacks Obj File Is Rel = False
+UIR Callbacks Obj File = ""
+Project Symbols H File Is Rel = False
+Project Symbols H File = ""
+Project Symbols Obj File Is Rel = False
+Project Symbols Obj File = ""
+
+[ActiveX Server Options]
+Specification File Is Rel = False
+Specification File = ""
+Source File Is Rel = False
+Source File = ""
+Include File Is Rel = False
+Include File = ""
+IDL File Is Rel = False
+IDL File = ""
+Register ActiveX Server = False
+
+[Signing Info]
+Sign = False
+Sign Debug Build = False
+Store = ""
+Certificate = ""
+Timestamp URL = ""
+URL = ""
+
+[Manifest Info]
+Embed = False
+
+[tpcSection]
+tpcEnabled = 0
+tpcOverrideEnvironment = 0
+tpcEnabled x64 = 0
+tpcOverrideEnvironment x64 = 0
+
Index: instr/uSMC/uSMC_ui.uir
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/instr/uSMC/uSMC_ui.uir
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: instr/uSMC/uSMCctrl.c
===================================================================
--- instr/uSMC/uSMCctrl.c (nonexistent)
+++ instr/uSMC/uSMCctrl.c (revision 255)
@@ -0,0 +1,532 @@
+/*
+
+usmc_ctrl -a
+usmc_ctrl -n 0 -i
+usmc_ctrl -n 0 -p 1 -s 5000 -m 10000 - p 0
+usmc_ctrl -n 0 -p 1 -h -p 0
+
+
+*/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifndef _WINDOWS
+# include "libusmc.h"
+# include <getopt.h>
+# define Delay(x) usleep((int)(x*1000000))
+#else
+# include "USMCDLL.H"
+# include <utility.h>
+# include <ansi_c.h>
+
+#define ERR(s, c) if(opterr) fprintf(stderr,"%s %c\n",s,c);
+
+
+int opterr = 1;
+int optind = 1;
+int optopt;
+char *optarg;
+
+int getopt(int argc, char **argv, char *opts){
+ static int sp = 1;
+ int c;
+ char *cp;
+
+ if(sp == 1)
+ if(optind >= argc ||
+ argv[optind][0] != '-' || argv[optind][1] == '\0')
+ return(EOF);
+ else if(strcmp(argv[optind], "--") == NULL) {
+ optind++;
+ return(EOF);
+ }
+ optopt = c = argv[optind][sp];
+ if(c == ':' || (cp=strchr(opts, c)) == NULL) {
+ ERR(": illegal option -- ", c);
+ if(argv[optind][++sp] == '\0') {
+ optind++;
+ sp = 1;
+ }
+ return('?');
+ }
+ if(*++cp == ':') {
+ if(argv[optind][sp+1] != '\0')
+ optarg = &argv[optind++][sp+1];
+ else if(++optind >= argc) {
+ ERR(": option requires an argument -- ", c);
+ sp = 1;
+ return('?');
+ } else
+ optarg = argv[optind++];
+ sp = 1;
+ } else {
+ if(argv[optind][++sp] == '\0') {
+ sp = 1;
+ optind++;
+ }
+ optarg = NULL;
+ }
+ return(c);
+}
+
+#endif
+
+#define MAXNODES 4
+USMC_Devices devices;
+USMC_StartParameters parstart[MAXNODES];
+USMC_Parameters parameters[MAXNODES];
+USMC_State parstate[MAXNODES];
+USMC_EncoderState parencstate[MAXNODES];
+#define ERRLEN 128
+char errstr[ERRLEN];
+
+// Function that prints information about device parameters to console
+void print_parameters(USMC_Parameters *Parameters)
+{
+ printf( "The parameters are:\n" );
+ printf( "Full acceleration time - %.0f ms\n", (double) Parameters->AccelT );
+ printf( "Full deceleration time - %.0f ms\n", (double) Parameters->DecelT );
+ printf( "Power reduction timeout - %.0f ms\n", (double) Parameters->PTimeout );
+ printf( "Button speedup timeout 1 - %.0f ms\n", (double) Parameters->BTimeout1 );
+ printf( "Button speed after timeout 1 - %.2f steps/s\n", (double) Parameters->BTO1P );
+ printf( "Button speedup timeout 2 - %.0f ms\n", (double) Parameters->BTimeout2 );
+ printf( "Button speed after timeout 2 - %.2f steps/s\n", (double) Parameters->BTO2P );
+ printf( "Button speedup timeout 3 - %.0f ms\n", (double) Parameters->BTimeout3 );
+ printf( "Button speed after timeout 3 - %.2f steps/s\n", (double) Parameters->BTO3P );
+ printf( "Button speedup timeout 4 - %.0f ms\n", (double) Parameters->BTimeout4 );
+ printf( "Button speed after timeout 4 - %.2f steps/s\n", (double) Parameters->BTO4P );
+ printf( "Button reset timeout - %.0f ms\n", (double) Parameters->BTimeoutR );
+ printf( "Button reset operation speed - %.2f steps/s\n", (double) Parameters->MinP );
+ printf( "Backlash operation distance - %d steps\n", (int)Parameters->MaxLoft );
+ printf( "Revolution distance - %d steps\n", (int)Parameters->RTDelta );
+ printf( "Minimal revolution distance error - %d steps\n", (int)Parameters->RTMinError );
+ printf( "Power off temperature - %.2f\xf8\x43\n", (double)Parameters->MaxTemp );
+ printf( "Duration of the output synchronization pulse - ");
+ if(Parameters->SynOUTP == 0)
+ printf( "minimal\n");
+ else
+ printf( "%.1f * [Tact Period]\n", Parameters->SynOUTP - 0.5);
+ printf( "Speed of the last phase of the backlash operation - ");
+ if(Parameters->LoftPeriod == 0.0f)
+ printf( "normal\n" );
+ else
+ printf( "%.2f steps/s\n", (double)Parameters->LoftPeriod );
+ printf( "<Angular Encoder Step> Equals <Angular Step Motor Step>/<%.2f>\n", Parameters->EncMult);
+
+}
+
+// Function that prints information about device start parameters to console
+void print_start_params ( const USMC_StartParameters sp ){
+ printf ( "* Steps Divisor - %d\n", sp.SDivisor );
+
+ if ( sp.SDivisor == 1 )
+ printf ( "* Slow start/stop mode - %s\n", sp.SlStart ? "Enabled" : "Disabled" );
+ else if ( sp.LoftEn ) {
+ printf ( "* Automatic backlash operation - Enabled\n" );
+ printf ( "* Automatic backlash operation direction - %s\n", sp.DefDir ? "CCW" : "CW" );
+ printf ( "* Force automatic backlash operation - %s\n", sp.ForceLoft ? "TRUE" : "FALSE" );
+ } else {
+ printf ( "* Automatic backlash operation - Disabled\n" );
+ }
+ if ( sp.WSyncIN )
+ printf ( "* Controller will wait for input synchronization signal to start\n" );
+ else
+ printf ( "* Input synchronization signal ignored \n" );
+
+ printf ( "* Output synchronization counter will %sbe reset\n", sp.SyncOUTR ? "" : "not " );
+}
+
+// Function that prints information about device state to console
+void print_state(USMC_State *State)
+{
+ printf( " The state is:\n" );
+ printf( "- Current Position in microsteps - %d\n", State->CurPos );
+ printf( "- Temperature - %.2f\xf8\x43\n", State->Temp );
+ printf( "- Step Divisor - %d\n", State->SDivisor);
+ printf( "- Loft State - %s\n", State->Loft?"Indefinite":"Fixed" );
+ printf( "- Power - %s\n", State->Power?(State->FullPower?"Full":"Half"):"Off" );
+ if(State->RUN)
+ printf( "- Step Motor is Running in %s Direction %s\n",
+ State->CW_CCW?"CCW":"CW", ((State->SDivisor==1) && State->FullSpeed)?"at Full Speed":"" );
+ else
+ printf( "- Step Motor is Not Running\n" );
+ printf( "- Device %s\n", State->AReset?"is After Reset":"Position Already Set" );
+ printf( "- Input Synchronization Logical Pin State - %s\n", State->SyncIN?"TRUE":"FALSE" );
+ printf( "- Output Synchronization Logical Pin State - %s\n", State->SyncOUT?"TRUE":"FALSE" );
+ printf( "- Rotary Transducer Logical Pin State - %s\n", State->RotTr?"TRUE":"FALSE" );
+ printf( "- Rotary Transducer Error Flag - %s\n", State->RotTrErr?"Error":"Clear" );
+ printf( "- Emergency Disable Button - %s\n", State->EmReset?"Pushed":"Unpushed" );
+ printf( "- Trailer 1 Press State - %s\n", State->Trailer1?"Pushed":"Unpushed" );
+ printf( "- Trailer 2 Press State - %s\n", State->Trailer2?"Pushed":"Unpushed" );
+ if( State->Voltage == 0.0f )
+ printf( "- Input Voltage - Low\n");
+ else
+ printf( "- Input Voltage - %.1fV\n", State->Voltage);
+
+}
+
+void print_enc_state ( USMC_EncoderState enc_state )
+{
+ printf ( "# The encoder state is:\n" );
+ printf ( "# Current Position in \"Half of Encoder Step\"s - %d\n", enc_state.ECurPos );
+ printf ( "# Encoder Position in \"Half of Encoder Step\"s - %d\n", enc_state.EncoderPos );
+
+}
+
+
+// Function that prints information about connected devices to console
+void printdevices(USMC_Devices DVS)
+{
+ DWORD i;
+ for( i = 0; i < DVS.NOD; i++)
+ {
+ printf("Device - %d,\tSerial Number - %.16s,\tVersion - %.4s\n",i,DVS.Serial[i],DVS.Version[i]);
+ }
+}
+
+int usmc_Set_Parameters(int Dev, int mode)
+{
+ USMC_Mode umode;
+ if( USMC_GetParameters(Dev, &parameters[Dev]) )
+ return TRUE;
+
+switch (mode) {
+case 1:
+ // Linear stage
+ parameters[Dev].MaxTemp = 70.0f;
+ parameters[Dev].AccelT = 200.0f;
+ parameters[Dev].DecelT = 200.0f;
+ parameters[Dev].BTimeout1 = 500.0f;
+ parameters[Dev].BTimeout2 = 500.0f;
+ parameters[Dev].BTimeout3 = 500.0f;
+ parameters[Dev].BTimeout4 = 500.0f;
+ parameters[Dev].BTO1P = 10.0f;
+ parameters[Dev].BTO2P = 20.0f;
+ parameters[Dev].BTO3P = 30.0f;
+ parameters[Dev].BTO4P = 60.0f;
+ parameters[Dev].MinP = 60.0f;
+ parameters[Dev].BTimeoutR = 500.0f;
+ parameters[Dev].LoftPeriod = 50.0f;
+ parameters[Dev].RTDelta = 20;
+ parameters[Dev].RTMinError = 15;
+ parameters[Dev].EncMult = 2.5f;
+ parameters[Dev].MaxLoft = 32;
+ parameters[Dev].PTimeout = 100.0f;
+ parameters[Dev].SynOUTP = 1;
+ break;
+case 0:
+// Rotation stage
+ parameters[Dev].MaxTemp = 70.0f;
+ parameters[Dev].AccelT = 200.0f;
+ parameters[Dev].DecelT = 200.0f;
+ parameters[Dev].BTimeout1 = 500.0f;
+ parameters[Dev].BTimeout2 = 500.0f;
+ parameters[Dev].BTimeout3 = 500.0f;
+ parameters[Dev].BTimeout4 = 500.0f;
+ parameters[Dev].BTO1P = 100.0f;
+ parameters[Dev].BTO2P = 200.0f;
+ parameters[Dev].BTO3P = 300.0f;
+ parameters[Dev].BTO4P = 600.0f;
+ parameters[Dev].MinP = 500.0f;
+ parameters[Dev].BTimeoutR = 500.0f;
+ parameters[Dev].LoftPeriod = 500.0f;
+ parameters[Dev].RTDelta = 200;
+ parameters[Dev].RTMinError = 15;
+ parameters[Dev].EncMult = 2.5f;
+ parameters[Dev].MaxLoft = 32;
+ parameters[Dev].PTimeout = 100.0f;
+ parameters[Dev].SynOUTP = 1;
+ break;
+ }
+
+ //
+
+ if( USMC_SetParameters( Dev, &parameters[Dev] ) )
+ return TRUE;
+
+ if( USMC_SaveParametersToFlash( Dev ) )
+ return TRUE;
+
+
+ if (mode){
+ if ( USMC_GetMode ( Dev, &umode ) ) return FALSE;
+ umode.TrSwap = 0;
+ if ( USMC_SetMode ( Dev, &umode ) ) return FALSE;
+ printf ( "Now, TrSwap is %d \n", umode.TrSwap );
+ }
+ //system("cls");
+ print_parameters( &parameters[Dev] );
+ printf("\nThese Parameters are Saved to Flash");
+
+ return FALSE;
+}
+
+int usmc_Init(int node, int mode){
+ printf("\nNode %d\n",node);
+ USMC_GetStartParameters(node,&parstart[node]);
+ USMC_GetLastErr(errstr,ERRLEN); if (strlen(errstr)) printf("i1 %s\n",errstr);
+
+ USMC_GetState(node,&parstate[node]);
+ USMC_GetLastErr(errstr,ERRLEN); if (strlen(errstr)) printf("i2 %s\n",errstr);
+
+ USMC_GetEncoderState(node,&parencstate[node]);
+ USMC_GetLastErr(errstr,ERRLEN); if (strlen(errstr)) printf("i3 %s\n",errstr);
+
+ print_state(&parstate[node]);
+ print_enc_state ( parencstate[node]);
+ print_start_params (parstart[node] );
+ usmc_Set_Parameters(node, mode);
+ return 0;
+}
+
+float usmc_speed=10000;
+
+int usmc_Move(int node, int pos, BOOL absrel){
+ time_t tcur=0, tprev=-1;
+ USMC_GetStartParameters(node,&parstart[node]);
+ USMC_GetLastErr(errstr,ERRLEN); if (strlen(errstr)) printf("x1 %s\n",errstr);
+
+ parstart[node].WSyncIN=absrel;
+ parstart[node].SlStart=1;
+ parstart[node].LoftEn=0;
+ print_start_params ( parstart[node] );
+ USMC_Start(node,pos,&usmc_speed, &parstart[node]);
+ USMC_GetLastErr(errstr,ERRLEN); if (strlen(errstr)) printf("x2 %s speed %f\n",errstr,usmc_speed);
+
+ do {
+ USMC_GetState(node,&parstate[node]);
+ USMC_GetLastErr(errstr,ERRLEN); // if (strlen(errstr)) printf("x3 %s\n",errstr);
+ tcur= time(NULL);
+ if (tcur != tprev){
+ printf("%d CurPos %d L%d R%d Rot%d %s %s\n",node,
+ parstate[node].CurPos,parstate[node].Trailer1,parstate[node].Trailer2, parstate[node].RotTr,
+ parstate[node].RUN?"Run":"Stopped",parstate[node].Power?"On":"Off" );
+ tprev= tcur;
+ }
+
+ } while ( parstate[node].RUN == 1 );
+
+
+ USMC_GetState(node,&parstate[node]);
+ printf("***** %d CurPos %d L%d R%d %s %s\n",node,
+ parstate[node].CurPos,parstate[node].Trailer1,parstate[node].Trailer2,
+ parstate[node].RUN?"Run":"Stopped",parstate[node].Power?"On":"Off" );
+ USMC_GetParameters(node,&parameters[node]);
+ USMC_GetEncoderState(node,&parencstate[node]);
+ printf("node %d ECurPos 0x%0x %f EncoderPos =0x%04x %f\n",node,
+ parencstate[node].ECurPos, (((parencstate[node].ECurPos)>>5)&0x8FFFFF)/parameters[node].EncMult,
+ parencstate[node].EncoderPos,((parencstate[node].EncoderPos >> 5)&0x8FFFFF)/parameters[node].EncMult);
+
+
+ return 0;
+}
+
+
+
+void usmc_PowerOnOff ( int cur_dev, int smpower ){
+
+ USMC_Mode mode;
+ if ( USMC_GetMode ( cur_dev, &mode ) ) return;
+ mode.ResetD = !smpower;
+ if ( USMC_SetMode ( cur_dev, &mode ) ) return;
+ printf ( "Now, Power of the node %d is %s\n", cur_dev, mode.ResetD ? "Off" : "On" );
+}
+
+int usmc_RelMove(int node, int pos){
+ return usmc_Move(node,pos, TRUE);
+}
+int usmc_MoveTo(int node, int pos){
+ return usmc_Move(node,pos, FALSE);
+}
+
+int Revert_Start_Position_to_0(int node)
+{
+ USMC_Parameters Prms;
+ // Initialize structures (in case this function runs first)
+ if( USMC_GetParameters(node, &Prms) )
+ return TRUE;
+ Prms.StartPos = 0;
+ if( USMC_SetParameters( node, &Prms ) )
+ return TRUE;
+ // Then of Course You Need to SaveToFlash
+ if( USMC_SaveParametersToFlash( node ) )
+ return TRUE;
+ //system("cls");
+ printf("\nStart Position is Reset to 0\n");
+ printf("\nPress any key to exit");
+ return FALSE;
+}
+
+int usmc_Reset(int node, int mode){
+
+usmc_Init(node,mode);
+USMC_SetCurrentPosition(node, 0);
+Revert_Start_Position_to_0(node);
+return 0;
+}
+
+int usmc_ReferenceMove(int node, int mode){
+
+int pos = 1000000;
+int dir=1;
+if (mode) dir = -1;
+
+USMC_GetState(node,&parstate[node]);
+usmc_MoveTo(node, parstate[node].CurPos -2 *pos * dir);
+USMC_GetState(node,&parstate[node]);
+pos = 5000;
+if (mode) pos=500;
+usmc_MoveTo(node, parstate[node].CurPos + pos * dir);
+USMC_GetState(node,&parstate[node]);
+usmc_speed /=5;
+usmc_MoveTo(node, parstate[node].CurPos -2 *pos * dir);
+USMC_GetState(node,&parstate[node]);
+pos = 2000;
+if (mode) pos=200;
+usmc_MoveTo(node, parstate[node].CurPos + pos *dir);
+USMC_GetState(node,&parstate[node]);
+usmc_speed /= 10;
+usmc_MoveTo(node, parstate[node].CurPos -2 *pos * dir);
+USMC_GetState(node,&parstate[node]);
+USMC_SetCurrentPosition(node, 0);
+Revert_Start_Position_to_0(node);
+return 0;
+}
+
+int help(){
+fprintf(stderr, "Usage: mikro [-i node][-n node] [-u up] [-d down] [-r node] [-h node] [-a] [-g] [-m pos]\n");
+ fprintf(stderr," Options:\n");
+ fprintf(stderr," -n node -i mode .. initialize node\n");
+ fprintf(stderr," -n node -h .. homing procedure for node\n");
+ fprintf(stderr," -n node -p 1 .. power on\n");
+ fprintf(stderr," -n node -p 0 .. power off\n");
+ fprintf(stderr," -n node -r mode .. reset node\n");
+ fprintf(stderr," -n node -u .. move node for +1000\n");
+ fprintf(stderr," -n node -d .. move node for -1000\n");
+ fprintf(stderr," -a .. current status of the nodes\n");
+ fprintf(stderr," -n node -v value -f cmd .. set value of the cmd on the node\n");
+ fprintf(stderr," -n node -g cmd .. get value of the cmd on the node\n");
+ fprintf(stderr," -n node -m position -s speed .. move node to position at speed (default 10000)\n");
+ fprintf(stderr," -l delaysec .. loop test with the delay delaysec\n");
+return 0;
+}
+
+
+#ifndef _WINDOWS
+
+int main (int argc, char ** argv){
+ int i,j,k;
+ int node=0,opt,value=0;
+ int EOldPos=-1;
+ if ( USMC_Init ( &devices ) ) abort();
+
+
+ while ((opt = getopt(argc, argv, "i:av:f:l:udn:m:s:v:g:h:r:p:")) != -1) {
+ switch (opt) {
+ case 'i':
+ usmc_Init (node, atoi(optarg));
+
+ break;
+ case 'a':
+ printdevices(devices);
+ for (i=0;i<devices.NOD;i++){
+
+ USMC_GetState(i,&parstate[i]);
+ printf("%d CurPos %d L%d R%d %s %s\t",i,
+ parstate[i].CurPos,parstate[i].Trailer1,parstate[i].Trailer2,
+ parstate[i].RUN?"Run":"Stopped",parstate[i].Power?"On":"Off" );
+ USMC_GetParameters(i,&parameters[i]);
+ USMC_GetEncoderState(i,&parencstate[i]);
+ printf("node %d ECurPos 0x%0x %f EncoderPos =0x%04x %f\n",i,
+ parencstate[i].ECurPos, (((parencstate[i].ECurPos)>>5)&0x8FFFFF)/parameters[i].EncMult,
+ parencstate[i].EncoderPos,((parencstate[i].EncoderPos >> 5)&0x8FFFFF)/parameters[i].EncMult);
+
+ }
+ break;
+
+ case 'l':
+ printf("usmc_MoveTo Loop\n");
+ for (i=0;i<5;i++){
+ int xpos=i*1000+10000;
+ usmc_MoveTo (1, xpos);
+ for (j=0;j<5;j++){
+ int ypos=j*1000+10000;
+ usmc_MoveTo (2, ypos);
+ for (k=0;k<50;k++){
+ int zpos=k*1000+10000;
+ usmc_MoveTo (3, zpos);
+ printf("x=%d y=%d z=%d\n",xpos,ypos,zpos);
+ Delay(atof(optarg));
+
+ }
+ }
+ }
+ break;
+ case 'n':
+ node = atoi(optarg);
+ break;
+ case 's':
+ usmc_speed = atoi(optarg);
+ break;
+ case 'p':
+ usmc_PowerOnOff(node,atoi(optarg));
+ break;
+ case 'm':
+ usmc_MoveTo (node, atoi(optarg));
+ printf("usmc_MoveTo node=%d pos=%d \n",node,atoi(optarg));
+
+ break;
+ case 'v':
+ value=atoi(optarg);
+ break;
+ /*
+ case 'f':
+ MIKRO_Set (node,optarg,value);
+ printf("MIKRO_Set node %d cmd=%s val=%d\n",node,optarg, value);
+ break;
+ case 'g':
+ MIKRO_Get (node,optarg,&i);
+ printf("MIKRO_Get node %d cmd=%s val=%d\n",node,optarg, i);
+
+ break;
+
+
+ */
+
+ case 'r':
+ printf("usmc_Reset node=%d mode=%d\n",node, atoi(optarg));
+ usmc_Reset (node, atoi(optarg));
+ break;
+
+ case 'h':
+ printf("usmc_ReferenceMove node=%d mode=%d\n",node, atoi(optarg));
+ usmc_ReferenceMove (node, atoi(optarg));
+ break;
+
+ case 'u':
+ usmc_RelMove(node, 1000);
+ break;
+ case 'd':
+ usmc_RelMove(node, -1000);
+ break;
+
+
+ default: /* '?' */
+ help();
+
+ break;
+ }
+ }
+ if (argc==1) help();
+
+
+ USMC_Close ();
+#ifdef _WINDOWS
+ getchar();
+#endif
+ return 0;
+}
+
+
+#endif
Index: instr/uSMC/uSMCctrl.h
===================================================================
--- instr/uSMC/uSMCctrl.h (nonexistent)
+++ instr/uSMC/uSMCctrl.h (revision 255)
@@ -0,0 +1,20 @@
+#ifndef usmcctrl_h
+#define usmcctrl_h
+
+#define MAXNODES 4
+USMC_Devices devices;
+USMC_StartParameters parstart[MAXNODES];
+USMC_Parameters parameters[MAXNODES];
+USMC_State parstate[MAXNODES];
+USMC_EncoderState parencstate[MAXNODES];
+
+int usmc_Set_Parameters(int Dev, int mode);
+int usmc_Init(int node, int mode);
+int usmc_Move(int node, int pos, BOOL absrel);
+void usmc_PowerOnOff ( int cur_dev, int smpower );
+int usmc_RelMove(int node, int pos);
+int usmc_MoveTo(int node, int pos);
+int Revert_Start_Position_to_0(int node);
+int usmc_Reset(int node, int mode);
+int usmc_ReferenceMove(int node, int mode);
+#endif