Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Filemotorcontrol.c
Function

ER motor_GetRegister(unsigned short dataAddr, long *value);

Example

The example below is used by modbus to read a specific register

Code Block
languagec#
firstline187
titleExample - motor_GetRegister - modbus.c
linenumberstrue
static long GetMdbRegisterData(UH addr)
{
  long res = 0;
  addr = modbusToMotorRegisters(addr);
  motor_GetRegister(addr, &res);
  return swapLongBytes(res);    //modbus uses MSB on 16bit values.
}


Testing the Motor

The motor can be controlled to target positions by setting the following in the MotorControlStruct passed.

VariableDescription
MotionGenerator

Sets the motion control type.

0 - no motion type
3 - position control
11 - torque control

TargetPos

Set the target position in a position control move.

Example:

TargetPos=1000

will set the target position to 1000 counts. Typically the resolution is 1000 counts/re








long TargetPos; long TargetSpeed; short TargetTorque; unsigned short TargetAcc; unsigned short TargetDec; unsigned char ControlWord; unsigned char MotionGenerator;