⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pwmgen.9

📁 CNC 的开放码,EMC2 V2.2.8版
💻 9
字号:
.TH PWMGEN "9" "2007-01-16" "EMC Documentation" "HAL Component".de TQ.br.ns.TP \\$1...SH NAMEpwmgen \- software PWM/PDM generation.SH SYNOPSIS\fBloadrt pwmgen output_type=\fItype0\fR[,\fItype1\fR...].SH DESCRIPTION\fBpwmgen\fR is used to generate PWM (pulse width modulation) orPDM (pulse density modulation) signals.  The maximum PWM frequencyand the resolution is quite limited compared to hardware-based approaches, but in many cases software PWM can be very useful.If better performance is needed, a hardware PWM generator is abetter choice..P\fBpwmgen\fR supports a maximum of eight channels.  The number ofchannels actually loaded depends on the number of \fItype\fR valuesgiven.  The value of each \fItype\fR determines the outputs for thatchannel..P.TPtype 0: single outputA single output pin, \fBpwm\fR, whose duty cycle is determined by theinput value for positive inputs, and which is off (or at \fBmin-dc\fR)for negative inputs.  Suitable for single ended circuits..TPtype 1: pwm/directionTwo output pins, \fBpwm\fR and \fBdir\fR.  The duty cycle on \fBpwm\fRvaries as a function of the input value.  \fBdir\fR is low for positiveinputs and high for negative inputs..TPtype 2: up/downTwo output pins, \fBup\fR and \fBdown\fR.  For positive inputs, thePWM/PDM waveform appears on \fBup\fR, while \fBdown\fR is low.  Fornegative inputs, the waveform appears on \fBdown\fR, while \fBup\fRis low.  Suitable for driving the two sides of an H-bridge to generatea bipolar output..SH FUNCTIONS.TP \fBpwmgen.make-pulses \fR(no floating-point)Generates the actual PWM waveforms, using information computed by\fBupdate\fR.  Must be called as frequently as possible, to maximizethe attainable PWM frequency and resolution, and minimize jitter.Operates on all channels at once..TP\fBpwmgen.update \fR(uses floating point)Accepts an input value, performs scaling and limit checks, and convertsit into a form usable by \fBmake-pulses\fR for PWM/PDM generation.  Can(and should) be called less frequently than \fBmake-pulses\fR.  Operateson all channels at once..SH PINS.TP\fBpwmgen.\fIN\fB.enable\fR bit inEnables PWM generator \fIN\fR - when false, all \fBpwmgen.\fIN\fR outputpins are low..TP\fBpwmgen.\fIN\fB.value\fR float inCommanded value.  When \fBvalue\fR = 0.0, duty cycle is 0%, and when\fBvalue\fR = +/-\fBscale\fR, duty cycle is +/- 100%. (Subject to\fBmin-dc\fR and \fBmax-dc\fR limitations.).TP\fBpwmgen.\fIN\fB.pwm\fR bit out (output types 0 and 1 only)PWM/PDM waveform..TP\fBpwmgen.\fIN\fB.dir\fR bit out (output type 1 only)Direction output: low for forward, high for reverse..TP\fBpwmgen.\fIN\fB.up\fR bit out (output type 2 only)PWM/PDM waveform for positive input values, low for negative inputs..TP\fBpwmgen.\fIN\fB.down\fR bit out (output type 2 only)PWM/PDM waveform for negative input values, low for positive inputs..SH PARAMETERS.TP\fBpwmgen.\fIN\fB.curr-dc\fR float roThe current duty cycle, after all scaling and limits have been applied.Range is from -1.0 to +1.0..TP\fBpwmgen.\fIN\fB.max-dc\fR float rwThe maximum duty cycle.  A value of 1.0 corresponds to 100%.  This canbe useful when using transistor drivers with bootstrapped power supplies,since the supply requires some low time to recharge..TP\fBpwmgen.\fIN\fB.min-dc\fR float rwThe minimum duty cycle.  A value of 1.0 corresponds to 100%.  Note thatwhen the pwm generator is disabled, the outputs are constantly low,regardless of the setting of \fBmin-dc\fR..TP\fBpwmgen.\fIN\fB.scale\fR float rw.TQ\fBpwmgen.\fIN\fB.offset\fR float rwThese parameters provide a scale and offset from the \fBvalue\fR pin to theactual duty cycle.  The duty cycle is calculated according to \fIdc =(value/scale) + offset\fR, with 1.0 meaning 100%..TP\fBpwmgen.\fIN\fB.pwm-freq\fR float rwPWM frequency in Hz.  The upper limit is half of the frequency at which\fBmake-pulses\fR is invoked, and values above that limit will be changedto the limit.  If \fBdither-pwm\fR is false, the value will be changed tothe nearest integer submultiple of the \fBmake-pulses\fR frequency.  Avalue of zero produces Pulse Density Modulation instead of Pulse WidthModulation..TP\fBpwmgen.\fIN\fB.dither-pwm\fR bit rwBecause software-generated PWM uses a fairly slow timebase (several to manymicroseconds), it has limited resolution.  For example, if \fBmake-pulses\fRis called at a 20KHz rate, and \fBpwm-freq\fR is 2KHz, there are only 10possible duty cycles.  If \fBdither-pwm\fR is false, the commanded duty cyclewill be rounded to the nearest of those values.  Assuming \fBvalue\fR remainsconstant, the same output will repeat every PWM cycle.  If \fBdither-pwm\fR istrue, the output duty cycle will be dithered between the two closest values,so that the long-term average is closer to the desired level.  \fBdither-pwm\fRhas no effect if \fBpwm-freq\fR is zero (PDM mode), since PDM is an inherentlydithered process.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -