DAS  3.1.6 - 18/09/2017
Data Structures | Typedefs | Functions
DXL.H File Reference

AMSs Functions used in DAS Program. More...

Go to the source code of this file.

Data Structures

struct  DXL_par
 DXL structure. Structure for the serial communication with the AMS adapter. More...
 

Typedefs

typedef struct DXL_par DXL_par
 DXL structure. Structure for the serial communication with the AMS adapter. More...
 

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...
 
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_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...
 
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)
 
void AMS_PWM_Zero (int mod)
 
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_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...
 
int DXL_Close (void)
 Close COM. More...
 
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_TxStr (char *tx, int len)
 send string to a serial port More...
 

Detailed Description

AMSs Functions used in DAS Program.

Version
2.8.2
Author
Daniele Bortoli

Definition in file DXL.H.

Typedef Documentation

§ DXL_par

typedef struct DXL_par DXL_par

DXL structure. Structure for the serial communication with the AMS adapter.

DXL_par

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_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'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_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_PWM()

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.

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_PWM_Zero()

void AMS_PWM_Zero ( int  mod)

Definition at line 2570 of file Spat_Device.c.

References AMS2, AMS_wopto(), ChkDigIO(), delay(), stepm::OOP, and das::StepM.

Referenced by OMU_DoPeltPow().

2571 {
2572 
2573  int er;
2574 
2575  er = ChkDigIO(DAS.StepM.OOP[AMS2], 0);
2576 
2577  if(mod)
2578  DAS.StepM.OOP[AMS2] |= 0x01; //bit 0 , 00000001
2579  else
2580  DAS.StepM.OOP[AMS2] &= 0xFE;
2581 
2582 
2583  // 1's complement
2584  DAS.StepM.OOP[AMS2] = ~DAS.StepM.OOP[AMS2];
2585  //write on the optoinsulated port
2586  //AMS_wopto(AMS2, DAS.StepM.OOP[AMS2]);
2587  AMS_wopto(AMS2, 1);
2588  delay(500);
2589  // again 1's complement for restoring the positive logic
2590  DAS.StepM.OOP[AMS2] = ~DAS.StepM.OOP[AMS2];
2591 
2592 
2593 
2594 
2595 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
#define AMS2
AMS2 address.
int ChkDigIO(unsigned char word, int bitn)
check for digital I/O Status
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
+ Here is the call graph for this function:
+ Here is the caller 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_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:

§ 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_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_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:
______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:46:13 for DAS - Rel. 3.1.6 - 18/09/2017.