In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote: Why don't you code like this: Main setb RB.0 ; 1 LED is on after executing this instruction (total off time: 5 cycles) nop ; 1 nop ; 1 nop ; 1 nop ; 1 clrb RB.0 ; 1 LED is off after executing this instruction (total on time: 5 cycles) nop ; 1 jmp Main ; 3 As power consumption is an issue, I assume that you clock the SX at a low rate. But even when you use the 32 kHz internal clock, an on/off cycle will be as short as 312.9 µs, i.e. the LED will flash at a rate of 3.2 kHz which is way too fast. Well, yes I know, Beau provided this sample code to measure the power consumption at different clock rates - it was not intended to blink LEDs. Nevertheless, after seeing this example an idea came up to my mind: Reducing the LED current by applying a PWM signal. Beau has calculated his results based upon the voltage of a fresh 9V battery. Let me re-do it just for this example based upon a 5V supply, and an LED current of 3mA: R = (5V - 1.65V) / 3mA = 1.12 kOhm Now, let's calculate the power balance: Total power consumption is 5V * 3mA = 15mW The LED converts Pled = 1.65V * 3mA = 4.95mW into light and some heat, but the majority of Pres = (5V - 1.65V) * 3mA = 10.05mW (or 15mW - 4.95mW) is dissipated into heat by the resistor. Now, let's assume, you generate a square wave with a 50% duty cycle on the LED-driving output pin as long as the LED shall be on. To make it simple, you can assume that the 50% duty cycle has the same effect as reducing the supply voltage by 50%, i.e. down to 2.5V. The results are now as follows: R = (2.5V - 1.65V) / 3mA = 283.3 Ohm Pled = 1.65V * 3mA = 4.95mW (same as before) Pres = (2.5V - 1.65V) * 3mA = 2.55mW As you can see, this is a much better energy balance. You could even optimize it by selecting a duty-cycle of less than 50% for the output signal for lower resistor values. Nevertheless, you should keep in mind that reducing the resistor value means higher peak currents to be sourced by the output pin, which is limited to an absolute maximum of 45mA according to the SX28 datasheet. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=89554#m89797 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)