PWM

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 CMM2

Syntax:
PWM channel, freq, chA [, chB [, chC ]]
PWM channel, STOP

PWM freq, ch2, ch1
PWM STOP

Description:

 (all except CMM1 and mono Maximite)

PWM channel, freq, chA [, chB [, chC ]]
Generate a pulse width modulated (PWM) output for driving analog circuits, sound output, etc. 
There are a total of five outputs designated as PWM in the diagrams on pages 6 and 7 (they are also used for the SERVO command). 
Controller 1 can have one, two or three outputs while controller 2 can have one or two outputs. Both controllers are independent and can be turned on and off and have different frequencies. 
'1' or '2' is the controller number and ‘freq’ is the output frequency . 
1A, 1B and 1C are the duty cycle for each of the controller 1 outputs while 2A and 2B are the duty cycle for the controller 2 outputs. 
The specified I/O pins will be automatically configured as outputs while any others will be unaffected and can be used for other duties. 
The duty cycle for each output is independent of the others and is specified as a percentage. If it is close to zero the output will be a narrow positive pulse, if 50 a square wave will be generated and if close to 100 it will be a very wide positive pulse 
Minimum frequency is 1Hz, maximum is 24MHz on the CMM2. Duty cycle and frequency accuracy will depend on frequency. 
The frequency can be any value of 240,000,000/n. The output will run continuously in the background while the program is running and can be stopped using the STOP command. 
The frequency and duty cycle can be changed at any time (without stoping the output) by issuing a new PWM command. 
The PWM function will take control of any specified outputs and when stopped the pins will be returned to a high impedance "not configured" state.

PWM channel, STOP
Stop the PWM on the specified channel and return the pins to a high impedance "not configured" state.

On the CMM1 and mono Maximite:

PWM freq, ch2, ch1
Generate a pulse width modulated (PWM) output for driving analogue circuits. ‘freq’ is the output frequency (between 20 Hz and 1 MHz) . 
The frequency can be changed at any time by issuing a new PWM command. 
The output will run continuously in the background while the program is running and can be stopped using the PWM STOP command. 
'ch2' and 'ch1' are the output duty cycles for channel 2 and 1 as a percentage. 
If the percentage is close to zero the output will be a narrow positive pulse, if 50 a square wave will be generated and if close to 100 it will be a very wide positive pulse. 
Both are optional and if not specified will default to the previously used duty cycle for that channel. 
The PWM output is generated on the PWM/sound connector and that assumes that the connector has been wired for PWM output. 
The frequency of the output is locked to the PIC32 crystal and is very accurate and for frequencies below 50 KHz the duty cycle will be accurate to 0.1%. 
The original monochrome Maximite has only one PWM/sound output so only 'ch2' can be set on that model.

 

Last edited: 30 September, 2020