Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Basic Electronics....


  • Please log in to reply
8 replies to this topic

#1 cbkernow

cbkernow

    New Member

  • Members
  • Pip
  • 2 posts

Posted 11 January 2012 - 10:45 AM

hi there, starting my journey with netduino and as I always expected its the electronics side of it that is going to cause me the problems rather than the .net side!! I'm building a basic intervalometer for a Canon 350d ("rebel" range in the US) which to trigger taking the picture simply "shorts" two of the three wires which plug intot he camera - http://www.diyphotog..._for_canon_dslr my previous electrical experiences is very basic car electrics so this would suggest a relay can be used but I'm not sure on what kind of relay, or can this be done without a relay? Is it possible to "connect" two pins together eg plug wire 1 into "pin X" and wire 2 into "pin Y" and the chip cmakes the circuit complete when required?

#2 ErikN

ErikN

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationNew York, NY

Posted 11 January 2012 - 03:56 PM

hi there, starting my journey with netduino and as I always expected its the electronics side of it that is going to cause me the problems rather than the .net side!!

I'm building a basic intervalometer for a Canon 350d ("rebel" range in the US) which to trigger taking the picture simply "shorts" two of the three wires which plug intot he camera - http://www.diyphotog..._for_canon_dslr

my previous electrical experiences is very basic car electrics so this would suggest a relay can be used but I'm not sure on what kind of relay, or can this be done without a relay? Is it possible to "connect" two pins together eg plug wire 1 into "pin X" and wire 2 into "pin Y" and the chip cmakes the circuit complete when required?


I've done something similar with Radio Shack Voice Recorder modules. The playback button is just a piece of metal that, when depressed, contacts two PCB traces. For my purposes I removed the button, soldered wires to each of the traces and placed them across a Reed Relay. To control the relay, you can tie one side to Vcc (through a resistor) and put the other to a digital pin on the microcontroller. When you want to trigger the relay, set the micro pin low. Otherwise leave it high. This requires an additional piece of equipment (the relay) but uses only 1 digital pin on your micro. Be sure you get a relay that will operate at the correct voltage. Since the Netduino works on 3.3V logic, you will want to use a relay that can reliably trigger when the difference over the coil is close to that.

I'm sure others have different suggestions. I'd be interested to see what others have done.

-Erik

#3 ErikN

ErikN

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationNew York, NY

Posted 15 January 2012 - 04:04 AM

I took a stab at creating a wiring example. I had to customize the Reed Switch to show the coil connections and I'm new to this Fritzing software so I didn't do it justice. Nevertheless it should be accurate. I've revised the drawing to show the Netduino board powering the coil rather than a voltage source. In my previous work I used a Parallax Basic Stamp II which allowed me to enter high impedance state - this is why I initially suggested tying one side of the coil to a voltage source. I'm less knowledgeable of the Netduino hardware so instead of guessing that the hardware could do high impedance, I went with it sourcing the power for the coil which is tied to ground on the other side (through a resistor is a good idea to limit current flow). With this set up, you just create an output port and change it from high to short your wires together or low to open them. The wires controlling your camera are isolated from the microcontroller. I suggested a Reed Relay because it requires very little power to operate. But that also means they can't handle much power through them either. I made the assumption the wires being shorted together carried a very small amount of current. If this is untrue, you'll need to use a higher rated relay or use resistors to limit the flow to meet the specification. Attached File  NetduinoReedResistor.png   43.74KB   49 downloads

#4 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 15 January 2012 - 12:02 PM

Hi everyone,

You really need to be using a buffer between the Netduino and the relay.
There are two hazards connecting it directly:
  • relay coil draws more current than the Netduino can handle,
  • back emf causes a voltage spike on the Netduino output pin.
Both hazards could destroy the output pin and possibly other parts of the Netduino.

Current
There is an FAQ page in the Wiki that lists the amount of current you can sink or source on each type of Netduino pin (some allow higher currents than others).

Check the coil specification for the relay you have and verify that the current required to turn it on does not exceed that stated for the Netduino pin you are using.

Good practice is to add a buffer using a transistor. The transistor acts as a switch to turn the relay coil on and off.

Back emf
The coil in a relay is an inductor. When current passes through it, energy is stored up in the magnetic field that is generated to close the contacts. (Like a flywheel.)
When you stop driving the current through the coil, the energy stored up forces the current to keep flowing. If there is nowhere for it to go, there will be a sudden rise in voltage - this can damage electronic circuits like the Netduino.

To prevent damage, a diode should be connected across the terminals of the coil. This diode is connected so that it does not conduct when you turn on the coil. Instead, at the moment the coil is turned off, the diode gives the current a path to dissipate and prevent damage to anything else that it connected.

Example
Both transistor and diode are shown in the famous Arduino Relays diagram.

The diagram shows one extra component, a resistor - this is to limit the amount of current from the Netduino into the transistor's base.

Hope this helps - Paul

#5 ErikN

ErikN

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationNew York, NY

Posted 16 January 2012 - 03:11 AM

The power output from the Netduino is very small as is the coil used by a small Reed Relay. Could this really cause damage? If so, can you show how the wiring should be done? I thought maybe you could just place a diode between the digital pin and relay coil to prevent the current from flowing backward and let it drain into ground (through the shown resistor). The problem with this would be the diode would drop the voltage and put it quite probably below the operating range of a cheap 5V Reed Relay you could pick up from Radio Shack. I'm not sure how you'd wire the diode across the coil in such a way that would prevent current from attempting to flow back to the Netduino when the coil is deactivated. I'm also curious to know how you figure out how much voltage or current will be on the line as the coil is discharged. I thought the coil would discharge through the resistor over time, a short time given the size of the coil on this relay, when the pin is driven low. I guess I'm just curious how much more hardware you'd need. Is there an alternate design that would be less complicated to short two wires together?

#6 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 16 January 2012 - 06:50 PM

Hi Erik!

The power output from the Netduino is very small as is the coil used by a small Reed Relay. Could this really cause damage?

Well, unfortunately, yes it can.

I did a quick search for a typical reed relay. I found this <5V / 12V family>. They are quite small as they are just a coil around the reed switch. The data sheet is for all the models in this family. At the top of the second page of the datasheet, the information about the coil is given. Just reading the Coil Resistance for the 5V ones, they vary between 150 ohms and 370 ohms. So at 5 volts these coils will use between 13.5mA and 33.3mA.
I know that this is a 5V relay not a 3.3V one, but it gives an indication of the sort of current that is needed to drive a small relay like this.
The Netduino can drive 8mA on most of its digital pins, and 16mA on some of the digital pins. <See Wiki.>

So ignoring the back emf issue, careful choice of relay and I/O pin might allow you to draw enough current without damaging the Netduino, but a poor/unlucky choice could draw too much current and cause damage.

If so, can you show how the wiring should be done? I thought maybe you could just place a diode between the digital pin and relay coil to prevent the current from flowing backward and let it drain into ground (through the shown resistor). The problem with this would be the diode would drop the voltage and put it quite probably below the operating range of a cheap 5V Reed Relay you could pick up from Radio Shack.

I'm not sure how you'd wire the diode across the coil in such a way that would prevent current from attempting to flow back to the Netduino when the coil is deactivated.

Did you spot the <link to relay circuit> in my previous post? - sorry if it was hidden, the blue does not always stand out very well.

The circuit shows that the diode goes in parallel with the coil. When you are driving the coil ON, no current flows in the diode and so there is no voltage drop wasting any of the available power.

At the moment the transistor is turned off, the current can't flow from top to bottom through the coil any more. But, the stored energy in the coil keeps pushing the current causing a positive voltage to appear at the bottom of the coil. The diode sees the voltage and begins to conduct. This allows the current to flow clockwise through the diode and coil until the energy dissipates. Since the diode gives the current a path to flow along, there is no dangerous build up of voltage.

I'm also curious to know how you figure out how much voltage or current will be on the line as the coil is discharged. I thought the coil would discharge through the resistor over time, a short time given the size of the coil on this relay, when the pin is driven low.

Without doing a clever analysis of the coil I can't tell you how much voltage will develop across the coil, or how much current will flow. Its a long time since I've used a circuit simulator in anger!

In your circuit when the Netduino positive output is switched off, the back emf in the coil will make the output pin of the Netduino suddenly go negative with respect to ground. Depending on the type of transistors used inside the Netduino, current may or may not flow from the output pin to satisfy the coil. If it does this will allow the coil to dissipate its energy as you intended, but the Netduino is not going to like seeing a negative voltage on its digital IO pin.

Is there an alternate design that would be less complicated to short two wires together? I guess I'm just curious how much more hardware you'd need. Is there an alternate design that would be less complicated to short two wires together?


Have a look at the relay diagram its not too bad - just an extra diode and transistor.
One big benefit of using the relay circuit with a transistor is that you can use relays that require coil voltages of 5V or more because the supply to the coil can be taken from a separate source rather than an IO pin.

Regards - Paul

#7 Dan Morphis

Dan Morphis

    Advanced Member

  • Members
  • PipPipPip
  • 188 posts

Posted 16 January 2012 - 07:56 PM

Hi everyone,

You really need to be using a buffer between the Netduino and the relay.
There are two hazards connecting it directly:

  • relay coil draws more current than the Netduino can handle,
  • back emf causes a voltage spike on the Netduino output pin.
Both hazards could destroy the output pin and possibly other parts of the Netduino.


To add to what Paul said, you really should add a pull-down resistor. Yes, you can specify when you create the OutputPort that you want it to be internally pulled down, but what about the 2-3 seconds that it takes for the Netduino to boot up? You don't want to have the state floating. If the pin floats high, it would cause the relay to trigger. While in this case the worse that would happen is the camera would take a picture. If what your triggering happens to be the mains, or a garage door, or some other device it could create a real safety hazard.

To add a pull-down resistor, add a 4k3 (or 10k) ohm resistor between the base of the transistor and ground. This will ensure the pin is *always* in a known state. Its either at ground, or high because you've commanded the pin high.

-dan

#8 ErikN

ErikN

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationNew York, NY

Posted 16 January 2012 - 09:35 PM

Thanks for the follow-ups. Inductors have always been strange to me.

Its a long time since I've used a circuit simulator in anger!




Maybe I've misunderstood. Did I give offense? I was genuinely interested in learning how to determine what a coil would produce for situations outside this specific application. I can't run and ask help whenever I have to deal with an inductor! Programming is easy and natural to me. Hardware is something I struggle with. I can use all the education people are willing to share.


-Erik

#9 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 16 January 2012 - 10:26 PM

Maybe I've misunderstood. Did I give offense?


Hi Erik,

No there was no offense - I'm sorry that I confused you.

"To use in anger" is an expression. I used it to mean to actually do something, or to actually use something - rather than have the capability, but not use it.
Say you have a fire extinguisher, hopefully you would never need to use it and it is just left stuck on the wall. You might have some training or practice to use it. But, if you actually used it to put out a real fire, then you might say that you used it "in anger".

I learnt to use a circuit simulator called "SPICE" many years ago at University. Since then I have not used one to simulate a real analogue circuit. I had the knowledge and the tools but I don't use them any more. (I have slowly moved away from electronics and into software.)

This is a great forum for people to ask questions. I have seen other forums where someone asks a question and people just shout at them "read the FAQ". I am glad it is not like that here.

For every person that has the courage to ask a question on the forum, I think there are probably another five who do not want to ask in case people think they are asking a stupid question.
If you are not sure - its not a stupid question! (Especially if the answer stops you damaging your Netduino :) ).

Paul




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.