Changing SimpleMotion baud rate

From Granite Devices Knowledge Wiki
Revision as of 15:51, 9 February 2017 by Tero K (Talk | contribs)


Jump to: navigation, search

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:

int pbs=1000000;//new bus baud rate
int slaveSMWatchdogTimeountMs=700;//adjustable in 10ms steps up to 8000 ms
 
//open SM bus with default baud rate
smSetBaudrate(460800);
smhandle=smOpenBus("COM1");
 
//reduce timeout because as following commands are sent to address 0 (broadcast to all devices), they will not return anything, so they will just timeout
smSetTimeout(50);
 
//setup SM bus watchdog feature. when communication is timeouted, motor will be stopped and baudrate is reset to default
smSetParameter(smhandle,0,SMP_FAULT_BEHAVIOR,((slaveSMWatchdogTimeountMs/10)<<8)|1);
 
//change baudrate of all devices on the bus (by giving address 0). it is important to change all devices at once so no communication errors happen due to wrong speed devices on the bus.
smSetParameter(smhandle,0,SMP_BUS_SPEED,pbs);
 
//reset errors that have come from above commands (SM library current version expects response from the commands even when they are broadcasted to address 0, thus it is expected not to give respose)
resetCumulativeStatus(smhandle);
 
//set longer timeout, to make SM bus watchdog activate on error, set this value higher than slaveSMWatchdogTimeountMs
smSetTimeout(1000);
 
//reopen SM bus device with new speed
smCloseBus(smhandle);
smSetBaudrate(pbs);
smhandle=smOpenBus("COM1");
 
//continue using bus at new speed normally.
//keep in mind that new commands must be sent to bus at least with the rate defined by slaveSMWatchdogTimeountMs.
//if any command fails to timeout, or by any other reason timeout occurs, then devices have reset to default speed 
//and reinitialization of the speed is needed.

[category:SimpleMotion]


In no event the Product Information or parts hereof shall be regarded as guarantee of conditions or characteristics. The Product Information or any part thereof may also not be regarded as a warranty of any kind. No liability of any kind shall be assumed by Author with respect to Product Information or any use made by you thereof, nor shall Author indemnify you against or be liable for any third party claims with respect to such information or any use thereof.

As content of this Wiki may be edited by user community, Granite Devices Oy or it's affiliates do not take any responsibility of the contents of this Wiki. Use information at your own risk. However, Granite Devices staff attempts to review all changes made to this Wiki and keep information trustworthy.

Without written consent, Granite Devices' Products or Intellectual Property shall not be used in situations or installations where living beings, material property, or immaterial property could be harmed by the operation, features or failures of Product. Products may only be used in a way where hazards like moving parts, electric shock, laser radiation, or fire can't be realized even if the content of this Wiki would suggest otherwise.