In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote: Chris, what you describe can also be seen as a PWM (Pulse Width Modulated) signal, starting with a relatively short duty cycle, increasing along a timed ramp until a 95% or even 100% duty cycle (for aways on) is reached. Usually, PWM signals are generated at higher frequencies but there is no reason why you should not generate one at 10 Hz - it is just a matter of timing. I'm not an SX/B expert but to my understanding you can't use SX/B's PWM function for this purpose as its frequency is too high and it can't be contolled by a parameter (besides the port pin, there are only parameters for the duty cycle, and the duration of the PWM signal). So you will have to "hand-code" this one. In principle, you would need a counter (let's call it the PWM accumulator, or PWMA). In a constant timed loop, or better within an ISR, starting with 0, the PWMA would be incremented every 391 µs. That is, after 256 * 391 µs it would roll over to zero, i.e. after 100.1 µs which is the period of approx. 10 Hz. Another variable is used to hold the duty cycle - let's call it DUTY. Whenever the PWMA is incremented, its new contents is compared against DUTY. When it is greater than DUTY, the PWM output pin is cleared to low otherwise, the output pin is set to high. The greater the value in DUTY is, the longer will the PWM output pin stay high. After the PWMA has rolled over, the next PWM cycle automatically begins. In order to implement a ramp, you need set DUTY to 0 at start-up, and then increment it periodically until it holds the value for the maximum duty cycle you need. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=104114#m104117 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)