Difference between revisions of "Unit PWM"

From Ultibo.org
Jump to: navigation, search
Line 341: Line 341:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 353: Line 353:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 365: Line 365:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 377: Line 377:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 389: Line 389:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 401: Line 401:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 413: Line 413:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 425: Line 425:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 440: Line 440:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 563: Line 563:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 575: Line 575:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 587: Line 587:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 599: Line 599:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 611: Line 611:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 623: Line 623:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 635: Line 635:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 647: Line 647:
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}

Revision as of 05:42, 27 September 2016

Return to Unit Reference


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

[Expand]
procedure PWMInit;
Description: Initialize the PWM unit and PWM device table


PWM functions

[Expand]
function PWMDeviceStart(PWM:PPWMDevice):LongWord;
Description: Start the specified PWM device


[Expand]
function PWMDeviceStop(PWM:PPWMDevice):LongWord;
Description: Stop the specified PWM device


[Expand]
function PWMDeviceWrite(PWM:PPWMDevice; Value:LongWord):LongWord; 
Description: Write a value to the specified PWM device


[Expand]
function PWMDeviceGetGPIO(PWM:PPWMDevice):LongWord;
Description: Get the GPIO pin used by the specified PWM device


[Expand]
function PWMDeviceSetGPIO(PWM:PPWMDevice; GPIO:LongWord):LongWord;
Description: Set the GPIO pin used by the specified PWM device


[Expand]
function PWMDeviceGetMode(PWM:PPWMDevice):LongWord;
Description: Get the current mode of the specified PWM device


[Expand]
function PWMDeviceSetMode(PWM:PPWMDevice; Mode:LongWord):LongWord;
Description: Set the current mode for the specified PWM device


[Expand]
function PWMDeviceGetRange(PWM:PPWMDevice):LongWord;
Description: Get the current range of the specified PWM device


[Expand]
function PWMDeviceSetRange(PWM:PPWMDevice; Range:LongWord):LongWord;
Description: Set the current range for the specified PWM device


[Expand]
function PWMDeviceGetFrequency(PWM:PPWMDevice):LongWord;
Description: Get the clock frequency of the specified PWM device


[Expand]
function PWMDeviceSetFrequency(PWM:PPWMDevice; Frequency:LongWord):LongWord;
Description: Set the clock frequency for the specified PWM device


[Expand]
function PWMDeviceGetPolarity(PWM:PPWMDevice):LongWord;
Description: Get the current polarity of the specified PWM device


[Expand]
function PWMDeviceSetPolarity(PWM:PPWMDevice; Polarity:LongWord):LongWord;
Description: Set the current polarity for the specified PWM device


[Expand]
function PWMDeviceConfigure(PWM:PPWMDevice; DutyNS,PeriodNS:LongWord):LongWord;
Description: Set the configuration of the specified PWM device


[Expand]
function PWMDeviceProperties(PWM:PPWMDevice; Properties:PPWMProperties):LongWord;
Description: Get the properties for the specified PWM device


[Expand]
function PWMDeviceCreate:PPWMDevice;
Description: Create a new PWM entry


[Expand]
function PWMDeviceCreateEx(Size:LongWord):PPWMDevice;
Description: Create a new PWM entry


[Expand]
function PWMDeviceDestroy(PWM:PPWMDevice):LongWord;
Description: Destroy an existing PWM entry


[Expand]
function PWMDeviceRegister(PWM:PPWMDevice):LongWord;
Description: Register a new PWM in the PWM table


[Expand]
function PWMDeviceDeregister(PWM:PPWMDevice):LongWord;
Description: Deregister a PWM from the PWM table


[Expand]
function PWMDeviceFind(PWMId:LongWord):PPWMDevice;
Description: To be documented


[Expand]
function PWMDeviceFindByName(const Name:String):PPWMDevice; inline;
Description: To be documented


[Expand]
function PWMDeviceFindByDescription(const Description:String):PPWMDevice; inline;
Description: To be documented


[Expand]
function PWMDeviceEnumerate(Callback:TPWMEnumerate; Data:Pointer):LongWord;
Description: To be documented


[Expand]
function PWMDeviceNotification(PWM:PPWMDevice; Callback:TPWMNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented


RTL PWM functions

[Expand]
function SysPWMAvailable:Boolean; 
Description: Check if a PWM device is available


[Expand]
function SysPWMStart:LongWord;
Description: Start the default PWM device


[Expand]
function SysPWMStop:LongWord;
Description: Stop the default PWM device


[Expand]
function SysPWMWrite(Value:LongWord):LongWord;
Description: Write a value to the default PWM device


[Expand]
function SysPWMSetMode(Mode:LongWord):LongWord;
Description: Set the mode for the default PWM device


[Expand]
function SysPWMSetRange(Range:LongWord):LongWord;
Description: Set the range for the default PWM device


[Expand]
function SysPWMSetFrequency(Frequency:LongWord):LongWord;
Description: Set the clock frequency for the default PWM device


[Expand]
function SysPWMConfigure(DutyNS,PeriodNS:LongWord):LongWord;
Description: Set the configuration of the default PWM device


PWM helper functions

[Expand]
function PWMGetCount:LongWord; inline;
Description: Get the current PWM count


[Expand]
function PWMDeviceGetDefault:PPWMDevice; inline;
Description: Get the current default PWM device


[Expand]
function PWMDeviceSetDefault(PWM:PPWMDevice):LongWord;
Description: Set the current default PWM device


[Expand]
function PWMDeviceCheck(PWM:PPWMDevice):PPWMDevice;
Description: Check if the supplied PWM is in the PWM table


[Expand]
procedure PWMLog(Level:LongWord; PWM:PPWMDevice; const AText:String);
Description: To be documented


[Expand]
procedure PWMLogInfo(PWM:PPWMDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure PWMLogError(PWM:PPWMDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure PWMLogDebug(PWM:PPWMDevice; const AText:String); inline;
Description: To be documented


Return to Unit Reference