Can the counters A/B be setup to create a PWM-signal at a lower frequency than
StefanL38
Posts: 2,292
Hello Counter-freaks,
as far as I understood the counters of the propeller there is an NCO-mode creating a "PWM"-signal with duty 50%
and there is a dutymode with witch I can create any dutys but only on a system-frequency.
Can two counters be combined to create a PWM-signal duty adjustable from 0% to 100% at lower frequencies say 10kHz?
Any advice is appreciated
best regards
Stefan
as far as I understood the counters of the propeller there is an NCO-mode creating a "PWM"-signal with duty 50%
and there is a dutymode with witch I can create any dutys but only on a system-frequency.
Can two counters be combined to create a PWM-signal duty adjustable from 0% to 100% at lower frequencies say 10kHz?
Any advice is appreciated
best regards
Stefan
Comments
Counters are explained really well with all the various modes and PWM and Duty mode etc. in the
·Propeller Education Kit Manual in chapter 7 (pp 119 to 168).
The NCO mode can be used to create PWM of ANY DUTY at ANY frequency but it requires more
attention and in SPIN there is a lower limit to the frequency due to time consumed by the Spin code.
The Duty mode is best run at FULL speed and is more like a DAC.
Actually you can even combine the two modes to create a WAVE of any form and that is how you can
play WAV files and also synthesize sound etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Samuel
www.RobotBASIC.com
Post Edited (SamMishal) : 1/3/2010 3:16:31 AM GMT
No, this is not possible.
You need an assembly loop in a cog to restart the counters periodically for a PWM.
Andy
@Sam: maybe I have to write more to specifiy in which way I want the PWM to work
Is it possible to do it in a set it and forget style with NO additional pasm-loop to create a 10kHz PWM with duty from 0% to 100%?
If both counters are in a logical mode and the two counters trigger each other cross over two IO-pins?
Did anybody think about it in this direction? So it would be for the cost of a second IO-pin but without the cost of a cog
best regards
Stefan
so as to avoid the overflow of the PHSA/B when the FrqA/B is added to it again and agin after it has already gone low.
So you do have to keep resetting the PhsA/B at the end of the PERIOD to make it go back high again for the next pulse at
the right time.
However the Duty mode is a set-and-forget operation. All you have to do is Set the FrqA/B and forget it. It will output the
right voltage for ever until you change the FrqA/B. I am not sure I understand this. The counters in both the Duty and PWM/NCO modes are OUTPUT modes and cannot RECEIVE
any signals they are just putting out high at appropriate instances.
In the Duty mode the high lasts only One clock tick and you get the right average voltage·by making as many consecutive highs
as needed.
With the PWM the high lasts so long as the PhsA/B register is negative (ie bit 31 is high) which you make sure you initialize with a
a number to make as many ticks staying high as you need for the DUTY time and then it goes low and you have to count
as many low ticks as needed to complete the PERIOD and then you set the PhsA/B again to the original number which will repeat
the whole signal which generates the PWM at the required frequency (ie Period) with the right Duty (ie high time).
Logical mode operations of the counters DO NOT·OUTPUT anything on the pins. They RECEIVE on the pins·then update the
PhsA/B by adding FrqA/B if the right logic on the two pins occurs.....but then that is an INTERNAL count and you can use the
PhsA/B register for certain things like counting or triggering conditions....BUT....it is INTERNAL....there is no PWM or Duty
generated on any pins.
So I think this is not what you meant???
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Samuel
www.RobotBASIC.com
·
If you add an XOR gate at the output, then a second prop pin can select invert or not-invert, in effect extending the range to 0 to 100%.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com