DAS  3.1.6 - 18/09/2017
De.c
Go to the documentation of this file.
1 #include <windows.h>
2 #include <stdio.h>
3 #include <io.h>
4 #include <fcntl.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include "mgui.h"
10 #include "DAS_Spatram.h"
11 #include "wsc.h"
12 #include "dxl.h"
13 
15 /********************************************************************/
16 /* */
17 /* Inizializza il modulo combo selezionato (mod): */
18 /* ritorna 1 se lo trova */
19 /* ritorna 0 se NON lo trova. */
20 /* */
21 /* */
22 int DE_Init(int mod)
23 {
24  return 1;
25 }
26 /* */
27 /* */
28 /********************************************************************/
29 /********************************************************************/
30 /* */
31 /* Setta i valori di funzionamento del motore passo-passo. */
32 /* mod 0-15 */
33 /* motor 0-3 */
34 /* coppia 0-100 0 to 1.5A */
35 /* step 0-13 passi/giro */
36 /* slope 0-255 rampa di accelerazione/decelerazione */
37 /* speed 1-50000 passi/s */
38 /* */
39 /* step: */
40 /* VALORE PASSI/GIRO */
41 /* 0 400 */
42 /* 1 800 */
43 /* 2 1000 */
44 /* 3 1600 */
45 /* 4 2000 */
46 /* 5 3200 */
47 /* 6 5000 */
48 /* 7 6400 */
49 /* 8 10000 */
50 /* 9 12800 */
51 /* 10 25000 */
52 /* 11 25600 */
53 /* 12 50000 */
54 /* 13 51200 */
55 /* */
56 /* */
57 void DE_SetMotor(int mod, int motor, int coppia, int step, int slope, int speed)
58 {
59 
60 }
61 /* */
62 /* */
63 /* */
64 /********************************************************************/
65 /********************************************************************/
66 /* */
67 /* Calibra il motore selezionato nella posizione di: */
68 /* home (mswitch = 0) */
69 /* work (mswitch = 1) */
70 /* */
71 /* mod 0-15 */
72 /* */
73 int DE_InitMotor(int mod, int motor, int mswitch)
74 {
75  sleep(200);
76  return 1;
77 }
78 /* */
79 /* */
80 /********************************************************************/
81 /********************************************************************/
82 /* */
83 /* Esegue n passi (step) sul motore selezionato */
84 /* (motor) nella direzione voluta (dir). */
85 /* */
86 /* mod 0-15 */
87 /* motor 0-3 */
88 /* step 0-4294967295 */
89 /* dir 0 = CW, 1 = CCW */
90 /* */
91 /* */
92 int DE_StepMotor(int mod, int motor, long step, int dir)
93 {
94 
95  char buf[80];
96 // char Dbuf[80];
97  int er = 0;
98  int c = motor, d = 0;
99 
100 
101 
102  switch(c)
103  {
104  //INPUT MIRROR
105  case 0: MPixmapSetImageFile(CPL.LedSM1, "SYS\\ledoff.bmp");
106  sprintf(buf, "%s", "Positioning");
107  MObjectSetText(CPL.Albl_LS[0], buf);
108  DXL.add = 0;
109  //AMS_MotorOn_Off(0, 1, 0);
110 // writelogmotor(0, c, er, dir, step, 0);
111  er = AMS_DoPos(mod, dir, 0, step, 0);
112  if (DAS.Flag.exemode != DBDEMO)
113  if(er) { Message("n Step not sent! 1", er); break; }
114 // writelogmotor(0, c, er, dir, step, 0);
115  //AMS_MotorOn_Off(0, 0, 0);
116  break;
117 
118  //GRATING
119  case 1: MPixmapSetImageFile(CPL.LedSM2, "SYS\\ledoff.bmp");
120  sprintf(buf, "%s", "Positioning");
121  MObjectSetText(CPL.Albl_LS[1], buf);
122  DXL.add = 0;
123  //AMS_MotorOn_Off(0, 0, 1);
124 // writelogmotor(0, c, er, dir, step, 0);
125  er = AMS_DoPos(mod, 0, dir, 0, step);
126  if (DAS.Flag.exemode != DBDEMO)
127  if(er) { Message("n Step not sent! 1", er); break; }
128 // writelogmotor(0, c, er, dir, step, 0);
129  //AMS_MotorOn_Off(0, 0, 0);
130  break;
131 
132  //FILTER WHEEL
133  case 2: MPixmapSetImageFile(CPL.LedSM3, "SYS\\ledoff.bmp");
134  sprintf(buf, "%s", "Positioning");
135  MObjectSetText(CPL.Albl_LS[2], buf);
136 
137  DXL.add = 1;
138 // writelogmotor(0, c, er, dir, step, 0);
139  er = AMS_DoPos(mod, dir, 0, step, 0);
140  if (DAS.Flag.exemode != DBDEMO)
141  if(er) { Message("n Step not sent! 1", er); break; }
142  DXL.add = 0;
143  break;
144 
145  }
146 
147 
148  return 1;
149 }
150 
151 
152 /* */
153 /* */
154 /********************************************************************/
155 
156 /********************************************************************/
157 /* */
158 /* Ritorna lo stato di attivita' del motore selezionato (motor). */
159 /* */
160 /* mod 0-15 */
161 /* 0 = Motore fermo */
162 /* 1 = Home attivato */
163 /* 2 = Work attivato */
164 /* 4 = Motore in movimento */
165 /* */
166 int DE_StsMotor(int mod, int motor)
167 {
168  return 1;
169 }
170 /* */
171 /* */
172 /********************************************************************/
173 /********************************************************************/
174 /* */
175 /* Ritorna il valore presente sulla porta selezionata (port). */
176 /* */
177 /* mod 0-15 */
178 /* port 0-255 */
179 /* */
180 unsigned int DE_ReadPort(int mod, int port)
181 {
182  return 1;
183 }
184 /* */
185 /* */
186 /********************************************************************/
187 /********************************************************************/
188 /* */
189 /* Permette di scrivere su di una porta selezionata (port) */
190 /* il valore impostato (data) */
191 /* */
192 /* mod 0-15 */
193 /* port 0-255 */
194 /* data 0-65535 */
195 /* */
196 void DE_WritePort(int mod, int port, unsigned int data)
197 {
198 
199 }
200 /* */
201 /* */
202 /********************************************************************/
203 /********************************************************************/
204 /* */
205 /* Imposta il valore di PWM per il canale selezionato: */
206 /* 0 = spegne l'output */
207 /* 255 = l'output e' fisso acceso */
208 /* valori intermedi sono modulati del valore impostato. */
209 /* */
210 /* mod 0-15 */
211 /* channel 0-1 */
212 /* value 0-255 */
213 /* */
214 void DE_PWM(int mod, int channel, int value)
215 {
216 
217 }
218 /* */
219 /* */
220 /********************************************************************/
221 /********************************************************************/
222 /* */
223 /* Accende o spegne il relais selezionato. */
224 /* */
225 /* mod 0-15 */
226 /* channel 0-1 */
227 /* value 0 = spento, 1 = acceso */
228 /* */
229 void DE_SetRelais(int mod, int channel, int value)
230 {
231 
232 }
233 /* */
234 /* */
235 /********************************************************************/
236 /********************************************************************/
237 /* */
238 /* Legge un canale del convertitore A/D. */
239 /* */
240 /* mod 0-15 */
241 /* channel 0-15 */
242 /* */
243 int DE_ReadAD(int mod, int channel)
244 {
245  int c;
246 
247  c=channel;
248  switch(c)
249  {
250  case 0:
251  return 5;
252  break;
253  case 1:
254  return 5;
255  break;
256  case 2:
257  return 5;
258  break;
259  case 3:
260  return 5;
261  break;
262  case 4:
263  return 5;
264  break;
265  case 5:
266  return 5;
267  break;
268  }
269  return 0;
270 }
271 /* */
272 /* */
273 /********************************************************************/
274 /********************************************************************/
275 /* */
276 /* Legge un dato contenuto nella EEPROM */
277 /* */
278 /* add 0-63 */
279 /* */
280 unsigned int DE_ReadEP(unsigned int add)
281 {
282  return 1;
283 }
284 /* */
285 /* */
286 /********************************************************************/
287 /********************************************************************/
288 /* */
289 /* Scrive un dato ad un indirizzo della EEPROM */
290 /* */
291 /* add 0-63 */
292 /* data 0-65535 */
293 /* */
294 unsigned int DE_WriteEP(unsigned int add, unsigned int data)
295 {
296  return 1;
297 }
298 /* */
299 /* */
300 /********************************************************************/
DXL_par DXL
Definition: De.c:14
void DE_SetRelais(int mod, int channel, int value)
Definition: De.c:229
DXL structure. Structure for the serial communication with the AMS adapter.
Definition: DXL.H:16
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
flag Flag
Structure for different flags.
#define DBDEMO
execution in demo mode
das DAS
Definition: Chktemp.c:26
int DE_ReadAD(int mod, int channel)
Definition: De.c:243
int DE_Init(int mod)
Definition: De.c:22
void MObjectSetText(MOBJECT obj, const char *text)
void sleep(clock_t wait)
Pauses for a specified number of milliseconds. .
Definition: Load.c:1566
int DE_InitMotor(int mod, int motor, int mswitch)
Definition: De.c:73
void DE_SetMotor(int mod, int motor, int coppia, int step, int slope, int speed)
Definition: De.c:57
int add
Peripheral address.
Definition: DXL.H:19
unsigned int data[576]
Conversion data buffer 64 samples * 8 channels * 2 bytes.
int DE_StsMotor(int mod, int motor)
Definition: De.c:166
void DE_PWM(int mod, int channel, int value)
Definition: De.c:214
unsigned int DE_ReadPort(int mod, int port)
Definition: De.c:180
void DE_WritePort(int mod, int port, unsigned int data)
Definition: De.c:196
int DE_StepMotor(int mod, int motor, long step, int dir)
Definition: De.c:92
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
Function prototypes.
unsigned int DE_WriteEP(unsigned int add, unsigned int data)
Definition: De.c:294
int AMS_DoPos(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Execute Positioning Execute Stepper positioning. Make all the control on the status of the selected m...
Definition: Dxl.c:644
int exemode
Set the Execution MODE (Execution modes)
unsigned int DE_ReadEP(unsigned int add)
Definition: De.c:280
______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:44:07 for DAS - Rel. 3.1.6 - 18/09/2017.