More pin voltage issues

Hi guys,

Here’s a problem. I want to power a low-power LED from An3 off the FEZ Domino. So I set the pins voltage to 1.15v and the FEZ is happy to respond. However… When I reboot the voltage hits 3.3v until the code is implemented. This will cause a problem with my circuit. I’m not going to pretend I’m knowledgeable about electronics but I’m learning on the fly… fast :slight_smile:

What can I do to protect the circuit from the voltage spike on boot-up? I may need spoon feeding on this guys :-[

Thanks in advance.


Heads up, I’m trying the device with a 3.3v LED. It may or may not work, will keep you posted. Any ideas in the mean time will be greatly appreciated. :slight_smile:


You are not suppose to use the analog output to power an led.
If you want to dim led then use PWM

Analog pins are for basic analog things.

To power a led:
Connect it to a Di pin (you can choose) and connect the cathode side to GND. Be sure to add a 220ohm resistor in between :wink: (Huh, Gus?! ;D)

You can then light your led like this: (as shown in the free beginners ebook)

OutputPort LED;
LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);

Dimming a LED can be done with PWM. (you need to connect the LED to Di5, Di6, Di8, Di9 or Di10)

And you dim it like this:

sbyte dirr = 1;
byte duty = 40;
PWM pwm = new PWM((PWM.Pin)FEZ_Pin.PWM.LED);
while (true)
pwm.Set(10000, duty);
duty = (byte)(duty + dirr);
if (duty > 90 || duty < 10)
dirr *= -1;

Okay… I need to read this book :smiley:

But, why is toggling power form a PWM pin setup different to taking a voltage from the Analogue pin setup? :\

Setting a PWM and taking a voltage are two diffident things because the PWM is outputting the wave, and the analog ports are measuring a voltage coming in.

But what about analogue out?

Analog out is a “signal” it is not meant to drive anything, not even an LED.

An analog output pin does not have the current driving capability to drive an LED. A digital drive pin most often has enough driving capacity to drive small LEDs with a properly sized current limiting diode.

A PWM signal is most often used to control an LEDs brightness as an LED takes a certain amount of voltage to ‘turn on’ (to get enough current to flow through it). By controlling it with PWM you are able to drive the LED at an appropriate current level while controlling it brightness level by controlling the amount of time it is on.

Is that like, a car is not meant to go over the speed limit or Apollo 13 was not meant to go around the moon? Or worse? I have it working on both you see.

[quote]Is that like, a car is not meant to go over the speed limit or Apollo 13 was not meant to go around the moon? Or worse?

I am not sure if you are joking or serious about your question! If you studied electronics you will know better about analog outputs. It is difficult to explain it in few lines of text. Basically, you are doing something wrong. If you need to dim an LED, use PWM like we explained to you before.

Forgive me if I sounded flippant, that was not my intention. I was trying to find an analogy between something frowned upon and something potentially dangerous. What I meant was, if an LED works using both PWM and Analogue Out then what is the potential problem? I will use PWM as you have suggested but I don’t fully understand the consequence of the difference, if the analogue out falls within a given tolerance.

The analog outputs are not meant to provide a large amount of current, which is required by a LED.

The danger is that you will DAMAGE your analog output pin and possible damage FEZ :slight_smile:

Say no more! That’s all I needed to hear :wink:

I think if nothing else, this topic raises an interesting question that I don’t know the answer to.

What WOULD be a good use of an Analog out pin? Is there anything that any of you have built into one of your projects, or seen a device that could use it?

Not many uses! Analog input are a lot more important than analog outputs. Funny, I have been an embedded system developer for over 10 years and I never needed to use an analog output! All “power-level” control is done using PWM, not DAC.

Playing audio is one use but this requires low-level support from GHI so thi si snot currently possible…but even with that, you still need to add an op-amp

I have used an analog output to control an optical filter. The filter’s phase characteristics were controlled by a voltage.

The box I did read the output of the filter, did a phase analysis, and then adjusted the analog output to correct the difference between the desired and actual phase shift. It was a closed loop system.

Many types of industrial motor speed controllers can make use of an analog output to control the motor speed. You can also use an analog output as an adjustable voltage reference to control other analog circuitry. Basically a D2A is used as a control not to directly power things.

ok, so it’s not very common :slight_smile: Great, I’ll continue ignoring it for the time being !