Ejemplo n.º 1
0
void LCD_Init(void)
{
    bitclr(P2OUT,RS);
    Delayx100us(250);             // Delay 100ms
    Delayx100us(250);
    Delayx100us(250);
    Delayx100us(250);
    LCD_Data |= BIT4 | BIT5;      // D7-D4 = 0011
    LCD_Data &= ~BIT6 & ~BIT7;
    _E();                         // Toggle E for LCD
    Delayx100us(100);             // 10ms
    _E();                         // Toggle E for LCD
    Delayx100us(100);             // 10ms
    _E();                         // Toggle E for LCD
    Delayx100us(100);             // 10ms
    LCD_Data &= ~BIT4;
    _E();                         // Toggle E for LCD

    Send_Cmd(DISP_ON);
    Send_Cmd(CLR_DISP);
    Delayx100us(250);
    Delayx100us(250);
    Delayx100us(250);
    Delayx100us(250);
}
Ejemplo n.º 2
0
XYPos(int axisIndex)
{
   char responce[255];
   char *cmd,*cmdlandmark;
   int nchars;
   float xpos, landmarkpos;
   float dist2ISO, LaserRef2ISO;

   if (axisIndex == X_AXIS)
   {
      cmd = "XP21R";
      cmdlandmark = "R2R";
      LaserRef2ISO = XLaserRef2ISO;
   }
   else if (axisIndex == Y_AXIS)
   {
      cmd = "YP21R";
      cmdlandmark = "R5R";
      LaserRef2ISO = YLaserRef2ISO;
   }
   else
   {
      cmd = "XP21R";    /* default X axis */
      cmdlandmark = "R2R";
      LaserRef2ISO = XLaserRef2ISO;
   }

   nchars = Send_Cmd(cmd, responce);
   xpos = atof(responce);

   nchars = Send_Cmd(cmdlandmark, responce);
   landmarkpos = atof(responce);

   dist2ISO = landmarkpos - xpos + LaserRef2ISO;

   fprintf(stdout,"%f\n",xpos);
   fprintf(stdout,"%f\n",dist2ISO);
   /* fprintf(stderr,"dist 2 ISO: %f\n",dist2ISO); */
   fflush(stdout);

   /* get status and clear up error bits */
   Send_Cmd(statusCmd, responce);

   return(0);
}
Ejemplo n.º 3
0
wait4Axis2Stop(char axis)
{
   char cmd[25];
   char responce[40];
   int nchars;

   sprintf(cmd,"%c=H\n",axis);

   /* loop until the resonce is 'E', which means the axis motor
      has stopped, while running the responce is 'N'
   */
   nchars = Send_Cmd(cmd, responce);
   fprintf(stderr,"result: '%s'\n",responce);
   while(strcmp(responce,"E") != 0)
   {
      delayMsec(250);
      nchars = Send_Cmd(cmd, responce);
      fprintf(stderr,"result: '%s'\n",responce);
   }
}
Ejemplo n.º 4
0
  MoveAxis(char *Cmd)
  {
     /* xMA x+100 xMD */
     char mcmd[40],wcmd[32],dcmd[32];
     char responce[255];
     char *cptr;
     char axis;
     char direction;
     int nchars;

     axis = toupper(*Cmd++);
     direction = *Cmd++;
     if ( (axis != 'X') && (axis != 'Y') )
     {
       fprintf(stdout,"Error invalid Axis '%c' specified, only X or Y valid\n",axis);
       return -1;
     }

     sprintf(wcmd,"%cMA",axis);
     sprintf(mcmd,"%cMA %c%c%s",axis,axis,direction,Cmd);
     sprintf(wcmd,"%c=H",axis);
     sprintf(dcmd,"%cMD",axis);

     /* 1st activate motor, then start the axis on it's way */
     nchars = Send_Cmd(mcmd, responce);

     /* 2nd wait until axis motor has completed */
     nchars = Send_Cmd(wcmd, responce);  /* has the axis motor stopped, N=no, E=yes */
     while(responce[0] != 'E')
     {
       delayMsec(250);
       nchars = Send_Cmd(wcmd, responce);
     }

     /* just a precaution delay before turn off motor */
     delayMsec(250);
     /* 3rd turn off motor */
     nchars = Send_Cmd(dcmd, responce);
     return ( 0 );
 }
Ejemplo n.º 5
0
Status()
{
   char *cmd = "ST";
   char responce[255];
   int status,bit,nchars;
   float ypos, xpos, landmarkXpos, landmarkYpos, Xdist2ISO, Ydist2ISO, laser2ISO, laserYref;

   nchars = Send_Cmd(cmd, responce);
   status = atoi(responce);
   fprintf(stdout,"Status: 0x%x\n",status);
   for (bit = 0; bit < 8; bit++)
   {
      if (status & (1 << bit)) fprintf(stdout,"\t'%s'\n",StatusVals[bit]);
   }
   fprintf(stdout,"\n");
   nchars = Send_Cmd("XP21R", responce);
   xpos = atof(responce);
   nchars = Send_Cmd("YP21R", responce);
   ypos = atof(responce);
   fprintf(stdout,"X-Position (vertical)   : %f mm, %f in\n",xpos,xpos/25.4);
   fprintf(stdout,"Y-Position (horizontal) : %f mm, %f in\n",ypos,ypos/25.4);

   /*
      Oops, R15 & R16 are only updated if the key pad is used, not much use here.
   nchars = Send_Cmd("R15R", responce);
   xpos = atof(responce);
   nchars = Send_Cmd("R16R", responce);
   ypos = atof(responce);
   */
   /* calc taken from CALDST.APR, used in PT controller to calc dist to ISO center */
   nchars = Send_Cmd("R10R", responce);
   laser2ISO = atof(responce);
   nchars = Send_Cmd("R11R", responce);
   laserYref = atof(responce);

   nchars = Send_Cmd("R2R", responce);
   landmarkXpos = atof(responce);
   nchars = Send_Cmd("R5R", responce);
   landmarkYpos = atof(responce);

   Xdist2ISO = landmarkXpos - xpos + laser2ISO;
   Ydist2ISO = landmarkYpos - ypos + laserYref;

   fprintf(stdout,"laser2ISO: %f, LaserYref: %f, LandmarkX: %f, LandmarkY: %f\n",
		laser2ISO,laserYref,landmarkXpos,landmarkYpos);
   
   fprintf(stdout,"X-Position relative to ISO (vertical)   : %f mm, %f in\n",
		Xdist2ISO,Xdist2ISO/25.4);
   fprintf(stdout,"Y-Position relative to ISO (horizontal) : %f mm, %f in\n",
		Ydist2ISO,Ydist2ISO/25.4);
   fprintf(stdout,"\n\n");
   
   return(0);
}
Ejemplo n.º 6
0
SoftLimits()
{
   char *cmd;
   char responce[255];
   int nchars;

   /* get status and clear up error bits */
   Send_Cmd(statusCmd, responce);

   /* calc taken from CALDST.APR, used in PT controller to calc dist to ISO center */
   nchars = Send_Cmd("R10R", responce);
   XLaserRef2ISO = atof(responce);
   nchars = Send_Cmd("R11R", responce);
   YLaserRef2ISO = atof(responce);

    nchars = Send_Cmd("R20R", responce);
    XShrouldLimit = atof(responce);
    nchars = Send_Cmd("R21R", responce);
    XHlimitIn = atof(responce);
    nchars = Send_Cmd("R22R", responce);
    XHlimitOut = atof(responce);
    nchars = Send_Cmd("R23R", responce);
    Y_XLL1 = atof(responce);
    nchars = Send_Cmd("R24R", responce);
    Y_XLH1 = atof(responce);
    nchars = Send_Cmd("R25R", responce);
    Y_XLL2 = atof(responce);
    nchars = Send_Cmd("R26R", responce);
    Y_XLH2 = atof(responce);
   
  if (verbose)
  {
    printf("XShrouldLimit: %lf, XHlimitIn: %lf, XHlimitOut: %lf\n",XShrouldLimit,XHlimitIn,XHlimitOut);
    printf("Y_XLL1: %lf, Y_XLH1: %lf, Y_XLL2: %lf, Y_XLH2: %lf\n",Y_XLL1,Y_XLH1,Y_XLL2,Y_XLH2);
  }
}
Ejemplo n.º 7
0
Archivo: ms.c Proyecto: boris-r-v/RIO
main()
{
	char *cmd, *str;
	char rbuf[256];
	int r, i;
	WORD texp;

	Open_Com(COM2, 9600, Data8Bit, NonParity, OneStopBit);

	// cmd = "#02\r";
	cmd = "$022\r";
	// cmd = "%0202080600\r"; /* non-check-sum */
	// cmd = "%0202080640\r"; /* check-sum */

	Send_Cmd(COM2, cmd, 0);
	Receive_Cmd(COM2, rbuf, 40, 0);
	printf("response: %s\n", rbuf);

	Close_Com(COM2);
}
Ejemplo n.º 8
0
main (int argc, char *argv[])
{
  int done;
  int status;
  char buffer[256];
  char responce[256];
  char *bptr;
  char *cmdline;
  int buflen = 1;
  int firstentry = 1;
  int chars;
  char cmdchar;
 
  if (argc < 2)
  {
    fprintf(stdout,"usage:  %s <devicename> (i.e. /dev/term/b)\n", argv[0]);
    exit(1);
  }

  verbose = 0;

  /* initialize Serial port to Gilson */
  Portfd = initPort(argv[1],PATIENT_TABLE);
 
  /* need this info for isocenter calcualtions */
  SoftLimits();

  if (argc > 2)
  {
     cmdchar = argv[2][0];
     /* printf("2nd arg: '%s'\n",argv[2]); */
     if (cmdchar != '-')
     {
	status = 0;
        switch( toupper(cmdchar) )
        {
	   case 'M':
        	MoveAxis(&(argv[2][1]));
        	/* get status and clear up error bits */
        	Send_Cmd(statusCmd, responce);
                XYPos(X_AXIS);
                XYPos(Y_AXIS);
		break;
	  case 'X':
                XYPos(X_AXIS);
		break;

	  case 'Y':
                XYPos(Y_AXIS);
		break;

	  case 'S':
                Status();
		break;

	  default:
		status = -1;
		break;
		
        }
  	fflush(stdout);
	return(status);
     }
     else if (strcmp(argv[2],"-debug") == 0)
     {
       verbose = 1;
     }
  }
 
  if (verbose)
    fprintf(stdout,"Init Device: %s\n",argv[1]);
 
  if (verbose)
     PrintSet();

/*
  fprintf(stdout,"%lf %lf %lf %lf %lf %lf %lf %lf \n",xyMinMax[0],xyMinMax[1],
		xyMinMax[2],xyMinMax[3],xyMinMax[4],xyMinMax[5],
		MaxXYSpeed[0],MaxXYSpeed[1]);
*/

  fflush(stdout);


  done = 1;
  while (done)
  {
    if (verbose)
    {
      fprintf(stdout,"M)ove Axis (MX+100,MY-100), S)tatus \n");
      fprintf(stdout,"\nCmds:  ");
    }
    else if (buflen)
    {
      if (!firstentry)
        fprintf(stdout,"Cmds:\n");   /* The GUI expects this prompt, verbatim */
      else
	 firstentry = 0;
    }
/**********/

    fflush(stdout);
    bptr = gets(buffer);
    buflen = strlen(buffer);
    if (bptr == NULL)
      break;
    switch( toupper(buffer[0]) )
    {
        case 'M':
                MoveAxis(&buffer[1]);
                break;
 
        case 'S':
                Status();
                break;
        case 'X':
                XYPos(X_AXIS);
                break;
        case 'Y':
                XYPos(Y_AXIS);
                break;
   
        case 'Q':
                done = 0;
                return;
                break;
    }
  }

}
Ejemplo n.º 9
0
void LCD_Second_Line(void)
{
    Send_Cmd(DD_RAM_ADDR2);
}
Ejemplo n.º 10
0
void LCD_First_Line(void)
{
    Send_Cmd(DD_RAM_ADDR);
}
Ejemplo n.º 11
0
void LCD_Clear(void)
{
    Send_Cmd(CLR_DISP);
    Delayx100us(10);
}