The troubleshooting of RS-232 connectivity issues can be done in three steps:
- Confirm that the RS-232 adapter is working
- Confirm that the RS-232 port of the controller is working
- Measure the command response time
Confirm that RS-232 adapter is working
- Find the port that the adapter is connected
- Connect Tx and Rx pins together
- Plug the adapter on your PC and by using a Serial terminal like RealTerm confirm that each command is being reflected back
Confirm that RS-232 port of the controller is working
- Connect the adapter on the Roboteq controller and turn the controller ON
- On the serial terminal make the below configurations:
- 115200 kb/sec
- 8 bits
- None parity
- 1 stop bit
3. Send the below command:
?UID_
The controller should reply its unique ID.
Measure the command response time
If the controller is suspected that produces delays in the process and the response of the serial commands, then the below script can be used to test its response time. The controller will issue a serial command through RS-232, then it will read it and measure the time in between. To achieve that, the Tx and Rx pin of the controller must be connected together as shown on the below picture. Connect with Roborun+ by using USB.
The script follows:
option explicit
#define VAR 10 ' This is the VAR that will be used for the response test. Default value is 10
#define TIMEOUT 1000 'maximum wait time without receiving a response
dim i as integer
i=0
setconfig(_echof,1) ' disable serial echo
wait(1)
setcommand(_var,VAR,0) 'initialize the VAR to 0
wait(1)
setconfig(_SCRO,1) 'change the script print output to RS-232
wait(100)
print("!var ",VAR," 1_") 'change the VAR value to 1
while(getvalue(_VAR,VAR)<>1) 'wait until value has changed
i++
wait(1)
if (i>timeout) 'terminate the script if there is a timeout
setconfig(_SCRO,2)
wait(100)
print("\n timeout error \n")
terminate
end if
end while
setconfig(_SCRO,2) 'change th script output to USB
wait(100)
print("\n Response time: ",i," ms\n")
By the time that you will click on “run” button, the script will issue a command, measure and report the response time. To run the test again, click again on “run” button. The expected response time is between 1 to 2 ms.