HomeContact Us

 

Host Controlled Operation

 

In this mode the host will send a series of ASCII commands to the controller over the RS-232 serial port. The controller process to the incoming commands and responses with the proper messages.

Programming Example in Visual BASIC 

The following example sets the linear acceleration to 500,000 Steps / sec , step rate at 100 KHz, and the distance to travel equal to 200,000 steps. Then the controller is commanded to make an absolute move on the X Axis.

Private SubCommand1_Click()

'Function Prototype
Declare Function SioPuts Lib "WSC32.DLL" (ByVal Port As Long, ByVal Buffer As String, ByVal Size As Long) As Long

Dim Code As Long
Dim StringToBeTransmtd As String


'Disable the joystick.
StringToBeTransmtd = "joff" + vbCr
Code = SioPuts(ThePort, StringToBeTransmtd, Len(StringToBeTransmtd))

' Set the linear acceleration of X Axis to 500,000 steps / sec / sec
StringToBeTransmtd = "accx 500000" + vbCr
Code = SioPuts(ThePort, StringToBeTransmtd, Len(StringToBeTransmtd))

' Set the linear velocity of X Axis to 100,000 steps / sec
StringToBeTransmtd = "velx 100000" + vbCr
Code = SioPuts(ThePort, StringToBeTransmtd, Len(StringToBeTransmtd))

' Set the position to move of X Axis to 200,000 steps 
StringToBeTransmtd = "posx 200000" + vbCr
Code = SioPuts(ThePort, StringToBeTransmtd, Len(StringToBeTransmtd))

'Command the X Axis of the controller to make an absolute move
StringToBeTransmtd = "movax" + vbCr
Code = SioPuts(ThePort, StringToBeTransmtd, Len(StringToBeTransmtd))

End Sub

Programming Example in 'C'

The following example sets the acceleration at 10  Million Steps / sec2   , step rate at 100 KHz, and the distance to travel equal to 100,000 steps. Then the controller isCommanded to make an absolute move.

void send_command(void)
{

char StringToBeTransmtd[80];

// Disable the joystick
strcpy(StringToBeTransmtd,"joff\n");
SioPuts(Port,StringToBeTransmtd,strlen(StringToBeTransmtd));


// Set the linear acceleration of X Axis to 500,000 steps / sec / sec
strcpy(StringToBeTransmtd,"accx 500000\n");
SioPuts(Port,StringToBeTransmtd,strlen(StringToBeTransmtd));

// Set the linear velocity of X Axis to 100,000 steps / sec
strcpy(StringToBeTransmtd,"velx 100000\n");
SioPuts(Port,StringToBeTransmtd,strlen(StringToBeTransmtd));

// Set the position to move of X Axis to 200,000 steps 
strcpy(StringToBeTransmtd,"posx 200000\n");
SioPuts(Port,StringToBeTransmtd,strlen(StringToBeTransmtd));

// 'Command the X Axis of the controller to make an absolute move
strcpy(StringToBeTransmtd,"movax\n");
SioPuts(Port,StringToBeTransmtd,strlen(StringToBeTransmtd));

 

The following is the information that you need to establish communication with OES line of controllers.

 

1) The baud rate is 19.2 K, 8-bit, no parity, one stop bit.

 

2) The Request-to-Send (RTS) of the serial port is used to reset the controller card. During initialization you would have to set this line to CLEAR.

 

3) To reset the controller, set the line to SET wait for at least 10 msec, then set it back to CLEAR.


4) ASCII characters should be terminated with CR or LF.


5) After sending each packet of data to the OES’ controller, sufficient time should be given to the controller to process it, usually 100msec.

To receive characters, a buffer is setup and all the incoming characters are stored in it until they are fetched by the application.

The following commands the X-axis to stop, and checks the receiving buffer for “X Stopping” string to make sure the X-axis has received and performed theCommand.

 

Private Sub cmdXPlus_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim S As String
    Dim Start As Single
    Dim Counter As Integer
    Dim Where As Long

StringToBeTransmtd = "stopx" & vbCr
   
        Do While (Counter < NoofRetries And Where = 0)
             Code = SioPuts(ThePort, StringToBeTransmtd, Len(StringToBeTransmtd))
             Start = Timer()
             Do While Timer() < Start + DelayTime
                DoEvents   ' Yield to other processes.
              Loop

             Where = InStr(strRcvdMsg, "X Stopping")
             Counter = Counter + 1
        Loop

If (Counter >= NoofRetries) Then
           If MsgBox("The controller is not responding! Turn the controller's power off.", vbOKOnly, "Error46") = vbOK Then Exit Sub
End If

End Sub

 

To test, send JON. You should receive “Joystick is on”.

 

Send JOFF. You should receive Joystick is off.

 

 


 

www.OESIncorp.com

Copyright   2002, 2003, 2004, 2005, 2006 Optimal Engineering Systems, Inc.