Sunday, 30 November 2014

What is a UART?


I'm taking an EdX class in embedded systems and I'm having a little trouble fully grasping what a UART is. The UART has been used as a means to an end, so it hasn't been described well yet.


A UART seems to be a communication system centered around a hardware component (also referred to as the UART?). Presumably they are controlled by standardized code libraries? We've been provided with some functions that control the UART, but it is not clear whether this is part of a standard library or written by the educators:


UART_Init();    // initialize UART for printing

It is not yet clear to me whether UARTs are standard on all microcontrollers, or specific to the device we're using. It seems that UARTs have a wide range of I/O capabilities, but what they are, and how widely they are used, is not clear to me.



A beginner-level explanation that can briefly describe and connect any/all of these threads together would rock:



  • UART hardware

  • UART software interface

  • UART's place in the wider electronics world

  • overview of usage & capability of UART



Answer



UART stands for Universal Asynchronous Receiver/Transmitter and is a way computers can "talk" to each other over a serial line. It is asynchronous because there is no separate clock line like there is for other serial protocols like SPI and I2C. Each byte is preceded by a start bit and followed by one or two stop bits (usually one).


Typically speeds are 9600, 19200, 57600, or 115200 baud, although some UARTs can go over a million baud. Baud rate is essentially bits per second, so a baud rate of 115,200 means you are sending 11,500 bytes per second since each byte has the overhead of one start bit and one stop bit.



Besides talking directly with another computer chip, UARTs are sometimes used to communicate with other peripherals. For example, it is very common to use a UART to communicate with a wireless modem, be it cell radio or Bluetooth using "AT" commands.


The outputs of a UART (Tx = transmit, Rx = receive) are at the same logic levels (usually 3.3v or 5v) as the rest of the circuit. The idle state of a UART line is a logic high. To connect two microcontrollers together in close proximity, you can tie the Tx lead of one UART to the Rx lead of another and vice versa.


However UARTs are also commonly used to drive RS-232 interfaces, which allow the signals to travel for several hundred feet. For this, you need a level-shifting circuit, since RS-232 uses different voltages than the logic levels on the PCB -- namely logic high becomes a negative voltage (typically -5v to -12v), and logic low becomes a positive voltage (typically +5v to +12v).


Do NOT connect the Tx and Rx leads of a UART directly to a RS-232 cable.


UARTs are usually included inside a microcontroller set of I/O peripherals, and there will be a number of registers associated with the UART. The UART will usually have a dedicated set of library routines provided by the microcontroller's manufacturer to access them. These will include a routine (or routines) to initiate the UART, such as setting its baud rate and other characteristics such as the character size (7 or 8 bits), parity, and stop bits (you can almost always ignore these last three items).


Then there will be routines to write a character, and read a character. At 115,200 baud, there can be a character coming in every 100 µs. So you often need to use an interrupt routine to collect them into a buffer so the base level of your firmware can process them later. UARTs often provide FIFO's (anywhere from four characters to 128 or more), so it is less likely you will miss a character.


There can be several UARTs in the same microcontroller, one PIC32 I have worked with had six of them. (Usually the pins for the UARTs are shared with other peripherals like SPI and I2C, so that meant you can have a few UARTs, a couple SPI and a couple of I2C interfaces, or a lot of UARTs, but none of the others). If one does run out of UARTs on the microcontroller, you can get them in separate ICs, usually interfaced via I2C or SPI interfaces.


best practice - Using a human finger to test a circuit


In this Linear Tech App Note 13, page 28, Jim describes:



A final form of probe is the human finger. Probing the circuit with a finger can accentuate desired or undesired effects, giving clues that may be useful. The finger can be used to introduce stray capacitance to a suspected circuit node while observing results on the CRT. Two fingers, lightly moistened, can be used to provide an experimental resistance path. Some high speed engineers are particularly adept at these techniques and can estimate the capacitive and resistive effects created with surprising accuracy.



Was he joking? If not, how do the such techniques work in practice to provide accurate estimation? Could anyone describe an actual scenario that those engineers applied such techniques?


The application note, and my question is in regards to low voltage, high speed signals, not mains or high voltage.



Answer



A finger is a very useful item of test equipment. The main problem when fault finding is knowing which bits of the circuit are susceptible, and which bits are OK. As you stare, dumbfounded, at a recalcitrant bit of board, it's good to be able to get any handle on what is going on, just a hint of where to start looking more closely. At one place I worked, its use was known as 'the laying on of hands'. A finger has the following uses and advantages.




  1. It is always available

  2. It can be used to inject ambient signals into a node, increasing the output of hum of RF breakthrough. Generally useful with high impedance low frequency circuits. Use capacitive (dry skin) or resistive (wet skin) coupling.

  3. It can be used to ground a node.

  4. At low frequencies it can add capacitance to a node, changing time constants, filter tuning etc.

  5. At microwave frequencies, it can absorb and redistribute RF radiation, damp resonances, reduce signal levels, absorb the higher harmonics on an open signal line.

  6. It's not generally recognised that high speed busses to memories and FPGAs are now running so fast that a finger on the lines will change rise-times, introduce crosstalk between clock and data, or reduce clock ringing, any of which can affect data integrity. I have dabbed a data bus while looking at the resultant TV picture, and could tell whether I had address setup or data crosstalk problems.

  7. It can take the temperature of components, from 'that's OK' through 'it's running a bit hot' to '$$$ it's that one!'

  8. It can cool selected hot components, improving the heatsinking, to see if temperature changes matter.

  9. The speed. While watching an oscilloscope trace, listening to a demodulated signal, or watching a BER number, you can stroke your finger across a whole board in seconds. Any place it changes, that's a good place to think about whether you expected it to change there.



As a seasoned engineer, there have been many times in my career when several of us have sat round a mis-performing board, and the joke round the table was that if we could 'buy an engineer's finger, and glue it just there', we'd be good to ship.


And the question of accuracy. You don't need 3 digit accuracy, you need to know whether none, or a few pFs, makes a difference here. Once you know where to play with, you switch back to soldering chip components or trimmers.


And yes, all this usefulness comes at a price, you must not use it on circuits above 40v.


power supply - Grounding and why charge leakage occurs


A basic nugget of info is missing in my end-to-end picture of how grounding works and why it's important. When a voltage is applied in a circuit the electric current starts flowing (or the field establishes itself). Now in an AC home circuit the current flows through the circuit like in DC, but happens to reverse directions 50 or 60 times a second too (Hz).



So why do some appliances have electric current leak onto their metallic surfaces at all in the first place. Should'nt all appliances's internals be designed so that there can never (or rarely) be any leakage of current ?


The whole point of my question is that why do we blame the lack of grounding when an appliance gives an electric shock - isn't the appliance equally to blame for being designed in a way that allows for charge leakage ?


Hence in the event of an electric shock isn't it equally important to investigate the appliance (in this case it's actually a custom assembled desktop computer) to find out why its circuit is leaking charge to its metallic body parts, instead of always expecting the grounding to remove that excess charge to the earth.


Another way to paraphrase this question is - are some appliances (especially assembled computers) likely/expected to leak charge. Hence in the event of rare shocks sometimes shouldn't it be more important to investigate the appliance itself for having the proclivity to receive leaked charge instead of blindly checking the grounding




amplifier - Reasons for 741 op-amp latching up?


what does 741 operational amplifier latch up mean? what are the reasons IN GENERAL for that? i need a general answer only




Saturday, 29 November 2014

Which voltage uses the "Kv" parameter in a BLDC (Brushless DC) motor?


According to the definition of a BLDC by Wikipedia:




\$K_V\$ is the motor velocity constant, measured in RPM per Volt (not to be confused with "kV," the abbreviation for "kilovolt")[6]. The \$K_V\$ rating of a brushless motor is the ratio of the motor's unloaded RPM to the peak (not RMS) voltage on the wires connected to the coils (the "back-EMF").



Since Wikipedia is not a recommended source, I'd like to know if the voltage is reffered to the peak value or the RMS one, and also if it depends on the type of conexion in the motor (Y/Δ).


My confusion starts because I've done a test with a motor I have, bought in Quadroufo. The characteristics of this motor are the following:



  1. \$K_V\$ = 2600

  2. P = 12 (stator)

  3. P = 14 (rotor)



For the experiment, I attached the rotor to a drill. While leaving the velocity of the drill still, I measured the BEMF with an osciloscope. The following is a picture in which I got the results about measuring voltage between lines (sorry about the labels in spanish):


Osciloscope Readings


With the frecuency parameter, I got the 'n' (mechanical velocity). Which is n = 2193.428571 RPM (with the ammount of poles in the rotor). From now on it's "conffusing time" about the deffinition of \$K_V\$. Which value of voltage should I use? Since I don't know which conexion the motor has (Y/Δ) I tried every possibility as you can see in the following chart:


enter image description here


Comparing the chart with the parameter \$K_V\$ that Quadroufo says, the most similar are the ones painted in yellow. Is this confirming that actually \$K_V\$ depends on the conexion type of the motor and also that is not reffered to the peak but to the RMS value?



Answer



My experience with motors is that they are usually specified as Ke = RMS voltage line-to-line / 1000RPM. The reason RMS voltage line-to-line is used, is because it is very easy to measure with a multimeter + doesn't need an oscilloscope.


Kv would be proportional to the reciprocal, and I'd expect it to be RPM / RMS line-to-line voltage.


In your case: 2193RPM / 0.738Vrms l-l = 2972RPM / Vrms,l-l, that's 15% higher than expected. There is bound to be some error in measurement (voltage in scopes is usually 1-2% or so off worstcase), and in part-to-part variation of the motor, but it sounds a little different.


ac - Energy stored and Lagging of Current In a Inductive Circuit



In a purely Inductive AC Circuit, the voltage/emf Leads the current in phase by 90. The graph between Voltage and Current is given below:


enter image description here


Now can anyone here please tell me in a more intuitive way how the current is varies sinosuidally with emf in every quarter of cycle? Also how Inductor stores Energy in its Magnetic Field?


I don't need any Mathematical Explanation. Thanks...




pcb design - Does a Guard Ring around a PLL loop filter make sense?



Should I guard a PLL loop filter against current leakage with a pour? If so, where can I connect the guard plane?


As an illustration: I use an IC in need of an external PLL-loop-filter connected to the charge pump (a MAX2769). The manufacturer recommends to use a C-R-C-network as follows:schematic (the DNIs are not installed, the installed caps are silver mica type from Cornell Dubilier).


As you can see, there is a 1M (or 100M?) resistor to a net called PLL_FILTER_FENCE. This network is used to pour a plane around the components like this:pcb This pour is intended to minimize current leakage from the components. As you can see, space does not allow for a plane that also encloses the IC pad. The plane will also introduce an additional filter pole which should not affect PLL performance.


Will this be helpful at all, as there is no low impedance source to connect the guard to?



Answer



Don't do it. The 1M resistor will have a significantly reduced impedance @ 1.5Ghz. Even if that were not the case, the floating pours can become really good antennas @ 1.5 Ghz. Think about what a patch antenna is: a trace to a copper pour. The resistor is trying to prevent this, but it can still resonate with adjacent signals.


I have worked with frequencies that are similar to yours. Here is what a typical design process is:



  1. Layout the board

  2. Do signal integrity on the fast signals


  3. Get the S-parameter models of your decoupling capacitors

  4. For each IC compute the impedance to ground from the power pins using FEM

  5. Add capacitors in the simulator in order to get your target impedance

  6. Add the capacitors to the layout, go to 4 and repeat until step 5 is satisfied

  7. Use FEM to compute the resonant modes of the planes

  8. Add capacitors to suppress them

  9. Add capacitors to the layout, go to 7


As you can see, doing the signal and power integrity at such frequencies is not a trivial task. You can end up with 1000's of capacitors. You will probably be okay, if you follow the layout recommendations of the manufacturers. Just remember, a floating plane is an antenna, if it happens to resonate at a frequency that is present on your board.


Decoupling at Ghz frequencies is not easy at all. Here is a typical impedance curve: decoupling Note how the capacitors become inductive. That is why you need to combine high values with low value capacitors. But it is not as easy as that, because the different valued capacitors can start resonating with each other. Always make sure you use the recommended capacitor part numbers from the manufacturers in the specified package sizes, if you are not able or willing to carry the level of analysis I have outlined.



Friday, 28 November 2014

operational amplifier - Can floating op-amp input pin destroy op-amp?


As a follow up to my question (see circuit diagram there), I am thinking further if I may be a cause of the problem. My idea that the second part of op-amp and another op-amp chip may have been damaged because, at some point in time, I did not connect their positive inputs, and was "hot-" connecting these inputs to the signal source on the same board.


I think it is very low probability, as initially, when things did not move properly, everything was connected, but anyway worth checking.


I saw this and this. My chips did not heat (I was checking it almost every time when operating them), no smoke and no craters up to physical damage. All op-amps were configured as voltage followers all the time, thus, as I understood, must drive output to some specific level, not saturate or get to "latch-up" situation.


Am I correct?


Update: op-amp is AD8512A (this info is available in my original question).


@PlasmaHH: looking to datasheet I see



The AD8510/AD8512/AD8513 have internal protective circuitry that allows voltages as high as 0.7 V beyond the supplies to be applied at the input of either terminal without causing damage




No word about unconnected input pins, or floating input pins.




batteries - How are cell failures handled in large lithium battery packs?


In a large battery pack of lithium-based cells for an electric vehicle or grid storage system, how are failed cells handled? Answers to another question indicate these cells are usually hardwired in parallel blocks (which are then connected in series and balanced) so that resistance isn't added in the path of high current.


What happens when a cell fails and acts as a short circuit?


It seems this would short out a block of parallel cells and decrease the capacity of the overall pack significantly. If the dead cell could be removed from the pack by an electronic or safety system (power transistor, fuse, physical removal &/or replacement) the rest of the parallel cells could continue functioning with a much smaller decrease in usable pack capacity.


Lead-acid batteries seem to be replaced on a timed maintenance schedule, or when certain usage metrics are exceeded, say in data center usage. With lithium batteries being so much more expensive, are there any typical electronic design features which handle failed cells automatically rather than by rotating out the entire pack before end of life?


Are chemistries such as LiFePO4, with 2000+ cycles to 80% capacity, reliable enough that cells failed to short circuit are rare enough to ignore as an electronic design issue?




Answer



I imagine from the questions that you have asked that you are planning some project that may require a high capacity lithium iron phosphate battery that you would like to build yourself.


The only large capacity battery pack in high numbers production that uses a number of cells in parallel vs only a couple of large cells in parallel is the Tesla. All of the other EV seem to go with the large capacity pouch cells and then only use a couple in parallel. The advantage to the Tesla is that their power to weight ratio is almost double that of everyone else.


The disadvantage has to be safety. Tesla has 104 patents on its battery pack and most of them have to do with safety. Specifically with how to deal with single cells that short or go into thermal runaway. FYI the Tesla S battery pack uses 74 cells in parallel and then 96 in series.


I have read through their patents and none of them deal with any sort of system to repair or remove damaged individual cells. They just make sure that on the rare occasion that a cell does short or heat up, start fire etc., that it is contained to that cell. They do this by separating each cell by a certain distance, using active and passive cooling, using a fuse at each cell etc.


Tesla brags that they can replace an entire battery pack out of a Tesla S in only 90 seconds, but they make no claims about repairing that battery pack. In fact because of all of the safety features like fire proof foam, it takes a couple of hours for a person to get access to the individual cells of the Tesla battery pack and by that time you have ruined the structure of the battery, so it is no longer useable to the car even if you did replace the destroyed individual cell.


So to answer your question, it appears that they put a lot of effort into preventing a shorted cell from destroying the rest of the pack, but otherwise they leave it there and let the rest of the cells in that parallel group take over.


Remember that the Tesla is demanding a very heavy load from its battery, not only pushing the cells to their limits to get a further distance out of the pack (some owners report cell voltages that dip below 3.0 volts) they also demand a high current for the crazy acceleration the Tesla gets.


From reading their patents, Tesla believes that over charging is much more dangerous than over discharging (this is from tests they have done in their labs). Over charging leads to fires and explosions while over discharging tends to speed up capacity loss.


Good luck in your project. Using lithium iron phosphate cells you are already a magnitude safer.



Thursday, 27 November 2014

operational amplifier - What does this op-amp circuit do? (part of an ECG)


I would like create an ECG circuit based on this schematic (from the AD620AN datasheet):



ECG circuit


I don't know this part of the circuit and how it works. I know this is called a right leg driven circuit which is reducing the effect of the noise. But I don't know exactly how negative feedback works in this case. Can someone help me?


Right leg driven



Answer



The right leg driver tries to drive the average voltage of the body to cancel out noise. The right leg is chosen because it is far from the heart, so any signal injected on there will be common mode to two electrodes near the heart.


The right leg drive is much more tightly coupled to the body than ambient noise it picks up from capacitive coupling to things like the AC power in the room.


The network in the feedback path of the right leg driver opamp provides some low pass filtering of the signal.


Wednesday, 26 November 2014

microcontroller - Can i connect something else to programming pins in STM32 (SWD)?


As in the topic: Can i connect something else to programming pins in STM32 (SWD)? For example a single LED with current limiting resistor connected to SWDIO and SWCLK pins. Will this load affect programming via this interface (SWD)? Should I use a buffer?



Answer




Yes, you can use STM32 SWD pins as GPIO, and yes, you need to think about the impact of doing so on the SWD functionality.


Likely you want anything else driven by those lines to be behind a buffer with a high impedance input, and you want anything that could drive those lines to be behind a specific enable.


But there's also a risk in re-purposing those lines, especially as GPIO output. If you do so, you will not be able to connect an SWD probe to the running system.


With a full capability SWD adapter, you should be able to perform a coordinated "connect under reset" where the CPU core is reset and the SWD connection is used to suspend operation before the program can re-purpose the pins and disable SWD. However, this can be difficult with some setups.


So generally, if you are going to re-purpose the pins, it's best for a program to provide a second or two of delay upon reset before doing so.


You probably also want to make doing so at all dependent on a macro definition, perhaps one passed on the compiler command line. That way, if you decide you want to use a breakpoint debugger, you can build the code with alternate settings that do not re-purpose the SWD pins (maybe something like arm-non-eabi-gcc -DNO_REPURPOSE_SWD), and so leave them operating in SWD mode to permit the debugger to function.


And of course whatever you connect to those pins needs to not problematically mis-operate if it sees SWD traffic rather than the intended signals. So things like motor drives are a very bad idea; but status LEDs, or serial advisory message outputs might be okay.


Tuesday, 25 November 2014

Why is there so much fear surrounding LiPo batteries?


I've been trying to design a charging system for a small robot powered by a 2S 20C lithium polymer (LiPo) battery. Were I to trust everything I read online, I would believe that the LiPo will kill me in my sleep and steal my life savings. The common advice I read, if you are brave enough to use LiPo batteries, is "never leave unattended", "never charge on top of a flammable or conductive surface", and "never charge at a rate faster than 1 C".


I understand why this is prudent, but what is the actual risk with LiPo batteries?


Nearly every cell phone, both Android and iPhone alike, contains a LiPo battery, which most people, including myself, charge while unattended—often-times while left on a flammable or conductive surface. Yet you never hear about someone bursting into flames because their cell phone exploded. Yes, I know there are freak accidents, but how dangerous are modern LiPo batteries? Why do so many online commenters treat stand-alone LiPo batteries like bombs waiting to go off, but don't even think twice about the LiPo sitting in their pocket?



Answer



Every cell phone (as well as laptop and nearly everything with a rechargeable battery) uses LiIon/LiPo (essentially equivalent for the purposes of this discussion). And you're right: In terms of actual incidences, lithium-ion and lithium-polymer are the safest battery chemistry to be in wide use, bar none.


And the only reason this now ubiquitous chemistry hasn't murdered you and/or your family several times over is that these cells aren't charged unattended. You may not be attending it personally, but every single one of those lithium-ion batteries has a significant amount of protection and monitoring circuitry that is permanently integrated into the pack. It acts as the gatekeeper. It monitors every cell in a battery.




  • It disconnects the output terminals and prevents them from being overcharged.

  • It disconnects the output if they are discharged at too high a current.

  • It disconnects the output if it is CHARGED at too high a current.

  • If any of the cells are going bad, the output is disconnected.

  • If any cell gets too hot, it disconnects the output.

  • If anyone of the cells is over-discharged, it disconnects the output (and permanently - if you forget to charge a lithium-ion battery for too long, you will find that it will no longer charge. It is effectively destroyed, and the protection circuit will not permit you to charge the cells).


Indeed, every single phone battery, laptop battery, *whatever battery that is a rechargeable lithium chemistry is the most closely monitored, scrutinized, and actively managed, the diametric opposite of 'unattended' as one can get for a battery.


And the reason so much extra trouble is done is because lithium-ion batteries are actually that dangerous. They need protection circuitry to be safe, and they are not even remotely safe without it. Other chemistries such is NiMH or NiCad can be used relatively safely as bare cells, without any monitoring. If they get too hot, they can vent (which has happened to me personally), and it can be pretty startling, but it isn't going to burn down your house or land you an extended stay in a burn unit. Lithium-ion batteries will do both, and that's pretty much the only outcome. Ironically, lithium-ion batteries have become the safest packaged battery by being the most dangerous battery chemistry.



You might be wondering what actually makes them so dangerous.


Other battery chemistries, such as lead-acid or NiMH or NiCad, are not pressurized at room temperature, though heat does generate some internal pressure. They also have aqueous, non-flammable electrolytes. They store energy in the form of a relatively slow oxidation/reduction reaction, one whose rate of energy release is too low to, say, cause them to eject 6-foot jets of flame. Or any flame, really.


Lithium-ion batteries are fundamentally different. They store energy like a spring. That's not a metaphor. Well, like two springs. Lithium ions are forced between the atoms of covalently-bonded anode material, pushing them apart and 'stretching' the bonds, storing energy. This process is called intercalation. Upon discharge, the lithium ions move out of the anode and into the cathode. This is very much electromechanical, and both the anode and cathode experience significant mechanical strain from this.


In fact, both anode and cathode alternatively increase or decrease in physical volume depending on the battery's state of charge. This change in volume is uneven however, so a fully charged lithium-ion battery is actually exerting nontrivial amounts of pressure on its container or other parts of itself. Lithium-ion batteries are generally under a lot of internal pressure, unlike other chemistries.


The other problem is their electrolyte is a volatile, extremely flammable solvent that will burn quite vigorously and easily.


The complex chemistry of lithium-ion cells is not even completely understood, and there are a few different chemistries with different levels of reactivity and inherent danger, but the ones with high energy density all can undergo thermal runaway. Basically, if they get too hot, lithium ions will begin reacting with oxygen stored as metal oxides in the cathode and release even more heat, which accelerates the reaction further.


What inevitably results is a battery that self-ignites, sprays its highly flammable solvent electrolyte out of itself, and promptly ignites that as well, now that a fresh supply of oxygen is available. That's just bonus fire however, there is still a ton of fire from the lithium metal oxidizing with the ample store of oxygen inside.


If they get too hot that happens. If they are overcharged, they become unstable and mechanical shock can make them go off like a grenade. If they are over-discharged, some of the metal in the cathode undergoes an irreversible chemical reaction and will form metallic shunts. These shunts will be invisible, until charging expands part of the battery enough that the separating membrane is punctured by one of these shunts, creating a dead short, which of course results in fire, etc.: The lithium-ion failure mode we know and love.


So, just to be clear, not only is overcharging dangerous, but so is over-discharging, and the battery will wait until you've pumped a ton of energy back into it before spectacularly failing on you, and without any warning or measurable signs.


That covers consumer batteries. All this protection circuitry is less able to mitigate the danger of high drain applications, however. High drain generates no small amount of heat (which is bad) and more worrying, it causes huge amounts of mechanical stress on the anode and cathode. Fissures can form and widen, leading to instability if you're unlucky, or just a shorter useful life if it is not too severe. This is why you see LiPos rated in 'C', or how quickly they can be safely discharged. Please, take those ratings seriously and derate it, both for safety and because many manufacturers simply lie about the C rating of their batteries.



Even with all that, sometimes an RC Lipo will just burst into flame for no reason. You absolutely need to heed the warnings to never charge them unattended, and everything else. You should buy a safety bag to charge them in because it might prevent your house from burning down (possibly with you or loved ones inside). Even if the risk is very low, the damage it can cause is vast, and the measures needed to mitigate most of that potential for damage are trivial.


Don't ignore everything you're being told - it's all spot on. It comes from people who have learned to respect LiPos for what they are, and you should too. The thing you definitely want to avoid is having this lesson taught to you by a lithium-ion battery, instead of peers online and offline. The latter might flame you on a forum, but the former will literally flame you.



Let me go a little more into how they fail. I've discussed the mechanism, but what really happens? Lithium-ion batteries really only have one failure mode, which is kind of exploding then shooting out a stunningly huge amount of fire in a giant jet of flame for several seconds, and then continuing general burning-related activities for a bit after that. This is a chemical fire, so you cannot extinguish it (lithium-ion batteries will still shoot out huge jets of fire even in the vacuum of space. The oxidizer is contained inside, it doesn't need air or oxygen to burn). Oh, and throwing water on lithium does nothing good, at least in terms of fire reduction.


Here is a 'greatest hits' list of some good examples of failure. Note that this does sometimes happen in high drain RC cases even with proper safety measures in place. Comparing high drain applications to the much safer and lower currents of phones is not at all a valid one. Hundreds of amperes ≠ a few hundred milliamperes.


RC plane failure.


Knife stabs smartphone-sized battery.


Overcharged LiPo spontaneously explodes.


Laptop battery in a thermal runaway is lightly pressed on, making it explode.


Monday, 24 November 2014

analog - Absolute value circuit around a non-zero value


I have searched for a few hours on the internet and in some circuit design books, but have been thusfar unable to find a circuit that produces absolute value around a number other than zero. Does anyone here know of such a circuit? An example IO would be: At Vin = 10, Vo = 10 At Vin = 9, Vo = 11 At Vin = 11, Vo = 11


I'm hoping to accomplish this with a single absolute value circuit, rather than subtracting 10 beforehand, taking the absolute value, and adding 10 or offsetting the result.


Thanks for any help




pcb - Decoupling cap: Closer to chip but with via or farther without via?



This may "yet another" question about decoupling but the question is pretty precise and I can not find an answer.


I have a 40 pin QFN where I need to fan out signals and then place tens of decoupling caps. To make things worse, the IC sits on a socket that occupies 8x the area of the QFN (5mmx5mm). (The socket occupies much area but does not add significant parasitics; it is rated up to 75 GHz). On the same layer I cannot place components within a radius of ~7mm. The backside is restricted as well due to the mounting holes of the socket but at least I can use partial real estate on the back side. But I would need to via down for that. However, I could place 50% of the capacitors onto the thermal ground paddle that I also created underneath the chip on the backside.


Now I have read multiple times there should not be a via between the coupling cap and the pin. But what is worse? Via or longer wire?


In terms of inductance, a 7mm trace would be around 5-7nH (http://chemandy.com/calculators/flat-wire-inductor-calculator.htm). A 22mil diameter/10mil hole is far below 1nH (http://referencedesigner.com/rfcal/cal_13.php).



Answer



Don't stress too much its all about minimizing that inductance. That doesn't always translate into distance. If I were you I would take steps to minimize all the contributions to the total path inductance between the pin and the cap. You don't mention what speeds your chip is running at but you do say it's in a QFN. I only say that because sometimes we get obsessed with adding decoupling when the package itself is a limitation.


So how crazy do you want to get? Lets minimize each section. Starting with the caps you could pick a lower inductance package for example a 306 (603 turned sideways), 201s if you can get your values, MLCC caps, or there's an X2Y variant made for decoupling and RF-land.


Next the mounting strategy, if one via is good why not two. More parallel vias should be a lower impedance. If doing 0306, or 201 style caps make sure to do the via to the side trick, again trying to minimize loop area.


Ok so now I say put them on the top. Make part of your top layer a copper flood for the power side. Then on the next layer 5 mil or less below the top make that GND. Use multiple gnd vias at the socket pins. This will give you a nice low impedance path from the above caps into those pins. I did an analysis one time on HS section of an FPGA. A nice tight plane structure and caps like I described outperformed capacitors directly underneath the parts using multiple vias.


Finally if you want to feel better about it you could do some simulation or analysis. There's plenty of topics written about PDN design out there. If you don't have a simulator check out Altera's free PDN excel tool. The design guide has some really nice information in it.



I've used those sockets before they're pretty nice, and have also stressed about where to put caps.


electromagnetism - Voltage on a Transmission Line with Ideal Conductors


Let's consider a transmission line with Perfect Electric Conductors.


We know that if an external AC source is applied, we get a voltage waveform between the conductors which is function of the position (and also of time, but focus on the first dependence).


But we know that in a perfect electric conductor the electric field is orthogonal to its surface, and this means that its surface is equipotential. This property is true in any situation (steady state or not), because the tangential electric field is always 0 in a perfect electric conductor.


The following picture shows clearly that E is orthogonal to the conductors' surface. enter link description here


But this seems in contrast with the fact that the voltage depends on the position.


Which is the solution?



Answer



The electric field being perpendicular to the conductor surfaces is a boundary condition imposed by their perfect conductance. The electric field lines terminate in the surface charge density according to $$ n \cdot \varepsilon \mathbf E = \sigma \space\space(1)$$ with n the normal vector to the surface, and σ the surface charge density. The question is now how a potential gradient can exist along the conductor surface while the electric field strength is normally incident.


A give-away is one of Maxwell's equations (Faraday's law): $$\nabla × \mathbf E + \frac{\partial \mathbf B}{\partial t} = 0\space\space(2)$$ which essentially tells us that the electric field is non-conservative in the presence of a time-varying magnetic field. Let's study this a bit more in depth.



From vector calculus we know that the divergence of a curl and the curl of a gradient are both zero: $$\nabla \cdot (\nabla × \mathbf A) = 0\space\space(3)$$ $$\nabla × (\nabla V) = 0\space\space(4)$$


As far as we know there is no magnetic charge, so according to Gauss' law for magnetic fields the magnetic induction has zero divergence:


$$\nabla \cdot \mathbf B =0$$ which allows us to use the identity of (3) to define a vector A such that $$ \mathbf B = \nabla × \mathbf A\space\space(5)$$ We call A the magnetic vector potential. Substituting (5) in (2) gives $$ \nabla ×( \mathbf E + \frac{\partial \mathbf A}{\partial t}) = 0$$ Now the identify of (4) allows us again to define the non-static electric scalar potential


$$ \mathbf E + \frac{\partial \mathbf A}{\partial t} = -\nabla \varphi$$ which shows that a potential gradient can exist that does not have the same direction as the electric field vector, as long as there is a time varying magnetic vector potential, so there really is no contradiction that the potential gradient can be at angles with the electric field.


pwm - Help with 555PWM motor control


I'm making a laser spirograph for a school project. It requires speed control of three motors. I used a simple 555 astable circuit with a pot for control, then the output goes into the base of a power transistor to make a PWM ground. I had indicator lights for all of them, and when the motors are off, I get a got a good pulse, but when I turn the motors on, they just stay at the same speed no matter what I do, and the indicators go dim (parallel to motors with a resistor). I think it might be because its just sucking the power from the transistor or something, but I can't be sure. Any help or Ideas? Schematic: Note: There are three of these modules in the circuit. Schematic


Transistor Package:Transistor





Single transistor level up shifter


I need a simple, single directionnal level shifter for 3.3V -> 5V conversion.


There are many options on the internet, some using a logic ic and some using 2 NPN transistors (converter and inverter), but I never found an option using only a single transistor (and 2 resistors).


My understanding is that when input is at 3.3V, the transistor is blocking and R2 pulls output up ; while when input is 0V the transistor is passing and pulls output down to transistor VCE(sat).


single directional level up shifter


So, why wouldn't such a converter work? There must be a reason...



Answer



The single-BJT level shifter in the question would work: If the input impedance of the device on the 5 Volt side is significantly higher than the 6.8 k shown in the question, the expected ~0.3 to ~5 Volt signal would be received (taking a 2n2222 as an example).


However, for lower impedance inputs, the input would act as a voltage divider with the 6.8 k resistor, attenuating the high part of the signal significantly.



For instance, if the input impedance of the load on the 5 Volt side were, say, 100 k, the signal would top out at around 4.6-4.7 Volts. Still not too bad.


Any lower, and the level becomes problematic. This is when one needs an alternative, such as a two-transistor set-up mentioned in the question, to drive the output rail harder.


Strange resistor colours


Normally this kind of thing wouldn't pose the slightest problem for me, but I am just trying to decipher the colours on a resistor.




  • Orange

  • Orange

  • Gold

  • Gold

  • Black


enter image description here


All the online tools tell me it's a 4-band 3.3Ω, but that ignores the 5th black band.


Yes, when I measure it it's 3.3Ω.



So how does the colour coding work for that then? Is it a 4-band with some mystery extra band? Or does that 5th band signify something special?



Answer



Alright, I finally found something that supports Spehro Pefhany's proposal. This is a common 4 band resistor.
The black band is there because both 3 and 4 band resistors aren't required to use gold and silver on the readings. Thus, some resistors can be read backwards (Yikes).


To solve this, the black band is put onto the resistor to tell which way it's supposed to be read. Later, this was replaced by deliberately spacing the bands, but it seems that some manufacturers still use the black band.


enter image description here


design - What are FIT's and how they used in reliability calculations?


In Military, Medical, Space, Professional eqt. design there is a need to be able to prove that your device can last a certain length of time with a certain confidence level. Or that reliability must be used in design to inform the design direction, either through component selection, component testing and sort or in amelioration techniques (like redundancy, FEC's - Forward Error Correction etc.).


How are FIT's (Failure In Time) used in the reliability aspect of design and verification? Examples of calculations?


How are FIT's determined/derived?


How is this related to MTTF (Mean Time To Failure) and MTBF (Mean Time Between Failures)




Answer



The term FIT (failure in time) is defined as a failure rate of 1 per billion hours. A component having a failure rate of 1 FIT is equivalent to having an MTBF of 1 billion hours. Most components have failure rates measured in 100's and 1000's of FITs. For components, such as transistors and ICs, the manufacturer will test a large lot over a period of time to determine the failure rate. If 1000 components are tested for 1000 hours, then that is considered to be equivalent to 1,000,000 hours of test time. There are standard formulas that convert the number of failures in a given test time to MTBF for a selected confidence level. For a system of components, one method of predicting the MTBF is to add the failure rates of each component and then taking the reciprocal. For example, if one component has a failure rate of 100 FITs, another 200 FITs and another 300 FITs, then the total failure rate is 600 FITs and the MTBF is 1.67 million hours. For military systems, the failure rates of each component can be found in MIL-HDBK-217. This document includes formulas to account for environmental and usage conditions such as temperature, shock, fixed or mobile equipment, etc. In initial stages of a design, these calculations are useful in determining the overall reliability of a design(to compare with the specified requirement) and which components are most significant in terms of the system reliability so that design changes can be made if deemed necessary. However, component reliability is more of an art than a science. Many components are so reliable that it is difficult to accumulate enough test time to get a good handle on their MTBF. Also, relating data taken at one set of conditions (temperature, humidity, voltage, current, etc.) to another is open to large errors. As already mentioned in the comments, all of these calculations are mean numbers and are useful in predicting the reliability of a large number of components and systems, but not any individual unit.


Sunday, 23 November 2014

bootloader - Flash/obtain ROM code for Sitara on BeagleBone Black


How is the ROM code loaded/provided on the BeagleBone Black?


I see a few possibilities:




  • It is loaded on in TI's factory and is immutable [unlikely]





  • It is flashed on during manufacture of BeagleBone [most likely]




  • Some other way




If it is open-source, where can it be obtained from?


If it is not open-source, and it is not flashed onto the Sitara by TI, can it be obtained as a binary blob, or can it be extracted from another Sitara?



How would it be flashed (via USB? JTAG?)


Does this ROM code take a similar function as a PC BIOS? Resetting initial system state (including configuring boot devices), then loading a bootloader?


This question is the sequel to this one.


I have been playing with FreeRTOS on some Cortex M3 and F1 boards for a while and I decided to start learning how more complex embedded systems work.



Answer



The AM335x ROM is fixed by TI, there is no real reason to need the code. It loads a small executable depending on the bootstrap pins from one of many possible locations including MMC, NAND, UART (via XMODEM), a server via Ethernet using the BOOTP protocol and others.


What is used as the program the ROM loads depends on your configuration.


In case of Linux a typical boot process looks like this:



  1. ROM loads U-Boot SPL


  2. U-Boot SPL initializes clocks (including MPU), RAM and some other stuff (like UART for console)

  3. SPL loads U-Boot proper

  4. U-Boot proper loads your OS or does whatever


U-Boot SPL is the stripped down version of U-Boot, which is used because U-Boot is too big (300k+) to be loaded into Sitara's RAM (or cache, however you call it, it's 128k).


In the particular case of BeagleBone both SPL and U-Boot are found in the eMMC (or SD card), either in the small FAT partition or in the first 2kB at fixed adress if there is no FAT partition.


SPL is actually a part of U-Boot and is built together with it, so if you want to experiment just build U-Boot usign the configuration for BeagleBone and play around with it.


Answering your other questions, the only thing done by ROM is to load the bootloader - all initialization of hardware, including the AM335x itself is done by the bootloader in either stage.


Keep in mind that not all bootloaders are two-stage, it's just that U-Boot is too big. On some other MPUs, like i.MX6 which has more built-in RAM there is no need to use two stages even with U-Boot.


microcontroller - Parameters when choosing a relay


Is this a good circuit to use as a air condition switch with a help of microcontrollers 5V? What relay to use in this situation?


http://i.stack.imgur.com/GIHhS.jpg


What parameters should I take into consideration when choosing relay?



Answer





What parameters should I take into consideration when choosing relay?



There are three main categories to look at, coil specification, contact specification and general technical data. I will discuss some common parameters below.


Contact specification




  • Contact configuration - Do you need a contact that closes (NC / normally closed), opens (NO / normally open) or switches over (CO / change over)?





  • Rated current - The maximum rated DC current. You should stay well below this value for some safety margin.




  • Rated voltage - Maximum switching voltage.




  • Rated load according to Utilization categories - Some manufacturers specify a maximum load for specific conditions. For example AC-1 (Non-inductive or slightly inductive loads) or AC-15 (Control of A.C. electromagnetic loads).




  • Breaking capacity - Specifies the maximum current the relay can switch off without being destroyed or causing an electric arc with unacceptable duration.





  • Minimum switching load - A minimum voltage/current may be necessary to overcome the contact resistance.




  • Contact material - There are lots of different contact materials used. Gold plating is useful for switching light load due to low contact resistance. Some silver alloys are more resistant to arcing than others.




Coil specification





  • Nominal voltage - Normally the rated DC voltage. Most relays are available with several coil types like 5V, 9V 12V and so on. This is a trade off between what voltage you have available and the maximum current you want/can switch (may be limited by transistor for example).




  • Operating range - Specifies the minimum (relay won't switch on below that) and maximum coil voltage (above could cause excessive current and/or maybe mechanical damage).




  • Holding voltage - Once the coil is magnetized and the contact closed, the voltage to hold the contact is often even lower than the minimum specified operating voltage.





  • Drop-out voltage - The voltage where the relay is guaranteed to switch off.




Other technical data



  • Mechanical life - Number of switching cycles (without load)

  • Electrical life - Number of switching cycles at specified load

  • Operate/release time - Self explanatory

  • Insulation between coil and contacts - This is important if you have to design according to safety regulations. You may require 4 or even 8kV for example.

  • Dielectric strength between open contacts - This may be of interest if you have to make sure that there is no arcing while the contact is open.


  • Ambient temperature range - Self explanatory

  • Environmental protection - If there the relay/device is going to be used in a harsh environment, this is worth looking at.


microcontroller - How can I measure battery voltage with my MCU?


I am currently using the PIC24FJ128GA010 and I am planning to use Input/Output port to connect my 4.2 V LiPo battery and to check if the voltage value doesn't go below 3.7 V.


I am thinking to connect it to any of my input/output pin but I am wondering two questions:



  1. Is it the correct pin?

  2. Should I do a specific montage with resistor?




plug - Preventing spikes when plugging jacks


I'm using an 8 output DAC (LTC2666) to control synthesizers via mono 3.5mm jack connections. It works fine most of the time but every once in a while, plugging in a jack into the synthesizer will break the DAC in all sorts of random ways, often requiring a power down.


Is there a proper way to protect my circuitry against whatever glitches are induced by the mechanical nature of plugging in a jack?



Answer



Generally speaking, the problem that you describe is often easily cured by adding a resistor in series with the signal. Resistor value is dependent on what the load impedance is but is often in the range of 22R to 100R.


Higher value is better but the tradeoff is the voltage drop caused by that series resistor and the load impedance.


The series resistor does two things:



1) limits peak current during short-circuit conditions.


2) minimizes the chance of latch-up if there is significant ground voltage difference between the two devices being connected as you are plugging one device into the other.


It won't cost you anything to see of that helps or eliminates your problem.


Saturday, 22 November 2014

arduino - Do voltage dividers waste battery?


I am attempting to make a battery powered alarm clock with an Arduino, and I would appreciate some help on the circuitry part. I am very inexperienced with electrical engineering.


I am using a voltage divider in parallel with the rest of my circuit so that I can feed it into a pin on an Arduino and read the battery life. I am using a two 100k resistors to lower my 4.5v power source to 2.25v (the maximum input voltage for a analog pin on an Arduino mini 3.3v is 3.3v). The three AAAs ran out of battery much quicker than expected, and I figured it might have something to do with the voltage divider. Is power constantly flowing through the voltage divider, even when I'm not reading any data from the pin? If so, does this reduce battery life?


Side question: I noticed the voltage divider was very inconsistent, is there a better way to lower the voltage going into the Arduino's analog pin?



Answer



Voltage divider indeed will drain your battery as long as it is powered. It is common to enable the divider just for reading the value and turn it off again. Here is an example of this approach used in Nordic Thingy (Page 65) :


enter image description here



With signal BAT_MON_EN you turn on/off the divider using the transistors and measure the divider value in signal BATTERY.


In your case, having 4.5V in a 200K resistors divider gives you a consumption of 22.5uA. The capacity of a AAA battery is ~1000mAh, so you have a total capacity of 3000mAh. Using digikey battery life calculator gives you an expected life of ~ 94000 hours, or ~4000 days (10 years). Just for the divider.


It could seem like it is a low consumption, but if you are building low-power devices, the average consumption of the whole system could be less than the divider consumption, in tens of uA or even nA.


digital logic - What equipment do I need to test an eye diagram for USB?


I'd like to test USB full speed with a goal of testing high speed (480 Mbit/s), I have a tek scope that does 300 MHz (which I could upgrade to 500 MHz) and I'm looking at a 500 MHz differential probe. As I understand it I also need a breakout board (which I'm not quite sure is the best thing to get), but I'm looking at this board from tek and one listed here.


What are the minimum requirements for a test like this?


Is this equipment list sufficient to preform an eye diagram test for full speed USB?


Is this equipment list sufficient to preform an eye diagram test for full speed USB if I have a 500 MHz scope?




Answer




What are the minimum requirements for a test like this?



Minimum requirements for test equipment to use for USB 2.0 signal quality evaluation is listed at USB.org in the following place. There are links that describe electrical test procedures and tool requirement for Rohde&Schwartz, Tektronix, Agilent, LeCroy, and Yokogawa oscilloscopes.


Typically the eye evaluation software tools are offered on scopes with no less than 2GHz bandwidth. For Tektronix, the eligible scope series are TDS7254/B, TDS7704/B, CSA7404/B, TDS6604/B, TDS6804/B, TDS6404, DPO7254, DPO7354, and DPO/DSA70000. The smallest eligible oscilloscope for USB 2.0 testing is MSO/DPO5204.


For FS eveluation you don't need differential probes, the scope does it mathematically using single-ended probes.


However, the software package can't be installed on smaller bandwidth scopes, so, even if 500 MHz bandwidth is OK for FS eyes, it is unlikely that you can use this scope.


dc - Fail circuit with N MOSFET, what is wrong?


I have a circuit with two DC power lines coming from BATT A (1A) & BATT B (2A) (two outputs of a power bank). There is a sliding switch on the power line of BATT A. I would like to keep only one switch to control both power lines.


I the following circuit with a N-Channel MOSFET (RFP30N06LE) to be able to control the power line of BATT B using the state of power line of BATT A ?


Circuit


I have a problem with it, I get 2V on the motor driver when the SW1 is open. Moreover the MOSFET M1 became quite hot.


The goal was to use M1 as switch for BATT B managed by SW1. Do you see any error that can cause my problem ?



Thanks for your help :)




Friday, 21 November 2014

microcontroller - Detecting dry-running of water pump


What are some reasonably reliable ways of detecting that a water pump (electrical motor based) is "dry running", i.e. no water is passing through the pump either because there is no water available at the inlet, or due to "air-block" ?


I'd prefer mechanisms that are least intrusive, i.e. ideally - do not require re-plumbing. However, if all practical mechanisms involves some plumbing work, then it might as well.


An indication regarding possible cost of sensors, installation skill required, would be very useful.



Answer



Given this additional detail:




Not familiar with the typical plumbing terminology, but it is certainly not submerged. Pump inlet is fed by an underground sump (about 10 feet deep), pump itself is at ground level, and it pumps up water into an overhead tank, which is about 40 feet above ground. Typically it is a 1.5HP 2000W 220VAC monoblock pump. I am just guessing that the configuration is "in-line", I could be wrong.



I've got a very simple, cheap, reliable solution for you: remote monitoring.


Nothing says your sensor has to be at the pump's inlet. You could place your sensor at the system's inlet. Submerge a cheap float sensor at the level of the inlet to the feeder pipe in your well (or whatever water source). Run wires back to the pump's power controller.


When the float sensor says the water level is below the feeder pipe, turn off the pump. Ten bucks, totally reliable. Done. =)


Multiple float switches are increasing depth in a tank


This figure shows multiple float switches at increasing depths in a tank to illustrate operation. You just need one at the bottom of your feed pipe. You do not need to disturb any existing plumbing to do this.


Thursday, 20 November 2014

load sharing in parallel generators


My question is the following: We have two 220V 20A generators connected in parallel to total power 8.8 kw 220 v 40 A load is 5.5 ohms I'm interested how each generator sees this load since every generator gives half the power. I put this question because one generator can not see this load like 5.5 ohms because it gives half power to not the full power I would like to have somebody explain it a little bit better because it makes me confused .


simplified question


my question is that since every generator in the parallel circuit gives half power in the ideal case it would mean that the generator 1 that gives 220v 20A that is half the power can not "see" the resistance of 5.5 ohms because if "seen" this resistance he had to give complete current in that case we have two problem generator 1 burned because it is not made for such a current problem two if generator 2 gives the same current then the law on energy conservation is not worth what is absolutely not possible thanks


The last attempt to explain what I asked is very simple


we have two 220v 20A generators and a load of 5.5 ohms if we connect this resistance to just one generator it exceeds its power because it is 220v and 20 A 4.4 kw and the current at that resistor is 40A which would mean that it exceeds the maximum power of one generator ok if we add another generator then together have enough power to supply load it if we know that every generator gives half power ie 220v and 20A it is impossible to "see "a resistance of 5.5 ohms




How to implement AC analysis in a resonant circuit in LTspice


In previous LTspice simulations, I've set the AC amplitude of the voltage source to 1 and then carried on with the .ac spice directive. How do I setup the AC analysis for this circuit?DC/DC Resonant Converter


Do I set the AC amplitude to 1 for each voltage source or only my 100V DC source? Does setting the AC amplitude to 1 for a particular source set that source as the input voltage?



Answer




Do I set the AC amplitude to 1 for each voltage source or only my 100V DC source?




For AC analysis, the switches are not activated at all, the will be replaced by the Roff value of the switch\$ ^* \$.



Does setting the AC amplitude to 1 for a particular source set that source as the input voltage?



No. From the help file:



For AC analysis, the value of AC is used as the amplitude of the source at the analysis frequency.



For all the sources you don't fill in a value, 0V or 0A is used. So, all sources are applied, either with the zero value or the user entered value.





What do you want to achieve with the AC analysis?


If you want to know the frequency response of the resonant circuit plus load: remove the switches and connect V1 directly and run the AC analysis from LTspice.


If you really want to know the behaviour with the switches included, I think you need to do the more elaborated way: duplicate the circuit and add a small AC source in series to V1 in one of the circuits and compare the results of both circuits for different frequencies running a lot of transient analyses.




\$ ^* \$ I figured that out by playing around: I removed everything except for V1 and S1 and V6 and connected S1 with 2 equal resistors to GND. Setting the vertical axis of the plot window to linear and playing around with setting different values for the AC amplitude for V1 and V6, I found that only changing the aplitude of V1 changed the voltage between the resistors, but not to the value I expected. Next, I plotted the current through the resistors and found the current equals the AC setting for V1 divided by the sum of the Roff of the switch and the 2 resistors.


Wireless communication over long distances


Would like to communicate between an Arduino and a PC but over a distance of 2500+ feet outside in the open, wirelessly. What would be the best way of doing this? The communcation devices I have found (xbee,...) dont go the distance.





arduino - Does something like a "reverse jumper wire" exist?


All these kits you can buy for arduino come with "jumper wires" which are great for connecting a pin on the arduino to a breadboard. But "pin" on arduino is the wrong word since it's a female part. The "jumper wires" are male on both sides. What about the times where you want to connect a pin from say, the Motor Shield to some other pin? I would need a female to female jumper wire. Do those exist?




Answer



There are also female to female jumper wires.


enter image description here


power - How to compare mAh and Wh


When looking at consumer electronic devices with batteries I sometimes see the battery capacity listed in Wh (watt hours) and sometimes in mAh (milliamp hours). I would like to be able to compare the two different metrics and I'm wondering how to convert from one value to the other.



Answer



The Simple Answer


DC Power is defined in terms of W = 1 V * 1 A - that is, the power that is delivered by sustaining 1V potential with 1A of current.


Thus, a battery pack that can deliver 5400mAh, that is 5.4Ah, while sustaining voltage of 10.4V (this happens to be running in my laptop right now), can in theory deliver up to 5.4 * 10.4 = 56.16 Wh = 56160mWh.


The Complicated Answer


The above get a lot more complicated with different battery chemistries, and with different measurement methods. Firstly, the mAh rating can depend on the actual current draw - in general, the more current you draw, the less capacity the battery has, but there are exceptions at both ends of this guideline (if you draw too slowly, self discharge affects your measurement, and if you drive quickly enough, the battery gets warmer, and if it doesn't break, it tends to perform better).



Also, the voltage across the battery changes with the load - this is at least simple, the more current you draw, the lower the voltage across the terminals (this is due to internal resistance).


Finally, some devices are essentially dumb loads (battery powered tools), and draw as much as they can from the battery.. and some devices handle voltage and current changes in a more intelligent manner (mostly laptops and other DC/DC converters).


This means that for dumb loads, you are more concerned with mAh ratings (perhaps measured until battery voltage remains above some usable threshold).. since this can be used to calculate time-to-empty (which is really what you or your users are after), and dumb loads are approximately constant current/constant resistance loads.


For smart loads, the discharge controller (DC/DC converter) would actually try to drain constant power - the lower the voltage, the more current it drains so that it can continue outputting constant power on it's business end.


Crystals, Oscillators, and Resonators. What the difference?



I am trying to figure out the difference between crystals, oscillators, and resonators. I'm starting to grasp it but I still have some questions.


From my understanding, an oscillator is built from a crystal and two capacitors. What is a resonator then? Is it a difference in terminology?


If an oscillator and a resonator are similar, why do these two items:


http://www.digikey.com/product-detail/en/HWZT-16.00MD/535-9379-ND/675574


http://www.digikey.com/product-detail/en/FCR16.0M2G/445-1646-ND/653108


have two pins out and no ground. Whereas this one


http://www.digikey.com/product-detail/en/ZTT-16.00MX/X908-ND/170095


has three pins one of which is a ground?


Will any of these three devices work as an external clock for a microcontroller?


PS: Bonus points for an explanation of how the capacitors help the crystal work properly. :)




Answer



Both ceramic resonators and quartz crystals work on the same principle: the vibrate mechanically when an AC signal is applied to them. Quartz crystals are more accurate and temperature stable than ceramic resonators. The resonator or crystal itself has two connections. On the left the crystal, right the ceramic resonator.


enter image description here enter image description here


Like you say the oscillator needs extra components, the two capacitors. The active part which makes the oscillator work is an amplifier which supplies the energy to keep the oscillation going.


enter image description here


Some microcontrollers have a low-frequency oscillator for a 32.768 kHz crystal, which often has the capacitors built-in, so that you only need two connections for the crystal (left). Most oscillators, however, need the capacitors externally, and then you have thee connections: input from the amplifier, output to the amplifier, and ground for the capacitors. A resonator with three pins has the capacitors integrated.


The function of the capacitors: in order to oscillate the closed loop amplifier-crystal must have a total phase shift of 360°. The amplifier is inverting, so that's 180°. Together with the capacitors the crystal takes care of the other 180°.


edit
When you switch a crystal oscillator on it's just an amplifier, you don't get the desired frequency yet. The only thing that's there is a low-level noise over a wide bandwidth. The oscillator will amplify that noise and pass it through the crystal, upon which it enters the oscillator again which amplifies it again and so on. Shouldn't that get you just very much noise? No, the crystal's properties are such that it will pass only a very small amount of the noise, around its resonance frequency. All the rest will be attenuated. So in the end it's only that resonance frequency which is left, and then we're oscillating.


You can compare it with a trampoline. Imagine a bunch of kids jumping on it randomly. The trampoline doesn't move much and the kids have to make a lot of effort to jump just 20cm up. But after some time they will start to synchronize and the trampoline will follow the jumping. The kids will jump higher and higher with less effort. The trampoline will oscillate at its resonance frequency (about 1Hz) and it will be hard to jump faster or slower. That's the frequencies that will be filtered out.

The kid jumping on the trampoline is the amplifier, she supplies the energy to keep the oscillation going.


Further reading
MSP430 32 kHz crystal oscillators


Wednesday, 19 November 2014

dsp - How to select ADC resolution, considering input signal SNR and digital signal processing?


What I knew: The ADC resolution selection depends on the ADC inherent noise and input signal SNR.


Our application: Very high precision measurement of signals ranging 1kHz to 10kHz. We want to get as accurate result as possible, even 24-bit result.


The above statement, however, does not take digital signal processing after ADC sampling into consideration.



Since DSP techniques such as FIR, FFT and etc. may reduce the noises greatly, is it possible that increasing ADC resolution may also improve the measurement result when taking DSP techniques into consideration?




ac - Transformer labeled 120v-60hz-35va-12v - What exactly does it do?


I have a pool light whose bulb physically broke, but I've found a way to open the water-tight bulb enclosure to get at the actual bulb. I'm trying to either hunt down a replacement bulb (rather than the whole expensive assembly) OR make some LED magic.


Either way, the transformer's somewhat permanently mounted and I'd like to use it as it's already there, water-tight, and has the specific fitting to match the pool light flange.


I just can't figure out what 35va-12v means, and google didn't really help. I assume 35VA means 35VAC, but 12V is a common DC voltage and it's on there too!


Of course, I tested it and I actually get 14 VAC. How would I, in the future, know that based on the label? Is there a spec for this kind of stuff?



Answer




If it is a plain transformer, without any additional electronics, then the 12V mentioned means 12V(AC). This is the voltage the transformer outputs at its rated load.


Now what is this rated load I speak of? It is about how much power the transformer can potentially output. The 35VA indication is a measure of how much power the transformer can deliver. This is simply the product of voltage and current. The voltage is 12V, so maximum current can easily be calculated I(max) = 35VA / 12V = 2.9A When experimenting with this transformer, you might want to add a 3A fuse at the 12V(AC) side, just to prevent overloading.


You wrote your lightbulb is broken, so your transformer has no load. This is a bit like you driving your car down hill. Your engine doesn't have to work very hard and you probably start accelerating a bit. An unloaded transformer increases its output voltage. 14V output voltage is perfectly normal with this transformer when unloaded. When you attach a 25W lightbulb to it, you'll notice the voltage drops to around 12V. With a conventional light bulb, you can use bulbs up to 35W with this transformer. When using other devices the maximum number of watts drops, depending on the exact device.


120V and 60Hz is related to your mains supply. It is what you get from the wall socket.


audio - building simple radio


I'd like to build a simple AM radio (so simple it will only receive a single AM channel).


What is the simplest way to build a single channel AM radio that will output to an 8ohm speaker? (e.g. 1030 AM)


My current thinking is along the following somewhat vague lines, but I'm hoping to make them more concrete.



  1. use a piece of wire as an antenna

  2. create an LC circuit to tune input from antenna to the desired frequency

  3. amplify the signal


  4. connect amplified signal to speaker


Aside from the antenna, I would prefer to use "discrete" off the shelf components such as capacitors and inductors of particular values that I could plug into my breadboard.



Answer



Your basic strategy to use a piece of wire for the antenna, into a L-C resonant circuit tuned to the frequency of the desired station, amplify that, then connect to a speaker is on the right track but misses at least one important step. That is to detect the AM signal, or to demodulate the amplitude modulated radio signal to get the original audio signal.


After the demodulator, you should also add a stage to drive the 8 Ω speaker with. That will be a stage meant to produce power, not necessarily amplify the voltage. To skip this, you can make just a line level audio signal and feed it into some ordinary audio amplifier, or powered speaker like you would hook up to a PC sounds card. The powered speaker is really just a power amplifier and speaker in a single box.


The simplest AM detector is just a diode. The output of the diode effectively rides the peaks of the RF signal, and goes up and down with its amplitude. You set up the impedance driven by the diode such that the output decays slowly enough so that it doesn't change much in the gap between carrier cycles, but does change fast enough to follow the modulated signal. Fortunately this isn't too hard since there is a large frequency ratio from audio to carrier. If the highest audio frequency is 5 kHz and the carrier is 1 MHz, then you have 200:1 difference.


A even better way to make a detector is to use a bipolar transistor as emitter follower. You can think of this as a powered diode in this application:



This audio out signal can probably be fed directly into a PC "powered speaker".



operational amplifier - Impedance to voltage range



I'm trying to get a voltage in a range from a potentiometer.


The potentiometer theorically varies between 22k and 40k (R1 in the shematic) but I'm unsure as I currently don't have it in my hands.


I want to "convert" the potentiometer value to a voltage in [0v-5v].


schematic


simulate this circuit – Schematic created using CircuitLab


Here, I first convert the impedance to a voltage trough a voltage divider (R2/R1+R2), and then I input this in a differential LIAO.


It should substract Vc from Va and multiply it with R4/43 and I should have : Vout = (R4/R3)(Va-Vc) which would give me a value in the right range.


But the problem is that It actually won't work because the second voltage divider won't just behave as if Va was a regulated voltage source, and with Thevenin theorem, you can find this equivalent circuit (here just for Va - Vb part) :


schematic


simulate this circuit



And then I have Vc = 1.91011 Volts while what I'd want there is Vc = 5*(22k/44k)(68k/78k) = 2.17949


How can i do ?



Answer



Your circuit has 7 resistors and produces a nonlinear response of voltage with respect to resistance.


Here is a circuit with only 5 resistors that can operate from a single 5.0V supply (using a rail-to-rail input* and rail-to-rail output op-amp) and which produces a linear voltage proportional to resistance.


schematic


simulate this circuit – Schematic created using CircuitLab


The variable resistance sees a constant current of 39.78uA.


To synthesize this circuit for other ranges, pick R1, R2 to something reasonable considering the op-amp input bias current, accuracy required, and current capability of the variable resistor, and overall consumption.


Pick R4 to maintain a constant current.



Pick R5 and R6 to make the output voltage correct at minimum and maximum resistance.


As simple as that! (some algebra omitted, but it's straightforward)


* actually the input range is only 0.87 to 1.59V so many R-R output op-amps will work.


Tuesday, 18 November 2014

Multiple two pin multi-color LEDs pattern - how does this work?


I'm quite blank when it comes to electronics, but am trying to learn...



So I bought a DIY Learning Kit from Banggood to get some solder practice.


As you can see from this video, the leds will change color and turn on and off in different patterns.


This question already establish that two pin RGB leds most likely contains some kind of micro chip, but it doesn't say anything about how they can be controlled.


The chip on the board is a STC15F204AE, and I guess that's the one responsible for creating the patterns. But again - how?


Is it just a fixed sequence pattern in the LED, and then the chip ensures that each LED receives power right after the previous, or is the LEDs addressable some how?



Answer



I'm afraid we're a smart about this as you are – for all we know (and as you know, from the answer you've linked to), the LED contains some controller itself. It might be controllable by shutting the supply voltage on and off, or by varying the input voltage.


The STC15F204AE is just a run-off-the-mill microcontroller – it was probably chosen for price reasons (it's not an established microcontroller brand, but uses the ancient, yet omnipresent 8051 CPU core architecture.) It executes some software (that we don't know) to send some commands (that we sadly don't know, either) to control the LEDs (which listen to some –unknown– form of commands).


transistors - What is this substance on board?



So I’m trying to fix my blu-ray player and there are two spots where this beige stuff is. Is this there intentionally, or is this the result of some malfunction?


Could someone please explain what it is and why it happened? Thanks Image of substance


Second image of substance



Answer



It's intentional. It's glue (of some sort) to keep parts steady and not break from vibrations when shipping or handling the unit.


mosfet - Why won't this DIY transistor attempt conduct


enter image description here


enter image description here


I've been trying to make a crude transistor device at home. So far I have not been successful. My electrical understanding is next to non existent other than what I've learned in the last 3 months since I read a wild article about inkjet printed transistors.



I am trying to use a method that doesn't require toxic materials or high temperatures.


This experiment seems promising, so I have tried to emulate the device based on a zinc-oxide semiconductor layer and wire-glue contacts as described here.


https://www.andaquartergetsyoucoffee.com/wp/wp-content/uploads/2009/05/zinc-oxide-experiments-i.pdf


According to the paper, a transistor/field effect is achieved with this device by applying 96 volts with the negative lead of the power supply attached to the gate and the positive attached to either source or drain.


the reason for the high required voltage seems to be the thickness of the gate dielectric which is a microscope cover slide around 0.12mm - 0.16mm thick. I was hoping my gate dielectric being ~ 0.01mm thick would allow the device to conduct at ~ 9 volts at the gate.


My attempts with some changes:


Materials used:



  • semiconductive "ink/paint": organic non-nano zinc-oxide powder + Isopropyl alcohol

  • source, drain and gate: conductive pen (ground carbon and non toxic binder)


  • source, drain and gate: wire glue (silver paste)

  • gate dielectric: kitchen grade cling wrap ( according to web search ~ 0.01mm )

  • substrate: glass microscope cover slides

  • 24 gauge non coated copper wire

  • wire glue (ground carbon and non toxic binder)

  • bench-top DC power supply 0-5 Amps 0-30 Volts


Attempt # 1:


https://i.imgur.com/52jjQoP.jpg





  • used conductive carbon pen to draw a line glass slide as the gate and used wire-glue to connect copper wire to one end. Then let dry in oven at ~ 100 degrees Fahrenheit for ~ 15 minutes




  • wrapped glass slide with 1 layer of cling wrap tightly and placed in oven at ~ 100 degrees Fahrenheit for ~ 15 minutes in an attempt to flatten out any wrinkles in the cling wrap. (only minor success)




  • Dripped solution of zinc-oxide and 91% Isopropoyl Alcohol on top of covered slide and let dry in oven at ~ 100 degrees Fahrenheit for ~ 15 minutes. A brittle layer ~ 1mm thick was created





    • drew source and drain ~ 2mm apart on a new glass slide and connected copper wire with wire glue. Let dry in oven at ~ 100 degrees Fahrenheit for ~ 15 minutes




    • placed second glass slide on top of the first with source and drain contact down touching the zinc oxide layer with the gate centered between source and drain




    • wrapped scotch tape tightly around the 2 glass slides to help with close contact between all layers.




    • connected negative lead of DC power supply to the gate and the positive lead to one side designated drain. Connected multi-meter to source and drain.





    • turned on power supply on lowest settings and slowly turned up amperage and voltage to max. 5 amp & 30 volt




    • No voltage or continuity could be measured between source and drain




    • the same steps were repeated using silver wire glue as source drain and gate also with negative result.







Attempt # 2


enter image description here


Similar to the first attempt with only 1 glass slide. I thought the connection between the source drain and zinc-oxide layer might not be close/clean enough.




  • used conductive carbon pen to draw a ~ 5mm wide line on the glass slide as the gate and used wire-glue to connect copper wire to one end. Then let dry in oven at ~ 100 degrees Fahrenheit for ~ 15 minutes





    • wrapped glass slide with 1 layer of cling wrap tightly and placed in oven at ~ 100 degrees Fahrenheit for ~ 15 minutes in an attempt to flatten out any wrinkles in the cling wrap. (only minor success)




    • dripped solution of zinc-oxide and 91% Isopropoyl Alcohol on top of covered slide and let dry in oven at ~ 100 degrees Fahrenheit for ~ 15 minutes. A brittle layer ~ 1mm thick was created




    • used syringe to draw source and drain lines directly on zinc-oxide layer with wire glue and then connected copper wire. Let dry in oven at ~ 100 degrees Fahrenheit for ~ 15 minutes





    • coated top with superglue to avoid the source and drain pulling off the zinc-oxide layer during handling. let dry over night




    • connected negative lead of DC power supply to the gate and the positive lead to one side designated drain. Connected multi-meter to source and drain.




    • turned on power supply on lowest settings and slowly turned up amperage and voltage to max. 5 amp & 30 volt




    • No voltage or continuity could be measured between source and drain







Here are a few pictures of the steps: https://imgur.com/a/jXAoOS0


At the moment I'm not able to verify if the materials I used would work in the exact same setup as described in the experiment I tried to emulate. For now I'm missing zinc nitrate, 2­propanol, and a DC power supply capable of 96 volt output.


What are the main flaws in my experiment?


I have the following assumptions that are difficult to verify at the moment:





  • my zinc oxide layer may be too inconsistent/brittle and is not creating a uniform surface.




  • my gate dielectric/substrate is not flat enough or made of the wrong material




  • my gaps are too large / gate dielectric is too thick and source and drain are too far apart




  • my materials are not pure enough and therefore not displaying expected properties





  • I've found that silver is used as an n-type dopant and since I expect my zinc oxide layer to be n-type, a p-type dopant is needed




  • Wile the experiment I'm trying to emulate uses wire glue, there is little explanation as to what the material is other than the statement that any conductive glue should work. My wire glue is ground carbon based just as the conductive pen I used. I've not found any info if carbon is n or p-type. perhaps carbon can't be used either. https://www.andaquartergetsyoucoffee.com/wp/wp-content/uploads/2009/05/zinc-oxide-experiments-i.pdf




  • I can't apply enough voltage to the gate since my supply maxes out at 30 volts.





  • my wiring is wrong




I'm thinking the flaws here are probably simple to point out for anyone with experience in this field. Any tips and ideas would be much appreciated. I'm wondering if I'm anywhere close to a working device.




arduino - Can I use TI'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...