All Tutorials / Steve G / Setting Servo speeds and Initialization Script Tutorial

Setting Servo speeds and Initialization Script Tutorial

Step 6. UARTInit() Commands.


[/b]Taken form the EZ-Script menu.[/b]

UARTInit( boardIndex, port, baudRate )

Initialize the Peripheral UART on the EZ-B v4 with the specified baud rate. The UART will stay initialized until the EZ-B v4 is power cycled, and therefore this command only needs to be called once.
The Board Index is the EZ-B index starting at 0.
The port can be 0, 1 or 2.
The baud rate can be between 1 and 3750000 bps. The UART receive buffers on the EZ-B v4 are 5,000 bytes.
Look at the UART Port section in the EZ-Script menu for the EZ-B Pin’s associated with each UART Port.
Example: UARTInit(0, 0, 9600 )

When using the UART0 port it always has to be initialized the first time you use it after power up by using the UARTInit() command. Once initialized, you don't have to send that command again untill the next time you power on the EZ-B.

Breakdown of the UARTInit() command.


UARTInit(0, 0, 9600 )

.) In the "UARTInit" command above, the first number is for defining the EZ-B v4's board number (the board number that the EZ-B connects to in the connection control),

.) The second number is for defining the UART port number (on the EZ-B),

.) And the last number is the baud rate, which must match the same baud rate number on the device you are going to use (Roomba, Sabertooth, Kangaroo ect).

There are lots of other reasons to use "Init" scripts, such as using an iRobot Roomba vacuum cleaners with an EZ-B. These require an "Init" script to initialize the controls. There are projects in the EZ-Cloud that use a Roomba Movement Panel which has a built in "Init" button, but it can be written as a script as well. Such an "Init script could look like the following...


#Init script for "Roomba 530".
UARTInit(0, 1, 115200)

Another example for a UARTInit() command, is for the SSC-32 servo controller. There is a dedicated control for the SSC-32 found in EZ-Builder, found by selecting "Project", "Add controls", "Servo", "SSC-32". But if you wish to use a script to control servos connected to the SSC-32, you will need a UARTInit() script first...


#Init script for "SSC-32" that has a choice 
#of baud rate baud rate.


These types of "Init" scripts can be placed in a connection script like has been mentioned previously, or can be put in to a script, and run when needed.