Saturday, 30 September 2017

transformer - Scaling of magnetic field strength and flux density measurements and shape of hysteresis loop


Note: this is part of a larger question which I was asked to separate into subquestions. Other subquestions: 1 and 2




I'm using the method outlined here to measure the induced magnetic flux density in a toroidal transformer made of Nanoperm (additional datasheets here and here). I have adapted the method to use a passive integrator rather than the op-amp integrator described in the tutorial. (I tried building the active one but it was giving me issues.)


The diagram of my circuit is given below:



schematic


simulate this circuit – Schematic created using CircuitLab


The signal generator is connected to an audio amplifier capable of driving large currents.


The first subplot in the two figures below show hysteresis loops measured at an input frequency of 50 Hz and 380 Hz for R2 = 37 kOhm. (I tried additional input frequencies and values of R2, and details of my complete experiment can be found in my original question.) Additionally, the raw voltages VM1 (V(R1)) and VM2 (V(C2)) are plotted in the second and third subplots, and the Fourier transform of V(C2) is plotted in the fourth subplot.


enter image description here enter image description here


To make my hysteresis loop comparable to those in the datasheets linked above, I converted the raw voltages measured by my probes to magnetic field strength H (units of A/m) and magnetic flux density (units of T) using the equations given in the tutorial linked above: $$H \equiv \frac{V_R(t)\cdot N}{R\cdot l_c}$$ where \$V_R\$ is the voltage across the resistor, \$N=6\$ is the number of turns, \$R = 400 \mbox{m}\Omega\$ is the shunt resistor connected to the audio amplifier, and \$l_c = 10.03 \mbox{ cm}\$ is the magnetic path length given here; and $$B(t) \equiv \int_{0}^t{\frac{E(t)}{-N\cdot A_c} dt}$$ where \$E\$ is the electromotive force (EMF) induced in the secondary winding, \$N=6\$ is the number of turns, and \$A_c = 0.88 \mbox{ cm}^2\$ is the cross-sectional area of the core given here. The raw voltages are plotted in the second and third subplots of each figure.


The MATLAB code used to generate H and B from the measurements is shown below:


R = 0.4; % ohms
N = 6; % number of turns
LFe = 10.03E-2; % m

AFe = 8.8E-5; % m^2

H = (V(:, 1)/R)*N/LFe;
B = V(:, 2)/(AFe*N);

figure (1); clf; subplot(2, 2, 1); scatter(H, B, 'k.')
xlabel('Magnetic field strength - H (A/m)')
ylabel('Magnetic flux density - B (T)')

where V(:, 1) and V(:, 2) correspond to the most recent 100 ms of data acquired by the differential probes VM1 and VM2 in the circuit diagram above. (Q1) I'm not sure why, but I am orders of magnitude off in both my calculations of H and B. I think V(:, 2) already accounts for the integration since it is the voltage across the capacitor on the measurement side, but I may be missing a multiplication by time in my calculation for B since the units for B are Teslas, which expressed in more fundamental units are \$\frac{V\cdot s}{m^2}\$. It would be great if someone could confirm this / correct me and let me know where my setup / calculation / code may be going wrong. (Q2) Might it have anything to do with the fact that the integrator has a gain of much less than 1 for the frequencies I'm looking at?



Additionally, for the 50 Hz case, (Q3) the shape of my hysteresis loop looks nowhere that of the hysteresis loop given in either of the datasheets here (page 3) or here even though both report measuring the hysteresis at 50 Hz. Does anyone why this is the case?




operational amplifier - When would you need a low bandwidth opamp?


This opamp has a unity gain bandwidth of 27kHz, which is by far the lowest I've ever seen. (I first misread the 7.7V/ms slew rate as 7.7V/\$\mu\$s, because that's the units most often used.)


27kHz looks very bad. Is there any reason why they would make opamps with these speciifications?




Answer



That 27kHz is nothing. The LPV511 has a little brother, the LPV521, which has a gain-bandwidth product of 6.2kHz.


They're not making it low-bandwidth on purpose. There is no real advantage to the low bandwidth, though it improves stability.
The low gain-bandwidth product is a consequence of the low power design. The LPV521 consumes only 350nA. You already mentioned slew rate, and it's closely related to bandwidth. The LPV521 has a slew rate of 2.4V/ms. To change the output level of an opamp fast you have to pump current to the output drivers. That's not what this opamp is designed for. Lots of applications are very low frequency, DC to a few tens of Hz at most. A typical application shown in the datasheet is a current monitor for a battery operated device, which will probably be near DC.


Anyway, you'll have to pay dearly for such a bad opamp ;-). Seriously, even in large quantities the LPV521 costs more than a dollar, while you can get common opamps for 6 or 7 cents. It's that 500nW you're paying for. Try to find other opamps which will operate on a coin cell for 5 years or more.


datasheet - What use is a Zener diode's leakage current spec?


Consider this datasheet for a family of Zener diodes. All of the parts 3V and under have their leakage current rated as some current at 1V. I've seen this is multiple family datasheets, but it really doesn't make sense. There is no relationship between the test voltage and Zener voltage. I could see a spec such Zener voltage at 1uA having utility. At least the test condition would remain consistent and have the same meaning for each part in the family. Why are Zeners spec'd the way they are?



Answer



Leakage current in processes such as these are not primarily controlled for. As long as the devices met some typical value at test then the product is released. The reason for this is that leakage (in it's various forms , Band to band, tunnelling, Hopping) is driven to a first order by impurities and defects which are by definition random.


Principally these devices are not usually operated in any really different mode other than as Zeners, so this is measurement is more of a reality check. And while I can see your argument, if the leakage at 1V is X then it should behave predictably at higher voltages. Of course this is swamped by the zener current once it hits its knee.


Your alternative suggestion, while also understandable would be very hard to do in a reproducible way. Here is a snip from that data sheet.


enter image description here


You can see from the curve in the 3rd quadrant that a fixed voltage (a vertical line) with a variable curve (variable from sample to sample) will show a little variation in the Leakage current. Due to the slope of the curve the sensitivity is low.


Now, flip it around, pick a fixed current as you suggest (a horizontal line) and imagine multiple curves occupying the 3rd quadrant from device to device. Due to the slope of the curve, a slight process variation would manifest itself in a wildly varying voltage. So much so that it would be useless as a measure.


ac - Current limiting at mains voltage


I am driving a BTB16-600BW triac using a MOC3052 exactly as suggested in the MOC3052 datasheet:


enter image description here



The current into the power triac gate is limited using the highlighted resistor. My triac requires at least 50 mA.


The resistor gets fairly hot during actual operation and no surprise: \$I^2R\$ (RMS) with the 10k resistor I'm using is about 1.2W if my calculations are correct.


Is there a better way to limit the current here, especially one that doesn't involve generating much extra heat? I don't mind spending a few more pennies on a solution that requires less tweaking - in particular, I'd love to just grab a purpose-built DIP6/8 IC that requires only a single additional passive to set the current limit.


I've seen a few circuits using transistors, but I don't have any with a high enough voltage rating, and if I'm going to buy something I'd prefer to buy the most suitable part for the job.



Answer



Use a high power resistor. For any given temperature, resistors will be more reliable than semiconductors, so there is no advantage in dissipating that power in a transistor.


This is common in power circuit design, for example dimmers and switched mode power supplies, you will need high power rated components because you are working at high voltages so even moderate currents produce high power dissipation.


I assume you are using a hard-fired technique, where you leave the gate current on continuously. In that case, the only way to reduce dissipation in the triac gate resistor is to use a more sensitive triac. But there is also the soft fired technique, where you only pulse the gate at the zero crossing and the triac stays latched on until the main current falls to zero. This is not suitable for all loads.


Friday, 29 September 2017

power - How to prevent DC motor from dropping voltage of supply when switching on


I have a circuit which uses an ATtiny85 output to a transistor (S9013), which will trigger a relay that controls a motor.


The reason for the transistor to relay is because I do not have a transistor that can take the current of the motor, so I am isolating it with a relay.


While I can purchase all these, it will take time to ship.


Here is the circuit:


SCHEMATIC NOT UPDATED, I HAVE A DIODE GOING ACROSS THE MOTOR, AND A 100uF CAPACITOR GOING ACROSS THE VCC AND GND TO SMOOTH OUT THE VOLTAGE (have also tried 100nF).


Everything works if I don't connect the motor OR if I isolate the motor with its own power source.


The issue now is that when the motor is switched on, there is a massive voltage drop and the ATtiny85 will reset. Here is a waveform of the motor trying to turn on three times:



Is there a way to prevent this drop or at least reduce it to a point where the ATtiny85 won't reset? I'm thinking wire up a simple voltage regulator but not sure if the added complexity will introduce other issues. I also know I can go out and buy a motor or voltage regulators but let's avoid that option.



EDIT: so as per the answer, a diode (cathode at +ve, anode at VCC) was added between +ve and VCC, assuming that there is a capacitor connected in parallel with the ATtiny85 (+ve end at VCC, -ve end at GND). Theory is that the cap gets charged while the motor is off to VCC. When the motor turns on, it's going to drop that voltage down to below VCC and the diode is going to be reverse-biased and prevent any conflict from the supply to going into the ATtiny85. The capacitor can now freely discharge into the ATtiny85 without the supply affecting it (without the diode, supply will average capacitor down faster than if it would just discharge alone). For reference, the bulk capacitance value I used was 100uF.



Answer



Put a diode between the supply and the bulk capacitor for the MCU. Since the diode will be reverse biased when the motor causes the brownout very little current will flow through it, preventing the MCU from browning out (at least until the bulk cap gets too low).


Split-phase 230VAC transformerless capacitive power supply for 5V@30mA regulated output -- series cap?


I'm a hobbyist developing a hybrid power switch (electromagnetic + solid state) for a resistive electric stove (8kW max) top. I have a profoundly autistic, disabled adult in the house and I need a fairly specialized system to automatically shut off the stove if the kitchen is vacated for any reason. It also requires a code to enable it. And there are a few other "features." We've kept the breakers off for years, but things are changing so that is no longer acceptable and we need to reactivate the stove now. But with safety features customized to our special needs here.


The entire system is in two physically separate parts. One is the control panel -- battery powered only and placed less than 2 meters away from the hybrid switch system. A signaling method with very low false positives will be used from there to the hybrid switch micro. The hybrid switch micro uses a MOC3023 to control an EMR and a MOC3063 to control a pair of SCRs (I prefer a pair of these over a TRIAC for several reasons.) Unless I find a better way, there are two sets of these, one for each split. The SCRs are used ONLY for a few cycles, with the EMRs once engaged no longer requiring the SCRs until shutoff.


The problem is in supplying power to the sealed (plastic) module that contains the hybrid switch optos and micro. That part of the switching system is buried into a counter/wall area and needs to be self-powered from the 220VAC split phase system it switches. No batteries, etc. I like transformers, but the weight and bulk put extra risks in the work ahead and will also complicate other applications at a later date. So I would like to resolve this issue now with a transformerless system.


Split-Phase 230VAC Capacitive Transformerless Supply, 5V@30mA


There are quite a few schematic pages but I'm posting just the preliminary transformerless power supply section above. I'm most concerned about C1. I gather it should be an X class capacitor. If it fails "short," the only protection I've got will be the 100mA fuse. I'm also ill-informed about MOVs and their correct specification for an application like this. And there probably are areas where I'm ill-informed that I don't even know about. Regardless, I've been "tasked" by family to "solve this stove problem" and solve it I will do. So there is no stopping that. The only question is about getting it done with risks reasonably mitigated.


I already know the advantages of galvanic isolation. A CHEAP COTS solution that has small physical volume and is designed for delivery of 5V in the area of 30-50mA would be interesting. Price and physical volume and weight are important and so is total dissipation. I want the supply and the load together to be under 1 watt total. That can be safely ensconced in a cavity. I also hope to put the micro and the rest (not shown) on this same board in SMT to keep it all as small as I can. But I could sacrifice that hope.



Technical comments about safety are very much appreciated. Bear in mind I'm solving an unusual set of requirements. I have approached local stove-top sellers, and a few of the national manufacturers, about their units. Some have disabling modes -- but the way they work doesn't help. I have researched other options and I believe I may be stuck doing some part (or all) of this. I have already built and tested the hybrid relay system, with optos, using a COTS power supply and it appears to work as well as I'm able to judge it.




capacitor - Why do RC circuit voltages decay *slowly* rather than instantly?


Let's take the simplest RC circuit imaginable:


schematic


simulate this circuit – Schematic created using CircuitLab


Now I think I properly understand why the voltage rises slowly after the leading edge of a pulse--the capacitor acts like a variable-resistor turning the circuit into a voltage divider. R1 delays the time it takes to charge the capacitor, and while it accumulates charge, its resistance slowly increases, changing the balance in the voltage divider to increase the voltage to OUT.


However, I don't understand why, in a situation where OUT is presumably much lower-impedance than R1 (e.g. OUT's a short), when the clock goes low the cap doesn't dump all its charge through OUT as fast as it could with a short. I understand that OUT is not usually a short and so does actually have some resistance, which means the charge has to flow out of the cap somewhat slower and is divided proportionally between R1 and OUT's load. But does this non-trivial resistance of OUT really account for all or even a significant portion of how slow the voltage decays? Or am I not considering some other effect?




Answer



OUT is simply a label so that the simulator can assign a voltage at that point. It is not part of a charging/discharging circuit.


The basic rule of capacitor charging is that you cannot instantly change the voltage across a capacitor (unlike a resistor). The capacitor in your circuit starts off with no energy and has 0V across it. So OUT will show as 0V. On the rising edge of the input the full voltage of the pulse appears across the 100R resistor. If the step voltage is V then the initial (charging) current will be V/100 amps. As the energy stored in the capacitor increases the voltage across it will increase (Vc). This reduces the size of the current (V - Vc)/100 amps. It is this increase in capacitor voltage that produces the characteristic exponential charging curve.


enter image description here


It will take ONE TIME CONSTANT (C x R) to reach about 67% of the final value.


When the input pulse returns to 0V the capacitor will start to discharge through the 100R resistor.


Calibration of reading of current measuring cicuit


Ok ,I'm making a small current meter device
I was able to take the voltage coming from a "shunt resistance " which is a current transducer that gives me an specific analog signal that proportional to the current passing in it , I take this signal into ADC , so I facing a problem of calibration


My question is : -The available methods to calibrate the reading -Is there some methods that I can make it programmatically without the need for a reference(external device ) or human interference ?


My goal in accuracy for now is 1% in readings . I'm measuring AC current. Range from 0.5 A to 80 A . Heat is not a problem .




Answer



You should be able to compute the scaling factor. The resistor will make volts from the current according to Ohm's law. After that you should know what gain you have into the A/D and what range the A/D is using.



For 1%, you probably do need to do some calibration. A large enough known voltage source with known resistor will give you a current. You can make the current as accurate as the resistor and your ability to measure the voltage accross it. With a 1/2 % resistor and any reasonable voltmeter (has to be good to 1/2 % minimum), you can know the current to 1%, then store that and the zero reading in EEPROM and correct from those on the fly each reading. Be aware that some of that might drift with temperature, so you want to calibrate at your center temperature or specify a narrow range.


Added:


Component values and amplifier offsets vary over temperature. I was assuming a two point calibration, which can always be mathematically reduced to


OUT = IN*m + b


M is the gain adjustment and B the offset adjustment. Since both gain and offset are functions of temperature, any one set of M and B values is only valid at the particular temperature the measurements were made to derive them. If this calibration temperature is in the middle of your usage range, then the actual temperature will never be more than 1/2 the range off of the temperature the unit was calibrated at. This may possibly be good enough and not require temperature compensation. If instead you set M and B to calibrate the unit at one end of the temperature range, then the actual temperature at usage time could be the full range off from the calibration temperature, making the worst case error higher.


Since you mentioned a A/D, you will have the measured values in digital form. This allows for performing the calibration equation above digitally. This also means the M and B values have to be stored in non-volatile memory somehow. The obvious answer is in the EEPROM of the same processor receiving the A/D readings. Calibrating digitally and storing the calibration constants in EEPROM is cheaper and better than ancient methods like trimpots. Trimpots cost real money, take board space, and themselves drift with time and temperature. On the other hand, most microcontrollers come with non-volatile memory, and usually have enough code space left over to perform the calibration computation at no additional cost. Even if not, using the next larger micro is usually a smaller increment than the cost of adding a trimpot.


As for AC measurements, why do you need them. Current shunts work at DC, so you should be able to calibrate the system at DC unless you have deliberately AC coupled the signal for some reason.


Thursday, 28 September 2017

power supply - Snubbing DCM (nonsynchronous) Buck converter


FINAL UPDATE:


I've posted an outcome report below. I'm very satisfied with how this has come out and I learned a lot in the process. More details and before/after shots in the answer below. Thanks to @Andy and @winny for their help and encouragement :)


Just a note to help search, the board used here is colloquially known as the "Fake LM2596 eBay buck converter". The chip behaves like an LM2576 (52kHz switching frequency instead of 150kHz) although it possibly lacks the protection circuitry.





I'm working with an LM2576-based buck converter as a learning project. Basically I've made a $0.99 eBay buck into a highly-affordable if somewhat less flexible demo board :)


enter image description here


The LM2576 enters discontinuous conduction mode (DCM) at light loads (<500mA or so), and when it does, it exhibits vigorous ringing on the switch node when the diode turns off, the residual energy in the inductor bouncing back-and-forth between the inductor and the diode capacitance:


enter image description here


The datasheet states this is nothing to worry about, but that it can be addressed with an RC snubber across the inductor if desired. I understand most folks wouldn't bother with it, but since this is a learning project and my first chance to design a real-life snubber, I want to do the best I can and learn as much as possible for future snubbing challenges.


Also, the ringing counts as EMI in my world, and it does couple to the output:


enter image description here


I've done a lot of research on snubbers, six distinct sources including Rudy Severns' eBook and all the application notes (and a master's thesis) I could find. Because I'm doing this as a learning project, I want to master the concepts and procedure in general, not just get a solution good enough for a particular application.


Here's the schematic (the actual diode is marked SS34, the SS3P5 is the closest available LTspice model):


enter image description here



And here's the board layout:


enter image description here


reverse side mirror-imaged for easier through-hole matching:


enter image description here


By following the prescribed procedure (detailed below), I get the values 1nF and 220R. These tame the ringing substantially:


enter image description here




UPDATE:


I installed a pot in the resistor position and discovered 430Ω provides maximal damping with a 1nF (C0G) cap.


With the optimal resistor in place, I was able to do better:



enter image description here




But they don't critically damp the ringing, which is what was indicated in [1] Todd at least and what I was after.


I've found on simulation that I can achieve critical damping (or something quite close) with the values 8.6nF and 350R.


enter image description here


So I'm wondering why the sources I found all pretty much agree, but all give me lower values than what seems to be called for.


I have a couple hypotheses:




  1. Mine is a special case. Most of the sources use synchronous buck converters in their example. These have a larger capacitance and much lower inductance. The formulas don't work when the situation is reversed. (In my case, L=47uH, C=100pF.)





  2. Nobody wants to snub to critical damping. In my case, the energy to be snubbed is small (single digit mW), in the more common cases, the designer is making a significant trade-off against efficiency and a couple wiggles left on the waveform is perfectly acceptable.




Can anyone help me understand what I'm seeing?


One anomaly I've noticed is that all the sources say the RC time constant of the snubber should be short compared to switching frequency but long compared to rise time of waveform to be snubbed. The values I got (1nF, 220R) have a time constant almost the same as the rise time of the ringing (~200ns).


(Update: I later realized I was measuring the rise time after installing the snubber. A close measurement of the unsnubbed circuit revealed a rise time of 116ns and the final snubber R value produced an RC of 426ns. This roughly 4x \$\tau\$ value seemed to be "bigger enough" :)




Prescribed procedure





  1. Add capacitance across switch node until ringing frequency is reduced to 1/3 original value (some say 1/2). This determines original C is 1/8th of added value (total C is 9 times original, sqrt(9)=3).




  2. Calculate characteristic impedance of new LC tank, sqrt(L/C). Use resistor of this value.


    On a close second reading, I discovered the sources disagree on which values to use for the characteristic impedance calculation. [1] Todd recommends using the original \$C_{parasitic}\$. Another uses the new total \$C_{parasitic} + C_{snubber}\$. The optimal value I found is nearly right in the middle of these two (209Ω < 430Ω < 670Ω).




Resources:



[1] Todd, Philip C.; Snubber Circuits: Theory, Design and Application



Answer



Basically this is a non-problem. You don't need to do suppress the free-wheeling ringing due to the inductor and drain-source capacitance of the open-circuit MOSFET (more likely than the diode) in a buck converter because nothing bad happens if you leave it alone. The voltage in both polarities is never bigger than the voltage due to switching so the MOSFET cannot harmed by it.


It's totally different on a flyback converter of course but this is a non-synchronous buck converter.


Just regard it is a little bit of energy that could not make it's way to the output.


After-thought - if you were really clever you might be able to find a way of harnessing these oscillations and feed that energy back to the input capacitor. That would certainly be a step in the ecologicial right direction.


The device data sheet has this circuit for reducing output ripple by up to 10 times: -


enter image description here


The LC network will rely on the ESR of the capacitor added being as low as possible and quite probably if you are using "any old" capacitor in the Cout position (ref diagram above) then its ESR and ESL will be poor. TI are not recommending a snubber to reduce ripple!


operational amplifier - simple adjustable current source for LED string


I want an simple adjustable current source that can drive a string of up to 9-10 LEDs at up to 350ma, with typical forward voltage of 2.85v, from a 30vdc power supply. I know there are off-the-shelf solutions, but I find they don't dim gracefully to zero, and they are expensive. LM317 is an option, but the current is reciprocal of adjustment resistor, and you can't get audio-taper pots at the low resistance values required. I just want to be able to dim with a potentiometer, without the need of a PWM signal. Here's a simple circuit that just uses a single PNP transistor:


current source


Vctrl is just a dummy variable to simulate rotation of the potentiometer shaft. Since vsupply will be 30v, Vbe of the transistor should be fairly inconsequential, (and I could remove it from the adjustment range by adding a small resistor between vsupply and the bottom of the pot).


But there are some areas I'd like to improve. Since the base current into the BJT is in the few-milliamp range, I have to use fairly small resistors and pot in the divider that generates the base voltage, so that's some waste. And I'd love to be able to drive 10 LEDs (instead of the 9 shown). But that leaves only 1.5v of "overhead" (30v supply minus 10 times 2.85v). So then R1 and the swing of Vbase have to become quite small.


So maybe I'm better adding an op-amp, like this circuit posted (in another thread by Andy aka):


enter image description here


So now R1 has exactly Vin across it (due to the op-amp action), and R1 can be very small, so I can probably drive 10 LEDs. And the voltage divider that generates Vin can use very large values and burn very little power.


The problem, and the crux of my question, is selecting an op-amp: it needs to be a single supply type. LT1006 is a possibility (I'm not allowed to link to the data sheet). It has a maximum supply listed as +/-22v, which I assume means a single supply of 30v is acceptable. But the high output appears to be about a volt below the high power supply, which is unacceptable (I only have a volt or so to burn in R1 if I want to drive 10 LEDs).


I could invert the circuit, use an NPN transistor, but the low voltage of the op-amp is still going to be a few hundred mv (I don't understand the comment at the top of the data sheet that the output can swing to GND while still sinking current). Possibly this could work, depending on just how low the op-amp can drive with supply at 30v and GND.



A lot of rambling background, but my question is, are there other op-amps that might work better for this (or are there other simple circuits I might want to consider) ?




Wednesday, 27 September 2017

power - Why does Oscilloscope cause short?


I want to measure how much power my PIC is using. At the output of my 3.3V regulator I put a 1 ohm resistor in series with the rest of the circuit. I was going to measure the voltage drop across that resistor to get the current and so on. With the 1 ohm resistor installed the circuit works just fine but when I put the probe of my o'scope across it it my 3.3V goes to zero. It seems as though the scope is creating a short to ground or something. Does anyone know why this happens or how to make it stop?



Answer



The ground clip on your o-scope is actually tied to ground. it is a hard short and rather low resistance. This means that you are shorting the 3.3 rail to ground with your ground probe.



To fix this there are two options,



  1. Put the resistor in the return path so that one side of it is ground. That way the ground probe does not hurt it.

  2. Use two probes, one for each side of the resistor and use the math function on your O-Scope.


Let me know if this is not clear. I can add more information.


Where should I put the kickback diode in a transistor switch?


When driving inductive loads with transistors, we use kickback diodes.


What I understand is a kickback diode supplies a path for the inductive charge to discharge. Also, an inductor will try to resist the change in the current, turning into something like a voltage source that will source the current in the same way it was before, in case of a break in the current (for example when the transistor turns OFF).


In the below circuits, there are two different placement of the kickback diode. D1 is placed in a logical way, so that the charge in L1 will discharge through it, protecting Q1's collector from over-voltage or breakdown.


However, the second circuit with D2 makes no sense to me. How can D2 prevent any damage when it is reverse biased? I was seeing this configuration rarely, however I saw it in a Lenze driver schematic and couldn't understand it.


How does D2 prevent any damage due to inductive kickback?


Kickback diode configurations



Answer




The first circuit D1 is correct in that it safely deals with the inductive kickback.


The second circuit makes little sense on its own. As Federico pointed out, D2 could provide a safe path for the kickback current it if were a zener, but it's not a shown as a zener and a 1N4001 is definitely not a zener.


D2 might make sense if L2 is more than just a inductor and could externally be driven backwards. That could be the case if it is a motor winding, for example. In that case D2 clips negative voltages before they can harm Q2, but it does nothing to safely limit inductive kickback when the transistor is turned off.


Tuesday, 26 September 2017

arduino - High Frequency Logic Level Conversion


I am using Arduino DUE for my project which gives a 3.3 volt output signal. I have to convert it to 5 volts to use it with another device. The problem is that my signal frequency is 1 MHz. I have tried using Spark Fun logic level converter which uses BSS138 MOSFET. The converter does give a signal of 1MHz but its output amplitude remains at 3.3 volts. I need to convert it to 5 volts. Can anyone tell me whats the problem. Why the signal amplitude remains at 3.3 volts? I have also tried the same circuit with 2n7000 MOSFET but it also gives the same problem. If frequency is the problem then can anyone suggest a level converter or circuit that can convert the 3.3 volt signal to 5 volts at 1MHz. Thank You


enter image description here



enter image description here




resistors - 1.8V to 5V, still not comfortable with transistors


I have a H-bridge IC L293DNE that needs 5V input signals to operate, however my available outputs are only 1.8V from a Gumstix Overo GPIO pin. I have a power supply that supplies me with +5V 1A. I've searched around for information about "Level Shifters" and "Logic Level Translation", but have been unable to find any good basic information.


I have a few 2N2222 transistors laying around, and I need to convert four 1.8V outputs to 5V, but I have no idea how the circuit should work. Will the 2N2222 do? Do I need resistors, and if so, where do I put them and how do I calculate the resistance needed?



Answer



(1) Try this (magic :-)


Use 2N2222 + 2 x 10k resistor.


When input is low transistor is on and output is pulled low.
When input is high transistor is off and output is pulled high by collector resistor.



This is a less usual arrangement but allows non-inverted switching - in highh = out high etc.


enter image description here


Gumstix output has to provide LC293 input current and Vdd/10k input current as well. Should be no problem. Collector resistor MAY not be needed depending on LC293 behaviour.


Added:


MOSFETS:


If you use low Vgsth MOSFETS instead of transistors you can remove the input resistors. As above, the LC293 inputs MAY float high when open circuit - alowing the collector resistor to be eliminated - but even if they do it may not be something you should depend on.




(2) This uses no transistor but may need component cvalue adjustment to work acceptably.


2k7 LC293 input to 5V
2k2 LC293 input to ground



LC293 input is now at 2.25V.
This is a valid high input.


Connect a silicon diode from LC293 input to Gumstix output (arrow points to Gumstix, or Anode to LC293 cathode to Gumstix)


Connect a 100k from Gumstix output to ground (more conceptual than actual)


Set Gumstix output to 1.8V.


Diode Cathode and Gumstix output now "want to be" at 1 diode drop ~= 0.6V below 293 input = 2.25 - 0.6 = 1.65V. ie the diode means the 293 input is hardly if at all affected when Gumstix output ii 1.8V.


Now drive Gimstix out to 0V.
LC293 input is now at about 0.6V.
The data sheet does not make it certain but this will probably turn the LC293 input off.


Check voltages in above to ensure no voltages exceed IC ratings.




logic level - Driving MOSFET gate using PIC


I would like to drive a MOSFET gate using 12V (in order to reduce the drain-source resistance). Using the answer from a few post i've read I have come up with the following circuit. Will this circuit work for an application where i will be switching the motor on and off one every 10 minutes?


Further more is this the best method of driving the FET? and is there any type of "MOSFET driver IC" i can use to reduce space on my PCB? enter image description here




avr - Good resources for learning about my STK500


I have a Atmel STK500. And I can't get my head around what half of the board does. Does any one know of any good resources for learning about it. I have the following books:



The primer book is good with the STK500 but only talks about the mega16(I think I maybe wrong on that don't have it to hand). But then stops after the first couple of pages and tells you how to only program the one microcontroller with it. Is there anything else I can look at to use my STK500 to its full potential? And configuring the jumpers as they confuse me being a novice. I would like to program other microcontrollers from atmel with it.



Answer




Go into the AVR Studio help files at Help > AVR Tools User Guide and click on the STK-500. It's the same files that come with the kit, but those are likely stuck on a CD-ROM somewhere in the sock drawer (mine certainly are). Pretty good info therein, anyway. If you're using Eclipse or something else, I can upload them or Google can reveal them.


arduino - I2C 3.3 to 5.0 V conversion


I'm trying to interface a 3.3V I2C device to a 5V Arduino.


I don't have any problem with SCL line. I can use a simple voltage divider but I have an issue with the SDA line as this is bi-directional.


I'm not at all sure how to handle this. I have though of adding a pair of diodes, with a voltage divider on the slave input side and nothing extra on the master input.


Are there any other solutions?



Answer



Good document about the subject is Bi-directional level shifter for I2C-bus and other systems which uses a single mosfet as a bi-directional level shifter.


attiny - In-place programming of ATtiny85


I've been playing around with an idea for a little hand-held gaming device using a Nokia 5110 screen and an ATtiny85.


The ATtiny is programmed using my Genuino UNO as ISP.


I was wondering if it's possible/sensible to include a breakout connector on the attiny pins so I can just plug it in whenever I want to update the code, rather than having to remove it from the gaming device? I'm worried about how signals from the ISP would interfere with the other devices connected?


I used Fritzing for the very first time to create a diagram of what I'm thinking of so far (I've breadboarded parts of it with the UNO instead of the ATtiny, and I haven't actually tested sharing the clock & data pins with the 3 controllers yet! The real thing would have more buttons and LEDs!)


enter image description here



Answer



Yes, it is very common to put a 6-pin ISP header on your board to allow the AVR to be reprogrammed in place. Even the Arduino has one of these on it.


Here is a nice application note from Atmel describing the typical pinout of the header along with some suggestions on how to make sure there will not be conflicts with the normal operation of the programming pins...



http://www.atmel.com/images/doc0943.pdf


If you plan on mass producing the board, you can even avoid needing the header by using this handy connector...


http://dangerousprototypes.com/2012/12/10/isptouch-header-less-isp-connector-for-avrs/


...or this one...


http://www.tag-connect.com/


Finally, you can connect directly to the chip itself using a chip clip like this ...


http://www.amazon.com/8-Pin-Gold-Plated-SOIC-Spacing/dp/B00DDE7N3C


voltage - A "fuse" for overvoltage


I'm an American living abroad in the land of 220v with various 110v appliances. Here in the Philippines, for some wacky colonial reason, the plugs are the same two flat prongs as the US, but the wall provides 220v power. I have a transformer, so this is all fine and well as long as I'm careful to not plug it into the wall. Always careful. (Which of course I am not.)


What I would like is a simple adapter plug that can go on the end of each 110v appliance (and never come off) with a fuse inside that will pop if it is ever accidentally plugged into the 220v socket. Obviously, fuses are for current and don't work for overvoltage, but I'm not sure if there's another term.



Do you know if a product like this exists? Do you think there's perhaps a way to DIY one if not?



Answer



It's a bit of a hack anyway. Best option would be to identify devices that do not support 220V and wire a different plug only available on your converters.


You can get a varistor.


This is a component that starts conducting above a certain voltage.
As seen here with the blue line, above +/-300 volts, current will quickly rise.
varistor


You must use a fuse or circuitbreaker in series with the varistor in order to disconnect the circuit when the varistor is conducting. You also have to use a varistor rated for enough power to prevent the varistor to blow before the fuse. Many devices will already contain varistors to reduce the effects of transients.


Beware, varistors can explode violently.


Another option would be to use a voltage monitoring relay. These are more expensive, but are less destructive.



Monday, 25 September 2017

microcontroller - What is drive strength a measurement of?


In microcontrollers and the like that have programmable drive strengths for GPIOs, said drive strengths are defined in mA. For example you might have a choice of 2mA, 4mA, 6mA, 8mA, etc. My assumption, is that for each output drive strength, there is a corresponding output buffer, and that the software drive strength setting controls a mux that decides which buffer drives the pin. Is that correct?


Second question: I understand that, for example, doubling the drive strength effectively doubles the size of the output buffer (or, equivalently, halves the output impedance), but what is the drive strength actually a measure of? Say the drive strength is 4mA, what does that actually mean? My guess is that the pins Voh/Vol is not guaranteed if you draw a higher current, but I'd be curious to know how these values are characterized/chosen by the vendor.


--


I wanted to add this in response to CL. below, but I'm not sure how to add images in comments.



This is from the same datasheet he references:


test


Edit: jump back and forth a few times between this table, and the "typical" curves below and one gets a better feel for an interpretation of drive strength. The question however remains unanswered. Perhaps this is only something someone who writes data sheets could answer. I suppose the question could also be generalized to "how do IC companies determine their min/typ/max values?". As an example in the image above, the drive strength for "full setting" is given as 15mA, with 3V Vcc, if you want a max Vol of Vss + 0.60V. What is the process to arrive at this number? Set the pin low and force it to sink current until Vol hits 0.6V, then take the current being sunk and round down to the nearest mA? There's probably a statistical component as well to arriving at the number. I'd be surprised if they only characterize one die, probably many over all the different PVT corners.




pcb - Altium: How can I edit a component from a library


I downloaded a library from the internet and I want to create a new PCB component using the ones in the downloaded library with little editing/changes (such as the footprint). Is that possible? How?




connector - How to tell polarity expected of a DC barrel jack?



I'm sure this information is somewhere around the internet, but I can't find it.


I have a device that takes a DC barrel jack. I don't know the polarity it expects though. There is a marking though. It looks like this:


___
--- 12VDC

I'm 99% sure it's a symbol to indicate the polarity, but which is it? Positive inside or positive outside?




Baud-rate for 8051 Microcontroller


I will like to know if a baud-rate of 9600 is so fast for an 8051 MCU using an 11.0952Mhz crystal. Why? I have observed some inconsistency in the behavior of my MCU, in that when I send a set of characters looking for a particular character to perform certain operations, I discover that my MCU does not perform the required operation. Meaning that there was a misplacement along the line during receiving. Then I did some serial routine. I sent a "ABC" from terminal to the MCU, which should transmit back to the terminal an increment of each character sent, hence it should give "BCD". But this is what i got consistently - "BD" missing "C". Meaning that the MCU missed "B". I also send other set of characters and discovered that some characters get missed by the MCU. What could be the cause of this. Could it be the Baud-rate or in my code. How can I possibly rectify this.



Here is the code.


void initUART()
{
SCON = 0x50;
TMOD = 0x20;
TH1 = TL1 =-3;
TR1 = 1;
}

void sendCHAR()

{
SBUF = uartBUFF[s];
while(!TI);
TI=0;
}

void serial_isr(void) interrupt 4
{
if (RI)
{

RI = 0;
tmpBUFF = SBUF;
charFLAG=1;
}
}

main()
{
IE= 0x91;
initUART();

while (1)
{
if(charFLAG)
{
SBUF = (tmpBUFF+1);
while(!TI);
TI=0;
charFLAG = 0;
}
}

}

Thanks!



Answer



How do you get the characters from the serial port buffer register? If you simply read them in a loop like


void main() {       
char c;
while (1) {
c=SBUF;
do_something(c);

}
}

Then you will miss characters once the execution time of do_something() gets longer. Note that this includes time spend in intterrupts. The 8051 serial port has no hardware fifos, a character will be overwritten by the next one if it was not read in time.


Our solution was to read the characters into a Ringbuffer during the serial Intterupt, and to use the FIFO in the main loop. Works (with high priority interrupt) for 460800 Baud with 7,3728 MHz crystal on a Silabs 80C51FXXX.


Update


As we now see the source coude, the bug is now clear: You wait in the main loop for your character to be sent. But that means you wait a whole "character time" without being able to read your interrupt character buffer, and another few cyles to detect and read the next. This is too long if the sender sends characters fast, as a PC does.


Sunday, 24 September 2017

arduino - How do I hook up an LED across the tx pin on my Atmega328?


I've built a standalone Arduino and upload sketches via this method From Arduino to a Microcontroller on a Breadboard. I would like to hook up an LED across TX like on the Arduino board, so I simply wired it to the TX pin with a resistor going to ground. And it works on a sketch where I am simply sending serial data at a 9200 baudrate. Both the Arduino TX and my ATmega TX LEDs blink correctly.


However, my application involves a baudrate of 19200, but when I upload this sketch, the TX pin on my ATmega stays on constantly, even if no serial data is being sent. What's even more interesting is that the Arduino TX led does blink correctly for the same sketch. Can anyone help?



Answer




Caveat: Even though the OP accepted my answer as the best one, another, better answer was posted after that, that you may want to read before reading mine. As noted by Chetan Bhargava, my solution may draw too much current to drive the LEDs from the serial lines.




Below is part of the schematic of a RS232-to-UART converter that I've made. In it, I connected LEDs (and their respective series limiting resistors) from the RX and TX lines to the Vcc line, just the way you could connect yours. Wire the anodes to Vcc and the cathodes to the TX/RX lines, with the current limiting resistor in series (either before or after the LED).


RX and TX LED connections


The LEDs must be connected to Vcc and not to ground because UART lines (i.e, the ATmega serial interface) are idle HIGH, i.e., they stay at Vcc levels when nothing is transmitted.


Note what gbulmer said in his comments, though:



... you might find at high baudrates, or long cables (or other things with reduced drive signals) that the communications start to become unreliable because the LEDs put an extra load on the connection. You might want to consider driving the LEDs indirectly with a MOSFET or darlington transistor.



I have had no problems with those LEDs attached to the serial lines up to 78600 bauds, but you might if you go faster.





If you were interested in connecting indicator LEDs as feedback in your ISP programmer, you could do the following. The ArduinoISP sketch (firmware) already drives three indicator LEDs:



  1. Heartbeat on D9: it blinks (fadding) to show that the sketch is working properly;

  2. Programming on D7: it's on when the actual programming is taking place;

  3. Error on D8: on when something goes wrong.


These indicators work perfectly with the ArduinoISP sketch.


To wire these LEDs, use the schematic below:


ArduinoISP shield



The schematic is for an Arduino Shield that I've made for programming ATmegas and ATtinies, for use with the ArduinoISP sketch. I hope this helps.


If you really want to attach LEDs to the transmitting lines, please answer the questions I posted as comments, then I'll update my answer.


Why are laptop power supplies marked "IT equipment only"?


Laptops are often shipped with switching power supplies that among other have a phrase for use with information equipment only on their body.


Why can't I use the same power supply to power a motor or a set of LEDs or a lamp given it's output voltage and its wattage are suitable? I mean it outputs say 36 volts of direct current and can supply say 50 watts - okay, that would do for my motor/LEDs/lamp, why can't I use that supply?


What's so special in those power supplies that they bear the "IT equipment only" mark?



Answer



It is part of the safety regulations. When deciding which specifications apply for testing, the product application is taken into account as the way of deciding which spec applies. So if a laptop manufacturer provides an external PSU, they will have it tested to the relevant specs, which includes the product category. There is no guarantee it will be suitable for other applications.


For example, if you drive a motor which has accessable metal parts, and that laptop PSU doesn't give you an earth connection back to the socket, unless you make a seperate connection to earth, there isn't naturally one back for you.


power - Are watts usually measured in watt-hours?


Pardon me, I'm a total newb to electronics. My question is, when a device is measured in watts, such as a 60-watt light bulb, is this ALWAYS supposed to be assumed to be watt-hours, i.e. 60 watts per hour?



Answer




Energy is an amount, while power is a rate at which energy is used.



  • Energy is measured in watt-hours (W·h) or joules (J).

  • Power is measured in watts (W) or joules per second (J/s).


Watt-hours are like buckets, and watts are like buckets per hour. If you have 5 buckets of energy and you pour one bucket per hour, you'll be able to pour for 5 hours before you run out.


If you turn on a 60-watt light bulb for 1 hour, you have used 60 watt-hours of energy. If you use it for 2 hours, you have used 120 watt-hours of energy. If you turn it on for only 1 minute, you have used 1 watt-hour.


It's a little confusing since the "per hour" is inside the term "watt", so to make the rate into an amount, you need to multiply by a time unit to cancel it out.


It would be a lot more intuitive if we worked in kilojoules and kilojoules per hour. :)


Saturday, 23 September 2017

microprocessor - Do 4-bit CPUs still outsell 32-bit CPUs in unit volume?


Way back in 2002, Jim Turley mentioned that about 14% of all CPUs sold were 4-bit CPUs, while about 8% of all CPUs sold were 32-bit CPUs. (Most people I know were surprised that any 4-bit CPUs were still being made, much less that they were doing so well).


It's 2011 now -- Do 4-bit CPUs still outsell 32-bit CPUs and 64-bit CPUs combined in unit volume? Where could I go to look up the latest numbers for sales by unit volume? What are the top websites and magazines to learn more about modern 4-bit CPUs and their development tools?




pwm - Help understanding Low side N-Channel MOSFET driver circuit


I took a simple circuit i found and started modifying it for my own purposes and realized i need to understand it's workings better to get where i need to be. Circuit


PWM+ and PWM- comes from a LED dimmer using 275Hz running at 12 volts I'm currently testing at 12 volts but would like to make it stable up to 15 volts. I placed D1 - D4 for reverse polarity protection, I'm using a 4n35 opto instead of the 4n25 shown.


The Led shown above was just for simulating a load, I've been testing at 84 watts and it gets up to 110 C in about 5-6 minutes then continues to climb. I'd like it to stay under 100 C for currents up to 10A without a heat sink and use a small heat sink for up to 16A. If i get the turn on and off time correct i believe this is achievable. Well at least according to my interpretation of the formulas for switching loses i found.


Currently i know my turn on time is too slow at about 500ns due to the 2N3906. I have only been using parts i have on hand until i can understand what i'm doing and order what i need. With the circuit below i'm shooting for a 150 - 100 ns turn on time. I know the turn off time is also producing a lot of heat and i'll address that by adding a npn to pull the gate down quickly.


So what i'm really asking for is how to determine the correct values for all the resistors (R3,R4,R5,R6) to get the turn on time i need after switching the pnp Q3 to something that can handle maybe 500-800ma. Specifically the math involved and how everything ties together.


I've been finding the formulas i need for most parts of the circuit like the current the gate needs for a specific turn on time and how to calculate the pnp base resistor but putting it altogether is proving elusive with out some help.



Once i understand this circuit i'll deal with turn off time via npn next.


This is my first attempt at driving a MOSFET and i'm just getting into electronics as a hobby so i'd appreciate all the help i can get.


******New*******


Thanks, That was a lot to digest. My 1st goal is to learn and my 2nd is to get this circuit working. So let me see if I understand what you said:


To clarify PWM+ and PWM- are DC and the 275Hz cannot be changed.




  1. removing the diodes – I only need either D1 or D2 since either one will block current from damaging the 4n35 in case of reverse polarity hookup, data sheet says up to 7V reverse polarity. I don't need D3 or D4 since the transistors themselves can handle 12 volts in reverse polarity? This will be used with screw terminals so in case a label is removed or I have a brain fart while hooking it up I want to be sure I won't fry it if its accidentally powered up with the polarities reversed.





  2. Power dissipation – I completely ignored RDSon and was focused only on the turn on switching losses. I have some irf3205 MOSFETs (RDSon = 8 milliOhm) that i'll use instead.
    PD Resistive @ 25C for 16A would be 16^2 * .008= 2.048 Watts, PD Resistive @ 100C for 16A would be 16^2 * (.008*1.5) = 3.072 Watts


    On to switching losses, assuming I modify the circuit and use a npn to pull down the gate. Tr is stated at 101ns so if I was shooting for a 150ns turn on and off time I would need to supply 500mA to the gate at >= 10V according to I = Qg/150ns = 474mA.
    So the ratio of switching time to steady state would be 300ns * 275Hz =8.25e-5 , I assume this wouldn't even matter? But if it does is this the formula I should be using: Pdswitching = (Crss * Vin^2 * fSW * Iload) / Igagte or Pdswitching = (211pF * 144V *275Hz *16A)/ 500mA = ~0.3mW


    So need to dissipate 2 to 3 watts depending on temperature. Pd = (Tj_max - Ta )/Rja = 75/62 = 1.21 Watts is what I can do without a heatsink and keep the temp limited to 100C correct? So when calculating for a heat sink I need to use Rjc and Rsc as follows? ((Tj-Ta) – P(Rjc + Rsc)) / P = 28.4 so any heat sink with a better thermal resistance will keep me under 100C?




  3. I'm now fully aware of how inadequate the 2n3906 is for driving the gate so do you have any recommendations for a PNP and NPN that will handle 800mA and besides the continuous current what should I be looking for to drive the gate at 475mA?



  4. Provide an active gate pull down. Do you mean add an npn transistor to the circuit and if so where would I be adding it? Something like this? this circuit doesn't seem to work on the simulator so i know i'm doing something wrong.

    enter image description here



Answer



Summary:




  • Remove all diodes except maybe D1.




  • Use a lower Rdson FET if you can.





  • Change R6 to as low as you can for now - 100 Ohms would not be too low, but ...




  • Provide an active FET gate pulldown - just am emitter follower, for much improved turn off times.




  • Run PWM as slow as you can tolerate.







You do not need D1 and D2 - remove either one.


If PWM+ is always positive wrt PWM- you do not need either of D1 or D2.


If PWM+ - PWM- is AC then placing D2 across the opto input with reverse polarity will place about equal load on PWM with both polarities of input. This may or may not matter.


D4 is not needed.


D3 is not needed.


Now for the hot stuff. You can like to use whatever you wish, but you may have to rewrite the laws of physics. The IRF540 has more Rdson than you want even when driven well - and the 4.7K turnoff resistor ensures that it has a slow and horribly hot turn off. Changing R6 to as low as you can stand will help heaps. With eg R6 = 100 R, IR5-R6_on is < = about 100 mA which is sad but only maybe 1% of your load current. Adding an emitter follower pulldown driver for turnoff will help immensely.


And it will still almost certainly be too hot. See below.
Changing to a MOSFET with Rdson more like 10 milliOhm or lower will help immensely and actually allow you to do what you want IF you do it properly.



IRF540 data sheet and another like unto it - almost


At 84 Watts load at 12V Il = 7A.
If you have say about 10V Vgs then at 10A an IRF540 has
at 25C by fig 1 - about Vds = 0.35V TYPICAL and at 175C by fig 2 - about Vds = 1V TYPICAL


In the first case as 7A you have about 2.5W dissipation at 25C TYPICAL and in the second case at 175C = 7 Watts.
Both of those are TYPICAL and both are with 20 uS pulses. ie reality will usually be worse.


The TO220 pkg has 62 C/W Rjc and
the D^2Pak claims 40 C/W Rja with 1" square FR4 PCB.


So TO220 rise with no heatsink =
= >= 62 C/W x 0.35 W at 25C = 22C rise

so Tj ~= 47C.


This is enough to start it up the pernicious -> hotter -> more Rdson -> more temperature rise -> more Rdson ... curve.


At 1 Watt you'd have 62C rise = Tj = ~~~ 90 C.


So it should not get that hot TYPICALLY as the 1 Watt is when Tj = 175C
were it not for the fact that this data sheet was influenced by marketers and tobacco salesmen and they use a 20 uS pulse width. And it's also typical. So say 100-120 C would be expectable. Your very very very slow turn off will add the coup de grace.


The circuit below shows two emitter followers as a gate driver.




Added:


Related only - high side driving 'trick'.


This is Olin's P Channel high side FET gate driver cct.

He says it achieves 200 nano-second switching.


Note the special magic from having R14 present, what that dos tohow Q2 works and the roles of R15 and R14. You should understand it yourself , but:
R14 makes Q2 an emitter follower "sort of". R14 is now driven to 1 Vbe below Vin high. Note the "no series resistor note.
HOWEVER, R15 is (here) 45 x R14 so as R14 voltage rises R15 will drop 5 x as much. So if Vin rises from 0V to ~= (3.3-Vbe) = say 2.7V, R15 will drop 5 x 2.7 ~= 13.5V. Thi provides all the drive needed but the gate of the FET does not need a zener clamp to prevent overdrive.


enter image description here


Bluetooth Interference with High Pitched Tone


i'm building a portable stereo system and am having some unwanted noise from the bluetooth receiver. the noise is typically a high pitched tone.


please see the attachment for my chicken scratch schematic.


the general setup is an amp connected to a 12V battery. there is also a step-down converter, connected parallel to the same battery, that goes to USB, which then connects to a bluetooth receiver that sends audio to the amp via an 1/8" cable.


i've tried adding a capacitor at 200µF to the battery terminals with no luck of eliminating the noise.


the high pitched tone goes away only when i power the bluetooth receiver from a separate power source.


I've ordered a ground-loop isolator, but haven't received it yet, so i figured if anybody can suggest something, that would be most excellent.


Also, I've tried subbing in alternate bluetooth converters, batteries, amps, and step-down converters, with no luck.



enter image description here




Tesla coil miniature model (slayer exciter) parasitic capacitor


I have been trying this miniature Tesla coil based on Slayer's exciter circuit (shown below). The part that I don't understand is how this parasitic capacitor exists? I know that for a capacitor there needs to be 2 opposite charges separated by a distance L (which should not be too large as the capacitance becomes negligible). So how do I visualize the capacitor based on these conditions (opposite charges and distance of separation)?


And even assuming that it exists, initially when the switch is turned on voltage is induced on the primary which is reflected on the secondry side charging the capacitor. But after a while since it's only a DC source the induced voltage slowly fades away, but how does the base emitter diode get reverse biased? I have made the circuit and it works even though I did not have the diode shown in the image, but I just want to get it working right! I did see an earlier post similar to this, but it did not really help with my questions.


enter image description here



Answer



The Slayer oscillator is actually a crude form of a resonant power supply. It runs at a resonant frequency. The resonant frequency is determined by L and C. Switching losses are reduced so that a BJT will run cool at sensible frequencies. You are stepping up so this makes L big and lots of turns make C significant. R has nothing to do with frequency. R is just for starting.


The transformer does have parasitic capacitance to ground. That is why C is drawn the way it is. If there was no parasitic capacitance to ground the oscillator would not work because its feedback path would be broken. Your diode does get reverse biased because AC current is flowing. I have used a red LED in place of D1 to indicate operation and give higher negative voltage on the transistor base to improve turnoff and possibly switching losses.


On your circuit, making R too small will actually make starting unreliable. You can ballpark R to give a small current that gives reasonable beta for Q. If your step-up ratio is too high, the oscillator won't start because the total gain would be less than unity. Make the step-up ratio N 10 or less so the oscillator won't need an exotic or nonexistent transistor.


Friday, 22 September 2017

Why do we need a ramp for stepper motor?


I am a newbie and trying to understand how i can run a stepper motor. The concept i had in mind was that steppers need digital pulses to run, and i tried it out too. I was able to run the stepper i am using very easily. But lately I came across a link where they have used a ramp for starting a stepper justifying it by saying that


"if we try to start the stepper motor with fast pulses then it just sits there and hums away not turning, We need to start the stepper off slowly and gradually increase the speed of the steps (ramping up)." Source:http://www.societyofrobots.com/member_tutorials/book/export/html/314


My question is why does the stepper then starts up with regular square pulses? Why do we need a ramp? All the other forums and tutorial always talk about providing digital pulses to the stepper for starting it up, why is the concept of ramp generation not discussed there? Is it a bad practice to run stepper with digital pulses?



Answer




When the controller steps the motor, the rotor has to move far enough (angle) that when the next coil (or coil pair) is energized it will pull the rotor in the correct direction. If the rotor has not moved through enough angle, then the coils will pull the rotor backwards and the motor just sits there and buzzes. You can find many illustrations and animations online that explain how normal operation works- imagine if the rotor only moved a fraction of the intended amount.


The rotor, shaft, and whatever is connected to the shaft all have inertia and there is friction of various kinds.


The maximum speed the stepper can turn the shaft is related to the torque available from the motor and the torque required to turn the shaft (available torque drops as RPM increases, and the required torque generally increases as the RPMs increase). That's not directly related to the inertia.


To actually get to the maximum (or some fraction thereof) you can only accelerate the RPM so fast without missing steps. The maximum acceleration is related to the inertia and the excess available torque at a given RPM. If the motor is doing all it can just to keep up with the current RPM then you can no longer accelerate. If the RPM are low enough, you don't need to ramp it up, you can simply tell it to step, but that will typically be only a fraction of the RPM the motor is capable of. Often linear ramps are used for simplicity, but a more convex curve would be optimal.


Here is a motor torque curve from Oriental Motor (a major Japanese maker):


http://www.orientalmotor.com/technology/articles/article-speed-torque-curves-for-step-motors.html


To predict the maximum rate of acceleration you need to know the torque and the mass moment of inertia. If you exceed the maximum rate of acceleration at a given loading then the motor will lose steps, so a reasonable safety margin is a good idea.


transistors - Why are the current directions in the hybrid-$pi$ model for BJT the same for both NPN and PNP?


Here is the hybrid-\$\pi\$ model:


enter image description here


with \$I_c\$ and \$I_b\$ going in, and \$I_e\$ going out. The same circuit can be used for both NPN and PNP, the only thing changing being \$V_{be}\$ for NPN and \$V_{eb}\$ for PNP.


The currents direction does not change, which is what I don't understand. We know that for a PNP in active mode, \$i_c = i_e+i_b\$.


For a NPN in active mode, \$i_e = i_b+i_c\$, which corresponds to the current flow shown on the hybrid-\$\pi\$ model.


Why is it the same for PNP?




Arduino Twitters


I'm looking for a list of cool projects that people have made with the arduino that twitter...i have read about plants that tweet when they need watering or pets who have a button to let you know when they are hungry....whole houses which twitter the power usage etc....


So is there a place to go for a list of these....? Or could people just link the individual projects here.



Answer



Botanicalls is a open project that takes time working. You can buy the kit and assemble or otherwise you have all information on the web to build and why not make improvements?


The project where arduino is a twitter notification as better success at marketing today is BakerTweet. This is a funny device where the baker select that product just out of the oven and this is published in twitter. What to does this serve? Those who do not live in town many times when we go to buy bread bakers are selling day-old bread. By this we know when we can go for fresh bread, cakes, buns, croissants, ... ;)


Another open project is the Tweet a Watt, this project is very interesting and useful because we can monitor the consumption of a device by the Twitter. From my point of view is an expensive project, but with a little imagination we can reduce cost if we are forced.


Oficial Tiwitter library



Silly projects (my point of view ;) ):
Bubblino
KickBee


linux - AVR-GCC: Ports Undeclared when compiling


My Setup



I'm running Ubuntu 12.10, and I want to be able to use gcc and avrdude to compile and program my ATmega328.


I followed this Ladyada tutorial: Ladyada AVR Tutorial


Everything installed perfectly, no errors or warnings. I have not installed avrdude yet, but that is beside the point.


I use the command:



avr-gcc -O0 -c blink_1MHz.c -o main.o



However, I get one warning, and many errors:


warning "device type not defined"


error: 'PORTC' undeclared (first use in this function)

The error above repeats itself for each Port and each Data Direction Register used in the code.


blink_1MHz.c is just some simple code I'm using to test my setup. It has worked on my Windows setup through AVR Studio 6.


I've tried Google, but the only real suggestion I got was to import the libraries:


#include 
#include
#include

Unfortunately, still nothing. I've been playing around with this for a while and I'm simply stumped. I saw suggestions that avr-libc isn't installed, but I have installed avr-libc. I would think that if I didn't have it installed, I would be seeing complaints about the libraries not existing.



Question


Could an enlightened individual suggest what may be the cause of these errors? Thanks.


EDIT


Amoch pointed out that I needed to check out avr/io.h; there you will see that you need to define the processor with the -mmcu flag. In my case, I have an ATmega328, so my command looked like:



avr-gcc -O0 -c blink_1MHz.c -mmcu=atmega328 -o main.o




Answer



I'm not familiar with AVRs but the compiler is telling you that it can't find where "PORTC" etc are defined. Normally these definitions are included via a header file, and from your post I would suggest that it is likely avr/io.h. You will need to take a look at this file and determine that it is the source of these missing definitions. Further more, the first error that is encountered states that "device type not defined". This means that this header file requires a #define to inform it which code to include for the processor that you are using. This would normally be provided to the compiler via a -D option.


Seeing that you have had this working on windows under AVR studio, I suggest that you dig into the compiler settings within the GUI or examine the console output and find out exactly what is being passed to the compiler under windows so that you can copy the settings in your custom build under linux.



switch mode power supply - Relationship between switching frequency and controller's crossover frequency in buck SMPS


Context: tuning the control loop of a buck SMPS. I specicifally have a TI TPS40200-based circuit in mind, but I think this applies to SMPS design in general.


Quoting from Type 2 compensation network:


Mr. Maniktala suggests that the loop gain transfer function of the switcher intersect
the 0 dB point at approximately 1/6th the switching frequency, with a slope of -1.

I have heard this before from another engineer, but did not get a chance to ask why. What is the reason the crossover frequency of the control network should be a fraction of the switching frequency? Why specifically around 1/5th or 1/6th?


Are there any other desirable traits when designing a compensation network for an SMPS controller other than the most basic criterion of >45 degree phase margin for system stability?



Answer




A switch mode power supply is essentially a sampled-data system, therefore the theoretical maximum bandwidth is one half the switching frequency. Practically the phase and transport lag there make it impossible to close the loop there, so 1/5 to 1/10th the switching frequency is a good rule of thumb.


There are many other considerations in compensating an SMPS- Gain margin, conditional stability, current vs. voltage mode, slope compensation, transient response, etc.


Check out www.ridleyengineering.com, there are lots of good free tutorials and papers there.


Thursday, 21 September 2017

simulation - LTSpice Has bizzare results for high input impedance devices


While simulating with LTSpice I discovered the simulator gives milliamps of inverting and non-inverting terminal current in op amps and also the same thing for MOSFETs, milliamps into gates. Here is a simple circuit demonstrating the current into a non-inverting terminal with an op amp. I will also put down that I measured only nanoamps of current into op amp inverting and non inverting terminals and also MOSFET gates in Multisim to verify that LTspice is incorrectly giving results, which leads me to believe LTSpice is seriously flawed and this should be reported to developers. Is this normal or is it a bug which should be reported to developers? Simple Circuit


Output current for non-inverting terminal


Another circuit With 2 inputs



Inverting terminal current




Why do USB connectors only fit one way?


Why do USB plugs only fit one way into USB ports?


Forgive my ignorance, but there are several types of plugs that are "omnidirectional" and do not have to be oriented a certain way to fit into the corresponding plug (pursuant to shape). In the case of USB, when you're trying to plug one in blind, it can be a bit annoying if you happen to be trying to do it upside-down.


I'm guessing this has to do with the pinouts, but then why doesn't the USB standard just negotiate for "pin 1" when something is plugged in, or use a functionally symmetrical pinout layout?



Answer




MOST connectors in the world only allow one mechanical orientation.


Ones that are not orientation specific are usually "concentric" such as the familiar 2.5 / 3.5 / 6mm plugs on earphones and similar. Where these have more than 2 conductors the contacts for the conductors at the inside end of the socket ride over the conductors for the tip end as the plugs are inserted. Care must be taken to ensure that no problems are cause by these spurious short term connections.


AC power connectors in some systems can be polarity insensitive, but this can lead to safety concerns where there is some difference in attribute between the two contacts other than their ability to provide power. eg in many systems the mains power is ground referenced with one conductor essentially at ground potential. Reversing the twocontacts would still lead to a functioning power connection but may bypass protection and safety systems.


BUT the vast majority of plug and socket systems are orientation sensitive.
Consider the plugs for keyboards and mice (DB9, PS/2, now USB), any 3 pin power plug, trailer power connectors, telephone and network connectors (RJ10, RJ11, RJ45, ...), XLR/Cannon and similar audio connectors, video connectors for monitors ("IBM"/Apple/Other), SCART AV connectors, DMI, ...
People are well used to this.
Why should USB be any different?


BUT, full size USB has two power connectors and two signal connectors. Rhe signal connections could easily enough be interchanged.
But interchanging the two power connections involves routing +ve and -ve signals correctly.
This could be done with a diode bridge and two diodes but the voltage drop of about 1.2 Volts represents a loss of about 25% of the Voltage and an immediate 25% power loss. This could be addressed with mechanical automated switching - essentially relays, or with low voltage drop electronic switches (MOSFETs or other) but the cost and complexity is not justified in view of the ease of "just plugging it in correctly".



Im Mini and Micro USB systems with potentially more conductors this could have been addressed by redundant arrangements of contacts but that wastes potential resources (size or contacts) and still only results in two possible alignments, 180 degrees apart rotationally. You still could not insert it aligned long side vertical or at an angle.




Super Solution:


For the ultimate connector consider these two conductor wholly functionally symmetric hemaphroditic connectors.



  • Not only can these be orientated in two orientations rotationally but there is no "male" or "female" connector - both 'plug' and 'socket' are identical.


This scheme can be extended to more conductors using a coaxial arrangement. This is a General Radio GR874 connector. If you ever meet something using these you can be fairly sure you are in the presence of greatness :-).


enter image description here


Many many more of the same



Wednesday, 20 September 2017

rf - 434MHz PCB Trace Antenna Design


Can anyone provide a reference design for a 434 MHz PCB Trace Antenna? Is it just a matter of creating a snake trace pattern about 17cm long and slapping a ground plane under it (with a trace thickness for say 50 ohms characteristic impedance to the ground plane given the PCB thickness)?


The context is that I think I'm heading toward using a trace antenna with the RFM12B transceiver module en route to passing regulatory standards. I've been told that embedding the antenna in the PCB is an easier / lower cost path to certification than allowing for a whip (or other externally connected) antenna. Any advice or pointers would be most appreciated!



Answer



Tye following may be useful. Most are 2.4 GHz focused but should provide some useful ideas.


TI 2.4 GHz PCB Antenna - AN 043 - 2.4 GHz but should have significant value.


Compact Integrated antennas - Freescale AN 2731 - significant relevance


A few zillion PCB antennas - all images linked to webpages


Commercial products - but some good idea starters


Inverted F design - 2.4 GHz but significant relevance



Wow Another inverted ed F design paper - looks superb


NO PCB antennas here BUT many432 MHz antennas




Related:


144/432 diplexers


Tuesday, 19 September 2017

soldering - How do I neatly bridge to a ground plane?


I have boards that through a mistake of my own have a bunch of vias that should connect to the ground plane, but are actually isolated. See all of the holes that are isolated:


alt text


So, I need to bridge all of them to the ground plane. Since there is no solder mask I figured I could just use solder to bridge the connections. Here is what my solution looks like:


alt text


Not so pretty. I am wondering if there are any suggestion of what I can do to short these in a better manner. I will have it fixed in my next board revision, but it is a few weeks before I will have the boards and need to solder a few of these up now.


ADDITION: The biggest problem I was having was the ground plane heated up very slow and It didn't seem to want to stick to both the pad and the ground plane at the same time.



Answer



Get a better soldering iron.


It's not the easiest solution, but in the long term (having a better iron improves everything), I think it is the best.



I have an OKI-Metcal soldering station, and I can easily solder D2PAK devices down to a solid copper plane with no thermal relieving at all. Any similar "Serious" iron should be able to do similar. (They generally run ~$200. It's an investment)


Also, what tip do you have on your iron? For something like that, a chisel tip (pick one for your iron, link is just an examle) is really essential to get good thermal contact between your iron and the copper plane.


Why does the I2C interface use the open-collector/open-drain?


The open-collector adds inconveniences like requiring an external pull-up resistor and slows down the throughput. Why did the I2C designers choose to use open-collector/open-drain?



Answer



Open drain allows there to be multiple masters on the same bus. If two masters try to transmit at the same time with push-pull drivers, they can damage each other, and even if they don't it's hard to tell which master will win. Open drain acts as a "wired AND", which makes it easy to share the line and arbitrate collisions. CAN does something similar, although the physical layer is differential instead of single-ended.


In I2C in particular, open drain allows the receiver to stretch the clock by holding it low when the receiver needs more time to process the data. Whether this is a bug or a feature is a matter of opinion.


bjt - Can a lightning detector's transistors be substituted with BC547 or 2N3904?


Enter image description here



I want to build this circuit, but I don't have the proper transistors. Can general purpose transistors like 2N3904, 2N4401, BC547, 2N2222, etc. be used instead of the BC109 in this circuit?


The circuit is a lightning detector.




resistance - how to calculate resistor value for optocoupler - 230V



I am trying to implement the following circuit. I am trying to understand how the resistance values are calculated. I followed this - "how do I calculate resistor value"


Mains detection with optocoupler


According to my optocoupler (SFH6202) datasheet, following are the calculations:


VF(typical) = 1.25V


If = 60mA


So



Vres = V - Vf = 230 - 1.25 = 228.75


R = Vres / If = 228.75/.06 = 3812.5


But the circuit shows two 100K resistors. Am I doing something wrong here?


Also the Power dissipation is:


P = Vres * Ifmax = 228.75 * 0.06 = 13.72 W


The power dissipation seems too high for 1/4, 1/8 or 1/10 W resistors. Am I doing something wrong in this calculation also? Or do I need some special kind of resistors?




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...