DAS  3.1.6 - 18/09/2017
Functions | Variables
Dxl.c File Reference

Procedures for AMS management. More...

#include <windows.h>
#include <stdio.h>
#include <math.h>
#include "mgui.h"
#include "DAS_Spatram.h"
#include "dcl.h"
#include "dil.h"
#include "bil.h"
#include "dscud.h"
#include "dxl.h"
#include "wsc.h"
+ Include dependency graph for Dxl.c:

Go to the source code of this file.

Functions

void AMS_assadd (int w)
 Assign AMS address
Procedure for assigment of the AMS address. More...
 
int AMS_AzzeraCoord (int id, int mtr)
 Set to zero the number of steps on the selected motor
Set to zero the number of steps on the selected motor. More...
 
int AMS_chkbitsts (int id, int bitn)
 check bit status
Procedure for the determination of the bit number status. More...
 
int AMS_chkbitsts_old (int id, int bitn)
 
void AMS_Default (int id)
 Set default values to AMS parameters
Procedure for setting the default values of power.speed, stepping and slope to the selected AMS adapter. More...
 
int AMS_dirfin (int id, int dira, int dirb)
 Set Final Directions
. More...
 
int AMS_Divisore (int id, unsigned long par1, unsigned long par2)
 
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 motor. More...
 
int AMS_ESlope (int id, int eslopea, int eslopeb)
 
int AMS_firmrev (int id)
 Firmware Revision Number
. More...
 
int AMS_Home (int id, int mota, int motb)
 Home position for the selected motor
the home position is reached with the standard parameters (1KHz, 2000 s/r) More...
 
int AMS_HomeDefault (int id, int mota, int motb)
 
int AMS_MotorOn_Off (int id, int mtr1, int mtr2)
 Motor ON-OFF.
Switch On-Off the selected motor of the selected AMS. More...
 
int AMS_Power (int id, int powa, int powb)
 Set Power for AMS
Procedure for setting the user choosed power to the selected AMS adapter. More...
 
int AMS_Proxy (int id)
 
void AMS_PWM (int id, int on, int off)
 set the on/off time on the PWM
set the on/off time on the PWM. More...
 
void AMS_PWM_OFF (int id)
 
int AMS_ReadAD (int id, int ch)
 
unsigned long AMS_ReadStep (int id, int motor)
 read performed steps
Procedure for the determination of the number of steps executed. More...
 
int AMS_sendstep (int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
 Send steps Procedure for sending steps to the Stepper Motor. More...
 
int AMS_SetPolarity (int id, int homea, int worka, int homeb, int workb)
 
int AMS_Slope (int id, int slopea, int slopeb)
 Set slope to the Stepper motors Procedure for setting the slope fot the Stepper Motors. More...
 
int AMS_Speed (int id, int speeda, int speedb)
 Set speed to the Stepper motors Procedure for setting speed for the Stepper Motors. More...
 
int AMS_Step (int id, int stepa, int stepb)
 Set stepping for the Stepper motors Procedure for setting steps for the Stepper Motors. More...
 
int AMS_TestHome (int id, int par1)
 verify if the home position has been reached
More...
 
int AMS_TestPos (int id, int motor)
 Test positioning status
Procedure for testing the positioning status of the selected motor. More...
 
int AMS_TestWork (int id, int par1)
 verify the if work position has been reached
More...
 
int AMS_TrackOff (int id, int amot, int bmot)
 tracking off Procedure for Stepper Motor tracking de-activation More...
 
int AMS_TrackOn (int id, int adir, int bdir, unsigned long acount, unsigned long bcount)
 Activate tracking Procedure for Stepper Motor tracking activation. More...
 
int AMS_wopto (int id, unsigned int w)
 write the value on the optoinsulated port
write the value on the optoinsulated port. More...
 
void D_Positioning (MOBJECT p, int id, long tout)
 Callback for the void D_VRange and display also the status in the corresponding CP labels. More...
 
int DB_StepMotor (int id, int motor, long step, int dir)
 Send steps to the selected stepper motor.
. More...
 
void delay (unsigned long d)
 Pauses for a specified number of milliseconds.
. More...
 
unsigned char DXL_ByteHex (unsigned char val)
 
int DXL_Close (void)
 Close COM. More...
 
unsigned char DXL_HexBin (char *str)
 
int DXL_Open (int addr, int com, int baud)
 Open COM. More...
 
int DXL_RxStr (char *rx, int *len)
 receive string from a serial port More...
 
void DXL_TxByte (unsigned char v)
 
void DXL_TxStr (char *tx, int len)
 send string to a serial port More...
 
void Message (char *str, int er)
 Create a message shell for the AMS errors (Debug Use).
. More...
 

Variables

das DAS
 
DXL_par DXL
 
flag FLAG
 

Detailed Description

Procedures for AMS management.

Author
Daniele Bortoli

Definition in file Dxl.c.

Function Documentation

§ AMS_assadd()

void AMS_assadd ( int  w)

Assign AMS address
Procedure for assigment of the AMS address.

Parameters
w= AMS ADDRESS

Definition at line 25 of file Dxl.c.

References DXL_par::add.

Referenced by AMS_AzzeraCoord(), AMS_chkbitsts(), AMS_chkbitsts_old(), AMS_Default(), AMS_dirfin(), AMS_Divisore(), AMS_DoPos(), AMS_ESlope(), AMS_firmrev(), AMS_Home(), AMS_HomeDefault(), AMS_MotorOn_Off(), AMS_Power(), AMS_Proxy(), AMS_PWM(), AMS_PWM_OFF(), AMS_ReadAD(), AMS_ReadStep(), AMS_sendstep(), AMS_SetPolarity(), AMS_Slope(), AMS_Speed(), AMS_Step(), AMS_TestHome(), AMS_TestPos(), AMS_TestWork(), AMS_TrackOff(), AMS_TrackOn(), and AMS_wopto().

26 {
27  DXL.add = w;
28 }
int add
Peripheral address.
Definition: DXL.H:19
DXL_par DXL
Definition: Dxl.c:18
+ Here is the caller graph for this function:

§ AMS_AzzeraCoord()

int AMS_AzzeraCoord ( int  id,
int  mtr 
)

Set to zero the number of steps on the selected motor
Set to zero the number of steps on the selected motor.

Parameters
id= AMS ADDRESS
mtr= 0 –> A Motor, = 1 –> B Motor
Returns

Definition at line 439 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by DB_ToolsKeyB_CB(), HomeAzimFast(), HomeFiltersFast(), HomeGratingFast(), HomeMirror(), HomeNDFiltersFast(), HomeZenithFast(), and Task_HomeGrat().

440 {
441  int er, d;
442  char buf[40];
443 
444  //Assign Address
445  AMS_assadd(id);
446 
447  sprintf(DXL.buftx, "3%02X", mtr);
448  DXL_TxStr(DXL.buftx,3);
449  d = ACKLEN;
450  er = DXL_RxStr(buf, &d);
451 
452  return er;
453 
454 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_chkbitsts()

int AMS_chkbitsts ( int  id,
int  bitn 
)

check bit status
Procedure for the determination of the bit number status.

Parameters
id= AMS ADDRESS
bitnBIT NUMBER –> 0 = LSB, 7 = MSB
Returns
sts: BIT STATUS –> sts = 0 –> bitn = 0, sts = 1 –> bitn = 1

Definition at line 192 of file Dxl.c.

References AMS_assadd(), DXL_par::bufrx, DXL_par::buftx, DXL_HexBin(), DXL_RxStr(), DXL_TxStr(), Message(), and STS0LEN.

Referenced by HomeAzimFast(), HomeFiltersFast(), HomeNDFiltersFast(), HomeTrack(), HomeZenithFast(), ReadInputCB(), Task_AMSH(), and Task_HomeGrat().

193 {
194 
195 
196  int sts = 2;
197 // char str[80], buf[80], *s;
198  int d, er;
199  unsigned long stbyte = 0;
200  unsigned char a;
201 
202 // buf[0] = 0;
203 // buf[1] = 0;
204  //Assign Address
205  AMS_assadd(id);
206 
207  //Read AMS Input
208 // delay (70);
209  sprintf(DXL.buftx, "/");
210  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
211  d = STS0LEN;
212 // delay (70);
213  er = DXL_RxStr(DXL.bufrx, &d);
214 // er = DXL_RxStr(buf, &d);
215 
216  if(er) Message("Serial Error!", er);
217  else
218  {
219  a = DXL_HexBin(DXL.bufrx);
220 
221 // sprintf(buf, "%d", a);
222 // MObjectSetText(CONFP.lblStatus, buf);
223 // if (a = 100)
224 // er = DXL_RxStr(buf, &d);
225 // a = DXL_HexBin(buf);
226 
227 
228 
229  switch (bitn)
230  {
231  case 0:
232  sts = (a >> 0) & 1;
233  break;
234  case 1:
235  sts = (a >> 1) & 1;
236  break;
237  case 2:
238  sts = (a >> 2) & 1;
239  break;
240  case 3:
241  sts = (a >> 3) & 1;
242  break;
243  case 4:
244  sts = (a >> 4) & 1;
245  break;
246  case 5:
247  sts = (a >> 5) & 1;
248  break;
249  case 6:
250  sts = (a >> 6) & 1;
251  break;
252  case 7:
253  sts = (a >> 7) & 1;
254  break;
255 
256 
257 
258 
259  }
260 
261 
262 
263 
264 // sprintf(buf, "A Proxy, Home = %d, Work = %d\nB Proxy, Home = %d, Work = %d\nAll bits = %02XH, %d%d%d%d%d%d%d%d bin",
265 // (a >> 3) & 1, (a >> 2) & 1, (a >> 1) & 1, a & 1, a,
266 // (a >> 7) & 1, (a >> 6) & 1, (a >> 5) & 1, (a >> 4) & 1,(a >> 3) & 1, (a >> 2) & 1, (a >> 1) & 1, a & 1, a & 0);
267 // Message(buf, er);
268 
269  }
270 
271 
272 
273 
274 // sprintf(str,"0x%s",buf);
275 // sprintf(str,"0x%s",DXL.bufrx);
276 // stbyte = strtol(str, &s, 16);
277 /*
278  switch (bn)
279  {
280  case 0:
281  sts = stbyte & 1;
282  sts = sts >> bn;
283  break;
284  case 1:
285  sts = stbyte & 2;
286  sts = sts >> bn;
287  break;
288  case 2:
289  sts = stbyte & 4;
290  sts = sts >> bn;
291  break;
292  case 3:
293  sts = stbyte & 8;
294  sts = sts >> bn;
295  break;
296  case 4:
297  sts = stbyte & 16;
298  sts = sts >> bn;
299  break;
300  case 5:
301  sts = stbyte & 32;
302  sts = sts >> bn;
303  break;
304  case 6:
305  sts = stbyte & 64;
306  sts = sts >> bn;
307  break;
308  case 7:
309  sts = stbyte & 128;
310  sts = sts >> bn;
311  break;
312  }
313 
314  if (sts == 2)
315  return 2;
316  else
317 
318 */
319  return sts;
320 
321 }
unsigned char DXL_HexBin(char *str)
Definition: Dxl.c:83
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
#define STS0LEN
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
DXL_par DXL
Definition: Dxl.c:18
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_chkbitsts_old()

int AMS_chkbitsts_old ( int  id,
int  bitn 
)

Definition at line 105 of file Dxl.c.

References AMS_assadd(), DXL_par::bufrx, DXL_par::buftx, DXL_RxStr(), DXL_TxStr(), and STS0LEN.

106 {
107 
108 
109  int bn = bitn;
110  int sts = 2;
111  char str[80], buf[80], *s;
112  int d, er;
113  unsigned long stbyte = 0;
114 
115  //Assign Address
116  AMS_assadd(id);
117 
118  //Read AMS Input
119  sprintf(DXL.buftx, "/");
120  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
121  d = STS0LEN;
122  er = DXL_RxStr(buf, &d);
123 
124  DXL.bufrx[0] = '0';
125  DXL.bufrx[1] = '0';
126  er = 0;
127  sprintf(str,"0x%s",buf);
128  stbyte = strtol(str, &s, 16);
129 
130  switch (bn)
131  {
132  case 0:
133  sts = stbyte & 1;
134  sts = sts >> bn;
135  break;
136  case 1:
137  sts = stbyte & 2;
138  sts = sts >> bn;
139  break;
140  case 2:
141  sts = stbyte & 4;
142  sts = sts >> bn;
143  break;
144  case 3:
145  sts = stbyte & 8;
146  sts = sts >> bn;
147  break;
148  case 4:
149  sts = stbyte & 16;
150  sts = sts >> bn;
151  break;
152  case 5:
153  sts = stbyte & 32;
154  sts = sts >> bn;
155  break;
156  case 6:
157  sts = stbyte & 64;
158  sts = sts >> bn;
159  break;
160  case 7:
161  sts = stbyte & 128;
162  sts = sts >> bn;
163  break;
164  }
165 
166  if (sts == 2)
167  return 2;
168  else
169  return sts;
170 
171 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
#define STS0LEN
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:

§ AMS_Default()

void AMS_Default ( int  id)

Set default values to AMS parameters
Procedure for setting the default values of power.speed, stepping and slope to the selected AMS adapter.

Definition at line 174 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_RxStr(), and DXL_TxStr().

Referenced by DB_Home_CB(), E_Home_SM4(), E_Home_SM6(), HomeAzimFast(), HomeFiltersFast(), HomeGratingFast(), HomeMirror(), HomeNDFiltersFast(), and HomeZenithFast().

175 {
176 
177  char buf[80];
178  int d, er;
179 
180  //Assign Address
181  AMS_assadd(id);
182 
183  // Set default values
184  DXL_TxStr("A", 1);
185  d = ACKLEN;
186  er = DXL_RxStr(buf, &d);
187 
188 
189 }
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_dirfin()

int AMS_dirfin ( int  id,
int  dira,
int  dirb 
)

Set Final Directions
.

Parameters
id= AMS ADDRESS
dira= 0/1 for Motor A
dirb= 0/1 for Motor B
Returns
int : Number of the AMS revision Program

Definition at line 457 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by DB_Home_CB(), DB_InitMotor(), HomeAzimFast(), HomeFiltersFast(), HomeGratingFast(), HomeMirror(), HomeNDFiltersFast(), and HomeZenithFast().

458 {
459  char buf[80];
460  int d, er;
461 
462  //Assign Address
463  AMS_assadd(id);
464 
465  // Set final direction
466  sprintf(DXL.buftx, "-%02X%02X", dira, dirb);
467  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
468  d = ACKLEN;
469  er = DXL_RxStr(buf, &d);
470 
471  return er;
472 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_Divisore()

int AMS_Divisore ( int  id,
unsigned long  par1,
unsigned long  par2 
)

Definition at line 946 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by HomeAzimFast(), HomeMirror(), and HomeTrack().

947 {
948 
949  char buf[80];
950  int d, er;
951 
952  //Assign Address
953  AMS_assadd(id);
954 
955  //set divisore
956  sprintf(DXL.buftx,">%08lX%08lX", par1, par2);
957  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
958  d = ACKLEN;
959  er = DXL_RxStr(buf, &d);
960 
961  return er;
962 
963 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_DoPos()

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 motor.

Parameters
id= AMS ADDRESS
dira= 0/1 for Motor A
dirb= 0/1 for Motor B
stepa= steps for Motor A
stepb= steps for Motor B
Returns
int er
er:
  • 0 = command executed correctly
  • 1 = No start character
  • 2 = Incongruent address
  • 3 = CheckSum error

Definition at line 644 of file Dxl.c.

References controlpanel::Albl_LS, AMS_assadd(), AMS_ReadStep(), AMS_sendstep(), AMS_TestPos(), optionini::amsprogbar, gui::ContrPanel, D_Positioning(), D_VRange(), DBDEMO, das::DOption, flag::exemode, das::Flag, FlgSM_Stop, das::Gui, stepm::postime, stepm::SM_A, stepm::SM_B, stepm::speed_Hz, Status(), das::StepM, TESTSZAMODE, and writelogmotor().

Referenced by DB_StepMotor(), DE_StepMotor(), HomeGratingFast(), and HomeMirror().

645 {
646  int er = 0;
647 // unsigned long x;
648  long ns, cont;
649  char buf[64];
650 
651  FlgSM_Stop = 0;
652 
653  //Assign Address
654  AMS_assadd(id);
655 
656 
657  if ((DAS.Flag.exemode != DBDEMO) & (DAS.Flag.exemode != TESTSZAMODE))
658  {
659 
660  // Testa se il precedente posizionamento e' finito
661  if(stepa)
662  er = AMS_TestPos(id, 0);
663  if(er) return er;
664 
665  // Testa se il precedente posizionamento e' finito
666  if(stepb)
667  er = AMS_TestPos(id, 1);
668  if(er) return er;
669  }
670 
671 /*********************************/
672 
673  if(stepa && id == 0)
675  D_VRange("Positioning Mirror",0, 255, 0, 0);
676  if(stepb && id == 0)
678  D_VRange("Positioning Grating",0, 255, 255, 0);
679  if(stepa && id == 1)
681  D_VRange("Positioning Filter Wheel",0, 0, 0, 255);
682  if(stepb && id == 1)
684  D_VRange("Positioning ND Filter Wheel",0, 192, 0, 255);
685  if(stepa && id == 2)
687  D_VRange("Positioning Zenith",0, 0, 255, 255);
688  if(stepb && id == 2)
690  D_VRange("Positioning Azimuth",0, 0, 192, 255);
691 
692 /*********************************/
693 
694 
695  // Trasmette numero di passi
696  if ((DAS.Flag.exemode != DBDEMO) & (DAS.Flag.exemode != TESTSZAMODE))
697  er = AMS_sendstep(id, dira, dirb, stepa, stepb);
698 
699 
700  if(stepa && id == 0)
701  {
702  if ((DAS.Flag.exemode != DBDEMO) & (DAS.Flag.exemode != TESTSZAMODE))
703  cont = (long) (stepa / (float) DAS.StepM.speed_Hz[id][DAS.StepM.SM_A]);
704  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[0], 0, cont);
705  }
706  if(stepb && id == 0)
707  {
708  if ((DAS.Flag.exemode != DBDEMO) & (DAS.Flag.exemode != TESTSZAMODE))
709  DAS.StepM.postime[id][DAS.StepM.SM_B] = (long) (stepb / (float) DAS.StepM.speed_Hz[id][DAS.StepM.SM_B]);
710  //cont = (long) (stepb / (float) DAS.StepM.speed_Hz[id][DAS.StepM.SM_B]);
712  //D_Positioning(DAS.Gui.ContrPanel.Albl_LS[1], 1, cont);
713  }
714  if(stepa && id == 1)
715  {
716  if ((DAS.Flag.exemode != DBDEMO) & (DAS.Flag.exemode != TESTSZAMODE))
717  cont = (long) (stepa / (float) DAS.StepM.speed_Hz[id][DAS.StepM.SM_A]);
718  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[2], 2, cont);
719  }
720  if(stepb && id == 1)
721  {
722  if ((DAS.Flag.exemode != DBDEMO) & (DAS.Flag.exemode != TESTSZAMODE))
723  cont = (long) (stepb / (float) DAS.StepM.speed_Hz[id][DAS.StepM.SM_B]);
724  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[3], 3, cont);
725  }
726  if(stepa && id == 2)
727  {
728  if ((DAS.Flag.exemode != DBDEMO) & (DAS.Flag.exemode != TESTSZAMODE))
729  cont = (long) (stepa / (float) DAS.StepM.speed_Hz[id][DAS.StepM.SM_A]);
730  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[4], 4, cont);
731  }
732  if(stepb && id == 2)
733  {
734  if ((DAS.Flag.exemode != DBDEMO) & (DAS.Flag.exemode != TESTSZAMODE))
735  cont = (long) (stepb / (float) DAS.StepM.speed_Hz[id][DAS.StepM.SM_B]);
736  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[5], 5, cont);
737  }
738 
739 
740 
742  D_VRange(NULL, 100, 0,0,0);
743 
744 /*********************************/
745  /* FILE DI LOG */
746  if(stepa && id == 0)
747  writelogmotor(0, 0, er, dira, stepa, 0);
748  if(stepb && id == 0)
749  writelogmotor(0, 1, er, dirb, stepb, 0);
750  if(stepa && id == 1)
751  writelogmotor(0, 2, er, dira, stepa, 1);
752  if(stepb && id == 1)
753  writelogmotor(0, 3, er, dirb, stepb, 1);
754  if(stepa && id == 2)
755  writelogmotor(0, 4, er, dira, stepa, 2);
756  if(stepb && id == 2)
757  writelogmotor(0, 5, er, dirb, stepb, 2);
758 /*********************************/
759 
760  if(er) return er;
761 
762  if ((DAS.Flag.exemode != DBDEMO) & (DAS.Flag.exemode != TESTSZAMODE))
763  {
764  // Testa se il precedente posizionamento e' finito
765  if(stepa)
766  er = AMS_TestPos(id, 0);
767  if(er) return er;
768 
769  // Testa se il precedente posizionamento e' finito
770  if(stepb)
771  er = AMS_TestPos(id, 1);
772  if(er) return er;
773 
774  /*******************************************************/
775  /* Conta numero di passi effettuati */
776  if(stepa)
777  {
778  ns = AMS_ReadStep(id, 0);
779  sprintf(buf, "Steps A: %ld", ns);
780  Status(buf);
781  }
782 
783  if(stepb)
784  {
785  ns = AMS_ReadStep(id, 1);
786  sprintf(buf, "Steps B: %ld", ns);
787  Status(buf);
788  }
789 
790  /******************************************************/
791  }
792  else //DEMO MODE
793  {
794  /* Conta numero di passi effettuati */
795  if(stepa)
796  {
797 
798  sprintf(buf, "Steps A: %ld", stepa);
799  Status(buf);
800  }
801 
802  if(stepb)
803  {
804 
805  sprintf(buf, "Steps B: %ld", stepb);
806  Status(buf);
807  }
808 
809  }
810 
811  FlgSM_Stop = 1;
812  return er;
813 }
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
void writelogmotor(int mod, int id_motore, int k, int d, long steps, unsigned char ams_id)
Write Motor Operations on Log File. Write on the SM.LOG file the commands send to the motors...
Definition: Spat_Device.c:48
optionini DOption
Options for DAS execution.
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
#define TESTSZAMODE
execution driven by SZAPRG file
flag Flag
Structure for different flags.
#define DBDEMO
execution in demo mode
int FlgSM_Stop
Steppers Motor Activity: 0 = Motors moving; 1 = Motors stopped.
Definition: DAS_Spat.c:140
long postime[AMSMAX][2]
time necessary for positioning
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
unsigned long AMS_ReadStep(int id, int motor)
read performed steps Procedure for the determination of the number of steps executed.
Definition: Dxl.c:60
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
controlpanel ContrPanel
Control Panel Structure.
void D_Positioning(MOBJECT p, int id, long tout)
Callback for the void D_VRange and display also the status in the corresponding CP labels...
Definition: Dxl.c:607
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
das DAS
Definition: Dxl.c:22
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
int AMS_sendstep(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Send steps Procedure for sending steps to the Stepper Motor.
Definition: Dxl.c:513
int AMS_TestPos(int id, int motor)
Test positioning status Procedure for testing the positioning status of the selected motor...
Definition: Dxl.c:31
int exemode
Set the Execution MODE (Execution modes)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_ESlope()

int AMS_ESlope ( int  id,
int  eslopea,
int  eslopeb 
)

Definition at line 966 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

967 {
968  char buf[80];
969  int d, er;
970 
971  //Assign Address
972  AMS_assadd(id);
973 
974  // Send slope
975  sprintf(DXL.buftx, ";%02X%02X", eslopea, eslopeb);
976  DXL_TxStr(DXL.buftx, 5);
977  d = ACKLEN;
978  er = DXL_RxStr(buf, &d);
979 
980  return er;
981 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:

§ AMS_firmrev()

int AMS_firmrev ( int  id)

Firmware Revision Number
.

Parameters
id= AMS ADDRESS
Returns
int : Number of the AMS revision Program

Definition at line 475 of file Dxl.c.

References AMS_assadd(), DXL_par::bufrx, DXL_RxStr(), DXL_TxStr(), and STS0LEN.

Referenced by DB_InitAMS().

476 {
477 // char buf[80];
478  int d, er;
479 
480  //Assign Address
481  AMS_assadd(id);
482 
483  // Firmware Revision
484  DXL_TxStr("%%", 1);
485  d = STS0LEN;
486  er = DXL_RxStr(DXL.bufrx, &d);
487 
488  return er;
489 }
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
#define STS0LEN
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_Home()

int AMS_Home ( int  id,
int  mota,
int  motb 
)

Home position for the selected motor
the home position is reached with the standard parameters (1KHz, 2000 s/r)

Home position for the selected motor
the home position is reached with the actual parameters for the motors.

Parameters
id= AMS ADDRESS
motaMotor A
motbMotor B
Returns
er:
  • 0 = command executed correctly
  • 1 = problems in COM communication

Definition at line 549 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by HomeGratingFast(), HomeMirror(), and HomeZenithFast().

550 {
551  char buf[80];
552  int d, er;
553 
554  //Assign Address
555  AMS_assadd(id);
556 
557  //Send Polarity for home and work
558  sprintf(DXL.buftx,"+%02X%02X", mota, motb);
559  DXL_TxStr(DXL.buftx, 5);
560  d = ACKLEN;
561  er = DXL_RxStr(buf, &d);
562 
563  return er;
564 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_HomeDefault()

int AMS_HomeDefault ( int  id,
int  mota,
int  motb 
)

Definition at line 567 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by HomeGratingFast(), HomeMirror(), and HomeZenithFast().

568 {
569  char buf[80];
570  int d, er;
571 
572  //Assign Address
573  AMS_assadd(id);
574 
575  //Send Polarity for home and work
576  sprintf(DXL.buftx,"<%02X%02X", mota, motb);
577  DXL_TxStr(DXL.buftx, 5);
578  d = ACKLEN;
579  er = DXL_RxStr(buf, &d);
580 
581  return er;
582 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_MotorOn_Off()

int AMS_MotorOn_Off ( int  id,
int  mtr1,
int  mtr2 
)

Motor ON-OFF.
Switch On-Off the selected motor of the selected AMS.

Parameters
addr= AMS address:
  • 0 = AMS1
  • 1 = AMS2
  • 2 = AMS3
mtr1
  • = 0 –> motorA OFF
  • = 1 –> motorA ON
mtr2
  • = 0 –> motorB OFF
  • = 1 –> motorB ON
Returns
er:
  • = 0 –> Operation concluded succesfully
  • = 1 –> Problems in stopping or starting motor

Definition at line 930 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by E_Home_SM3(), and Task_HomeGrat().

931 {
932  char buf[80];
933  int er = 0, d;
934 
935  //Assign Address
936  AMS_assadd(id);
937 
938  sprintf(DXL.buftx, "2%02X%02X", mtr1, mtr2);
939  DXL_TxStr(DXL.buftx,strlen(DXL.buftx));
940  d = ACKLEN;
941  er = DXL_RxStr(buf, &d);
942  return er;
943 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_Power()

int AMS_Power ( int  id,
int  powa,
int  powb 
)

Set Power for AMS
Procedure for setting the user choosed power to the selected AMS adapter.

Parameters
idAMS ADDRESS:
  • 0 = AMS1
  • 1 = AMS2
  • 2 = AMS3
powapower assigned to motor A (Range: 00h-4Ch, Bit weight = 0.02A, Default = 19h = 0.5A)
powbpower assigned to motor B (Range: 00h-4Ch, Bit weight = 0.02A, Default = 19h = 0.5A)
Returns
er:
  • 0 = command executed correctly
  • 1 = No start character
  • 2 = Incongruent address
  • 3 = CheckSum error

Definition at line 326 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, delay(), DXL_RxStr(), and DXL_TxStr().

Referenced by DB_InitAMS().

327 {
328  char buf[80];
329  int d, er;
330 
331  //Assign Address
332  AMS_assadd(id);
333 
334  sprintf(DXL.buftx, "&%02X%02X", 0, 0);
335  DXL_TxStr(DXL.buftx, 5);
336  d = ACKLEN;
337  er = DXL_RxStr(buf, &d);
338  delay(50);
339  //send power
340  sprintf(DXL.buftx, "&%02X%02X", powa, powb);
341  DXL_TxStr(DXL.buftx, 5);
342  d = ACKLEN;
343  er = DXL_RxStr(buf, &d);
344 
345  return er;
346 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_Proxy()

int AMS_Proxy ( int  id)

Definition at line 986 of file Dxl.c.

References AMS_assadd(), DXL_HexBin(), DXL_RxStr(), DXL_TxStr(), Message(), and STS0LEN.

987 {
988 
989  char buf[128];
990  int d, er;
991  unsigned char a;
992  //Assign Address
993  AMS_assadd(id);
994 
995  DXL_TxStr("/", 1);
996 
997  d = STS0LEN;
998  er = DXL_RxStr(buf, &d);
999  if(er) Message("Serial Error!", er);
1000  else
1001  {
1002  a = DXL_HexBin(buf);
1003  sprintf(buf, "A Proxy, Home = %d, Work = %d\nB Proxy, Home = %d, Work = %d\nAll bits = %02XH, %d%d%d%d%d%d%d%d bin",
1004  (a >> 3) & 1, (a >> 2) & 1, (a >> 1) & 1, a & 1, a,
1005  (a >> 7) & 1,(a >> 6) & 1, (a >> 5) & 1, (a >> 4) & 1,(a >> 3) & 1, (a >> 2) & 1, (a >> 1) & 1, a & 1 );
1006  Message(buf, er);
1007  }
1008 
1009  return er;
1010 }
unsigned char DXL_HexBin(char *str)
Definition: Dxl.c:83
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
#define STS0LEN
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:

§ AMS_PWM()

int AMS_PWM ( int  id,
int  on,
int  off 
)

set the on/off time on the PWM
set the on/off time on the PWM.

Parameters
id= AMS ADDRESS
on= on time
off= off time
Returns

Definition at line 492 of file Dxl.c.

References ACKLEN, DXL_par::add, AMS_assadd(), DXL_par::buftx, delay(), DXL_RxStr(), and DXL_TxStr().

Referenced by ADTesterCB(), OMU_AssignPow(), and ShutCB().

493 {
494  char buf[80];
495  int er, d;
496 
497  //Assign Address
498  AMS_assadd(id);
499 
500 // on = 450;
501 // off = 50;
502  sprintf(DXL.buftx, "6%08X%08X", (unsigned int)on, (unsigned int)off );
503  DXL.add = 1; //AMS2 address
504  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
505  delay(500);
506  d = ACKLEN;
507  er = DXL_RxStr(buf, &d);
508 
509 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
int add
Peripheral address.
Definition: DXL.H:19
DXL_par DXL
Definition: Dxl.c:18
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
int on
PRG execution control variabile.
Definition: DAS_Spat.c:109
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_PWM_OFF()

void AMS_PWM_OFF ( int  id)

Definition at line 584 of file Dxl.c.

References ACKLEN, DXL_par::add, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by OMU_DoPeltPow().

585 {
586  char buf[80];
587  int er, d;
588 
589  //Assign Address
590  AMS_assadd(id);
591 
592 // on = 450;
593 // off = 50;
594  sprintf(DXL.buftx, "7", 1);
595  DXL.add = 1; //AMS2 address
596  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
597  d = ACKLEN;
598  er = DXL_RxStr(buf, &d);
599 
600 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
int add
Peripheral address.
Definition: DXL.H:19
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_ReadAD()

int AMS_ReadAD ( int  id,
int  ch 
)

Definition at line 1013 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

1014 {
1015 
1016  char buf[80];
1017  int d, er;
1018 
1019  //Assign Address
1020  AMS_assadd(id);
1021 
1022  // Send slope
1023  sprintf(DXL.buftx, ":%02X", ch );
1024  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1025  d = ACKLEN;
1026  er = DXL_RxStr(buf, &d);
1027 
1028  return er;
1029 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
static double ch
Definition: SOLPOS.C:120
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:

§ AMS_ReadStep()

unsigned long AMS_ReadStep ( int  id,
int  motor 
)

read performed steps
Procedure for the determination of the number of steps executed.

Parameters
id= AMS ADDRESS
motor= 0 –> A Motor, = 1 –> B Motor
Returns
unsigned long = number of steps

Definition at line 60 of file Dxl.c.

References AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by AMS_DoPos(), AMS_TestPos(), DB_ToolsKeyB_CB(), and Task_HomeGrat().

61 {
62 
63  char buf[80];
64  int d, er;
65  long ns;
66 
67  //Assign Address
68  AMS_assadd(id);
69 
70  sprintf(DXL.buftx, "1%02X", motor);
71  DXL_TxStr(DXL.buftx, 3);
72  d = 15;
73  er = DXL_RxStr(buf, &d);
74  if(er == 0)
75  {
76  sscanf(buf, "%lx", &ns);
77  return ns;
78  }
79 
80  return 0;
81 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_sendstep()

int AMS_sendstep ( int  id,
int  dira,
int  dirb,
unsigned long  stepa,
unsigned long  stepb 
)

Send steps Procedure for sending steps to the Stepper Motor.

Parameters
id= AMS ADDRESS
dira= 0/1 for Motor A
dirb= 0/1 for Motor B
stepa= steps for Motor A
stepb= steps for Motor B
Returns
int er
er:
  • 0 = command executed correctly
  • 1 = No start character
  • 2 = Incongruent address
  • 3 = CheckSum error

Definition at line 513 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by AMS_DoPos(), SD_PosAADev(), SD_Position(), and SD_PosOMUDev().

514 {
515  char buf[80];
516  int d, er;
517 
518  //Assign Address
519  AMS_assadd(id);
520 
521  //Send step number
522  sprintf(DXL.buftx,".%02X%08lX%02X%08lX", dira, stepa, dirb, stepb);
523  DXL_TxStr(DXL.buftx, 21);
524  d = ACKLEN;
525  er = DXL_RxStr(buf, &d);
526 
527  return er;
528 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_SetPolarity()

int AMS_SetPolarity ( int  id,
int  homea,
int  worka,
int  homeb,
int  workb 
)

Definition at line 530 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

531 {
532  char buf[80];
533  int d, er;
534 
535  //Assign Address
536  AMS_assadd(id);
537 
538  //Send Polarity for home and work
539  sprintf(DXL.buftx,"*%02X%02X%02X%02X", homea, worka, homeb, workb);
540  DXL_TxStr(DXL.buftx, 21);
541  d = ACKLEN;
542  er = DXL_RxStr(buf, &d);
543 
544  return er;
545 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:

§ AMS_Slope()

int AMS_Slope ( int  id,
int  slopea,
int  slopeb 
)

Set slope to the Stepper motors Procedure for setting the slope fot the Stepper Motors.

Parameters
id= AMS ADDRESS
slopeaslope for motor A
slopebslope for motor B
Returns
int er
er:
  • 0 = command executed correctly
  • 1 = No start character
  • 2 = Incongruent address
  • 3 = CheckSum error

Definition at line 368 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by DB_InitAMS().

369 {
370  char buf[80];
371  int d, er;
372 
373  //Assign Address
374  AMS_assadd(id);
375 
376  // Send slope
377  sprintf(DXL.buftx, "(%02X%02X", slopea, slopeb);
378  DXL_TxStr(DXL.buftx, 5);
379  d = ACKLEN;
380  er = DXL_RxStr(buf, &d);
381 
382  return er;
383 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_Speed()

int AMS_Speed ( int  id,
int  speeda,
int  speedb 
)

Set speed to the Stepper motors Procedure for setting speed for the Stepper Motors.

Parameters
id= AMS ADDRESS
speedaspeed for motor A
speedbspeed for motor B
Returns
int er
er:
  • 0 = command executed correctly
  • 1 = No start character
  • 2 = Incongruent address
  • 3 = CheckSum error

Definition at line 386 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by DB_InitAMS().

387 {
388  char buf[80];
389  int d, er;
390 
391  //Assign Address
392  AMS_assadd(id);
393 
394  // Send speed
395  sprintf(DXL.buftx, "4%02X%02X", speeda, speedb);
396  DXL_TxStr(DXL.buftx, 5);
397  d = ACKLEN;
398  er = DXL_RxStr(buf, &d);
399 
400  return er;
401 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_Step()

int AMS_Step ( int  id,
int  stepa,
int  stepb 
)

Set stepping for the Stepper motors Procedure for setting steps for the Stepper Motors.

Parameters
id= AMS ADDRESS
stepastepping value for motor A
stepbstepping value for motor B
Returns
int er
er:
  • 0 = command executed correctly
  • 1 = No start character
  • 2 = Incongruent address
  • 3 = CheckSum error

Definition at line 349 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by DB_InitAMS().

350 {
351  char buf[80];
352  int d, er;
353 
354  //Assign Address
355  AMS_assadd(id);
356 
357  // Send step
358  sprintf(DXL.buftx, "'%02X%02X", stepa, stepb);
359  DXL_TxStr(DXL.buftx, 5);
360  d = ACKLEN;
361  er = DXL_RxStr(buf, &d);
362 
363  return er;
364 
365 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_TestHome()

int AMS_TestHome ( int  id,
int  par1 
)

verify if the home position has been reached

verify the if home position has been reached

Parameters
id= AMS ADDRESS
par10 = Motor A; 1 = Motor B
Returns
int d:
  • 0 = home not reached
  • 1 = Home reached
Parameters
id= AMS ADDRESS
par10 = Motor A; 1 = Motor B
Returns
er:
  • 0 = home not reached
  • 1 = Home reached

Definition at line 1042 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::bufrx, DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by D_Homing().

1043 {
1044 
1045 // char buf[80];
1046  int d, er;
1047 
1048  //Assign Address
1049  AMS_assadd(id);
1050 
1051  sprintf(DXL.buftx,"G%02X", par1);
1052  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1053  d = ACKLEN;
1054  er = DXL_RxStr(DXL.bufrx, &d);
1055  d = atoi(DXL.bufrx);
1056 
1057  return d;
1058 
1059 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_TestPos()

int AMS_TestPos ( int  id,
int  motor 
)

Test positioning status
Procedure for testing the positioning status of the selected motor.

Parameters
id= AMS ADDRESS
motor= 0 –> A Motor, = 1 –> B Motor
Returns

Definition at line 31 of file Dxl.c.

References AMS_assadd(), AMS_ReadStep(), DXL_par::bufrx, DXL_par::buftx, DXL_RxStr(), DXL_TxStr(), MLoopWhileEvents(), and STS0LEN.

Referenced by AMS_DoPos().

32 {
33 // char buf[80];
34  int d, er;
35  long ns;
36  //Assign Address
37  AMS_assadd(id);
38 
39 // if (steps > period)
40 // {
41 // nv = steps / period;
42 // }
43 // k = 1;
44  do
45  {
46 // if(k)
47 
48  sprintf(DXL.buftx, "8%02X", motor);
49  DXL_TxStr(DXL.buftx, 3);
50  d = STS0LEN;
51  er = DXL_RxStr(DXL.bufrx, &d);
52  ns = AMS_ReadStep(id, motor);
54  //}while(DXL.bufrx[0] == '0' && DXL.bufrx[1] == '0' && er == 0);
55  }while(DXL.bufrx[0] == '0' && DXL.bufrx[1] == '0' && er == 0 && ns != 0);
56 
57  return er;
58 }
void MLoopWhileEvents(int discard)
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
#define STS0LEN
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
DXL_par DXL
Definition: Dxl.c:18
unsigned long AMS_ReadStep(int id, int motor)
read performed steps Procedure for the determination of the number of steps executed.
Definition: Dxl.c:60
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_TestWork()

int AMS_TestWork ( int  id,
int  par1 
)

verify the if work position has been reached

Parameters
id= AMS ADDRESS
par10 = Motor A; 1 = Motor B
Returns
er:
  • 0 = home not reached
  • 1 = Home reached

Definition at line 1064 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

1065 {
1066 
1067  char buf[80];
1068  int d, er;
1069 
1070  //Assign Address
1071  AMS_assadd(id);
1072 
1073 
1074  sprintf(DXL.buftx,"H%02X", par1);
1075  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1076  d = ACKLEN;
1077  er = DXL_RxStr(buf, &d);
1078 
1079  return er;
1080 
1081 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:

§ AMS_TrackOff()

int AMS_TrackOff ( int  id,
int  amot,
int  bmot 
)

tracking off Procedure for Stepper Motor tracking de-activation

Parameters
id= AMS ADDRESS
amot= 1 –> Execute operation on A motor, = 0 –> No operation on A Motor
bmot= 1 –> Execute operation on B motor, = 0 –> No operation on B Motor
Returns
int er
er:
  • 0 = command executed correctly
  • 1 = No start character
  • 2 = Incongruent address
  • 3 = CheckSum error

Definition at line 422 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by HomeAzimFast(), HomeFiltersFast(), HomeNDFiltersFast(), HomeTrack(), and Task_AMSH().

423 {
424  char buf[80];
425  int d, er;
426 
427  //Assign Address
428  AMS_assadd(id);
429 
430  sprintf(DXL.buftx, "5%02X%02X", amot, bmot);
431  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
432  d = ACKLEN;
433  er = DXL_RxStr(buf, &d);
434 
435  return er;
436 
437 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_TrackOn()

int AMS_TrackOn ( int  id,
int  adir,
int  bdir,
unsigned long  acount,
unsigned long  bcount 
)

Activate tracking Procedure for Stepper Motor tracking activation.

Parameters
id= AMS ADDRESS
adirdirection of motor A
bdirdirection of motor B
acountCOUNT = 10E6/F with F = 200 / StepFrac * (rpm) / 60 for motor A
bcountCOUNT = 10E6/F with F = 200 / StepFrac * (rpm) / 60 for motor B
Returns
int er
er:
  • 0 = command executed correctly
  • 1 = No start character
  • 2 = Incongruent address
  • 3 = CheckSum error

Definition at line 404 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by HomeAzimFast(), HomeFiltersFast(), HomeNDFiltersFast(), and HomeTrack().

405 {
406  char buf[80];
407  int d, er;
408 
409  //Assign Address
410  AMS_assadd(id);
411 
412  sprintf(DXL.buftx, "0%02X%08lX%02X%08lX", adir, acount, bdir, bcount);
413  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
414  d = ACKLEN;
415  er = DXL_RxStr(buf, &d);
416 
417  return er;
418 
419 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AMS_wopto()

int AMS_wopto ( int  id,
unsigned int  w 
)

write the value on the optoinsulated port
write the value on the optoinsulated port.

Parameters
id= AMS ADDRESS
w= number of bit to be setted (0-7)
Returns

Definition at line 911 of file Dxl.c.

References ACKLEN, AMS_assadd(), DXL_par::buftx, DXL_RxStr(), and DXL_TxStr().

Referenced by AMS_PWM_Zero(), ExtLamp(), ExtShutt(), FANECU(), FANPeltier(), HgLamp(), HiresPS(), OOP_CB(), Peltier(), PeltierPS(), QjLamp(), and SD_FNTorqueM().

912 {
913  char buf[80];
914  int d, er;
915 
916  //Assign Address
917  AMS_assadd(id);
918  //Write the opto port
919  sprintf(DXL.buftx, "9%02X", w);
920  DXL_TxStr(DXL.buftx, 3);
921  d = ACKLEN;
922  er = DXL_RxStr(buf, &d);
923 
924  return er;
925 }
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define ACKLEN
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
Definition: Dxl.c:18
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
Definition: Dxl.c:25
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_Positioning()

void D_Positioning ( MOBJECT  p,
int  id,
long  tout 
)

Callback for the void D_VRange and display also the status in the corresponding CP labels.

Parameters
pMGUI Object (label in CP)
idmotor positioning /param tout: time out

Definition at line 607 of file Dxl.c.

References AMS1, optionini::amsprogbar, D_VRange(), DBDEMO, das::DOption, flag::exemode, das::Flag, MObjectSetText(), stepm::postime, stepm::SM_B, st, and das::StepM.

Referenced by AMS_DoPos(), and DemoInitMotor().

608 {
609  unsigned long st, et, x;
610  long tl;
611  char buf[80];
612 
613  if (DAS.Flag.exemode == DBDEMO)
614  tout = 1000;
615 
616  st = GetTickCount();
617  do
618  {
619  et = GetTickCount();
620  x = labs(et - st);
621  //g = x % 10;
622  //sprintf(buf, " %u %u", x, g);
623  //Status (buf);
624  //MLoopWhileEvents(0);
625  //if((x % 10 == 0) && (x > 0))
626  if(x > 0)
627  {
629  {
630  D_VRange(NULL, (long) x * 100 / tout, 255, 0, 0 );
631  tl = (long) ((double)fabs(((double)(labs(et - st) - tout))/1000.0 ));
632  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(labs(et - st) - tout))/1000.0 ));
633  MObjectSetText(p, buf);
634  DAS.StepM.postime[AMS1][DAS.StepM.SM_B]=(unsigned long)(tl*1000);
635 
636  }
637  }
638  }while(labs(et - st) < tout);
639 
640 }
stepm StepM
Stepper motors parameters structure.
optionini DOption
Options for DAS execution.
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
flag Flag
Structure for different flags.
#define DBDEMO
execution in demo mode
void MObjectSetText(MOBJECT obj, const char *text)
long postime[AMSMAX][2]
time necessary for positioning
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
static double p
Definition: SOLPOS.C:131
#define AMS1
AMS1 address.
static double st
Definition: SOLPOS.C:142
das DAS
Definition: Dxl.c:22
int exemode
Set the Execution MODE (Execution modes)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_StepMotor()

int DB_StepMotor ( int  id,
int  motor,
long  step,
int  dir 
)

Send steps to the selected stepper motor.
.

Parameters
id= AMS address:
  • 0 = AMS1
  • 1 = AMS2
  • 2 = AMS3
motor
  • = 0 –> Motor A
  • = 1 –> Motor B
step–> number of steps to be performed
dir= direction of the stepper rotation:
  • = 0 –> clockwise
  • = 1 –> counterclockwise)
Returns
er:
  • = 0 –> positioning successful
  • = 1 –> Problems encountred

Definition at line 816 of file Dxl.c.

References DXL_par::add, controlpanel::Albl_LS, AMS_DoPos(), gui::ContrPanel, DBDEMO, flag::exemode, das::Flag, das::Gui, controlpanel::LedSM, Message(), MObjectSetText(), and MPixmapSetImageFile().

Referenced by ActMvAzimCB(), ActMvGratCB(), ActMvZenCB(), D_Calibra(), SD_Azimuth(), SD_FilterW(), SD_Grating(), SD_Mirror(), SD_NDFilterW(), SD_Position(), SD_PosOMUDev(), SD_Zenith(), and SD_Zenith_H().

817 {
818 
819  char buf[80];
820 // char Dbuf[80];
821  int er = 0;
822  int c = motor, d = 0;
823 
824 
825 
826  switch(c)
827  {
828  //INPUT MIRROR
829  case 0: MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[id][0], "SYS\\ledoff.bmp");
830  sprintf(buf, "%s", "Positioning");
832  DXL.add = 0;
833  er = AMS_DoPos(id, dir, 0, step, 0);
834  if (DAS.Flag.exemode != DBDEMO)
835  if(er) { Message("n Step not sent! 1", er); break; }
836  break;
837 
838  //GRATING
839  case 1: MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[id][1], "SYS\\ledoff.bmp");
840  sprintf(buf, "%s", "Positioning");
842  DXL.add = 0;
843  er = AMS_DoPos(id, 0, dir, 0, step);
844  if (DAS.Flag.exemode != DBDEMO)
845  if(er) { Message("n Step not sent! 2", er); break; }
846  break;
847 
848  //FILTER WHEEL
849  case 2: MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[id][0], "SYS\\ledoff.bmp");
850  sprintf(buf, "%s", "Positioning");
852 
853  DXL.add = 1;
854  er = AMS_DoPos(id, dir, 0, step, 0);
855  if (DAS.Flag.exemode != DBDEMO)
856  if(er) { Message("n Step not sent! 2", er); break; }
857  DXL.add = 0;
858  break;
859 
860  // ND FILTER WHEEL
861  case 3: MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[id][1], "SYS\\ledoff.bmp");
862  sprintf(buf, "%s", "Positioning");
864 
865  DXL.add = 1;
866  er = AMS_DoPos(id, 0, dir, 0, step);
867  if (DAS.Flag.exemode != DBDEMO)
868  if(er) { Message("n Step not sent! 2", er); break; }
869  DXL.add = 0;
870  break;
871 
872 
873  //Zenith
874  case 4: MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[id][0], "SYS\\ledoff.bmp");
875  sprintf(buf, "%s", "Positioning");
877 
878  DXL.add = 2;
879  er = AMS_DoPos(id, dir, 0, step, 0);
880  if (DAS.Flag.exemode != DBDEMO)
881  if(er)
882  {
883  Message("n Step not sent! 3", er);
884  break;
885  }
886  DXL.add = 0;
887  break;
888  //Azimuth
889  case 5: MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[id][1], "SYS\\ledoff.bmp");
890  sprintf(buf, "%s", "Positioning");
892 
893  DXL.add = 2;
894  er = AMS_DoPos(id, 0, dir, 0, step);
895  if (DAS.Flag.exemode != DBDEMO)
896  if(er) { Message("n Step not sent! 4", er); break; }
897  DXL.add = 0;
898  break;
899 
900 
901  }
902 
903 
904  return 1;
905 }
gui Gui
Graphic User Interface Structure.
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
flag Flag
Structure for different flags.
#define DBDEMO
execution in demo mode
void MObjectSetText(MOBJECT obj, const char *text)
int add
Peripheral address.
Definition: DXL.H:19
DXL_par DXL
Definition: Dxl.c:18
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
controlpanel ContrPanel
Control Panel Structure.
das DAS
Definition: Dxl.c:22
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)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ delay()

void delay ( unsigned long  d)

Pauses for a specified number of milliseconds.
.

Definition at line 1113 of file Dxl.c.

References DWORD.

Referenced by AMS_Power(), AMS_PWM(), AMS_PWM_Zero(), AutoR_SetND_Filter(), AutoRange(), CreateList(), D_Average(), D_Calibra(), DB_GetCCD(), E_Almucantar(), E_DFMeasure(), E_DirectSun(), ExMaster(), ExtLamp(), ExtShutt(), FANECU(), FANPeltier(), FTP_Back_UP(), InitCCD_AMS(), MDQuitCB(), OOP_CB(), Peltier(), PRG_Check(), ShutCB(), and ViewPlot().

1114 {
1115  DWORD s, e;
1116  s = GetTickCount();
1117  do
1118  e = GetTickCount();
1119  while((unsigned long)labs(e - s) < d);
1120 }
#define DWORD
Definition: DSCUD.H:75
+ Here is the caller graph for this function:

§ DXL_ByteHex()

unsigned char DXL_ByteHex ( unsigned char  val)

Definition at line 1140 of file Dxl.c.

References ch.

Referenced by DXL_TxStr().

1141 {
1142  unsigned char ch = val;
1143  if(ch <= 9) ch += '0';
1144  else ch += '0' + 7;
1145  return ch;
1146 }
static double ch
Definition: SOLPOS.C:120
+ Here is the caller graph for this function:

§ DXL_Close()

int DXL_Close ( void  )

Close COM.

Definition at line 1258 of file Dxl.c.

References DXL_par::com, SioDone(), and SioReset().

Referenced by DB_CloseCOM().

1259 {
1260  int er;
1261  er = SioReset(DXL.com, 64, 64);
1262  return(SioDone(DXL.com));
1263 }
NoMangle int DLL_IMPORT_EXPORT SioDone(int)
NoMangle int DLL_IMPORT_EXPORT SioReset(int, int, int)
DXL_par DXL
Definition: Dxl.c:18
int com
Comunication port.
Definition: DXL.H:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DXL_HexBin()

unsigned char DXL_HexBin ( char *  str)

Definition at line 83 of file Dxl.c.

References ch.

Referenced by AMS_chkbitsts(), AMS_Proxy(), and DXL_RxStr().

84 {
85  unsigned char ch;
86  if(str[0] <= '9')
87  ch = (str[0] - '0') << 4;
88  else
89  ch = (str[0] - '0' - 7) << 4;
90  if(str[1] <= '9')
91  ch += str[1] - '0';
92  else
93  ch += str[1] - '0' - 7;
94  return ch;
95 }
static double ch
Definition: SOLPOS.C:120
+ Here is the caller graph for this function:

§ DXL_Open()

int DXL_Open ( int  addr,
int  com,
int  baud 
)

Open COM.

Parameters
addr0
com=
  • COM1 = 0
  • COM2 = 1
  • COM3 = 2
  • COM4 = 3
baud=
  • Baud110 = 0
  • Baud300 = 1
  • Baud1200 = 2
  • Baud2400 = 3
  • Baud4800 = 4
  • Baud9600 = 5
  • Baud19200 = 6
  • Baud38400 = 7
  • Baud57600 = 8
  • Baud115200 = 9
Returns
er:
  • 0 = operation concluded succesfull
  • not 0 = problems occurred

Definition at line 1243 of file Dxl.c.

References DXL_par::add, Baud19200, DXL_par::com, NoParity, OneStopBit, SioBaud(), SioParms(), SioReset(), DXL_par::speed, and WordLength8.

Referenced by DB_InitCOM().

1244 {
1245  int er = 0;
1246  DXL.speed = baud;
1247  DXL.com = com;
1248  DXL.add = addr; // Default device address
1249 
1250  SioReset(DXL.com, 64, 64);
1253 
1254 
1255  return er;
1256 }
#define Baud19200
Definition: WSC.H:120
int speed
Baud rate.
Definition: DXL.H:18
#define WordLength8
Definition: WSC.H:94
NoMangle int DLL_IMPORT_EXPORT SioReset(int, int, int)
int add
Peripheral address.
Definition: DXL.H:19
DXL_par DXL
Definition: Dxl.c:18
NoMangle int DLL_IMPORT_EXPORT SioParms(int, int, int, int)
#define OneStopBit
Definition: WSC.H:86
#define NoParity
Definition: WSC.H:78
NoMangle int DLL_IMPORT_EXPORT SioBaud(int, unsigned)
int com
Comunication port.
Definition: DXL.H:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DXL_RxStr()

int DXL_RxStr ( char *  rx,
int *  len 
)

receive string from a serial port

Parameters
rxreceived string
*lennum of chars to be received
Returns
er: num of received chars

Definition at line 1187 of file Dxl.c.

References DXL_par::add, DXL_par::bufrx, DXL_par::com, DWORD, DXL_HexBin(), p, SioGets(), SioRxQue(), and st.

Referenced by AMS_AzzeraCoord(), AMS_chkbitsts(), AMS_chkbitsts_old(), AMS_Default(), AMS_dirfin(), AMS_Divisore(), AMS_ESlope(), AMS_firmrev(), AMS_Home(), AMS_HomeDefault(), AMS_MotorOn_Off(), AMS_Power(), AMS_Proxy(), AMS_PWM(), AMS_PWM_OFF(), AMS_ReadAD(), AMS_ReadStep(), AMS_sendstep(), AMS_SetPolarity(), AMS_Slope(), AMS_Speed(), AMS_Step(), AMS_TestHome(), AMS_TestPos(), AMS_TestWork(), AMS_TrackOff(), AMS_TrackOn(), AMS_wopto(), DB_InitAMS(), DB_StsMotor(), FPGACB(), HomeFiltersFast(), and HomeNDFiltersFast().

1188 {
1189  unsigned char cksm = 0, rcksm, add;
1190  int c, p = 0;
1191  DWORD st, et;
1192 
1193  DXL.bufrx[0] = DXL.bufrx[1] = 0;
1194 
1195  st = GetTickCount();
1196  do
1197  {
1198  c = SioRxQue(DXL.com);
1199  et = GetTickCount();
1200  //}while(c < *len && labs(et - st) < 2000);
1201  }while(c < *len && labs(et - st) < 500);
1202 
1203  SioGets(DXL.com, DXL.bufrx, c);
1204 
1205 
1206  while(DXL.bufrx[p++] != '$' && p < 80);
1207 
1208  if(p == 80)
1209  // No start character
1210  return 1;
1211  p--;
1212  add = DXL_HexBin(&DXL.bufrx[p + 1]);
1213  if(add != DXL.add)
1214  // Incongruent address
1215  return 2;
1216  cksm += DXL.bufrx[p + 1];
1217  cksm += DXL.bufrx[p + 2];
1218  for(c = p + 3; c < 80; c++)
1219  {
1220  if(DXL.bufrx[c] != '#')
1221  {
1222  cksm += DXL.bufrx[c];
1223  rx[c - 3] = DXL.bufrx[c];
1224  }
1225  else
1226  {
1227  c++;
1228  rcksm = DXL_HexBin(&DXL.bufrx[c]);
1229  rx[c - 4] = 0;
1230  break;
1231  }
1232  }
1233  if(rcksm != cksm)
1234  // CheckSum error
1235  return 3;
1236  *len = c - 3;
1237  return 0;
1238 }
NoMangle int DLL_IMPORT_EXPORT SioGets(int, LPSTR, unsigned)
unsigned char DXL_HexBin(char *str)
Definition: Dxl.c:83
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
int add
Peripheral address.
Definition: DXL.H:19
DXL_par DXL
Definition: Dxl.c:18
static double p
Definition: SOLPOS.C:131
#define DWORD
Definition: DSCUD.H:75
NoMangle int DLL_IMPORT_EXPORT SioRxQue(int)
static double st
Definition: SOLPOS.C:142
int com
Comunication port.
Definition: DXL.H:17
+ Here is the call graph for this function:

§ DXL_TxByte()

void DXL_TxByte ( unsigned char  v)

Definition at line 1148 of file Dxl.c.

References DXL_par::com, and SioPutc().

Referenced by DXL_TxStr().

1149 {
1150  SioPutc(DXL.com, v);
1151 }
DXL_par DXL
Definition: Dxl.c:18
NoMangle int DLL_IMPORT_EXPORT SioPutc(int, char)
int com
Comunication port.
Definition: DXL.H:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DXL_TxStr()

void DXL_TxStr ( char *  tx,
int  len 
)

send string to a serial port

Parameters
*txsent string
lennum of chars to be sent

Definition at line 1153 of file Dxl.c.

References DXL_par::add, ch, DXL_ByteHex(), and DXL_TxByte().

Referenced by AMS_AzzeraCoord(), AMS_chkbitsts(), AMS_chkbitsts_old(), AMS_Default(), AMS_dirfin(), AMS_Divisore(), AMS_ESlope(), AMS_firmrev(), AMS_Home(), AMS_HomeDefault(), AMS_MotorOn_Off(), AMS_Power(), AMS_Proxy(), AMS_PWM(), AMS_PWM_OFF(), AMS_ReadAD(), AMS_ReadStep(), AMS_sendstep(), AMS_SetPolarity(), AMS_Slope(), AMS_Speed(), AMS_Step(), AMS_TestHome(), AMS_TestPos(), AMS_TestWork(), AMS_TrackOff(), AMS_TrackOn(), AMS_wopto(), DB_InitAMS(), DB_StsMotor(), FPGACB(), HomeFiltersFast(), and HomeNDFiltersFast().

1154 {
1155  unsigned char cksm = 0, ch;
1156  int c;
1157 
1158  DXL_TxByte('$');
1159 
1160  ch = DXL_ByteHex((unsigned char) ((DXL.add >> 4) & 0x0F));
1161  DXL_TxByte(ch);
1162  cksm += ch;
1163  ch = DXL_ByteHex((unsigned char) (DXL.add & 0x0F));
1164  DXL_TxByte(ch);
1165  cksm += ch;
1166  for(c = 0; c < len; c++)
1167  {
1168  DXL_TxByte(tx[c]);
1169  cksm += tx[c];
1170  }
1171  DXL_TxByte('#');
1172  ch = DXL_ByteHex((unsigned char) ((cksm >> 4) & 0x0F));
1173  DXL_TxByte(ch);
1174  ch = DXL_ByteHex((unsigned char) (cksm & 0x0F));
1175  DXL_TxByte(ch);
1176  DXL_TxByte(13);
1177 }
static double ch
Definition: SOLPOS.C:120
int add
Peripheral address.
Definition: DXL.H:19
unsigned char DXL_ByteHex(unsigned char val)
Definition: Dxl.c:1140
DXL_par DXL
Definition: Dxl.c:18
void DXL_TxByte(unsigned char v)
Definition: Dxl.c:1148
+ Here is the call graph for this function:

§ Message()

void Message ( char *  str,
int  er 
)

Create a message shell for the AMS errors (Debug Use).
.

Parameters
*strtext to be displayed
erNumber of error
Returns
void

Definition at line 1085 of file Dxl.c.

References DXL_par::add, DXL_par::bufrx, DXL_par::buftx, palette::DB_BG_Plbl, palette::DB_FG_Plbl, DEFAULT_FONT, DPAL, lbl, LEFT_ALIGN, MCreateLabel(), MCreateShell(), MLabelSetAlignment(), MObjectSetBackgroundRGB(), MObjectSetForegroundRGB(), MShellRealize(), and SF_MODAL.

Referenced by AMS_chkbitsts(), AMS_Proxy(), DB_StepMotor(), DB_ToolsKeyB_CB(), DE_StepMotor(), FPGACB(), HomeAzimFast(), HomeFiltersFast(), HomeGratingFast(), HomeMirror(), HomeNDFiltersFast(), HomeZenithFast(), and ReadInputCB().

1086 {
1087  char buf[80];
1088  MOBJECT sh, lbl;
1089 
1090  sprintf(buf, "DEBUG: AMS%d, Err = %d", DXL.add+1, er);
1091 
1092  sh = MCreateShell(buf, SF_MODAL);
1094 
1095  lbl = MCreateLabel(sh, str, DEFAULT_FONT);
1098 
1099  sprintf(buf, "Txed: %s", DXL.buftx);
1100  lbl = MCreateLabel(sh, buf, DEFAULT_FONT);
1103 
1104  sprintf(buf, "Rxed: %s", DXL.bufrx);
1105  lbl = MCreateLabel(sh, buf, DEFAULT_FONT);
1108 
1109  MShellRealize(sh);
1110 }
void MObjectSetBackgroundRGB(MOBJECT obj, int r, int g, int b)
MOBJECT lbl
Definition: DFileMan.c:42
short DB_FG_Plbl[3]
Foreground PASSIVE Label Colors.
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
void MShellRealize(MOBJECT obj)
MOBJECT MCreateLabel(MOBJECT parent, const char *text, MTFont font)
palette DPAL
Definition: 2DPlot.c:27
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
int add
Peripheral address.
Definition: DXL.H:19
#define DEFAULT_FONT
Definition: Mguidefs.h:877
#define SF_MODAL
Definition: Mguidefs.h:1019
DXL_par DXL
Definition: Dxl.c:18
short DB_BG_Plbl[3]
Background PASSIVE Label Colors.
MOBJECT MCreateShell(const char *title, int flags)
void MLabelSetAlignment(MOBJECT p, int align)
void * MOBJECT
Definition: Mguidefs.h:192
#define LEFT_ALIGN
Definition: Mguidefs.h:915
void MObjectSetForegroundRGB(MOBJECT obj, int r, int g, int b)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

§ DAS

das DAS

Definition at line 22 of file Dxl.c.

§ DXL

DXL_par DXL

Definition at line 18 of file Dxl.c.

§ FLAG

flag FLAG

Definition at line 20 of file Dxl.c.

______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:45:09 for DAS - Rel. 3.1.6 - 18/09/2017.