Difference between revisions of "Unit PWM"
Line 427: | Line 427: | ||
! '''Note''' | ! '''Note''' | ||
| To be documented | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''RTL PWM functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysPWMAvailable:Boolean; </pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if a PWM device is available</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysPWMStart:LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start the default PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysPWMStop:LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Stop the default PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysPWMWrite(Value:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write a value to the default PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Value''' | ||
+ | | The value to write | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | The exact meaning of value may depend on the device and other configured options, in many cases the value will represent the "on" time of each pulse with regard to the duty cycle of the waveform output by the device | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysPWMSetMode(Mode:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the mode for the default PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Mode''' | ||
+ | | The mode value to set (eg PWM_MODE_MARKSPACE) | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysPWMSetRange(Range:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the range for the default PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Range''' | ||
+ | | The range value to set | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | The exact meaning of range may depend on the device and other configured options, in many cases the range will represent the period of one full cycle of the waveform output by the device | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysPWMSetFrequency(Frequency:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the clock frequency for the default PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Frequency''' | ||
+ | | The frequency to set in Hz | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysPWMConfigure(DutyNS,PeriodNS:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the configuration of the default PWM device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''DutyNS''' | ||
+ | | The "on" time part of the cycle (Nanoseconds) | ||
+ | |- | ||
+ | ! '''PeriodNS''' | ||
+ | | The duration of one full cycle (Nanoseconds) | ||
+ | |- | ||
+ | ! '''Return''' | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} |
Revision as of 04:09, 2 September 2016
Return to Unit Reference
Contents
[hide]Description
Pulse Width Modulation (PWM) is a technique of encoding a pulsed signal so as to control the ratio of on to off by switching the signal between on and off at a very high rate.
This on and off switching allows control of the average power supplied to the load and therefore gives fine grained control of things such as motor speeds, lamp dimming and heating elements.
PWM is also used in many low power applications as well such as controlling servo motors and can even by used for audio applications such as class D amplifiers.
This unit deals with the usage of PWM for control applications (for audio applications see the Audio unit) and provides methods to control the state, frequency, duty cycle, range and mode of PWM host controllers. Not all devices support all of these concepts so this API includes a properties function to allow obtaining information about a PWM device and its capabilities.
Constants
To be documented
Type definitions
To be documented
Public variables
To be documented
Function declarations
Initialization functions
PWM functions
function PWMDeviceStart(PWM:PPWMDevice):LongWord;
function PWMDeviceStop(PWM:PPWMDevice):LongWord;
function PWMDeviceWrite(PWM:PPWMDevice; Value:LongWord):LongWord;
function PWMDeviceGetGPIO(PWM:PPWMDevice):LongWord;
function PWMDeviceSetGPIO(PWM:PPWMDevice; GPIO:LongWord):LongWord;
function PWMDeviceGetMode(PWM:PPWMDevice):LongWord;
function PWMDeviceSetMode(PWM:PPWMDevice; Mode:LongWord):LongWord;
function PWMDeviceGetRange(PWM:PPWMDevice):LongWord;
function PWMDeviceSetRange(PWM:PPWMDevice; Range:LongWord):LongWord;
function PWMDeviceGetFrequency(PWM:PPWMDevice):LongWord;
function PWMDeviceSetFrequency(PWM:PPWMDevice; Frequency:LongWord):LongWord;
function PWMDeviceGetPolarity(PWM:PPWMDevice):LongWord;
function PWMDeviceSetPolarity(PWM:PPWMDevice; Polarity:LongWord):LongWord;
function PWMDeviceConfigure(PWM:PPWMDevice; DutyNS,PeriodNS:LongWord):LongWord;
function PWMDeviceProperties(PWM:PPWMDevice; Properties:PPWMProperties):LongWord;
function PWMDeviceDestroy(PWM:PPWMDevice):LongWord;
function PWMDeviceRegister(PWM:PPWMDevice):LongWord;
function PWMDeviceDeregister(PWM:PPWMDevice):LongWord;
function PWMDeviceFindByName(const Name:String):PPWMDevice; inline;
function PWMDeviceFindByDescription(const Description:String):PPWMDevice; inline;
function PWMDeviceEnumerate(Callback:TPWMEnumerate; Data:Pointer):LongWord;
function PWMDeviceNotification(PWM:PPWMDevice; Callback:TPWMNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
RTL PWM functions
function SysPWMWrite(Value:LongWord):LongWord;
function SysPWMSetMode(Mode:LongWord):LongWord;
function SysPWMSetRange(Range:LongWord):LongWord;
function SysPWMSetFrequency(Frequency:LongWord):LongWord;
function SysPWMConfigure(DutyNS,PeriodNS:LongWord):LongWord;
Return to Unit Reference