Reading actual drive state with SimpleMotion V2

From Granite Devices Knowledge Wiki
Jump to: navigation, search

Reading a variable from drive is easily accomplished by using SimpleMotion V2 function smRead1Parameter, smRead2Parameters or smRead3Parameters. Usage is looks like:

//read raw value of current
smint32 readout;
smRead1Parameter(  handle, nodeAddress, SMP_ACTUAL_TORQUE, &readout );

This C++ example shows how to read actual current driven into motor and convert it to amperes.

//read raw value of current
smint32 readout;
smRead1Parameter(  handle, nodeAddress, SMP_ACTUAL_TORQUE, &readout );
//as raw value is integer in "hardware units" scale, convert it to amperes
float actualcurrent;
const float HWcurrentScale=560;//counts/A, this conversion value is for Argon
//current in amps is now in actualcurrent
//TODO, do error checking for all sm commands

It is also possible to read multiple values at one SM command to achieve higher throughput:

//read raw value of current, velocity and position
smint32 torque,position,velocity;
smRead3Parameters(  handle, nodeAddress, SMP_ACTUAL_TORQUE, &torque, 

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.