Raw redirect is a feature supported in Roboteq controllers, firmware version 2.1 and later, that can be used to send and receive data using RS-485 interface. The protocol used for that is Modbus RTU. In RTU mode one frame is defined based on the Modbus RTU regulations (after specific silent time goes by, see Modbus Manual for more details).


Hardware connections

Modbus RTU uses a pair of twisted cables.  Data + goes to RS485 + of the controller and data- to RS485-. 



1. Raw Redirect must be set to RS in Roborun+ Utility

2. Modbus mode must be set to RS485 RTU

3. Set the script output to USB

The two above commands need to be sent for the Raw redirect to work

Micro Basic commands

Receiving frames


result = getvalue(_CD, 1)


Returns the number of frames waiting on the FIFO buffer and copies the last frame into the read buffer


result = getvalue(_DDT, ee)


Returns the received frame. The data will be available only after a CD query has been sent.




ee =1…64.

1 : byte size

2-64: data 0 to data 64


Transmitting frames


setcommand(_CU, ee, nn)


Is used to build and send Raw frames in serial interfaces. It can be used to enter the out-port (RS232 or RS485), frame length, and data, one element at a time. The frame is sent immediately after the frame length is entered, and so it should be entered last.




 ee = 1…18


 1: out-port (0 for RS232, 6 for RS485)

 2: frame length

 3…18 = data0  to data15


 nn = value



Script example







'Raw Redirect example

'The Raw Redirect must be enabled and the Modbus mode must be set to 'RS485 RTU

'Applicable in firmware versions 2.1 or later



'*********** CONFIGURATIONS *************


option explicit


'Variable definitions


#define SEND_DATA_LENGTH 'Define the send data length in bytes 


dim sendFrame[SEND_DATA_LENGTHas integer

dim inputBuffer[64as integer

dim as integer

dim incomingFrameLength as integer


'Initialize variables



incomingFrameLength 0


'A 4 byte sample data frame







for andwhile i<64







setconfig(_SCRO,2'set the script output to USB

setconfig(_ISM,4'set the Raw redirect to RS485

setconfig(_DMOD,6'set the Modbus mode to RS485 RTU




'************* MAIN LOOP *******************




'1. Send a RS-485 frame once in a loop


for i=andwhile 3+SEND_DATA_LENGTH


    setCommand(_CU,i,sendFrame[i-3]) 'send byte 3~6




setCommand(_CU,1,6'set the output port to RS-485



'2. Check if there is any frame received in the FIFO buffer and read it


if (getValue(_CD,1))


    incomingFrameLength getValue(_DDT,1)' get the frame size


    for andwhile incomingFrameLength


        inputBuffer[i] = getValue(_DDT,i+1'update the input buffer







end if


wait(1'Loop frequency 1 Khz


goto start




Notes:  By removing the section 1 on the main loop you will read only data though RS-485. By removing section 2 on the main loop you will send only the sample data using RS-485.