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
What can I do to protect the circuit from the voltage spike on boot-up? I may need spoon feeding on this guys :-[
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 (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);
Thread.Sleep(Timeout.Infinite);
Dimming a LED can be done with PWM. (you need to connect the LED to Di5, Di6, Di8, Di9 or Di10)
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.
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?
[/quote]
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.
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 http://en.wikipedia.org/wiki/Operational_amplifier
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.