Synchronized PWM Child

This MotoHawk™ block references a PWM parent block and drives the output with a square wave with a specified phase offset relative to the parent.

Block ID

motohawk_pwm_child

Library

MotoHawk_lib/Analog I/O Blocks

Description

Input Signals

Duty Cycle (int16)[-4096 (-100%) to 4096 (100%)]

Duty cycle describes the percentage of the period the output should be asserted for. 0% implies the output is not asserted(OFF) whilst 100% implies that the output is asserted for the entire period(ON). The period of assertion is defined by the frequency of excitation of the referenced Parent PWM Output.

H-Bridge outputs use the sign of the duty cycle to convey direction. The absolute value of the duty cycle is taken for PWM Outputs that don't support direction.

Phase (int16)[-4096 (-100%) to 4096 (100%)]

The phase input defines the phase of actuation of this output relative to the referenced parent. A phase offset of 0 will have this output start at the same time as the parent. A positive value will have the assertion point lag the parent by this proportion of the parent's period. Thus a 25% value would see this output assert once 25% of the parent's period had expired. A value of -25% implies the child will lead the parent. -25% == 75%.

A value greater than 100% is clipped to 100% and a value of less than -100% is clipped at zero.

Optional Output Signals

Fault Status (uint8)[0 - OK, 1 - Fault, 2 - Indeterminate]

This optional output port is exposed by the Output Fault Status checkbox, which is only supported for some resources. The port will report the fault status of the resource. It behaves in the same manner as the IO Fault Status block. The fault status is queried each time this block executes.

The behavior of the fault status is dependent upon the capability of the underlying hardware. Some hardware may cache observed faults and report them when next queried whilst other hardware may only be able to report the instantaneous fault status. Often Indeterminate is returned when the hardware is unable to determine the fault status of the output when it was queried. For example, some outputs can only detect open circuit while they are asserted and so may report indeterminate while not asserted.

Load Current (int16)[mA]

When "Output Current" is checked the drive current in milliamps is provided. Support of this port is dependent upon the hardware supporting such functionality

Referencing the Parent PWM Output

Those modules that support calibrated IO will provide two methods to select the parent PWM block. These are by resource and by name. Use the resource when the parent resource is not calibrated. Use the "Vardec Name" when parent resource supports calibration. An update error will result if the resource name is used.

Those modules that don't support calibrated IO won't present a dialog to select the reference method. Here the resource name is referenced.

Limitations

The level of child PWM support is defined by the capability of the hardware. Modules that can't support this capability will not populate resources in the drop down menu. Modules that have capability will have selectable resources. However in some cases the selected child can only be used with a subset of the PWM Outputs that the module has at its disposal. Generally only PWM resources that can operate as a child can be selected to operate as a parent to a child PWM. There can also be further limitations. Build or runtime errors will result (depending on the module type) if a legal child PWM attempts to use an incompatible parent PWM.

The number of children that a parent PWM Output can support may also be limited.

MPC5xx based Modules

The MPC5xx based modules utilize the TPU to implement this behavior. The parent and child must reside on the same TPU bank and can only support a maximum of two child PWMs. Runtime errors will result if an inappropriate configuration is attempted. There are a few common errors to check if the resource is not behaving as expected.

To check the common errors look at the resource creation status in the display(System|Debug|Resources|PWM|"ResourceName").

Error Enum Common Causes
TPU Config Check parent PWM is enabled as parent PWM.
Check parent and child are on same TPU bank.
TPU Primative Usage Use 2 or fewer child PWM per parent PWM.
TPU Primative Count Use 2 or fewer child PWM per parent PWM.
Hardware not Supported Check that resource is on a TPU bank.

MotoCoder Targets

MotoCoder targets will generate build errors if too many children have been associated with a parent or the child resource is not compatible with the selected parent.

Block Parameters

Parameter Field Values Comments/Description
Resource Drop-down list Select from available resources
Parent Reference Type Only visible when is selectable option Select Method for choosing the Parent PWM. Only available for Classic Module Types
  By Resource Enable Drop-down list
By VarDec (Calibration) Name Open Parent Name field
Parent Resource Drop-down list Select the resource of Parent PWM block this child is to use
Parent Reference Name Alpha-numeric text, single-quote enclosed Select the name of Parent PWM. On MotoCoder modules, this is a reference to the 'Name' of the parent definition. On Classic modules, this is the Calibration Name of the parent when Parent Reference Type is set to 'By Vardec'.
Output Current Check box  (enable) When "Output Current" is checked, the drive current in milliamps is provided.
Output Fault Status Check box  (enable) Only visible for supporting modules (Classic Module Types) or when already checked. This option exposes the optional diagnostic output port on the block when checked. Modules that don't support this option expose dignostic information via blocks like Detailed Fault Status or IO Fault Status.

The fault status of the output is queried when the block executes, which will report one of these values:
0 - OK
1 - Fault
2 - Indeterminate

"motohawk_fault_status_enum" is a script that returns a cell array with that enumeration. It can be used in the Enumeration field of a probe to decode the return value of this block.

The behavior of the fault status is dependent upon the capability of the underlying hardware. Some hardware may cache observed faults and report them when next queried whilst other hardware may only be able to report the instantaneous fault status. Often Indeterminate is returned when the hardware is unable to determine the fault status of the output when it was queried. For example, some outputs can only detect open circuit while they are asserted and so may report indeterminate while not asserted.
Allow I/O pin to be calibrated Check box  (enable) Name, Access Levels and Group Strings fields available. This field is only available on Classic modules, see ModuleTypes for help.
Name Alpha-numeric text, single-quote enclosed Name as displayed in the calibration tool. No special characters, such as spaces, dashes, commas (underscore allowed)
Read Access Level 0-8 Sets security level 1 lowest, 4 highest, for user access to read value. A setting of zero indicates unsecured access is allowed.
Write Access Level 0-8 Sets security level 1 lowest, 4 highest, for user access to write value. A setting of zero indicates unsecured access is allowed.
Group String Alpha-numeric text, single-quote enclosed Determines Folder name and hierarchy. Use "|" character between folder names to delineate subfolder structure