Editing Changing SimpleMotion baud rate
Your changes will be displayed to readers once an authorized user accepts them. (help) |
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | RS485 based [[SimpleMotion V2]] bus supports changing baud rate on the fly from the default 460800 | + | RS485 based [[SimpleMotion V2]] bus supports changing baud rate on the fly from the default 460800 PBS. The procedure in simplest form is done by writing new baudrate value into parameter SMP_BUS_SPEED, and after that closing and re-opening the bus with the same speed. |
However, in addition it is recommended to setup watchdog feature that will reset bus baudrate to default in case of connection is lost and timeouted. Example: | However, in addition it is recommended to setup watchdog feature that will reset bus baudrate to default in case of connection is lost and timeouted. Example: | ||
Line 94: | Line 94: | ||
} | } | ||
− | // | + | //your SimpleMotion application |
int main() | int main() | ||
{ | { | ||
− | smSetDebugOutput(SMDebugMid,stderr); | + | /*in your SM application, the code might follow this kind pattern: */ |
+ | smSetDebugOutput(SMDebugMid,stderr); | ||
− | |||
if( OpenBusWithCustomBaudrate() == smfalse ) | if( OpenBusWithCustomBaudrate() == smfalse ) | ||
{ | { | ||
Line 107: | Line 107: | ||
} | } | ||
− | |||
while(1) | while(1) | ||
{ | { | ||
+ | //do some communication. in this demo we just read SMP_DEVICE_TYPE and check if errors occur: | ||
+ | |||
smint32 deviceType; | smint32 deviceType; | ||
int slaveAddress=enter some address here; | int slaveAddress=enter some address here; | ||
Line 143: | Line 144: | ||
*Newly set baud rate will stay active only when device stays on (logic voltage on and drive not restarted). Baud rate will always reset to default 460800 BPS if device is powered off/on. | *Newly set baud rate will stay active only when device stays on (logic voltage on and drive not restarted). Baud rate will always reset to default 460800 BPS if device is powered off/on. | ||
*If you setup the SimpleMotion watchdog has been set, then baud rate will also reset to default also if connection is lost for certain period of time. This is useful ensuring that you can re-connect again to the device with default baud rate and then re-do the baud date change procedure. | *If you setup the SimpleMotion watchdog has been set, then baud rate will also reset to default also if connection is lost for certain period of time. This is useful ensuring that you can re-connect again to the device with default baud rate and then re-do the baud date change procedure. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− |