What does Smart-Pin mode %01000 PWM Triangle do?
JonTitus
Posts: 193
in Propeller 2
I have used the following program to produce continuous pulses on a Smart Pin (#20). Is that what this mode does? I expected to see a triangular waveform. Changing the X- and Y-register values changes the pulse width and the frame period. Why the word "triangle" in the mode title? What is the particular use or application for this type of PWM? I plan to add more details in the documentation for the Smart-Pin modes and want to understand what they do. (I use the default system-clock frequency for simplicity.) The attached scope images show a logic-1 time of 1.29 usec and a period of 41.1 usec for the settings in the code. Thanks. --Jon
CON
dat
org 0
dirl #20 'Setup Smart-Pin at P20
wrpin NCO_Config, #20 'Set configuration for PWM Triangle mode
wxpin X_RegData, #20 'Set base period at 1 usec (25 MHz/#25)
dirh #20 'Finished setup
wypin Y_RegData, #20
.myloop nop
jmp #.myloop 'Program waits forever
NCO_Config long %0000_0000_000_00000_00000000_01_01000_0
Y_RegData long $0000_0010
X_RegData long $0200_0001

Comments
Not quite, the triangle is an Up/Down counter whose value plots like a staircase triangle, hence the name. There is no DAC/comp.
Simpler PWM uses a UP counter only, and that value plots like a staircase sawtooth.
A sawtooth PWM means all trailing edges are at the same time, whilst triangle allows multiple PWMs to have time-separated edges, permitting user controlled dead times on all edges.
MOSFET Bridge power drivers prefer to turn off one mosfet, then allow some ns before they turn on the opposing mosfet. PWM Triangle allows that.
Does the word "it" refer to the counter count or to the captured value (register Y)? --Jon
Edit: Fixed small error in jm_servo.spin2
I am very visual person, so I use colors and overlay elements. Note that this diagram is not annotated, but you will see what I mean. It is deliberately setup to show the difference in the two modes given the same input values. The 'scope traces are from these values.
Edit: I decided to annotate my graphic using notation similar to Jon's.
Edit: ( both of you I guess
The numbers I used in the figure came from a short program that I'll use as an example so people can relate the register information to the timing. Cheers. --Jon
IIRC Chip made it so you can config 2,3,6, etc PWMs and then a single start has all counters in sync from then on.