Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
335 | f9daq | 1 | // USMCDLL.h - header file with declorations of USMCDLL.dll functions and used structures |
2 | // -SD |
||
3 | // Note::C++ |
||
4 | // Use functions with reference arguments as in sample |
||
5 | // Note.C |
||
6 | // Use functions with address of operator in invoke expression: func(var1, &struct); |
||
7 | // (For Rev. 24) Will work correctly with firmware version 24.03 or better |
||
8 | |||
9 | #pragma once |
||
10 | |||
11 | #include <windows.h> |
||
12 | |||
13 | // Please use the USMCDLL.lib to easely import functions from dll with "dllimport" (In Microsoft Visual Studio) |
||
14 | #ifdef USMCDLL_EXPORTS |
||
15 | #define USMCDLL_API __declspec(dllexport) |
||
16 | #else |
||
17 | #define USMCDLL_API __declspec(dllimport) |
||
18 | #endif |
||
19 | |||
20 | // Structure representing connected devices |
||
21 | typedef struct USMC_Devices_st{ |
||
22 | DWORD NOD; // Number of the devices ready to work |
||
23 | |||
24 | char **Serial; // Array of 16 byte ASCII strings |
||
25 | char **Version; // Array of 4 byte ASCII strings |
||
26 | } USMC_Devices; // Structure representing connected devices |
||
27 | |||
28 | // Structure representing some of divice parameters |
||
29 | typedef struct USMC_Parameters_st{ |
||
30 | float AccelT; // Acceleration time (in ms) |
||
31 | float DecelT; // Deceleration time (in ms) |
||
32 | float PTimeout; // Time (in ms) after which current will be reduced to 60% of normal |
||
33 | float BTimeout1; // Time (in ms) after which speed of step motor rotation will be equal to the one specified at |
||
34 | // BTO1P field (see below). (This parameter is used when controlling step motor using buttons) |
||
35 | float BTimeout2; // |
||
36 | float BTimeout3; // |
||
37 | float BTimeout4; // |
||
38 | float BTimeoutR; // Time (in ms) after which reset command will be performed |
||
39 | float BTimeoutD; // This field is reserved for future use |
||
40 | float MinP; // Speed (steps/sec) while performing reset operation. (This parameter is used when controlling |
||
41 | // step motor using buttons) |
||
42 | float BTO1P; // Speed (steps/sec) after BTIMEOUT 1 time have passed. (This parameter is used when controlling |
||
43 | // step motor using buttons) |
||
44 | float BTO2P; // |
||
45 | float BTO3P; // |
||
46 | float BTO4P; // |
||
47 | WORD MaxLoft; // Value in full steps that will be used performing backlash operation |
||
48 | DWORD StartPos; // Current Position Saved to FLASH (see Test MicroSMC.cpp) |
||
49 | WORD RTDelta; // Revolution distance – number of full steps per one full revolution |
||
50 | WORD RTMinError; // Number of full steps missed to raise the error flag |
||
51 | float MaxTemp; // Maximum allowed temperature (Celsius) |
||
52 | BYTE SynOUTP; // Duration of the output synchronization pulse |
||
53 | float LoftPeriod; // Speed of the last phase of the backlash operation. |
||
54 | float EncMult; // Should be <Encoder Steps per Evolution> / <SM Steps per Evolution> and should be integer multiplied by 0.25 |
||
55 | |||
56 | BYTE Reserved[16]; // <Unused> File padding |
||
57 | |||
58 | } USMC_Parameters; |
||
59 | |||
60 | // Structure representing start function parameters |
||
61 | typedef struct USMC_StartParameters_st{ |
||
62 | BYTE SDivisor; // Step is divided by this factor (1,2,4,8) |
||
63 | BOOL DefDir; // Direction for backlash operation (relative) |
||
64 | BOOL LoftEn; // Enable automatic backlash operation (works if slow start/stop mode is off) |
||
65 | BOOL SlStart; // If TRUE slow start/stop mode enabled. |
||
66 | BOOL WSyncIN; // If TRUE controller will wait for input synchronization signal to start |
||
67 | BOOL SyncOUTR; // If TRUE output synchronization counter will be reset |
||
68 | BOOL ForceLoft; // If TRUE and destination position is equal to the current position backlash operation will be performed. |
||
69 | BYTE Reserved[4]; // <Unused> File padding |
||
70 | } USMC_StartParameters; |
||
71 | |||
72 | // Structure representing some of divice parameters |
||
73 | typedef struct USMC_Mode_st{ |
||
74 | BOOL PMode; // Turn off buttons (TRUE - buttons disabled) |
||
75 | BOOL PReg; // Current reduction regime (TRUE - regime is on) |
||
76 | BOOL ResetD; // Turn power off and make a whole step (TRUE - apply) |
||
77 | BOOL EMReset; // Quick power off |
||
78 | BOOL Tr1T; // Trailer 1 TRUE state (TRUE : +3/+5Â; FALSE : 0Â) |
||
79 | BOOL Tr2T; // Trailer 2 TRUE state (TRUE : +3/+5Â; FALSE : 0Â) |
||
80 | BOOL RotTrT; // Rotary Transducer TRUE state (TRUE : +3/+5Â; FALSE : 0Â) |
||
81 | BOOL TrSwap; // If TRUE, Trailers are treated to be swapped |
||
82 | BOOL Tr1En; // If TRUE Trailer 1 Operation Enabled |
||
83 | BOOL Tr2En; // If TRUE Trailer 2 Operation Enabled |
||
84 | BOOL RotTeEn; // If TRUE Rotary Transducer Operation Enabled |
||
85 | BOOL RotTrOp; // Rotary Transducer Operation Select (stop on error for TRUE) |
||
86 | BOOL Butt1T; // Button 1 TRUE state (TRUE : +3/+5Â; FALSE : 0Â) |
||
87 | BOOL Butt2T; // Button 2 TRUE state (TRUE : +3/+5Â; FALSE : 0Â) |
||
88 | BOOL ResetRT; // Reset Rotary Transducer Check Positions (need one full revolution before it can detect error) |
||
89 | BOOL SyncOUTEn; // If TRUE output syncronization enabled |
||
90 | BOOL SyncOUTR; // If TRUE output synchronization counter will be reset |
||
91 | BOOL SyncINOp; // Synchronization input mode: |
||
92 | // True - Step motor will move one time to the destination position |
||
93 | // False - Step motor will move multiple times by steps equal to the value destination position |
||
94 | DWORD SyncCount; // Number of steps after which synchronization output sygnal occures |
||
95 | BOOL SyncInvert; // Set to TRUE to invert output synchronization signal |
||
96 | |||
97 | BOOL EncoderEn; // Enable Encoder on pins {SYNCIN,ROTTR} - disables Synchronization input and Rotary Transducer |
||
98 | BOOL EncoderInv; // Invert Encoder Counter Direction |
||
99 | BOOL ResBEnc; // Reset <Encoder Position> and <SM Position in Encoder units> to 0 |
||
100 | BOOL ResEnc; // Reset <SM Position in Encoder units> to <Encoder Position> |
||
101 | |||
102 | BYTE Reserved[8]; // <Unused> File padding |
||
103 | |||
104 | } USMC_Mode; |
||
105 | |||
106 | // Structure representing divice state |
||
107 | typedef struct USMC_State_st{ |
||
108 | int CurPos; // Current position (in microsteps) |
||
109 | float Temp; // Current temperature of the driver |
||
110 | BYTE SDivisor; // Step is divided by this factor |
||
111 | BOOL Loft; // Indicates backlash status |
||
112 | BOOL FullPower; // If TRUE then full power. |
||
113 | BOOL CW_CCW; // Current direction. Relatively! |
||
114 | BOOL Power; // If TRUE then Step Motor is ON. |
||
115 | BOOL FullSpeed; // If TRUE then full speed. Valid in "Slow Start" mode only. |
||
116 | BOOL AReset; // TRUE After Device reset, FALSE after "Set Position". |
||
117 | BOOL RUN; // Indicates if step motor is rotating |
||
118 | BOOL SyncIN; // Logical state directly from input synchronization PIN |
||
119 | BOOL SyncOUT; // Logical state directly from output synchronization PIN |
||
120 | BOOL RotTr; // Indicates current rotary transducer press state |
||
121 | BOOL RotTrErr; // Indicates rotary transducer error flag |
||
122 | BOOL EmReset; // Indicates state of emergency disable button (local control) |
||
123 | BOOL Trailer1; // Indicates trailer 1 logical state. |
||
124 | BOOL Trailer2; // Indicates trailer 2 logical state. |
||
125 | float Voltage; // Input power source voltage (6-39V) -=24 version 0nly=- |
||
126 | |||
127 | BYTE Reserved[8]; // <Unused> File padding |
||
128 | } USMC_State; |
||
129 | |||
130 | // New For Firmware Version 2.4.1.0 (0x2410) |
||
131 | typedef struct USMC_EncoderState_st{ |
||
132 | int EncoderPos; // Current position measured by encoder |
||
133 | int ECurPos; // Current position (in Encoder Steps) - Synchronized with request call |
||
134 | |||
135 | BYTE Reserved[8]; // <Unused> File padding |
||
136 | } USMC_EncoderState; |
||
137 | |||
138 | // ~New For Firmware Version 2.4.1.0 (0x2410) |
||
139 | |||
140 | typedef struct USMC_Info_st{ |
||
141 | char serial[17]; |
||
142 | DWORD dwVersion; |
||
143 | char DevName[32]; |
||
144 | int CurPos, DestPos; |
||
145 | float Speed; |
||
146 | BOOL ErrState; |
||
147 | |||
148 | BYTE Reserved[16]; // <Unused> File padding |
||
149 | } USMC_Info; |
||
150 | |||
151 | |||
152 | #ifdef __cplusplus // C++ |
||
153 | extern "C" { |
||
154 | // |
||
155 | // The USMC_Init function initializes driver and returns devices information |
||
156 | // |
||
157 | USMCDLL_API DWORD USMC_Init( USMC_Devices &Str); // OUT - Array of structures describing all divices (may be NULL) MUST NOT be deleted |
||
158 | |||
159 | // |
||
160 | // The USMC_GetState function returns structure representing current state of device |
||
161 | // |
||
162 | USMCDLL_API DWORD USMC_GetState( DWORD Device, // IN - Device number |
||
163 | USMC_State &Str // OUT - Structure representing divice state |
||
164 | ); |
||
165 | // |
||
166 | // The USMC_SaveParametersToFlash function saves current parameters of controller in static memory |
||
167 | // so thay can be loaded at start up time |
||
168 | // |
||
169 | USMCDLL_API DWORD USMC_SaveParametersToFlash( DWORD Device // IN - Device number |
||
170 | ); |
||
171 | // |
||
172 | // The USMC_SetCurrentPosition function sets current position of controller |
||
173 | // |
||
174 | USMCDLL_API DWORD USMC_SetCurrentPosition( DWORD Device, // IN - Device number |
||
175 | int Position // IN - New position |
||
176 | ); |
||
177 | // |
||
178 | // The USMC_GetMode function returns USMC_Mode structure last sent to device |
||
179 | // |
||
180 | USMCDLL_API DWORD USMC_GetMode( DWORD Device, // IN - Device number |
||
181 | USMC_Mode &Str // OUT - Structure representing some of divice parameters |
||
182 | ); |
||
183 | // |
||
184 | // The USMC_SetMode function sets some of device parameters |
||
185 | // |
||
186 | USMCDLL_API DWORD USMC_SetMode( DWORD Device, // IN - Device number |
||
187 | USMC_Mode &Str // IN/OUT Structure representing some of divice parameters |
||
188 | ); |
||
189 | // |
||
190 | // The USMC_GetParameters function returns USMC_Parameters structure last sent to device |
||
191 | // |
||
192 | USMCDLL_API DWORD USMC_GetParameters( DWORD Device, // IN - Device number |
||
193 | USMC_Parameters &Str // OUT - Structure representing some of divice parameters |
||
194 | ); |
||
195 | // |
||
196 | // The USMC_SetParameters function sets some of divice parameters |
||
197 | // |
||
198 | USMCDLL_API DWORD USMC_SetParameters( DWORD Device, // IN - Device number |
||
199 | USMC_Parameters &Str // IN/OUT Structure representing some of divice parameters |
||
200 | ); |
||
201 | // |
||
202 | // The USMC_GetStartParameters function returns USMC_StartParameters structure last sent to device |
||
203 | // |
||
204 | USMCDLL_API DWORD USMC_GetStartParameters( DWORD Device, // IN - Device number |
||
205 | USMC_StartParameters &Str // OUT - Structure representing start function parameters |
||
206 | ); |
||
207 | // |
||
208 | // The USMC_Start function sets start parameters and starts motion |
||
209 | // |
||
210 | USMCDLL_API DWORD USMC_Start( DWORD Device, // IN - Device number |
||
211 | int DestPos, // IN - Destination position |
||
212 | float &Speed, // IN/OUT - Speed of rotation |
||
213 | USMC_StartParameters &Str // IN/OUT - Structure representing start function parameters |
||
214 | ); |
||
215 | // |
||
216 | // The USMC_Stop function stops device |
||
217 | // |
||
218 | USMCDLL_API DWORD USMC_Stop( DWORD Device // IN - Device number |
||
219 | ); |
||
220 | // |
||
221 | // The USMC_GetLastErr function return string representing last error |
||
222 | // |
||
223 | USMCDLL_API void USMC_GetLastErr( char *str, // OUT - String buffer |
||
224 | size_t len // IN - Lenght of that string buffer in bytes |
||
225 | ); |
||
226 | |||
227 | // |
||
228 | // The USMC_GetDllVersion function returnes version values of USMCDLL.dll |
||
229 | // |
||
230 | USMCDLL_API void USMC_GetDllVersion( DWORD &dwHighVersion, // OUT - High Version Value |
||
231 | DWORD &dwLowVersion); // OUT - Low Version Value |
||
232 | |||
233 | // |
||
234 | // The USMC_Close function closes virtual driver window "microsmc.exe" |
||
235 | // |
||
236 | USMCDLL_API DWORD USMC_Close( void ); |
||
237 | |||
238 | // |
||
239 | // The USMC_RestoreCurPos function checks AReset bit and if it is TRUE |
||
240 | // restores previous CurPos value |
||
241 | // |
||
242 | USMCDLL_API DWORD USMC_RestoreCurPos(DWORD Device // IN - Device number |
||
243 | ); |
||
244 | |||
245 | // New For Firmware Version 2.4.1.0 (0x2410) |
||
246 | |||
247 | // |
||
248 | // The USMC_GetEncoderState function returns structure representing current position of encoder |
||
249 | // |
||
250 | USMCDLL_API DWORD USMC_GetEncoderState( DWORD Device, // IN - Device number |
||
251 | USMC_EncoderState &Str // IN/OUT Structure containing encoder state |
||
252 | ); |
||
253 | |||
254 | // ~New For Firmware Version 2.4.1.0 (0x2410) |
||
255 | |||
256 | } // extern "C" |
||
257 | #else // C |
||
258 | DWORD USMC_Init( USMC_Devices *Str ); |
||
259 | DWORD USMC_GetState( DWORD Device, USMC_State *Str ); |
||
260 | DWORD USMC_SaveParametersToFlash( DWORD Device ); |
||
261 | DWORD USMC_SetCurrentPosition( DWORD Device, int Position ); |
||
262 | DWORD USMC_GetMode( DWORD Device, USMC_Mode *Str ); |
||
263 | DWORD USMC_SetMode( DWORD Device, USMC_Mode *Str ); |
||
264 | DWORD USMC_GetParameters( DWORD Device, USMC_Parameters *Str ); |
||
265 | DWORD USMC_SetParameters( DWORD Device, USMC_Parameters *Str ); |
||
266 | DWORD USMC_GetStartParameters( DWORD Device, USMC_StartParameters *Str ); |
||
267 | DWORD USMC_Start( DWORD Device, int DestPos, float *Speed, USMC_StartParameters *Str); |
||
268 | DWORD USMC_Stop( DWORD Device ); |
||
269 | void USMC_GetLastErr( char *str, size_t len ); |
||
270 | DWORD USMC_Close( void ); |
||
271 | DWORD USMC_GetEncoderState( DWORD Device, USMC_EncoderState *Str); |
||
272 | #endif // C/C++ |
||
273 |