Monday, 31 March 2014

switches - Remove pin to close switch



I'm looking for a small fairly rugged normally open switch that closes when a "pin" is removed. It needs to take about 12V It needs to be passive and not require power. Is there such a component?


Basically, I want to be able to pull out a pin or a small plug to turn a device on.


I can think of a mechanical solution, a plastic pin that blocks the current flow, once removed the contacts would press together. But, for my application (a drone) I don't think I can build something rugged enough.


So is there a type of store-bought component that will do this?




Sunday, 30 March 2014

control system - Proportional controller



Sirs,


I am not able to understand why Proportional controller introduces offset.Please consider follwing paragraph I found on internet, credit to **



**, regarding offset error of Proportional only controller -


" If the operator should increase the flow out of the tank, the tank level will begin to decrease due to the imbalance between inflow and outflow. While the tank level decreases, the error increases and our proportional controller increases the controller output proportional to this error. Consequently, the valve controlling the flow into the tank opens wider and more water flows into the tank.


As the level continues to decrease, the valve continues to open until it gets to a point where the inflow again matches the outflow. At this point the tank level (and error) will remain constant. Because the error remains constant our P-controller will keep its output constant and the control valve will hold its position. The system now remains at balance, but the tank level remains below its set point. This residual sustained error is called Offset." enter image description here


I believe that measured variable here is level of liquid in the tank and not the outflow. Considering the bold statements in above paragraph, my question is why the valve will open only unitill inflow matches outflow? Shouldn't it open till the level measured equals setpoint? Then why the offset should come into pitcutre?



Answer



This is talking about a simple proportional controller. The control output is merely the system output minus the control input times some constant:


  C = K(I - S)



Where I is the control input to the system, S the actual system response, C the control output that drives the system, and K the proportionality constant.


The tank example above is a little squirrely. Let's consider speed control of a car as a example. In that case, I is the speed you want to go, S is the speed you are actually going, and C is how hard you step on the gas. Let's say you want to go 50 MPH but the car starts at stop, which mean S is 0. Let's say K is 2, and the resulting C is then in percent of full throttle. Initially K(I - S) is 100, so you step on the gas all the way (100%). As the car speeds up, I-S gets lower, so you let up on the gas. That makes sense because you know intuitively you don't need to floor it to maintain 50 MPH on level ground with no wind.


However, the problem now is that you won't ever get to your desired speed. If you were at 50 MPH, then I-S would be 0, and you'd let off the gas completely, which clearly won't maintain 50 MPH. This simple proportional-only controller always requires some error to maintain a non-zero output. For example, let's say to maintain 50 MPH would require a 25% control output (step on the gas 1/4 of the way), and that steady state speed is linear with throttle setting. In that case, the system would assymptotically approach 40 MPH and stay there. K(I - S) is 20, which is the control output required to maintain 40 MPH.


One way to address this problem is to make K larger. However, that will make things unstable or jerky. Suppose you take this to the extreme and make K infinite. That means you either fully floor it or fully let up on the gas, depending on whether you are below or above 50 MPH. You can probably see intuitively that it would be a very jerky ride. While your speed would probably average reasonably close to 50 MPH, the car would constantly go a little slower, which would floor the gas, which would make it go faster after a little while, which would let off the gas, which would make it slower after a little while, etc.


Obviously this is bad for the car, uncomfortable for the passengers, and a inefficient way to run a gasoline engine. However, some control systems work quite nicely like this, especially when the system can only be on or off in the first place. The heating system in your house works like this, for example. The thermostat turns the furnace either fully on or fully off. The temperature does oscillate a little, but not enough for you to care. In this case, the heater only works full on or full off, so this is the efficient way to run it. To keep from turning the heater on and off too often, the thermostat has a little hysteresis. It might, for example, turn on the heater when the temperature gets down to 69.5° and off when it gets up to 70.5°. This keeps the heater on and off for long enough at a time to not stress it too much and for it to stay efficient.


In other control systems, this offset is dealt with by adding other terms to the equation above than just one that is proportional to the offset. In a PID (Proportional, Integral, Derivative) system, there are additional terms proportional to the time integral of the offset and the time derivative of the offset. Each of these terms has its own gain factor (K value in the equation above). It is the I term that nulls out any long term offset.


state machines - VHDL interview question - detecting if a number can be divided by 5 without remainder


I saw a nice interview question for VHDL - build a system that receives a number and detects if it can be divided by 5 without remainder. I tried to solve that with a state machine (I suppose they don't want you to use mod or rem) and while I did have initial success (numbers like 5, 10, 15, and numbers such as 20, 40, 80 worked), other numbers like 130, 75 and so on failed for me.



I would show my state machine but it's a complete mess (it's not a code, it's a drawing), and like I said, not even working.


Basically what I tried to do is write down in binary numbers that are divisible by 5, and build a state machine that will work for them.


I would be glad if you could show me how to solve this problem, and how to think when facing something like this.


Thank you!



Answer



Doing a remainder operation in serial fashion is actually quite easy. The key assumption is that the data comes in MSB-first if it's serial. You only need N states to compute a remainder modulo N. Start in the "0" state and if you end up in the "0" state after the last bit (it doesn't matter how many bits there are), the remainder is zero.


schematic


simulate this circuit – Schematic created using CircuitLab


Think about how you'd do long division if the only thing you needed to keep track of was the remainder:


process (clk)

begin
if rising_edge(clk) then
if reset = 1 then
state <= 0;
else
if (state & din) >= N then
state <= (state & din) - N;
else
state <= state & din;
end if;

end if;
end if;
end process;

communication - Using of RF transcieivers to communicate over 230VAC powerline


Initially I need to communicate between several devices placed within one appartment (or a building). All those devices will be connected to 230 VAC power line.


I'd like to skip any wireless communication as it will not guarantiee that neighbours will not interfere with each other.


And I'd like to have a cheap and small solution.


Initially I stuck with TDA5051A which is created directly for what I need. In addition its datasheet including detailed application schemes:


enter image description here


However the chip is moderately big (10mm long SO16 package) and a bit pricie (about $3/piece not including price of additional needed components).


So this is why I turned to figure out how to do this with in the same way as RF-wireless communication does. But instead of the air I will use 230VAC power line as the medium:


enter image description here


So my questions are:





  1. Is it enough to use a capacitor between the powerline and the transceiver?




  2. Which wire is better to use for communication: line of neutral?




  3. How can I be sure that the signal will reliably transmitted within one single powerline wire AND will not be transmitted wirelessly with any significant power to the neighbours electrically isolated powerline wires?





  4. Is it possible to place any filter at the apartment (or building) inlet to restrict data transmission to/from neighbours?




  5. I will be very appreciated if anyone will share ready-to-use schematic




  6. Is there anything else I should think about or take into account?





Thank you in advance!



Answer



This question assumes that connecting an RF signal to a power line does not convert the power line into an antenna. The power line will become an antenna and you will find that neighbors will in fact interfere with each other.


It's also quite probable (in some cases) that powerline comms will extend their range to neighbouring houses.


So, what you need to do is think about using some kind of protocol that can allow neighbours to interfere with each other without this necessarily causing an operational problem.


pcb - Are solder fumes bad for me?


I do a fair bit of soldering (lead-free). Is breathing in solder/flux/paste fumes actually going to harm me?


Are cheap fume extractors worth buying?



Answer



Solder fumes aren't very good for you. Some people can become sensitized to flux fumes, especially from the older rosin flux used in cored solder, and get breathing problems:



Controlling health risks from rosin (colophony) based solder fluxes


The no-clean flux isn't as bad.


I once felt quite ill after assembling about 30 boards that I had to do myself as my distributor wanted them very quickly.


Breathing out whilst you are soldering each joint helps a lot, if you don't have fume extraction.


How do you measure apparent power consumption of a transformer (primary coil) with no load on secondary?


Lets say 120 Volts at 60 Hz with a Transformer across it with 1 Henry as the primary and 1 Henry on the secondary. The secondary has no load and is an open circuit. How would I physically measure the Apparent Power of the primary coil?


Side question, if secondary is shorted, will voltage across the primary head towards zero?




mosfet - Flyback Diodes For Inductive Loads With Long Wire Runs


I have a project that uses several high power DC solenoids (50 VDC) that will have ~10 feet of wire between them and the driver board. This is for pinball machines. These solenoids typically come with flyback diodes pre-installed on their terminals which makes sense and is very common with any switching inductive load.


However, when I look at schematics for the old driver boards from their heyday in the 80's and 90's I see flyback diodes there too.


Is there a reason you would want flyback diodes at both ends of the wire run?


schematic


simulate this circuit – Schematic created using CircuitLab




Answer



To draw the circuit with some extra stray components


schematic


simulate this circuit – Schematic created using CircuitLab


Only D1 is necessary.


D2 can only control the kickback from L1. The kickback from L2 is not controlled by D2. If L2 is large enough, if there's enough wire or it runs in a loop rather than as a pair twisted with its return, then there could be enough energy stored in L2 to concern Q1.


Solenoids are often sold with D2 incorporated, to simplify the circuit. It doesn't hurt to have both D1 and D2, as it affords some measure of redundancy.


Some FETs have an 'unclamped avalanche' rating, for use as solenoid drivers without D1. They will safely take a specified kickback energy without failing. This is rarely the case for BJTs.


Saturday, 29 March 2014

Is there any reasoning behind component names?



All the components I own have strange names, like a transistor called 2N2222 and a motor driver called L293D. When you see these kind of things writen down do you instantly know what it means or do you have to google it every time?


How much information is hidden in these codes or are they totally random?



Answer



The prefix often has a specific meaning, but the numbering following the prefix often doesn't.


In general:



1N... = diodes
2N... = transistors


A... (2 letters + 3 digits) = germanium transistor, e.g. AF117
B... (idem) = silicon transistor, e.g BC847




For diodes like 1N400x the last digit is kind of counter to indicate the diodes belong to the same series:



1N4001: 50V
1N4002: 100V
1N4003: 200V
1N4004: 400V
1N4005: 600V
1N4006: 800V
1N4007: 1000V




The 1N4148 is a typical switching diode. For it's SMT counterpart manufacturers use the same number (4148), but with a different prefix: Fairchild calls it an LL4148, Rectron an MM4148.
On the other hand, the SMT version of the BC547 transistor is the BC847, so there they keep the prefix, but change the number. You try and find the logic in it.


IC manufacturers often release new devices with their own prefix, like "LT" for Linear Technology, or "LM" for National Semiconductor, so sometimes it refers directly to the name, but often it doesn't. When other manufacturers make compatible parts, however, they often stick to the same part number, so that prefix doesn't always tell you who the manufacturer is. A MAX809, for instance, is made by (at least) Maxim, On Semiconductor and NXP. "TIP" originally meant "Texas Instruments Power" but you'll also find a TIP110 transistor with Fairchild.


Like Matt says sometimes the number following the prefix refers to the device's function. He mentions the MAX232 as an EIA232 driver, and guess what the MAX485 is. FTDI's FT232R is also an EIA232 bridge. But those are really exceptions.


Sometimes the last digit refers to the number of opamps, for instance, in a device.



LF411 = single opamp
LF412 = dual LF411




I once asked a question about other than manufacturer's prefixes in IC type numbers, but there seems to be little systematical in it.


surface mount - SMD LED: How to calculate optical power (in mW) from luminous intensity (in mcd)?



I chose an LED for my application but I need optical power, in mW.


In the data sheet, luminous intensity is shown in mcd but I did not find formulas for calculation although there are graphs, etc.


Where luminous intensity is 180 mcd and viewing angle 120°, etc.


Please provide any necessary formulae for my case.


I could not find the exact formula on this website.




twisted pair - factors influencing capacitance of a cable


I am out of my depth here so I am looking for a simple explanation. If you have twisted pair cables of differing makeup, varying in conductive material, diameter of the conductor, number of twists per meter and number of pairs in the cable. What if any effect the pairs capacitance.


This is in the sphere of telecoms.


EDIT:


C = (EoErA)/d


capacitance seems to be based on “Permittivity” which is a function of conductivity which would imply that it will differ by from copper to aluminium.


also the area of the conductor, so that conductors with a larger surface area have more capacitance.


and lastly the insulator and distance between the conductors will play a role.



Are there any effects that I am missing? does the number of pairs around the one tested make any difference?


EDIT: I seem to have misunderstood Permittivity it seems to be only to do with the insulator not the conductor.



Answer



Capacitance is a function of the spacing of the conductors and the dielectric constant (aka relative permittivity) of the insulating materials. All other things being equal, the capacitance between two wires will be proportional to the dielectric constant of the insulator.


A vacuum (and dry air) has a dielectric constant of 1. Insulating plastics have dielectric constants in around 2-4 generally.


The thicker the insulation, the wider spaced the wires will be, and thus the lower the capacitance per linear unit, again, all other things being equal.


You can approximate the capacitance of an unshielded twisted pair by:


C(pF/ft) = \$\frac{2.2\epsilon }{log_{10}(\frac{1.3D}{f d})}\$


Where


D is the diameter of of the wire including insulation (inches)



d is the conductor diameter (inches)


\$\epsilon\$ is the dielectric constant of the insulation


f is the stranding factor (about 1)


Here's another reference that gives a derivation of a similar approximation.


The resistance of the conductors does not directly affect the capacitance but it will have other effects on the performance, especially when the lengths are long. Look up the Heaviside condition for more on that.


gpio - 1.5V-rated MOSFET doesn't react to a gate input of 1.8V


I am not really an electronics specialist, but a software engineer (so excuses if I 'm asking stupid questions).


I am trying to use a microcontroller GPIO output rated at 1.8V. When this pin becomes high, I want to enable a 12V relay. I am using a N-channel MOSFET from freetronics


The specs for the MOSFET can be found here.


For some reason the 1.8V seem insufficient to drive the MOSFET although it is specified for 1.5V min. I've tried a standalone setup using a 1.5V AA battery and that doesn't work either. But if I apply 3.3V with the same setup, it works (just so you know my wiring is OK).


Unfortunately my microcontroller (Intel Edison) only has 1.8V GPIOs.



Am I missing something? How can I make this work? Should I use a different MOSFET? And if so, which one?


Your help is much appreciated.




Friday, 28 March 2014

ground - Grounding in circuit diagrams


Often I see in circuit diagrams that the circuit is connected to the ground:


enter image description here



I understand that this creates a reference for zero potential, but why does all of the current not simply flow right into the ground? I must have a fundamental misunderstanding somewhere.



Answer



The current doesn't all just flow to ground because of Kirchoff's Current Law. Kirchoff's Current Law states that the sum of the currents entering and leaving a node must be equal to zero. If x amps flow from the power supply, x amps must return to the power supply.


In your schematic, before the earth connection was added, the voltages had no reference. Adding the earth connection puts the negative terminal of the supply at earth potential, making all the voltages earth referenced. If you prefer to think of it in terms of Spice, the negative terminal and earth nodes were merged. The current still has to flow back to the power supply, where it came from. Additionally, if any other point in the circuit were tied to earth, the current would still flow back to the negative terminal of the power supply through earth.


What is difference between I2C and TWI?


What is difference between I2C and TWI interfaces? Wikipedia says, that TWI is variant of I2C. Some other sources says that only name is differ...



Answer



I agree with everything @Wouter said... Namely, TWI is used by manufacturers (like Atmel) to refer to their I2C interface to avoid legal trouble with Philips since I2C is a registered trademark. Some manufacturers (like Atmel) have implemented proprietary features on top of I2C so that their TWI is an I2C superset.


To answer your follow-up question, yes. It is enough just to change the name. A trademark only protects the name. If it were patented, the situation would be different.



However, it is difficult to defend a patent on a modulation/encoding scheme since it is mostly just math. Often, copyright is used for this, but it is usually pretty easy to circumvent, since the copyright protects only the exact specific instantiation (implementation) of the protocol, not the protocol itself in most cases.


design - "zero voltage drop diode"...Really?


In my research for this question, I found this by a new user that hasn't been seen before or since. His low investment here and the "say goodbye to traditional bad stuff" language makes his answer a bit dubious, but just in case he's onto something, I thought I'd fish for some clarification.


His original answer is the classic unformatted block of text with no diagrams, but I think he's describing this:


schematic



simulate this circuit – Schematic created using CircuitLab


I'm pretty sure that won't work as described. Or did I read the description wrong?



Answer



He's talking about biasing a diode with a voltage source.


schematic


simulate this circuit – Schematic created using CircuitLab


I've taken the liberty of adding C2 since the output will have some offset, and left out his "tweaks". The threshold will depend on the ratio of currents between the two diodes. The current through D2 will obviously be less so there will be a non-zero threshold, but much less than without bias.


Thursday, 27 March 2014

communication - Software to create timing diagrams


In my professional life, I sometimes need to create timing diagrams for protocols: UART, SPI, etc. However, I can't find any good programs available. What programs can be recommended for this and what is the experience using them?




operational amplifier - What is the advantage of the inverting opamp circuit over non-inverting one?


Op amp circuits are designed to achieve a specific gain regardless of the differences between individual op amps. One very common circuit has a gain of -R2/R1. Here's a (corrected) schematic:


inverting op amp schematic


Another common configuration has a gain of R2/R1+1 and is non-inverting:


non-inverting schematic


What I can't see is why on earth anyone would use the inverting one, except for the odd case where you actually want inversion. The non-inverting one has high input impedance without an extra input stage, and almost the same gain. Is there any advantage to the first example?


Also, since the first example does not have high input impedance, it can take significant current to drive. So, often a source follower is placed before the amplifier. For the second configuration, is there any reason why a source follower would ever be necessary?



Answer



The inverting configuration is capable of gains less that 1, and can be used as a mixer. Here is a good primer.



http://chrisgammell.com/2008/08/02/how-does-an-op-amp-work-part-1/


I don't know exactly why (anyone feel free to chime in), but the fact that negative feedback is holding the negative input terminal at 0v means that node is a proper place to sum currents, making the mixer circuit viable (although inverting). Op amps are also cheap and come in packages with more than one, so you can usually just invert something again if it's "upside down"


modulation - What is the basic difference between AM and FM radio?


I want to know the basic/fundamental difference between AM and FM radio. Why nowadays FM radio has replaced AM and has become more popular?



Answer



Short answer: FM is far less susceptible to disturbance of the signal.


enter image description here


This is an AM modulated signal. The contours are the baseband signal which we recover by demodulation. Notice that there's a spike in the signal, which may be caused by a thunderstorm for instance.


enter image description here


This is the demodulated signal. The demodulator doesn't "know" that the spike isn't actual part of the signal, so it can't remove it, and the listener will hear a tick in the symphony she's listening to.


FM has a constant amplitude, and the demodulator won't be fooled by spikes in amplitude since it will detect variations in frequency.



enter image description here


This is an FM signal. The baseband signal determines the change in frequency of the carrier. Notice that the spike doesn't change the frequency, so it won't be audible after demodulation.


terminology - What is the name of this springy type oscilloscope probe accessory?


Exactly what it says on the tin.


Oscilloscope probe with spring-type ground connector of unknown name


How is this pictured accessory called? The obvious place to look for a name would be the probe manual, but it looks like they decided to add the accessory to the package after making the manual, since it's not on the component list.



Answer



It's a "Probe tip ground clip" (or something very similar like the examples below)
An example of it being named as such is here. It's called "Probe tip ground" here. It is also called a "Probe tip spring adapter" here.
Whatever it's exact name, I think the main thing is to have "tip" in there, as it differentiates from the standard ground clip by implying the clip is used at the probe tip.


Basically, it's function is to shorten the ground lead, as this lowers inductance and enables higher frequency signals to be displayed accurately.
Try it with a very fast rising signal, and compare it to using the normal ground clip and you will see the difference. A common mistake is using the wrong setup to probe a signal and then assume the fault is with the signal, when it's really issues caused by the setup.



The way to use it is like the following picture, touch the ground wire to the IC ground pin, and the probe tip touches the pin you wish to probe:


Probe tip ground example


When designing your board, you can add dedicated test points to make getting to the signals easier. You can even add on board probe tip adapters (available from any decent distributor) if you have enough space.


For a detailed discussion of scope probes the Tektronix ABCs of Probes is good reading.
Here is a diagram from the above link showing the effects of different ground lead lengths on a fast rising signal:


Probe Ground Lead Length Effects


series charging three 18650 batteries with three chargers off the same 5V supply



being from a CS background I am a complete noob at this. I'll keep this short. I have a couple of 18650 batteries that i salvaged from an old laptop battery. I want to make a balanced 3S charger with over-discharge protection. I know that I could use a 3S BMS, but BMS aren't good at charging as they dont balance the cells properly.


I've seen many YouTube videos, regarding DIY balanced 18650 chargers and most of them uses this schematics enter image description here this works perfectly for charging only and also does the cell-balancing.



But i wish to obtain the output from the charging modules as they also features a over-discharge protection IC in them. And embedded them into a project, without any hassle.


So, the question: will this work? those are TP4056 with over-discharge protection.tp4056 balanced charger with over-discharge




Wednesday, 26 March 2014

electromagnetism - Constant current in a circuit?


schematic


simulate this circuit – Schematic created using CircuitLab


A battery pumps electrons by creating an electric field and converting electric potential energy to kinetic. Near the positive terminal the electrons have more kinetic energy so shouldn't the current be higher?


An analogy might clarify my question: If you drop a ball from a building, the ball will speed up as it reaches the ground because more potential energy has been converted to kinetic energy. Similarly, shouldn't the electrons move faster as they approach the positive terminal, since they have more kinetic energy? And consequently shouldn't the current be higher?



Answer



In electrical circuits velocity is pretty much the current (Coulombs/sec). Kinetic energy is proportional to velocity-squared (1/2*m*v^2), it means that if you have a constant current, you have on average a constant kinetic energy.


Therefore, since the entire wire is filled with electrons (virtually gapless); all the electrons must have the same velocity (same current), and so the kinetic energy is equal every where.


Analogy, where water molecules = electrons. You can see that the molecules at the start of the pump don't have a larger velocity (current). enter image description here



Another weaker analogy is that a train. Imagine the engine (battery) as the mechanism that applies the force (voltage/emf) to the rest of the carts (electrons). All the carts in the train will have the same velocity.


digital logic - XBee and PIR sensor


I've ordered XBee wireless transceiver and PIR (motion, here is link) sensor.


When I enable DIO0 digital input port on XBee with "ATD0 3" command it becomes high. I measure it with volmeter and get value of 3.3v. Same with PIR sensor, when motion is detected, output pin becomes high with same 3.3v, but when it becomes low it does not pull to the ground. How is it possible to get movement alert in such scheme?


Because when movement is detected, 3.3v on both sides gives nothing, same for state of rest, when 3.3v on XBee pin and ±0v (but not ground) on PIR sensor output pin could not be detected in Xbee.


On my Arduino I had no problems with that with simply plugging PIR output pin to Digital input port.


I'm a newbie in electronics, excuse me for such dumb question and my mistakes =)


Thanks!



Answer



You need an external pull-down resister.



It sounds like your sensor can only source current, it can't sink current. The sensor can't pull it low on its own, so need a pull-down resister to do that when the sensor isn't driving the pin. Many microcontrollers have internal pull-ups or pull-downs on their inputs. Unfortunately, assuming your XBee follows this datasheet, the XBee does not have an internal pull-up. In that case you'll need an external resister to act as a pull-down for you. If you include more details on how you are wiring this up, someone may have a suggestion for how to put a pull-down in place.


microcontroller - Communicating via USART with an AVR - Input Buffer?


I am currently building a robot (as some of you may know from my previous questions). The current task I a dealing with is that of communication. To keep things simple, assume I have 5 commands to deliver from my ground station to my robot:



  1. Drive forward

  2. Drive reverse

  3. Activate servo 1

  4. Activate servo 2

  5. Motor speed


Now, I am sending these commands from my computer to a USB to Serial adapter and then over an RF link. But this is not important, as far as I know, to my question.



So my question is, how does communication work in general? My idea is that I will have five different 8 bit data packets (one for each command) which I will continuously send from my computer. So I will keep an infinite loop going which will check, say, the position of an analog joystick. If it is pointing upward, command 1 will carry the drive forward message. If it is pointing downward, command 2 will carry the message, etc. Depending on how far the joystick is in the up/down position will dictate the contents of command 5. And the state of some keys on the keyboard will dictate whether commands 4 and 5 contain info to actuate servos.


So, again, I plan on having a continuous loop which will check each of the 5 states and send the appropriate commands over the USART from the computer's side.


The problem I am having, conceptually at least, is that what if there is a lag on the robot's end to process the data coming through the USART? As I understand, to ensure data isn't lost, the data is stored in a buffer on the MCU. Essentially, I want a "last in first out" system on my robot, so even if I miss the older commands for whatever reason, the robot is doing what I want it to do now, not what I wanted 2 seconds ago. But with this methodology, I'm also afraid that I will skip data packets of commands 1-4 because it will just keep reading the last data packet (i.e. command 5).


I came up with this communication "roadmap" on my own, so I'm sure there are much better ways to accomplish what I want. But I hope you understand what I mean. Also, I am using an ATmega328 on my robot, if it matters.


I would appreciate any advice pertaining to this situation.



Answer



What I usually do is I try to ensure that the controller doesn't send commands faster than the robot can process. Sending instructions consistently faster than can be processed by the robot will always eventually result in a loss of information with either a FIFO or a LIFO buffer. As a backup to intermittent lag on the robot I would use a small FIFO buffer. The exact size depends on what the trade-off between lost commands vs. responsiveness.


a LIFO buffer really doesn't make much sense in any case because you'll end up with an out of order operation in case the robot responds to commands slowly. consider the following:



  1. Send drive forward command


  2. Send Activate servo 1

  3. Send drive back command

  4. Send Activate servo 2


With a LIFO structure, say all the commands get sent before the robot gets time to process any commands. The commands are now going to be executed in reverse order! The robot will activate servo 2, drive back, activate servo 1, then drive forward. Most likely this is never what you want.


If you're only ever processing the latest instruction, then no additional buffer would be needed at all.


transistors - Why is there no Phase Shift in CC and CB Configuration


I am curious why in common base and common collector configurations there is no phase shift between output and input (at low frequencies, where stray capacitance doesn't "kick in" yet)?


I get it why there is a phase shift in common emitter configuration. If the signal at the base (input) is increased, then the collector current through collector resistor R also increases, which makes a larger voltage drop across it. According to formula \$V_{CE} = V_{CC} - Ic*Rc\$ it can be easily seen that \$V_{CE}\$ decreases as \$V_{RC}\$ increases - therefore 180° phase shift.


In case of common base, as the signal at the emitter (input) increases, \$Vc\$ also increases as \$Vc = V_{CE} + V_{RE}\$. \$V_{CE}\$ increases as input signal is increased. But shouldn't it decrease just like it does in CE configuration? Why does collector current increase with increase of emitter current anyway?


CB configuration is more logical to me (regarding phase shift), since output is taken from emitter, which just follows the base (input).



I am not certain if I understand phase shift of any of above configurations at all. Sources always say that there is or there isn't any phase shift in certain configuration, but they never say why is it the way is it - the explanation behind that fact. And that is what I would like to know.



Answer



Common Collector


The common collector configuration is also sometimes called an emitter-follower. You find it almost anywhere there is a need to boost current compliance. For example, perhaps the most common use is for a very simple voltage regulator:


schematic


simulate this circuit – Schematic created using CircuitLab


Here, \$R_1\$ and zener \$D_1\$ set up a voltage that is about one diode-drop above the desired regulated voltage. \$Q_1\$'s emitter simply follows the base voltage, except one diode-drop below it. It draws current from its collector, as needed, and substantially boosts the compliance current range of the regulated output voltage.


Note that if the zener voltage were higher, then the emitter output would also be higher. The emitter follows its base and is "in phase" with it. If the base voltage were to vary up and down, the emitter would simply follow it. So the output voltage, which is at the emitter, is in phase (not out of phase) with its base voltage. It simply follows it.


I expect this isn't confusing. But since you are discussing everything except the common-emitter situation, then perhaps this is worth discussing here.


Common Base



The common base configuration isn't used often "at low frequencies, where stray capacitance doesn't "kick in" yet." It is more commonly used at RF. But when it is used at low frequencies, this is usually in circumstances as either a cascode or as a low-impedance input where that is appropriate (current signaling instead of voltage signaling.) I'm not going to discuss every possible way of looking at it. But here's a simplified version of one I've discussed elsewhere here:


schematic


simulate this circuit


This is a sink/source output driver that will convert an I/O pin's output voltage (which is assumed to be based upon a \$5\:\text{V}\$ power supply rail and drives IN) into a \$150\:\text{V}\$ output capable of sinking and sourcing current. The output does invert the input signal. But it does so using a common base BJT (\$Q_3\$) that does things "in phase" with the input.


(It's not a crafted design. It has a number of problems that would require additional components in any realistic use. It's purpose is to keep close to the minimum requirements for illustration purposes.)


Take a close look. When the I/O pin goes LOW, this pulls down on \$R_2\$ and \$R_3\$. pulling down on \$R_3\$ turns off \$Q_2\$, of course. But it creates an emitter current in \$Q_3\$, via \$R_2\$. This current is passed along to the collector, which causes a voltage drop across \$R_1\$. So when the signal "pulls down" on the emitter, via \$R_2\$, this causes the collector to also be "driven downward." Note here that the input signal moved "downward" and that the collector of \$Q_3\$ also goes "downward" in response. This is "in phase" and not "out of phase." With this emitter current being translated into collector current, via \$Q_3\$, there is now current to feed the base of \$Q_1\$, which becomes active and pulls the output to its supply rail of \$150\:\text{V}\$. Similarly, when the I/O pin goes HIGH (or close to \$5\:\text{V}\$) then \$Q_3\$ is off (the base voltage and the emitter voltage are nearly the same) and then \$R_1\$ pulls \$Q_3\$'s collector towards the \$150\:\text{V}\$ rail causing \$Q_1\$ to go off. But, of course, this also supplies base current into \$Q_2\$ (via \$R_3\$) and turns it on, pulling the output LOW.


Above Common Base Example Explored


The above common base schematic doesn't have part values and I didn't show it "in action." I just discussed it, a little. And perhaps I wasn't concrete enough to make the point well. So I'll expand that discussion by providing a simulation using LTspice and then I'll point to the generated output results to clarify my earlier points.


First, the schematic I used for simulation purposes. (I'm using BJTs with a high breakdown voltage.)


common base circuit



Note that I've added a small-valued resistor as the "series resistance" of some MCU I/O pin. (It doesn't affect the results. But it adds a tiny bit of realism.) That said, the above schematic again is NOT a practical one. It is pretty obvious that I didn't do much thinking about the resistor values, for example. And that's only the beginning of its problems.


So please don't imagine that this is useful. It's only purpose is for illustration.


Let's now look at the emitter voltage and the collector voltage of \$Q_3\$:


emitter and collector voltages


It is obvious, on its face, that these two signals (the emitter voltage and the collector voltage of \$Q_3\$) are in phase with each other. It would be difficult to argue otherwise.


In case you are curious, let's also take a look at the input voltage and the output voltage of the entire circuit:


enter image description here


You can see that the output inverts the sense of the input. But this is the entire circuit, which just happens to use a common base BJT within it.


The common base BJT itself? In the earlier graphic you can see that the input signal at its emitter is "in phase" with the output signal at its collector. No question of it.


Summary



These are just two examples to make the case. You can compose many others. The results will be similar.


You need to be flexible in how you see things. In the common-emitter case, for example, where you seem to already understand that the signal is inverted, there is another way to "see it." When the signal at the base of a CE amplifier is pulled up, this also pulls up on the emitter. The emitter follows the base. So does that mean the CE arrangement is really just an "emitter follower?" No. Not really. Yes, the emitter does follow the base (that is always the case when you apply a signal to the base.) But here, the output signal is taken from the collector. And when the emitter follows the base (up or down), this generates an emitter current that is "in phase" with the base signal. However, since this current then is applied to the collector load resistor and the output is taken directly from the collector, it follows that the collector load resistor drops more voltage with an increasing emitter current. So the collector is \$180^\circ\$ out of phase, as the increasing emitter current causes a decreasing collector voltage because of the increasing collector resistor voltage drop.


In the common base case, the signal is applied to the emitter and the collector is the output. I've provided a sample schematic to show what happens where. Pulling down on the emitter (via a resistor) causes the emitter current to increase and thereby causes the collector voltage to decrease (just as in the CE arrangement.) But here, since the input signal goes downward to create an increasing voltage drop across the collector load, causing the collector voltage itself to go downward too, then this is a case where the collector voltage "follows" the emitter voltage. So it's "in phase."


In the common collector case, the emitter simply follows the base in a still more obvious way. Clearly, in this case the signal at the base is replicated at the emitter, but with increased current compliance. But again, "in phase."


Note that even the CE case has an "emitter follower" perspective. The point here is that the BJT is just a BJT. It does what it always does. The reason for the different "perspectives" is mostly so that you can pick out the primary (1st order) behavior that's important. In reality? The BJT has no clue by itself. It's just a BJT in a circuit. It has no clue what's going on. It just "behaves" like a BJT. It doesn't know anything about where the "common" lead is at. So you can take a circuit described as common-emitter and look at it from a perspective of common-collector (or emitter-follower) for a moment, while looking at the emitter behavior for a moment before looking at the collector behavior. It's all a matter of perspective.


Neil, I see, wrote a comment to you that makes sense to me. He wrote:



Get a transistor, power supply, resistors, DMM and find out what happens.



How true that is. This leads me to a bit of a long discourse that most are going to want to ignore. But here it is, anyway:



tl;dr Postscript


I've always had a great difficulty in just remembering arbitrary rules. It was hard for me to just memorize mathematical conclusions, for example. I had to be able to see how they worked in order to retain them well. Not just be told that they worked. I don't learn by parroting back what people say. I learn by thinking about what they say and making sense in my own mind about it, where possible.


It's one of the reasons I strongly supported the International Astronomical Union's decision in 2006 to reclassify Pluto as a dwarf planet. The trigger of this change was Eris, discovered in 2005, which was 25% more massive than Pluto. But the real problem had been around for a long time before. Scientists didn't actually have a widely accepted or clear definition of what a planet actually is or should be. And the prior 15 years' improvements in solar system models, plus the discovery of Eris, made this lack of clarity manifest.


Stern & Levison 2002, Mohanty & Jayawardhana 2006, and Basri & Brown 2006 provided theoretical and empirical results which let us take note that nature itself provided a clear separation of nearly six orders of magnitude difference between the other eight planets in our system and Pluto. Pluto really belonged in a class that included Erin and did not include Mercury or Jupiter.


When nature shows you a distinction like that, you don't hold onto old, muddled ideas which confuse rather than enlighten.


There's another great story to be found in Jagdish Mehra's biography of Richard Feynman, "The beat of a different drum."



In the summer the Feynmans would take their vacations in the Catskill mountains. There would be a large group of people there, but the fathers would all go back to New York to work during the week and only come back again over the weekend. 'On weekends, when my father came,' recalled Richard, 'he would take me for walks in the woods. When the other mothers saw this, they thought it was wonderful and that the other fathers should take their sons for walks. They tried to work on them but they did not get anywhere, at first. They wanted my father to take all the kids, but he didn't want to because he had a special relationship with me. So it ended up that the other fathers had to take their children for walks the next weekend.


'The next Monday, when the fathers were back at work, we kids were playing in a field. One kid said to me, "See that bird? What kind of bird is that?" I said, "I haven't the slightest idea what kind of bird it is." He says, "It's a brown-throated thrush. Your father does not teach you anything!"


'But it was the opposite. He had already taught me: "See that bird? It's a Spencer's warbler." (I knew he didn't know the real name.) "well, in Italian it's Chutto Lapittida. In Portuguese, it is Bom da Peida. In Chinese, it's Chung-long-tah, and in Japanese it is Katano Tekeda. You can know the name of that bird in all the languages in the world, but when you are finished, you'll know absolutely nothing whatever about the world. You'll know about the humans in different places, and what they call the bird. So let's look at the bird and see what it is doing -- that's what counts." I learned very early from my father the difference between knowing the name of something and knowing something.'



Feynman explained, 'My father understood that knowledge was different from the names of things. The names of things are only a convention that human beings use to discuss things, and of course that is important. But when he would tell me about looking at the birds, it was not just to look at them but to see what they were doing. As an example, he said, "Look, see the birds walking around there. They seem to be pecking their feathers all the time. Why do you think they do that?" And I said, "Well, I don't know." I was a kid of ten or eleven. I said, "Maybe their feathers get ruffled when they are flying." I made an attempt at an explanation. He then said, "If that were the case, they would peck more when they just landed after they flew. And after they got straightened out, walking around, they wouldn't peck so much. So let's see, watch those that land and then see how long they go on pecking and whether or not they peck in their feathers at the same rate." After a while we discovered that indeed they did. So it was not due to a need to straighten out their feathers just after flying. You see, he had made a little experiment, learning how to observe and discuss.'



The point of all this is, "Don't memorize and parrot conclusions others reached.' Listen, but then observe and learn and see how things work. Propose for yourself new ways to think about why those things act that way and test out those new ways, to see if they continue to work well. Learn to think for yourself.


Anyone can parrot. Even a 3 year old can.


Neil's advice is good. Set down, do, observe, think. Don't take rules handed down from on high, as gospel. Work out the details on your own. Think about them. Make your own sense of the world.


A BJT is just a BJT. We humans like to imagine that it is in CE, CB, or CC arrangement. It helps us to orient ourselves when examining a circuit. But the BJT itself? It just sits there and responds. It doesn't know what surrounds it. It just is. The terms are there for you and me and for others to help us communicate. But don't get mired in words. Learn behavior through observation. Make up your own ideas about what you observe. You can later learn to associate behaviors with the words people assign to them.


Tuesday, 25 March 2014

Using parallel capacitor-diode pairs to limit current in an AC circuit


I want to limit current from an AC source using capacitors. As I am using dielectric (polar) capacitors, I thought I could use 2 capacitors with opposite polarity in parallel with a diode in front of each capacitor to protect it from reverse bias damage (see circuit diagram for clarification). My thinking was that every time the source's polarity switches, the current will go through a different capacitor-diode pair, always with the capacitor's reactance limiting the source's current.



When attempting to do this in practice, no current moves at all, so I must be misunderstanding something very important. Would any kind sage be interested in pointing out my error? I'm a physicist who likes to tinker, so if this is something embarrassingly stupid, that I should have learned in AC 101, I apologize. Circuit Diagram


I'm mostly interested in understanding the general idea of why this won't work, but if you'd like details, the AC source is mains (120VAC, 60Hz), the capacitors are 22uF, 400V, the diodes are 5A, 1000V rated.



Answer




I'm mostly interested in understanding the general idea of why this won't work ...



Because there is no discharge path once the capacitors are charged.


schematic


simulate this circuit – Schematic created using CircuitLab


Figure 1. Rearranging the diodes provides a discharge path for the capacitors and reverse polarity protection.



How it works:



  • When L goes positive D1 is reverse biased and C1 charges. D2 prevents C2 being charged more than 0.7 to 1.0 V reverse.

  • When L goes negative the reverse happens.


The effective capacitance will be the value of one of the capacitors since only one is in use at any time.


I used this arrangement almost 40 years ago to replace a failed starting capacitor on a family friend's 230 V well pump. (It died on a Friday evening on a bank-holiday weekend. How do capacitors know what day it is?) I used a couple of valve amplifier capacitors and suitable diodes. It worked but I was concerned about the long-term reliability due to the small reverse bias on each cycle so I replaced it with an unpolarised capacitor as soon as possible.




Update after comments.


schematic



simulate this circuit


Figure 2. Original redrawn with GND applied between the two capacitors to assist in visualisation with the simulation.


enter image description here


Figure 3. Results of simulation of Figure 2 when V1 is set to 100 Vp-p.


Oscilloscope probe compabitibility


I bought a very old Philips oscilloscope some time ago (see my post. This is a Philips PM 3253). Although this Philips really has a lot of features, I cannot really use it well, since I cannot do good readings below 1 MHz because of the bad screen (focus problems, lines stay very long on the screen, or the signals are 'clipped').


Now I saw another one at a local 2nd hand site: Metrix OX8050


I was wondering if the probes between these two scopes (or actually in general in case this one is already sold) are interchangeable.



Answer



Basic probes generally are interchangeable


Basic probes means probes with BNC connectors. Specialist probes, with extra pins and built-in amplifiers (such as differential probes or current probes) are generally not compatible with other brands of scope.


One thing to watch for is the input capacitance of the scope. Capacitance can vary between typically 10 and 15pF. Decent quality probes are adjustable, but not all of them can adjust far enough for all scopes. If you don't get them adjusted right, high frequencies will be distorted, and square waves may be slightly rounded or may ring.


Monday, 24 March 2014

How do flyback diodes (on an H-bridge) affect the motion of the motor?


I'm designing an H-bridge and one of the features I'd like to have is to allow the motor to keep it's momentum even when the H-bridge is off.


Obviously flyback diodes are used in H-bridge designs to allow the coils to discharge. I feel like I don't have a very intuitive understanding of this concept, but my hypothesis is that this will cause the motor to stop spinning (or at least slow down a bit until the voltage on one of the motor's terminals is no greater than the power supply +0.7V). Is this correct? What does this mean from a mechanical perspective?




arduino - How can I get my atmega328 to run for a year on batteries?


Scenario


I have created a nice electronic door lock for my dorm room. It is currently an Arduino Diecimila with a servo [un]locking the door. It has a numerical keypad with 3x4 buttons and 5 LED's (2 serie pairs and one single LED). It also currently runs on a cellphone charger.


I have now redesigned it to run on a standalone Arduino (ATmega328), but would really like to have it run on AA batteries or even a 9V battery.


For the software part, I figured I could put sleep calls for certain times inside the loop method to keep the ATmega power consumption as low as possible. And let the LED's "flash" with as long as possible time off.


Question 1


When a button is pressed during the few milliseconds which the board sleeps, will it be "remembered"/"held" until it comes out of sleep and then be picked up as a button press?


What would be the best way to handle this button press on sleep? Can I code it to wake up upon button activity, or must I just let it sleep for e.g. 10m.s. in every loop?



Question 2


How would I approach the math of calculating how many AA batteries are needed to run this device for 10 months?


Also, I don't know how to measure the average power usage per minute or so, since it alternates quickly etc.


The Device


My door lock device



Answer



The Atmega328 provides six power saving modes, ordered from minimal to excellent (estimated current consumptions from this forum post):



  • SLEEP_MODE_IDLE: 15 mA

  • SLEEP_MODE_ADC: 6.5 mA


  • SLEEP_MODE_PWR_SAVE: 1.62 mA

  • SLEEP_MODE_EXT_STANDBY: 1.62 mA

  • SLEEP_MODE_STANDBY : 0.84 mA

  • SLEEP_MODE_PWR_DOWN : 0.36 mA


Quoting the original question:



I figured I could put sleep calls for certain times inside the loop method"



You would need to use sleep_cpu() after setting up the sleep mode you require, from the list above. The Arduino Playground has a useful post about this.



The application needs to be interrupt driven, use the above sleep modes extensively, and wake the processor up on button push, timer overflow and watchdog timer events to actually execute tasks.


Additional power savings can be obtained through the following steps:



  • Use the microcontroller's internal oscillator and a low clock rate (8MHz instead of 16) - but ensure that time and timing related code still works as expected. A different version of the bootloader might be needed for this.

  • Avoid keeping LEDs on for long if the application uses them. Using a rapid double or triple flash of short duration (0.05 second on, 0.5 second off), with gaps of seconds in between, ensures noticeable indication with minimal power consumption

  • Use a switching regulator instead of a linear one, if a regulator is required.

  • Run the microcontroller at lower voltage if supported, 3.0 Volts (e.g. CR2032 Lithium cell, no regulator needed) or 3.3 Volts instead of 5 Volts.

  • Follow recommendations in the datasheet for unused input and output pin settings for minimum power wastage.


Incorporating these suggestions allows for running microcontroller applications for weeks or months on a single CR2032 coin cell, and years on a LR123 type lithium cell. Of course, your mileage may vary depending on what sensors, outputs and actual processing your application requires.



Some useful references:



20v solar panel powering two 12v fans and a 6v pump (swamp cooler for burning man)


Building a solar swamp cooler for burning man, how can I use a 20v 0.8a (in full sun) 15watt solar panel to power TWO 12v 0.4a fans, AND a 6v 0.1a water pump?


One of the fans and the water pump have their own mini solar panels (that don't work very well), any way I can connect the solar panels in series?


What components would I need (and where would I get them) to make this work? This apparatus would ideally function only in full sun (in a remote Nevada desert)


Sorry, I'm a newb at this, and thanks for any insights!




Sunday, 23 March 2014

sensor - What's the cheapest way to detect vibration with Arduino?


What's the cheapest way to detect vibration with Arduino?


What's the vibration sensor that I need?


I want to detect PING PONG NET vibration and light on led if touched.



Answer



Piezo sensors are cheap, reliable and designed for the purpose you suggest - arduino tutorial



In the uk, bitsbox has one for 75p. You can probably find others cheaper, or salvage from electronic toys.


EDIT following poster's clarification of use: Sound is vibration through the air, I see no reason why a piezo sensor cannot accomplish what you suggest, but the form factor may not be ideal for fixing to ping pong nets! I think a flex sensor would be more suitable, sewn into the top of the net.


batteries - Is it safe to run and charge a deep cycle battery in an enclosed space like a bedroom?



I'd like to experiment with running a small server (5.5 watts) / 85AH deep cycle battery / charged via 30 watt solar panel from my bedroom.


I generally keep the window open, but want to make sure it's relatively safe for me to keep the battery inside and out of the sun. I hear the recharge process can release fumes which, if concentrated in a small area, can be toxic, but want to know if discharging also creates fumes and, in either case, if keeping the window open is preventative enough to prevent a build up.


Thanks for your response.



Answer



Not "safe" without extra care. Death unlikely but likely possible if you "just do it".


Can be made "safe"


Discharge will not release 'fumes' in general use.


Risk from "gassing" (Gargoyle knows) can be kept small but not zero when charging with a panel of that relative size. ie 12v say & 30 Watt = 2.5A. 24V = 1.25 A. + say 3% and 1.5% ~ of bat 1 hour rate.


Small but non zero chance of Hydrogen and sulphuric acid fumes if battery not designed to vent unless 100% sealed with full recombination control. Ventilation would be an extremely good idea.


More if required ...



Long long long ago I charged a truck battery at a moderately high rate in a small closed room where I was sleeping :-). Took many weeks for my throat and nasal linings to "recover".




Data point: Just came across this [here](http://www.vonwentzel.net/Battery/00.Glossary/ ) while looking for something else:




  • Gassing: This is a very dangerous condition that can occur if batteries are charged too fast. One of the byproducts of Gassing are Oxygen and Hydrogen. As the battery heats up, the gassing rate increases as well and it becomes increasingly likely that the Hydrogen around it will explode.
    The danger posed by high Hydrogen concentrations is one of the reasons that the American Boat and Yachting Council (ABYC) requires that batteries be installed in separate, well-ventilated areas.




  • " ... As the battery heats up, the gassing rate increases as well and it becomes increasingly likely that the Hydrogen around it will explode. The danger posed by high Hydrogen concentrations is one of the reasons that the American Boat and Yachting Council (ABYC) requires that batteries be installed in separate, well-ventilated areas." | From here | And ABYC site here





American boat and Yachting council website here
http://www.abycinc.org/


No open access data available on AYBC site - you have to be a member to read about how to be safe.


automotive - What is the polarity of a car cigarette lighter adapter?


There is a center pin, and two outside tabs. Which are positive and negative?



Answer



Every car that I have seen had center-positive cigarette lighter 'sockets'.


All (as far as I know) modern cars use negative ground systems, so the outer negative 'body' is vehicle ground and positive center is battery


You would expect this polarity to be maintained even with positive ground vehicles made by any sane manufacturer (and most insane ones as well).


AFAIR some old British Vehicles and Volkswagens had positive ground systems. No doubt there were others.


Saturday, 22 March 2014

diodes - Lithium ion battery charging problem




I am making a rechargeable led light My power source is mobile litium ion battery, (3.7)v 1800mah Whenever is use to chrge this battery with the mobile charger 5v... The diode in4007 connected to the positive terminal of the battery its get as heated that it can melt the soldering... I don't know why it's happening I have changed several diode & the same problem is repeating time & again.... And one thing I have noticed that when I have connected a 2ohm resistor in the series the diode temperature is constant & when without of resistor it's get melt... Why it is happening plzz anyone reading this then plzz ans ur opinion One more thing when the battery gets charged more then half then while chrging that battery with the only single diode without resistor in series the the battery charges properly & the diode temperature also be in constant... Ans plzz guys




avr - Why would the VCC/GND pins of an ATtiny26 not be aligned?


In the following pinout diagram for an ATtiny26 microcontroller, a 20-pin IC:


ATTINY26 pinout diagram


The VCC/AVCC and GND pins aren't aligned. Surely it would be easier for PCB design to connect these by going straight across rather than having to cross (requiring vias, a second layer, or complex routing).


Why would these pins be switched as so?



Answer



One very good reason, as I learned myself from a recent prototype, is reversing the physical layout of the IC in a circuit.


I plugged a through-hole version of this microcontroller into a socket backwards, and spent about an hour with an oscilloscope trying to determine why pins were not behaving as expected.



When I discovered the IC was in backwards (and recovered from the desire to shoot myself), I realized I was thankful that a polarity reversal hadn't rendered the IC useless. With the pins backwards in this arrangement, the chip actually receives VCC and GND correctly in both directions.


In IC's with VCC on pin 1, and GND on the opposite corner, they heat up and generally fail very quickly when inserted backwards.


amperage - Designing ammeter for an external ATX power supply adapter


I'm trying to design and build an external ATX power supply adapter, much like this one. I want to use it as a benchtop power supply. I wanted my adapter to have one more feature: I wanted it to have a voltmeter and an ammeter at each positive rail (+12V and +5V). I'm planning on having an ATmega328P do the voltage readings and display them in a common 16x2 LCD.


Here's where my problems begin. I'm having trouble designing the ammeters. My first attempt at it was the schematics below.


My attempt at an ammeter and voltmeter for ATX power supply adapter


The idea behind the schematics is that I'll read voltages in ports A0 and A2 to determine voltages of +12V and +5V rails, respectively, using ATmega328P ADC. There I would have my voltmeters, no problem. The voltage dividers in each circuit are there to bring voltages to the ADC's 5V limit.


To determine currents for the +12V and +5V rails, I would calculate the differences A1 - A0 and A3 - A2, assuming I'll be using 0R1 (0.1 ohm) 5W shunt resistors.



The shunts I'm planning to use yield 100mV/A. I plan on making readings well below 7A to respect the 5W spec on the resistors.


The problem is that I'm not comfortable having to make two readings to get the currents. I would much rather have the shunt connected to ground and then make a single voltage reading at its other end using the ATmega's 1.1V internal analog reference. That would give me the accuracy I want, all the way to about 6A. But then I don't know how to design such circuit so that all current that goes to each rail gets measured.


So, my question is: Is this design going to work? I'm afraid I won't have enough accuracy, especially because I'm depending on two readings to calculate current. Will the stacked up errors be too much?


Another related question: is there a better way to measure the current of each rail?



Answer



A single-ended reading from the perspective of your micro is the way to go. Use an accurate analog circuit to compute the difference and quantize that difference with a single ADC channel to get your reading.


I suggest using a smaller shunt (something that will produce 10mV at your maximum load) and a part from the INA210 family - these parts are highly accurate and work in both the high-side and low-side.


enter image description here


If you don't end up with the exact gain you want, you can simply voltage-divide the output of the INA21x and feed that into your ADC input.


A confusion about radial schemes in power distribution


My lecture notes about distribution systems/radial schemes say the following:


•In this scheme, feeders radiate from a substation in all directions and feed distributors at one end only.


• SA is the feeder which feeds the distributor BC at its end B.


The lecture includes the following picture of a radial scheme:


enter image description here


Question: How does this form a complete circuit ? Put differently, the service lines are not part of a circuit as far as I can see.




differential - Difference between natural response and forced response?


Reference


Second post on EdaBoard.com



Time response of a system is the time evolution of the variables. In circuits, this would be the waveforms of voltage and current versus time.


Natural response is the system's response to initial conditions with all external forces set to zero. In circuits, this would be the response of the circuit with initial conditions (initial currents on inductors and initial voltage on capacitors for example) with all the independent voltages set to zero volts (short circuit) and current sources set to zero amps (open circuit). The natural response of the circuit will be dictated by the time constants of the circuit and in general roots of the characteristics equation (poles).


Forced response is the system's response to an external stimulus with zero initial conditions. In circuits, this would just be the response of the circuit to external voltage and current source forcing function... continue reading



Questions





  1. How can there be even a natural response? Something has to be inputted to create an output? The way I see it is like turning of the main water line and then turning on your faucet and expecting water to come out.




  2. How can we v(t) (from the link above) be solved for if we don't know dv(dt) in order to find the natural response?




  3. If you can please expand on the 2 concepts (natural response and forced response) by explaining their differences in Layman's terms, it would be lovely.







@Felipe_Ribas Can you please confirm this and answer some of the questions? (you can just edit this directly if you want)

  1. Given an an equation 10dy/dt + 24y = 48 means rate of change of output + 24 * output = 48. The initial conditions are y(0)=5 and dy/dt=0.

    • That would mean that the input is 48/(24*5) Is that a correct assumption? The solution to that is 0.4 which is the constant input?






Answer



Think about a simple mechanical system like an elastic bar or a block attached to a spring against gravity, in real world. Whenever you give the system a pulse (to the block or to the bar), they will begin an oscillation and soon they will stop moving.


There are ways that you can analyze a system like this. The two most common ways are:




  1. Complete solution = homogeneous solution + particular solution




  2. Complete response = Natural resopnse (zero input) + forced response (zero state)





As the system is the same, both should result the same final equation representing the same behavior. But you can separate them to better understand what each part means physically (specially the second method).


In the first method, you think more from the point of view of a LTI system or a mathematical equation (differential equation) where you can find its homogeneous solution and then its particular solution. The homogeneous solution can be viewed as a transient response of your system to that input (plus its initial conditions) and the particular solution can be viewed as the permanent state of your system after/with that input.


The second method is more intuitive: natural response means what is the system response to its initial condition. And forced response is what is the system response to that given input but with no initial conditions. Thinking in terms of that bar or block example I gave, you can imagine that at some point you pushed the bar with your hands and you are holding it there. This can be your initial state. If you just let it go, it will oscillate and then stop. This is the natural response of your system to that condition.


Also you can let it go but still keeps giving some extra energy to the system by hitting it repeatedly. The system will have its natural response as before but will also show some extra behavior due to your extra hits. When you find your system complete response by the second method, you can see clearly what is the system natural behavior due to those initial conditions and what is the system response if it had only the input (with no initial conditions). They both together will represent all the system's behavior.


And note that the Zero State response (Forced response) also may consist of a "natural" portion and a "particular" portion. That is because even with no initial conditions, if you give an input to the system, it will have a transient response + permanent state response.




Example response: imagine that your equation represent the following circuit:


RL Circuit


Which your output y(t) is the circuit current. And imagine your source is a DC source of +48v. This way, making the summation of element's voltage in this closed path, you get:



\$\epsilon=V_L+V_R\$


We can rewrite the inductor voltage and resistor voltage in terms of current:


\$\epsilon=L\frac{di}{dt} + Ri\$


If we have a power source of +48VDC and L = 10H and R = 24Ohms, then:


\$48=10\frac{di}{dt}+24i\$


which is exaclty the equation you used. So, clrearly your input to the system (RL circuit) is your power supply of +48v only. So your input = 48.


The initial conditions you have are y(0) = 5 and y'(0) = 0. Physically it represents that at a t=0 moment, my current of the circuit is 5A but it is not varying. You may think that something happened previously in the circuit which left a current in the inductor of 5A. So in that given moment (initial moment) it sill has those 5A (y(0)=5) but it is not increasing or decreasing (y'(0) = 0).


Solving it:


we first assume the natural response in the format: \$Ae^{st}\$


and then we will find the system behavior due to its initial condition, just as if we had no power supply (\$\epsilon=0\$) which is the Zero-Input response:



\$10sAe^{st} + 24Ae^{st} = 0\$


\$Ae^{st}(10s + 24)=0\$


\$s=-2,4\$


So,


\$i_{ZI}(t)=Ae^{-2,4t}\$


Since we know that i(0) = 5:


\$i(0)=5=Ae^{-2,4 . 0}\$


\$A=5\$


\$i_{ZI}(t)=5e^{-2,4t}\$


Note that until now everything is consistent. This last equation represents the system response with no input. If I put t=0, I find i=5 which correspond to the initial condition. And if I put \$t=+\infty\$ I will find i=0 which also makes sense if I do not have any source.



Now we may find the particular solution to the equation which will represent the permanent state due to the power supply presence (input):


we assume now that \$i(t)=c\$ where \$c\$ is a constant value which represents the system output in the permanent state since the input is also a constant. For each system, the output format depends on the input format: if the input is a sinusoidal signal, the output also will be. In this case we have only constant values which makes things easier.


So,


\$\frac{di}{dt}=0\$


then,


\$48 = 0.10 + 24c\$ (using the differential equation)


\$c=2\$


\$i(\infty)=2\$


which also makes sense because we have a DC power supply. So after the transient response of turning the DC power supply ON, the inductor will behave as a wire and we will have a resistive circuit with R=24Ohms. Then we should have 2A of current since the power supply has 48V accross it.


But note that if I just add both results to find the complete response, we will have:



\$i(t) = 2 + 5e^{-2,4t}\$


Now I messed things up in the transient state because if I put t=0 we no longer will find i=5 as before. And we have to find i=5 when t=0 because it is a given initial condition. This is because the Zero-State response has a natural term which is not there and also has the same format as we found before. Adding it there:


\$i(t) = 2 + 5e^{-2,4t} + Be^{st}\$


The time constant is the same so it only left us B:


\$i(t) = 2 + 5e^{-2,4t} + Be^{-2,4t}\$


And we know that:


\$i(t) = 2 + 5 + B = 5\$ (t=0)


So,


\$B=-2\$


Then, your complete solution is:



\$i(t) = 2 + 5e^{-2,4t} - 2e^{-2,4t}\$


you may think of this last term we find as a correction term of the forced response to match the initial conditions. Another way to find it is imagining the same system but no with no initial conditions. Then solving all the way again, we would have:


\$i_{ZS}(t) = 2 + Ae^{-2,4t}\$


But as we now are not considering the initial conditions (i(0)=0), then:


\$i_{ZS}(t) = 2 + Ae^{-2,4t} = 0\$


And when t=0:


\$A=-2\$


so the forced (Zero-State) response of your system is:


\$i_{ZS}(t) = 2 - 2e^{-2,4t}\$


It is a bit confusing but now you can view things from different perspectives.



-Homogeneous/Particular solutions:


\$i(t) = i_p(t)+i_n(t) = 2 + 3e^{-2,4t}\$


The first term (2) is the particular solution and represents the permanent state. The rest of the right side is the transient response, also called homogeneous solution of the equation. Some books call this also Natural response and Forced response since the first part is the forced part (due to the power supply) and the second part is the transient or natural part (system's characteristic). This is the fastest way to find the complete response I think, because you only have to find the permanent state and a natural response once. But may not be clear what is representing what.


-Zero input / zero state:


\$i(t) = i_{ZS}(t)+i_{ZI}(t) = 2 - 2e^{-2,4t} + 5e^{-2,4t}\$


note that is the same equation but the second term is splitted in two. Now, the first two terms (\$2 - 2e^{-2,4t}\$) represent the Zero-State response. In other words, what would happen to the system if there was no initial current and you turned ON the +48V power source.


The second part (\$5e^{-2,4t}\$) represent the Zero-Input response. It shows you what would happen to the system if no input was given (power source remained in 0v). It is only an exponential term which would go to zero since it has no input.


Some people also call this Natural/Forced response format. The natural part would be Zero-Input and the Forced part would be the Zero-State, which by the way is composed by a natural term and particular term.


Again, they all will give you the same result which represents the whole situation behavior including the power source and initial conditions. Just note that in some cases it might be useful to use the second method. One good example is when you are using convolutions and you may find the impulse response to your system with Zero-State. So breaking those terms might help you to see things clearly and also using an adequate term to convolve.


Friday, 21 March 2014

microcontroller - How to make an entire (irregular) surface sense touch with a capacitive sensor?


I'm looking for a way to make a surface touch sensitive. The sensors have to interface with a keyboard encoder to send signals to the computer as keypresses. This is just the way it has to operate. I have capacitive proximity sensors, but I'm thinking they will not be capable of extending their field to an entire (and irregularly shaped) surface. Is there some kind of capacitive switch that can be used with a foil-like material or fabric-like material that could be glued to the inside of an object, thus making the outside touch sensitive?



Answer



Usually you would etch the capacitive switches onto a PCB, but with an irregular surface some aluminium foil glued to the back of the surface (with wire from foil to capacitive sensing circuit) should work fine.
The larger the area and the thinner the insulating surface material the better.


A uC like the PIC16F1828 would be good for this application, they have a capacitive sensing peripheral with something like 8 (maybe more) channels.


shielding - Connecting the Shield of a strain gage cable connector to PCB with ADC


I have a half-bridge strain gage sensor (pre-assembled product) with a 30cm cable, which I am trying to interface with my PCB containing a 24-bit ADC.


The connector at the cable end toward the ADC (i.e., the end away from the strain gage) has the following four pins, based on my reading of the resistances:



  • Pin 1: V_Excitation

  • Pin 2: Doesn't seem to be connected to anything

  • Pin 3: V_signal

  • Pin 4: Ground


All good so far.



However, in addition, there is the metallic shield constituting the body of the connector.


Being new to strain gages and ADC measurements, I am unsure of the shield's significance -- I presume it has something to do with minimizing interference-based offsets. (Also, I don't want to break open the cable to see what's inside but I'm guessing it is a standard twisted-pair cable.)


Question A: What role exactly does the shield play in a strain gage / ADC application?


Question B: And thus which of the following is good practice to follow with the shield? :



  1. Just isolate shield from GND (i.e., leave shield alone) ?

  2. Or connect shield directly to the Ground plane on my ADC pcb ?

  3. Or place 4.7 nF Capacitor and 1M resistor between shield and Ground, as suggested for USB connector shield in this question ?

  4. Or connect shield to metal chassis of my enclosure only, as suggested in this question ?




Answer



As a general guideline, it is preferable to connect any cable shields to the metal chassis (not PCB ground), at just one end. To keep things simple when multiple shielded cables connect out from some central device, the shield connection should be done only at the "hub" device, and left open at the "spoke" devices.


Similarly, for a chain of devices connected by shielded cable, each shield ought to be connected to the chassis of the upstream device, and left open at the downstream end. Yes, this does mean that the shields of different links of such a chain might be at different potentials, depending on how well earthed the individual devices are, but this is generally not a problem.


A basic, inexpensive addition incorporated in many consumer device cables today, is a clamp-on ferrite bead or "split bead" at each end of the cable, close to the connector. This reduces high frequency EMI off the shield with minimal complexity. A good document about such RFI beads is here.


Note that the chassis is usually connected to "earth" of the location, not to ground of your circuit board.


Of course, this is a simplification of a fairly complex subject, but it serves the purpose for designs at frequencies where surface effects do not predominate. As frequency of signals involved rises into GHz, other factors need addressing.


pcb - What is the usage of Zero Ohm & MiliOhm Resistor?


I am new to PCB design and I noticed that some schematics use 0Ω or 100mΩ resistors. What is their purpose and why do we need to use them in our PCB design?


Normally if we wish to probe how much current the load is taking, we put a jumper pin across the PCB trace (then measure current across the pin using a multimeter). Adding resistors for this purpose seems like it would waste a lot of PCB real-estate. Is this the sole reason why 100mΩ resistors are being placed (since I = V/0.1Ω) instead of a jumper pin?


If so, is there any consideration we should take when placing such a mΩ resistor on board so it doesn't affect the signal or behaviour of the circuit?



Answer




Zero Ohm "resistors" are frequently used as links on single side boards because they can be placed by component insertion machines that can insert resistors.


High volume single sided board manufacturers often use a separate link inserting machine - whose frighteningly fast speeds need to be seen to be believed.




A 1 Ohm resistor is "just another component".
It may be used as a current sense resistor or for some other circuit function.


If using resistors for current sensing for measurement purposes.


Worst case voltage drop across them should be small compared to total circuit voltage so that they do not affect operation. eg if a circuit draws 1 amp and has a 5V supply then a 1ohm resistor would drop 1 Volt. This is 20% of total circuit voltage and would be excessive in essentially all real world cases.
A 0.1 Ohm resistor would drop 0.1 V at 1A = 2% of supply and MAY be acceptable depending on circuit.
A 0.01 Ohm resistor will drop 0.01V at 1A = 0.2% and would almost always be acceptable.


The 0.1 Ohm resistor will drop 100 mV per Amp so 1 mA will produce 100 uV.

Many low cost DMMs have a 200 mV range with a resolution (but not accuracy) of 0.1 mV = 100 uV, so they can read current in a 0.1 Ohm resistor to 1 mA resolution. Similarly they can read current in a 0.01 Ohm resistor to 10 mA resolution.


Placing the sense resistors with one side grounded allows ground referenced measurement which may be convenient. The Voltage drop must not affect circuit operation.


Sometimes bypassing the sense resistor with a capacitor - maybe 10 uF or 100 uF depending on circuit, will further reduce impact on the circuit.


Where high frequency noise is present use of a DMM or other meter to measure voltage so as to calculate current will give bad results die to noise entering the meter. In such a case use an eg 0.1 Ohm sense resistor, feed the voltage via a series 1k resistor to the meter and add a say 10 uF across the meter terminals.


arduino - Can I use TI&#39;s cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...