Skip to main content

Posts

Showing posts with the label Tips and Tricks

Arduino Blinking LEDs

Arduino boards have I/Os (Input/Output) that can either receive or transmit signals. One of its basic functions is digital input/output. It can be programmed to output digital signals that can be used drive devices, such as an LED . To drive an LED, you will have to add a resistor to regulate the current to the LED. The digital output is about 3V (5V or a little less for 5V board), and for an LED the forward voltage is about 2V. What is left (1V) divided by the resistor sets the current. Current is typically 10 to 20mA. Driving an LED Below is an example code for alternating LEDs on Arduino Pro Micro Board. It uses pins 2, 3, 4, and 5 as digital outputs. My 11 year old son helped out in the programming. :) void setup() {   // initialize digital pins 2, 3, 4, and 5 as outputs.   pinMode(2, OUTPUT);   pinMode(3, OUTPUT);   pinMode(4, OUTPUT);   pinMode(5, OUTPUT); } // the loop function runs over and over again forever void loop() {   di...

Arduino Transistor DC Motor Control

Arduino boards have PWM (Pulse Width Modulation) outputs that can be used to control like the speed of a DC motor. On a Pro Micro, those outputs are encircled white on the board. You can program it such that it outputs on a scale of 1-255, 1 being the slowest and 255 being the fastest. PWM gives out pulses whose width is varied (modulated) while the period is constant. The longer it is high, the higher power it delivers to the circuit. PWM can be used to drive a transistor (switch) which in turn drives the motor ON and OFF. The longer the switch is ON, the higher the power delivered to the motor, and thus faster. The circuit consists of a transistor Q1 (TIP31) NPN transistor, driven by the PWM from Arduino. The resistor is to limit the current to the base, but enough to operate the transistor in saturation when the input is high. The diode is to protect the motor from any back emf that might come from the motor when the current is cut off. The circuit is supplied by a 9V battery. ...

Microcontroller for Dummies

I got my cute little micro-controller board this week and immediately sat down to see what cool things it can do together with my circuits and components. It's an Arduino compatible micro board. There's a lot hype over these micro-controller boards, and rightfully so because of the many exciting possibilities of what you can do with your circuits. The micro-controller will be your interface to your computer, as it can accept analog and digital inputs and can be programmed through the open-source Arduino IDE (Interface Drive Electronics). It connects to the computer through USB. All you need is some little skills in programming in C language, and it's open to the world of many exciting possibilities. For the newbies in programming, don't lose heart because it's not really difficult to learn. You'll actually find it fun to learn. Arduino Compatible Micro Board   So what can a micro-controller really do? The fact that you can connect it your computer is a...

Noise RMS, Noise Power and Noise Peak-to-Peak : Understanding Noise Part III

In the first and second half of the series we discussed about some basic concepts of noise in electronics. It is so often vague and abstract to many, that we often try to avoid dealing with it as much as possible. But this is really something we cannot ignore, and so it is imperative that every engineer understand its nature. Below is an illustration of how we might imagine a noise is. Reality check: it is present even in the most "noiseless" DC signal we can imagine. But we would like to be able to quantify it in terms of RMS, Peak-to-Peak, Power, and Noise Density. Noise generally can be thought of to be present in all frequencies at different levels, but circuits do have specific bandwidths. And so when we quantify noise, we think in terms of frequency and bandwidth. Noise Root Mean Square (RMS)   It is basically a measure of one standard deviation of the noise plot distribution. Imagine looking at a noise plot on a time domain, seeing the noise amplitude variations. ...

Why does an Op Amp Oscillate?

Ever saw an op amp circuit oscillating and behaving weirdly? We basically have just two options: give up to the idea it's not really going to work and try another circuit, or the better option would be is to figure out what is wrong and make it work. As some well known author has said, every op amp sits there waiting to oscillate [1]. I discussed in one of my articles here, titled What's The Feedback Around Op Amp All About?, the concept of negative feedback and how the large open loop gain makes the overall closed loop gain stable and predictable. It is when this negative feedback becomes not negative anymore, that is, if it becomes positive, that the circuit becomes unstable and starts to oscillate. Figure 1 General Feedback Topology How can that possibly happen? To put it in simplest terms, it happens when enough phase shift is introduced in the complete feedback path which includes the amplifier itself, enough to make the feedback turns180 degrees around, thus ma...

Mixed Signal Grounding - Grounding Series Part III

This is the last installment of the grounding series articles I have posted. In Part II of this series, we have explained that star ground provides a single or common reference point to a circuit in an effort to avoid sharing of paths that could cause errors and degrade the integrity of the signals. This is accomplished by selecting a single "mecca" point where all ground return paths meet, and that this point should be a low impedance node. But this scheme is not always practical and doesn't solve all the woes of circuit grounding. Long routes going to the mecca point can itself be a source for error as it becomes inductive to high frequency signals. The rule of keeping the routes or wires as short as possible applies to grounding as well. The other scheme that we have described is the use of ground plane, because it presents much lesser resistance and inductance compared to the individual wires and traces. But we have cautioned that there are two paths the signal ...

To Use Star Ground or Ground Plane? Grounding Series Part II

Building circuits whether on a PC (Printed Circuit) board or a breadboard, grounding have always been important. Careful grounding becomes critical on applications where performance and integrity of the signals are of prime importance. Examples are low-level application such as in audio, in precision sensing and measurement circuits, and in mixed analog and digital circuits . When do we use star ground and ground plane? What is the difference between the two? Which is actually better? We will try to answer first what the difference between the two is. Star Ground Also sometimes called mecca ground, this is based on the concept of creating a single return point in the circuit as a common reference in order to avoid ground loops and thus circuit errors (See figure 1 [1]). In the figure, we could see the input signal return path is shared, assuming very high input impedance and no significant current flowing in it. Those in the path of significant current flow, such as the power supp...

Practical Integrator Circuit - A Triangle Waveform Generator

Below is a basic op amp configuration of converting a square wave input to triangular waveform. Figure 1 The concept is pretty simple. The square wave input produces a current that is translated to a voltage ramp across the capacitor. The positive cycle of the input produces a negative ramp output, while the negative input produces a positive ramp. The ramp is governed by the following basic equation: Equation 1 where Ic  is produced by the input voltage divided by Rin, since the same current flows in the resistor and in the capacitor. Note that the input has to be centered and symmetrical about the positive input terminal which is connected to ground, in order to produce a symmetrical output. But this basic configuration has some serious problems. Even if the output starts at zero, it will not be centered at zero, and will not stay at the same center or common mode value due to the inherent offsets of the amplifier. Figure 2 A technique in order to hold th...

Not All Circuit Grounds are Created Equal - Grounding Series Part I

I was once asked by a friend/colleague if it is alright to pick any of the grounds in the circuit to make a measurement. I answered it depends on what you are trying to measure, and I reminded that what he calls ground is supposedly a "reference" to his circuit, and will be a reference to his measurement. There will be multiple "ground" points in the circuit, and not all of them are created equal. What we call ground is ideally zero volts but this is often confusing, because there really can only be one point in the circuit that is truly zero volts. Given a ground plane or ground traces in our PC board, they can actually be at varying potentials due to errors introduced in the circuits by what we call ground loops. Figure 1 Ground Loop There will be errors unique to each individual ground points. These errors may or may not affect your circuit's performance depending on the applications. We can perhaps get away with our little concept of ground being...

Supply Bypassing and Decoupling, Are They Really Necessary?

We see these bypass or decoupling capacitors on the supply pins, and maybe we wonder what if we just take them out so we can save a few components on the circuits. Or perhaps out of plain ignorance we forgot about it, and I have seen people do that and be faced with seemingly impossible problem to contend with, like outputs oscillating, or behaving weird even in the absence of inputs. What could be wrong? Only to find out at the end of the day that they missed something critically important in the circuit. So what do they do really? They provide a low impedance path to the ground for noise and any ac components that might be present on the power supply lines. For example, a sudden current change in an IC can cause a large glitch on the supply. The capacitor will help prevent that by providing immediate current requirements. In this manner it helps maintain the supply node to be low impedance. Being low impedance means it can source a varying amount of load current and being able t...