| ApossC SDK V01.15

Functions
SDK_Miscellaneous_IO.mc File Reference

Functions with IO samples. More...

`#include <SysDef.mh>`
`#include "SDK_Miscellaneous_IO.mh"`

Go to the source code of this file.

## Functions
long | sdkSetupPwmGenerator_UserParamMode (long userParam, long digOutPWM, long frequency, long cycleRange, long polarity)
| Setting up a PWM output with a user parameter as input source. More...
long | sdkSetupPwmGenerator_AxisModeVel (long axisNo, long digOutEnable, long digOutPWM, long frequency, long cycleRange, long polarity)
| Setting up a PWM output with a virtual amplifier as input source. More...
long | sdkScaleAnalogInput (long analogInputNo, long minVoltage, long maxVoltage, long offsetVoltage, long minValue, long maxValue)
| Scaling of an analog input with user units. More...

## Detailed Description

Functions with IO samples.

Revision
  183

Definition in file SDK_Miscellaneous_IO.mc.

## Function Documentation

## ◆ sdkScaleAnalogInput()

long sdkScaleAnalogInput | ( | long | analogInputNo,
|  | long | minVoltage,
|  | long | maxVoltage,
|  | long | offsetVoltage,
|  | long | minValue,
|  | long | maxValue
| ) |  |

Scaling of an analog input with user units.

This function scales an analog input signal to user specific user units. Additionally, an offset of the analog input signal can be specified.

Parameters

  analogInputNo | Analog input number(0-xx zero based)
  minVoltage | Minimum input voltage (mV)
  maxVoltage | Maximum input voltage (mV)
  offsetVoltage | Voltage offest, for example, if the voltage range is 0 to 4 V, 2 V should be interpreted as 0 (mV)
  minValue | Scaling value minimum value to be used in the program (Uu)
  maxValue | Scaling value maximal value to be used in the program (Uu)

Returns
  value: Always 1 in this function
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Examples
  PWM_1Ax_ESCON.mc.

Definition at line 127 of file SDK_Miscellaneous_IO.mc.

128 {
129 double scale;
130
131 // Scale the maximal and minimal voltage to internal value
132 maxVoltage = ((double)0x8000/10000)* maxVoltage;
133 minVoltage = ((double)0x8000/10000)* minVoltage;
134
135 // Scale
136 scale = ((double)maxValue-(double)minValue)/ ((double)maxVoltage-(double)minVoltage);
137 if((long)scale>1)
138 {
139 VIRTANIN_PARAM(analogInputNo,VIRTANIN_UUFACT_UNITNO)=1000;
140 VIRTANIN_PARAM(analogInputNo,VIRTANIN_UUFACT_DIGNO)=(long)(scale*1000);
141 }
142 else
143 {
144 VIRTANIN_PARAM(analogInputNo,VIRTANIN_UUFACT_UNITNO)=(long)(scale*1000);
145 VIRTANIN_PARAM(analogInputNo,VIRTANIN_UUFACT_DIGNO)=1000;
146 }
147
148 // Offset
149 offsetVoltage = -((double)0x8000/10000)* offsetVoltage;
150 HWANIN_PARAM(analogInputNo,HWANIN_OFFSET)=offsetVoltage;
151
152 print("sdkScaleAnalogInput: ", analogInputNo);
153 return(1);
154 }

## ◆ sdkSetupPwmGenerator_AxisModeVel()

long sdkSetupPwmGenerator_AxisModeVel | ( | long | axisNo,
|  | long | digOutEnable,
|  | long | digOutPWM,
|  | long | frequency,
|  | long | cycleRange,
|  | long | polarity
| ) |  |

Setting up a PWM output with a virtual amplifier as input source.

This function sets all important parameters for the use of a PWM output. As input a virtual amplifier is used, where the input source is interpreted as signed 16bit value. Afterwards, standard ApossC move commands such as AxisCvelStart() can be used. A feedback is not implemented with this function. Not all MACS controllers support PWM signals.

Parameters

  axisNo | Axis module number digOutEnable Enable output number which is automatically set when an axis drive command is started (0-xx zero based)
  digOutPWM | Digital output number for the PWM (0-xx zero based)
  frequency | Frequency of the PWM output (default 1000)
  cycleRange | Duty cycle range A value of 90% means a duty cycle range of 5-95 (default 90)
  polarity | Polarity of the reference signal (default 0) 0 HWPWMGEN_POLARITY_POSITIVE: Output Signal is not inverted 1 HWPWMGEN_POLARITY_NEGATIVE: Output Signal is inverted

Returns
  value: Always 1 in this function
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Examples
  PWM_1Ax_ESCON.mc.

Definition at line 74 of file SDK_Miscellaneous_IO.mc.

75 {
76 // To enable PWM generation, the HW Digital Output has to be switched to this mode
77 HWDIGOUT_PARAM(0,HWDIGOUT_PISRC_BIT1+digOutPWM) = 0x400;
78
79 // Input value is an unsigned 16bit value
80 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_MODE) = HWPWMGEN_MODE_SIGNED;
81
82 // Polarity of the reference signal
83 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_POLARITY) = polarity;
84
85 // Frequency of the PWM output
86 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_FREQUENCY) = frequency;
87
88 // Duty cycle range and source
89 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_DUTYCYCLE_RANGE) = cycleRange;
90 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_PISRC_DUTYCYCLE) = VIRTAMP_PROCESS_SRCINDEX(axisNo,PO_VIRTAMP_REFVEL);
91
92 // Set up the virtual amplifer for axis command
93 // Resolution +/- 0x8000 (signed 16 bit value)
94 VIRTAMP_PARAM(axisNo,VIRTAMP_REF100PERC) = 0x8000;
95 // Automatic setting of the enable output
96 VIRTAMP_PARAM(axisNo,VIRTAMP_REFOUTP) = digOutEnable+1;
97 VIRTAMP_PARAM(axisNo,VIRTAMP_REFOUTN) = digOutEnable+1;
98
99 // Because no feedback is processed, the tracking error must be switched off.
100 AXE_PARAM(axisNo,POSERR) = 0x7FFFFFF;
101
102 // Position controller is bypassed, the set speed is transferred directly
103 AXE_PARAM(axisNo,KPROP) = 0;
104 AXE_PARAM(axisNo,KDER) = 0;
105 AXE_PARAM(axisNo,KINT) = 0;
106 AXE_PARAM(axisNo,FFVEL) = 1000;
107
108 print("sdkSetupPwmGenerator_AxisModeVel:");
109 return(1);
110 }

## ◆ sdkSetupPwmGenerator_UserParamMode()

long sdkSetupPwmGenerator_UserParamMode | ( | long | userParam,
|  | long | digOutPWM,
|  | long | frequency,
|  | long | cycleRange,
|  | long | polarity
| ) |  |

Setting up a PWM output with a user parameter as input source.

This function sets all important parameters for the use of a PWM output. As input a UserParameter is used, where the input source is interpreted as unsigned 16bit value. Not all MACS controllers support PWM signals.

Parameters

  userParam | User parameter number 1-100 which sets the PWM Input value is an unsigned 16bit value
  digOutPWM | Digital output number for the PWM (0-xx zero based)
  frequency | Frequency of the PWM output (default 1000)
  cycleRange | Duty cycle range A value of 90% means a duty cycle range of 5-95 (default 90)
  polarity | Polarity of the reference signal (default 0) 0 HWPWMGEN_POLARITY_POSITIVE: Output Signal is not inverted 1 HWPWMGEN_POLARITY_NEGATIVE: Output Signal is inverted

Returns
  value: Always 1 in this function
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Examples
  PWM_1Ax_ESCON.mc.

Definition at line 33 of file SDK_Miscellaneous_IO.mc.

34 {
35 // To enable PWM generation, the HW Digital Output has to be switched to this mode
36 HWDIGOUT_PARAM(0,HWDIGOUT_PISRC_BIT1+digOutPWM) = 0x400;
37
38 // Input value is an unsigned 16bit value
39 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_MODE) = HWPWMGEN_MODE_UNSIGNED;
40
41 // Polarity of the reference signal
42 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_POLARITY) = polarity;
43
44 // Frequency of the PWM output
45 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_FREQUENCY) = frequency;
46
47 // Duty cycle range and source
48 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_DUTYCYCLE_RANGE) = cycleRange;
49 HWPWMGEN_PARAM(digOutPWM,HWPWMGEN_PISRC_DUTYCYCLE) = USER_PARAM_SRCINDEX(userParam);
50
51 print("sdkSetupPwmGenerator_UserParamMode:");
52 return(1);
53 }
HWANIN_PARAM
#define HWANIN_PARAM(modno, parno)
HW Analog Input Parameters: Setter.
Definition: SdoDictionary.mh:10540
VIRTANIN_UUFACT_DIGNO
#define VIRTANIN_UUFACT_DIGNO
Scale factor.
Definition: SdoDictionary.mh:5728
VIRTAMP_PROCESS_SRCINDEX
#define VIRTAMP_PROCESS_SRCINDEX(modno, parno)
Virtual Amplifier Process Data: Source Index.
Definition: SdoDictionary.mh:6404
HWANIN_OFFSET
#define HWANIN_OFFSET
Offset which will be added to the output value.
Definition: SdoDictionary.mh:10558
VIRTAMP_REFOUTN
#define VIRTAMP_REFOUTN
Number of output which must be set if reference is negative (reset if positive)
Definition: SdoDictionary.mh:5435
HWPWMGEN_POLARITY
#define HWPWMGEN_POLARITY
Polarity of the reference signal.
Definition: SdoDictionary.mh:9461
HWDIGOUT_PARAM
#define HWDIGOUT_PARAM(modno, parno)
HW Digital Output Parameters: Setter.
Definition: SdoDictionary.mh:10338
USER_PARAM_SRCINDEX
#define USER_PARAM_SRCINDEX(parno)
User Parameters: Source Index.
Definition: SdoDictionary.mh:239
KDER
#define KDER
Derivative Factor for PID position control loop.
Definition: SdoDictionary.mh:2413
VIRTAMP_REF100PERC
#define VIRTAMP_REF100PERC
Output reference value to use at 100 percent.
Definition: SdoDictionary.mh:5442
HWPWMGEN_FREQUENCY
#define HWPWMGEN_FREQUENCY
Frequency of the PWM output.
Definition: SdoDictionary.mh:9472
POSERR
#define POSERR
Maximum tolerated position error.
Definition: SdoDictionary.mh:2444
PO_VIRTAMP_REFVEL
#define PO_VIRTAMP_REFVEL
Output reference velocity.
Definition: SdoDictionary.mh:6438
HWDIGOUT_PISRC_BIT1
#define HWDIGOUT_PISRC_BIT1
Source for input signal.
Definition: SdoDictionary.mh:10426
VIRTAMP_PARAM
#define VIRTAMP_PARAM(modno, parno)
Virtual Amplifier Parameters: Setter.
Definition: SdoDictionary.mh:5280
HWPWMGEN_PISRC_DUTYCYCLE
#define HWPWMGEN_PISRC_DUTYCYCLE
Source for pwm duty cycle.
Definition: SdoDictionary.mh:9494
VIRTAMP_REFOUTP
#define VIRTAMP_REFOUTP
Digital output for positive direction signal.
Definition: SdoDictionary.mh:5425
HWPWMGEN_PARAM
#define HWPWMGEN_PARAM(modno, parno)
HW PWM Generator Parameters: Setter.
Definition: SdoDictionary.mh:9439
HWPWMGEN_MODE_UNSIGNED
#define HWPWMGEN_MODE_UNSIGNED
Definition: SdoDictionary.mh:9499
VIRTANIN_UUFACT_UNITNO
#define VIRTANIN_UUFACT_UNITNO
Scale factor.
Definition: SdoDictionary.mh:5720
AXE_PARAM
#define AXE_PARAM(modno, parno)
Axis Parameters: Setter.
Definition: SdoDictionary.mh:2293
VIRTANIN_PARAM
#define VIRTANIN_PARAM(modno, parno)
Virtual Analog Input Parameters: Setter.
Definition: SdoDictionary.mh:5700
HWPWMGEN_DUTYCYCLE_RANGE
#define HWPWMGEN_DUTYCYCLE_RANGE
Duty cycle range.
Definition: SdoDictionary.mh:9484
HWPWMGEN_MODE_SIGNED
#define HWPWMGEN_MODE_SIGNED
Definition: SdoDictionary.mh:9498
HWPWMGEN_MODE
#define HWPWMGEN_MODE
Mode.
Definition: SdoDictionary.mh:9450
FFVEL
#define FFVEL
Velocity Feed forward.
Definition: SdoDictionary.mh:2644
KPROP
#define KPROP
Proportional value for PID position control loop.
Definition: SdoDictionary.mh:2404
KINT
#define KINT
Integral value for PID position control loop.
Definition: SdoDictionary.mh:2422

Data Sheets | Released Software | Software Manuals | Hardware Manuals | Maxon Shop

Maxon Support Center