Applicable Model(s)

HMC2000
HMC3000
HMC4000
HMC7000
MLC Series

Title

Pulse Width Modulation

Date

01/25/2023

Rev

04

P/N

0907-7009

Summary

Maple Systems HMC and MLC products are capable of producing four types of Pulse Width Modulation (PWM) signals when using specific output modules. This document describes each of the four types of PWM output, and then lists which registers to configure, how to configure those registers, and the minimum and maximum ranges of each register. Review the module specification sheets to ensure PWM is available.


Solution

There are four types of Pulse Width Modulation (PWM) signals available as outputs for the HMC3000, HMC7000, HMC2000, and HMC4000 Series, as well as the MLC Series: Normal, CW/CCW, Pulse/Direction, and Trapezoidal (Fixed Pulse). In Normal mode, both Channel 1 and Channel 2 can be enabled to output. They may have different Duty Cycles but have to have the same frequency. CW/CCW mode can only be configured for Channel 1, but a positive frequency turns on Channel 1 and a negative frequency turns on Channel 2. Pulse/Direction mode can only be configured for Channel 1, but a positive frequency sets Channel 2 low and a negative frequency sets Channel 2 high. Trapezoidal (Fixed Pulse) mode can only be set for Channel 1, Channel 2 is not useable in this mode.

When using PWM outputs, different product lines have different maximum frequencies ranging from 1 kHz to 200 kHz. To find more information about a specific product, please see the I/O Module Guide for that product series.

For further information and training on PWM, please reference these tutorials found on the Maple Systems website under support:

How to use PWM

Using PWM with DC Motor

NOTE: In the following waveforms, Channel 1 is yellow, and Channel 2 is blue.

Normal: The frequency must be the same for channel 1 and channel 2, but the Duty Cycle is independently adjustable for each channel. Duty Cycle can be adjusted while the output is running. The valid range is 0 to 100%, but the effective range will vary depending on the device being controlled. The output must be shut off to adjust the frequency. The Channel 1 and Channel 2 outputs can be enabled and disabled independently.

CW/CCW: When the frequency is positive, the output signal is generated on Channel 1, and Channel 2 is not used. When the frequency value is negative, the output signal is generated on Channel 2, and Channel 1 is not used. The frequency can be adjusted while running, and the Duty Cycle is fixed at 50%.

Pulse/Direction: The output signal is generated on Channel 1. If the frequency value is positive, Channel 2 is held low. If the frequency value is negative, Channel 2 is held high. The frequency can be adjusted while running, and the Duty Cycle is fixed at 50%.

Trapezoidal (Fixed Pulse): The output signal is generated on Channel 1. The frequency ramps up from the minimum frequency to the maximum frequency in the interval specified by acceleration time. The output signal is generated until the specified number of pulses has been sent. As the number of pulses approaches the specified count, the frequency ramps down from the maximum frequency to the minimum frequency in the interval specified by deceleration time. When the specified number of pulses is reached, the output signal stops but remains enabled. The Duty Cycle is fixed at 50%.

Configuring the HMC3000, HMC2000, and HMC4000 Series PWMs

The HMC3000, HMC2000, and HMC4000 series I/O modules have PWM functionality built in, with specific registers and bits predefined for setup and control. For the register addresses listed below, nn stands for which slot the module was installed (slot 1 is 01, slot 2 02, etc.).

For each of the modes and registers listed below, first configure the PWM output using the configuration register for that channel and mode. Then, set the parameter values and define a way to monitor the error flags. Finally, enable the output by setting the Enable Output bit for that channel.

Normal:

FunctionRegister AddressDescription
Output, PWM PulseY0 (Channel 1)Y1 (Channel 2)Physical Output
ConfigurationMWnn24MWnn30Set to 1 for Normal mode
Frequency SettingMWnn25MWnn31Range is 1 to 200,000 or 200kHz
ON Duty Cycle SettingMWnn27MWnn33Range is 0 to 100
Enable Output FlagMnn576Mnn577Output enabled when ON
ON Duty Error FlagMnn466Mnn471ON with an error, resets automatically
Frequency Setting Error FlagMnn467Mnn472ON with an error, resets automatically

CW/CWW:

FunctionRegister AddressDescription
Output, PWM PulseY0 (Channel 1)Y1 (Channel 2)Physical Output
ConfigurationMWnn24MWnn30Set to 3 for CW/CCW mode
Frequency SettingMWnn25MWnn31Range is -10,000 to -1 and 1 to 10,000
Enable Output FlagMnn576Mnn577Output enabled when ON
Frequency Setting Error FlagMnn467Mnn472ON with an error, resets automatically

Pulse/Direction:

FunctionRegister AddressDescription
Output, PWM PulseY0 (Channel 1)Y1 (Channel 2)Physical Output
ConfigurationMWnn24MWnn30Set to 7 for Pulse/Direction mode
Frequency SettingMWnn25MWnn31Range is -100,000 to -1 and 1 to 100,000
Enable Output FlagMnn576Mnn577Output enabled when ON
Frequency Setting Error FlagMnn467Mnn472ON with an error, resets automatically

Fixed Pulse:

FunctionRegister AddressDescription
Output, PWM PulseY0 (Channel 1)Y1 (Channel 2)Physical Output
ConfigurationMWnn24MWnn30Set to 9 for Fixed Pulse mode
Minimum FrequencyMWnn25MWnn31Range is 1 to 100,000
Maximum FrequencyMWnn27MWnn33Range is 1 to 100,000
Acceleration TimeMWnn37MWnn38Range is 0 to 65535
Deceleration TimeMWnn39MWnn40Range is 0 to 35536
Total PulsesMWnn41MWnn430 to 4,294,967,295
Elapsed PulsesMWnn45MWnn470 to 4,294,967,295
Enable Output FlagMnn576Mnn577Output enabled when ON
Frequency Setting Error FlagMnn467Mnn472ON with an error, resets automatically
Acceleration Time Error FlagMnn468Mnn473ON with an error
Deceleration Time Error FlagMnn469Mnn474ON with an error
Total Pulses Setting Error FlagMnn470Mnn475ON with an error
Total Pulses ReachedMnn784Mnn785ON when Total Pulses are sent

Configuring the HMC7000 Series PWMs

The HMC7000 series I/O modules that have PWM functionality have specific registers and bits predefined for setup and control. For the register addresses listed below, nn stands for which slot the module was installed (slot 1 is 01, slot 2 02, etc.). Any N/As are due to Channel 2 not supporting the Fixed Pulse, CW/CCW, or Pulse DIR modes.

For each of the modes and registers listed below, first configure the PWM output using the configuration register for that channel and mode. Then, set the parameter values and define a way to monitor the error flags. Finally, enable the output by setting the Enable Output bit for that channel.

Normal:

FunctionRegister AddressDescription
Output, PWM PulseY2 (Channel 1)Y4 (Channel 2)Physical Output
ConfigurationMWnn24MWnn30Set to 1 for Normal mode
Frequency SettingMWnn25
MWnn26
MWnn25
MWnn26
Range is 1 to 10,000 or 10 kHz
ON Duty Cycle SettingMWnn27
MWnn28
MWnn31
MWnn32
Range is 0 to 100
Enable Output FlagMWnn36_0MWnn36_1Output enabled when ON
ON Duty Error FlagMWnn29_2MWnn29_7ON with an error, resets automatically
Frequency Setting Error FlagMWnn29_3MWnn29_3ON with an error, resets automatically

CW/CCW:

FunctionRegister AddressDescription
Output, PWM PulseY2 (Channel 1)Y4 (Channel 2)Physical Output
ConfigurationMWnn24MWnn24Set to 3 for CW/CCW mode
Frequency SettingMWnn25
MWnn26
MWnn25
MWnn26
Range is -10,000 to -1 and 1 to 10,000
Enable Output FlagMWnn36_0MWnn36_0Output enabled when ON
Frequency Setting Error FlagMWnn29_3MWnn29_3ON with an error, resets automatically

Pulse/Direction:

FunctionRegister AddressDescription
Output, PWM PulseY2 (Channel 1)Y4 (Channel 2)Physical Output
ConfigurationMWnn24MWnn24Set to 7 for Pulse/Direction mode
Frequency SettingMWnn25
MWnn26
MWnn25
MWnn26
Range is -10,000 to -1 and 1 to 10,000
Enable Output FlagMWnn36_0MWnn36_0Output enabled when ON
Frequency Setting Error FlagMWnn29_3MWnn29_3ON with an error, resets automatically

Fixed Pulse:

FunctionRegister AddressDescription
Output, PWM PulseY2 (Channel 1)N/APhysical Output
ConfigurationMWnn24N/ASet to 9 for Fixed Pulse mode
Minimum FrequencyMWnn25
MWnn26
N/ARange is 1 to 10,000
Maximum FrequencyMWnn27
MWnn28
N/ARange is 1 to 10,000
Acceleration TimeMWnn37N/ARange is 0 to 32767
Deceleration TimeMWnn39N/ARange is 0 to 32767
Total PulsesMWnn41
MWnn42
N/A0 to 2,147,483,647
Elapsed PulsesMWnn45
MWnn46
N/A0 to 2,147,483,647
Enable Output FlagMWnn36_0N/AOutput enabled when ON
Frequency Setting Error FlagMWnn29_3N/AON with an error, resets automatically
Acceleration Time Error FlagMWnn29_4N/AON with an error
Deceleration Time Error FlagMWnn29_5N/AON with an error
Total Pulses Setting Error FlagMWnn29_6N/AON with an error
Total Pulses ReachedMWnn49_0N/AON when Total Pulses are sent

Configuring the MLC Series PWMs

The MLC Base modules and I/O Expansion modules both work in a similar fashion, but use different registers, so first is listed the Base module registers, then the I/O Expansion module registers. For the I/O Expansion module register addresses listed below, nn stands for which slot the module was installed (slot 1 is 01, slot 2 02, etc.). Any N/As are due to Channel 2 not supporting the Fixed Pulse, CW/CCW, or Pulse DIR modes.

For each of the modes and registers listed below, first configure the PWM output using the configuration register for that channel and mode. Then, set the parameter values and define a way to monitor the error flags. Finally, enable the output by setting the Enable Output bit for that channel.

MLC Base Module Registers:

FunctionChannel 1Channel 2
Output PinY0Y1
Enable BitM816M832
ON Duty Setting ErrorM818M834
Frequency Setting ErrorM819M835
Acceleration Time Setting ErrorM820M836
Deceleration Time Setting ErrorM821M837
No. of Total Pulse Setting ErrorM822M838
End of Total PulsesM823M839
Configuration RegisterMW59MW75
Frequency of Min Frequency Register (LSW, MSW)MW60, MW61MW76, MW77
Duty Cycle or Max Frequency Register (LSW, MSW)MW62, MW63MW78, MW79
Acceleration Time Setting RegisterMW64MW80
Deceleration Time Setting RegisterMW65MW81
Total Pulses Setting RegisterMW66, MW67MW82, MW83
Elapsed Value RegisterMW68, MW69MW84, MW85

MLC I/O Expansion Module Registers:

FunctionChannel 1Channel 2
Output PinYnn002Ynn004
Enable BitMnn016Mnn018
Direction FlagMnn017N/A
Configuration RegisterMWnn00MWnn26
Frequency or Min Frequency Register (LSW, MSW)MWnn02, MWnn03N/A
Duty Cycle or Max Frequency Register (LSW, MSW)MWnn04, MWnn05MWnn26, MWnn27
Acceleration Time Setting RegisterMWnn06N/A
Deceleration Time Setting RegisterMWnn07N/A
Total Pulses Setting RegisterMWnn08, MWnn09N/A

Register and Bit Definitions, Settings, and Ranges:

Register/BitDescriptionCPU Base Unit SettingI/O Expansion Setting
Configuration Register16-bit register that sets the mode being used by the PWM.0: Not defined
1: Normal (Fixed Frequency)
2: Norman (Variable Frequency)
3: CW/CCW (Fixed Frequency)
4: CW/CCW (Variable Frequency)
7: Pulse/Dir (Fixed Frequency)
8: Pulse/Dir (Variable Frequency)
9: Fixed Pulse
0: Not defined
1: Normal (Fixed Frequency)
3: CW/CCW (Variable Frequency)
7: Pulse/Dir (Variable Frequency)
9: Fixed Pulse
Frequency Setting or Min Frequency Register32-bit register that sets the Frequency (in Normal, CW/CCW, and Pulse/Dir) or the Min Frequency (Fixed Pulse).Range:
MLC1-F Models: 1 to 100,000 for Normal or Fixed Pulse modes. -100,000 to -1 or 1 to 100,000 for CW/CCW or Pulse/Dir modes. MLC1-E & MLC2-E Models: 1 to 200,000 for Normal or Fixed Pulse modes. -200,000 to -1 or 1 to 200,000 for CW/CCW or Pulse/Dir modes.
Range:
1 to 10,000 for Normal or Fixed Pulse modes. -10,000 to -1 or 1 to 10,000 for CW/CCW or Pulse/Dir modes.
Duty Cycle or Max Frequency Register32-bit register that defines the Duty Cycle (Normal), or Max Frequency (Fixed Pulse).Range:
1 to 100 for Normal mode. 1 to 100,000 for Fixed Pulse mode.
Range:
1 to 100 for Normal mode. 1 to 100,000 for Fixed Pulse mode.
Acceleration Time16-bit register that determines acceleration time in Fixed Pulse mode.Range:
0 to 65535 (in 10ms)
Range:
0 to 32767 (in ms)
Deceleration Time16-bit register that determines the deceleration time in Fixed Pulse mode.Range:
0 to 65535 (in 10ms)
Range:
0 to 32767 (in ms)
Total Pulses Register32-bit register that defines the Total Number of Pulses in Fixed Pulse mode.Range:
128 to 4,294,967,296
Range:
0 to 2,147,483,647
Elapsed Value Register32-bit register that records the Elapsed Value in Fixed Pulse mode.Range:
0 to 4,294,967,296
Range:
0 to 2,147,483,647
Pulse EnableEnable bit for PWM signal output.
End of Total PulsesIndicates when the Total Number of pulses has been reached in Fixed Pulse mode.
Duty Cycle Setting errorIndicates if the value for Duty Cycle is out of range.
Frequency Setting ErrorIndicates if the value for Frequency is out of range.
Acceleration Time Setting ErrorIndicates if the value for Acceleration Time is out of range.
Deceleration Time Setting ErrorIndicates if the value for Deceleration Time is out of range.
No. of Total Pulses ErrorIndicates if the value for Total No. of Pulses is out of range.
Scroll to Top