| ApossC SDK V01.15

SDK_Miscellaneous_IO.mc
Go to the documentation of this file.
1
9 #pragma once
10
11 #include <SysDef.mh>
12 #include "SDK_Miscellaneous_IO.mh"
13
14
33 long sdkSetupPwmGenerator_UserParamMode(long userParam, long digOutPWM,long frequency, long cycleRange, long polarity)
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 }
54
74 long sdkSetupPwmGenerator_AxisModeVel(long axisNo, long digOutEnable, long digOutPWM, long frequency, long cycleRange, long polarity)
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 }
111
127 long sdkScaleAnalogInput(long analogInputNo, long minVoltage, long maxVoltage,long offsetVoltage, long minValue, long maxValue)
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 }
155
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
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.
Definition: SDK_Miscellaneous_IO.mc:33
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
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.
Definition: SDK_Miscellaneous_IO.mc:74
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
SDK_Miscellaneous_IO.mh
Declaration of the IO functions.
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
sdkScaleAnalogInput
long sdkScaleAnalogInput(long analogInputNo, long minVoltage, long maxVoltage, long offsetVoltage, long minValue, long maxValue)
Scaling of an analog input with user units.
Definition: SDK_Miscellaneous_IO.mc:127
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