=20 > The frequency is the time between pulses. Unpedantically, yes, although no but I know what you mean. Time between pulses can describe the same thing in a different way However, time between pulses doesn't take into account the width of the pulse. If you had pulses coming at 50 per second, the frequency is 50Hz. This is 20ms for a complete cycle, that is for example, the time from one leading edge to the next. If the pulse is 1ms then the time between pulses must be 19ms When doing bit-banged PWM you might have a counter that goes from 0 to 100 and a timer that takes 20ms to count from 0 to 100. A register is set to the PWM duty cycle you want. When a match occurs between the counter and the register, the state of the output pin is changed, most likely from '1' to '0'. This is how it's done on a PIC using TMR2 and the PWM module. The frequency remains the same, the 'off' and 'on' times of the pin can be altered with eg using ADC on a potentiometer Hz is generally much more common a unit, but time between pulses is used for specific cases eg, obviously, timed events. So you have the example of an infra-red remote control. The carrier IR is 38kHz but the specification for the pulses mandates a time, in ms, for the length of packets of 38kHz and also for the time in ms between packets > The duty cycle is the percentage of time the line is high. > So I guess that a perfect square wave would have a duty cycle of 50%? Yes. The terms 'mark' and 'space' are also used. 'mark' is the high, and 'space' is the low > PWM is simply changing the duty cycle from 1 - 99%=20 Yes, or approaching 0% and 100% even closer > Normally the frequency is 20 ms? Are you talking about servos ? =20 > So when you say "high duty cycle" do you mean the time the > line is high compared to low? So like 75% would be high? Probably. It can be relative. Some motors won't start until maybe 30% (ie any PWM less than 30% simply heats the windings) so 30% in that case is low. > And my other question, why do you need to invert a square > wave? It doesn't seem logical to me at the moment 'square' is a misnomer. Only a 50% duty cycle is really a 'square' wave. Anything else is rectangular. Inverting a 50% duty wave makes no difference to the wave http://en.wikipedia.org/wiki/Square_wave The reason you would invert a wave is because the polarity of it doesn't suit you. When making circuits up with logic ICs, including the 555, you can often get the wave you want but it's upside-down. eg the action of a potentiometer might be backwards - high duty cycle CCW and low duty cycle CW. A logic inverter (gate or transistor) will make the pot act the 'intuitive' way. Low duty left, high duty right. Other examples include deriving an inverted signal for a chip enable (often active low) or reset (often active high) from a common source or interconnected pathway Joe --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .