Difference between revisions of "Reading actual drive state with SimpleMotion V2"
From Granite Devices Knowledge Wiki
| [checked revision] | [checked revision] |
(Created page with "This C++ example shows how to read actual current driven into motor. <syntaxhighlight lang="cpp"> smint32 readout; float actualcurrent; //read raw value of current smRead1Pa...") |
|||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | Reading a variable from drive is easily accomplished by using SimpleMotion V2 function smRead1Parameter, smRead2Parameters or smRead3Parameters. Usage is looks like: | |
| − | + | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
| + | //read raw value of current | ||
smint32 readout; | smint32 readout; | ||
| − | + | smRead1Parameter( handle, nodeAddress, SMP_ACTUAL_TORQUE, &readout ); | |
| + | </syntaxhighlight> | ||
| + | This C++ example shows how to read actual current driven into motor and convert it to amperes. | ||
| + | <syntaxhighlight lang="cpp"> | ||
//read raw value of current | //read raw value of current | ||
| + | smint32 readout; | ||
smRead1Parameter( handle, nodeAddress, SMP_ACTUAL_TORQUE, &readout ); | smRead1Parameter( handle, nodeAddress, SMP_ACTUAL_TORQUE, &readout ); | ||
//as raw value is integer in "hardware units" scale, convert it to amperes | //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 | const float HWcurrentScale=560;//counts/A, this conversion value is for Argon | ||
| − | + | actualcurrent=float(smint16(ana2))/HWcurrentScale; | |
| + | //current in amps is now in actualcurrent | ||
| + | |||
| + | //TODO, do error checking for all sm commands | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
| + | It is also possible to read multiple values at one SM command to achieve higher throughput: | ||
| + | <syntaxhighlight lang="cpp"> | ||
| + | //read raw value of current, velocity and position | ||
| + | smint32 torque,position,velocity; | ||
| + | smRead3Parameters( handle, nodeAddress, SMP_ACTUAL_TORQUE, &torque, | ||
| + | SMP_ACTUAL_POSITION_FB, &position, SMP_ACTUAL_VELOCITY_FB, &velocity ); | ||
| + | </syntaxhighlight> | ||
| + | |||
[[category:SimpleMotion]] | [[category:SimpleMotion]] | ||
Latest revision as of 12:03, 9 July 2014
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 actualcurrent=float(smint16(ana2))/HWcurrentScale; //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, SMP_ACTUAL_POSITION_FB, &position, SMP_ACTUAL_VELOCITY_FB, &velocity );