Archives For Tutorials

Contactor and flyback diodeThe contactors that came in yesterday needs two modifications before they can be put into the pinball cabinet:

1. add a flyback (aka snubber) diode to each contactor.
2. make the clicking sound louder when the coil is energized

This post is about the first mod: adding the “flyback” or “snubber” diode. So what is a flyback diode? Wikipedia puts it as follows:

 

A flyback diode (sometimes called a snubber diode, freewheeling diode, suppressor diode, or catch diode) is a diode used to eliminate flyback, which is the sudden voltage spike seen across an inductive load when its supply voltage is suddenly reduced or removed.

When the contactor clicks, it means the coil inside is charged by applying power to the A1+ and A2- terminals. When you remove the power from those terminals, the energy still present inside the coil will flow back damaging the circuit. The diode prevents that from happening and damaging other components in the circuit.

There are various threads on the HyperSpin forums about contactors, I found the “All About Contactors” thread particularly helpful. However, I did not really like the aesthetics of the most common solution: soldering two pieces of wire to the diode and put it in both screw terminals (A1+ and A2-). I know this sounds stupid, since those things will be inside the machine, but I guess that must be a mild form of OCD ;-)

This is the solution I found, which has a cleaner look to it I think:

First, get a contactor and a 1N4007 (datasheet) diode. Also have needle nose pliers and a small flat-head screwdriver at hand:

Then, pop off the beige top plastic plate by pressing the three tabs on either side of the contactor. Then remove the screws on terminals A1+ and A2-:

Next up: fit the diode inside the small space on top of the black exposed plastic and bend the legs downwards onto the metal plates that the screws for A1+ and A2- screw into:

Next put the screws back in A1+ and A2-, pushing the legs of the diode onto the metal plates. Finally put the beige top plate back on and marvel at your accomplishment!

Easy and looking good I think! Just a few minutes work and no soldering iron required, which is nice after soldering hundreds of connector pins over the past few days.

 

In the previous post, I showed that the temperature sensor returns a more or less meaningles value anywhere between 0 and 1023. The lower the value, the lower the temperature.

I also showed how to get a voltage reading instead of just a number. Today, I post a link to an article that accompanies Oomlout‘s ARDX kit, about how to get an actual temperature from a temperature sensor.

Of course I could repeat all they say here and claim its my own, but as I learned it from using my ARDX kit, it is logical to point you to the source: http://www.oomlout.com/a/products/ardx/circ-10

Enjoy!

Tonight, I have spent some time looking into the sensor code for the G3H project. In the code I posted last week, sensors are read through a digital pin and exactly that value is displayed. A digital pin outputs a value between 0 and 1024 of type integer. An integer is a whole number, meaning no comma: 1, 2, 3, 4, 5 are integers, but 1.05 and 2.35 are not. Those numbers are usually called floats. More info on integer, float and other data types can be found on wikipedia.

If you measure the voltage on the pin, you will find that it is anywhere between 0V and 5V, where 0V corresponds to the digital value 0 and 5V corresponds to 1024. This is not entirely true as the minimum voltage is 0.005V, or 5 millivolts.

That means that each step up, measured digitally (the range between 0 and 1024) corresponds to 5V/1024 steps = 0.0048828125V.

This can be easily put into a short function you can use for all sensors using a digital pin:

/*
* getVoltage() – return the voltage on the analoge input defined by pin
*
*/
float getVoltage(int pin) {
return (analogRead(pin) * .004882813);
// reading a digital pin returns a value between 0 and 1024, which corresponds to a voltage range between 0V and 5V.
// So, one digital step means 5V/1024 = ~0.005V, or about 5 millivolt
}

/*
* getVoltage() – return the voltage on the analoge input defined by pin
*
*/
float getVoltage(int pin) {
return (analogRead(pin) * .004882813);
// reading a digital pin returns a value between 0 and 1024, which corresponds to a voltage range
// between 0V and 5V.
// So, one digital step means 5V/1024 = ~0.005V, or about 5 millivolt
}

With this value it is a lot easier to translate the value read from the sensor to meaningful data. In a future post I will show you how to use a thermistor to measure temperature and use this information to translate the voltage on the digital pin to degrees centrigrade or fahrenheit.