Friday, 30 September 2016

opto isolator - reverse function optocoupler


Ok, I know the basic function of an optocoupler is "turn on irLED, triggering a phototransistor and allowing current to flow"; an optical off then on switch.


Is there a reverse optocoupler, i.e. "turn on irLED, unknown component is triggered and stops/blocks current flow", an optical on then off switch?


Circuit A does something that includes a charging function then activates Circuit B. As long as Circuit B has [enough] power, Circuit A is removed from it's power source (turned off) by a signal from Circuit B. When Circuit B's power is gone/too low, signal is removed and Circuit A's power is returned and starts process over again.


I know how optical relays work (Circuit A on, Circuit B off, trigger on, Circuit A off, Circuit B on, trigger off, original condition). A standard optocoupler is essentially one half of this. I am wanting the other half.





Proof;Only Reciprocal Circuit are passive circuit


Consider a two-port reciprocal network : $$ \ Y= \left[ {\begin{array}{cc} 0 & -1/2 \\ -1/2 & 0 \\ \end{array} } \right] \ $$
then how can we proof that it is a passive network or circuit?


I have no idea how to prove it ....any hints or suggestions please...?



Answer



Prove that the circuit only dissipates energy, never creates it. (=the total input power via the ports to the circuit must be greater or equal to zero), no matter what thevenin sources are connected to it.


Playing with a shift register and some LEDs


Building on this question, I've now got a shift register to play with, and I've been trying to work it manually with a couple of switches, like so: shift register LED array


I have resistors (2.2K) between the switches and VCC, even though that's not shown in the schematic. It doesn't work, though.


When I press the clock switch, sometimes an LED will light, and sometimes it won't. Sometimes several LEDs light. Never does it "shift" a zero "bit". If I just hit the input switch a bunch of times, it shifts in bits, sometimes one at a time, sometimes several at a time.


What gives? What have I done wrong here?



Answer



The switch is "bouncing": Each time you open or close it, there is a period where it makes a bit of noise on the clock line. The chip sees this noise as multiple transitions and clocks in more bits than you intended. To fix this, you need a "debouncing" circuit. Google should find you something.


edit:


You can't just switch voltage to an input like that. Then the input is at +5V when the switch is closed, but floating when the switch is open. You need at least a pulldown resistor after the switch.


kirchhoffs laws - Mesh Analysis for circuit having Current Source



I have the following question: Since the current through the current source is not given (may be error), I assume it to be 2 A. Now since the resistors 6 Ω and 3 Ω are in parallel, I calculate the equivalent resistance and reduce the circuit.


enter image description here


to the following


enter image description here


But to do mesh analysis I need to know the internal resistance of the current source, right? So how can I do mesh analysis? Please advise.



Answer



@elecman, there are multiple ways in solving this circuit. One is with Mesh Analysis and the other way is Nodal Analysis. I really wish there was a way you and I can chat while we work on this problem, but let's still solve this circuit for both ways.


FOR MESH ANALYSIS:


You've have simplified the circuit by combining the resistors in parallel. Resistors in parallel have the same voltage. So now once we get the voltage across the 2 ohms resistor, it will be the same voltage across the 3 ohms resistor. Then from Ohm's Law, we can calculate the current going through the 3 ohms resistor.


In order to get the voltage across the 2 ohms resistor, we need to get the current entering it. Let's call this current I2 (since it is in the second loop). Let's call the current in the first loop I1. By Looking at the circuit, I1 = 2A. So there is no need to do a mesh equation for the first loop since we know what I1 is. However, to find I2, let's do a mesh loop for loop 2:



The current going through the 12 ohms resistor can go up or down, depending on what current (between I1 and I2) is stronger, however since we want the current to go in the direction of I2, we will make this current I2 - I1.


-36v + 12 * (I2 - I1) + 2 * I2 = 0


From there you can solve for I2. With I2, you can get the voltage across the 2 ohms resistor which would be 2 * I2 (which is the same voltage across the 3 ohms resistor) and from there you should get the current going through the 3 ohms resistor which should be = (2 ohms * I2)/3 ohms.


FOR NODAL ANALYSIS:


All we have to do is find the voltage across the 3 ohms and from there get the current across the 3 ohms using Ohm's Law. There is no need to combine anything, just write your nodal equations. Let's call the voltage across the 3 ohms resistor, V3. So assuming currents that are entering the top V3 node are -ve, while currents leaving the top node are +ve, we have


-2amps + (V3 - 36v)/12 + V3/6 + V3/3 = 0.


From there you can find V3, and use V3/3 to get the current going through the 3 ohm resistor.


Wednesday, 28 September 2016

switch mode power supply - What is the current limit/saturation of series inductors?


I am currently trying to increase a 12Vdc 30A (from a computer power suppy) to 24Vdc 12A. The circuit I have used is based on a application note for the NCP3063 boost circuit with an external mosfet, but I am having problems trying to find a large inductor which is capable of handling the average inductor current of 25.7A.


So, to increase the current through my inductor, could I simply put two inductors in series? If they both had a saturation point of about 10A, would that then give me twice the inductance and twice the current limit?



Answer



Two inductors in series would still saturate at 10A and also you'd have twice the inductance. Two inductors in parallel would share the current reasonably well but now the net inductance has halved because they are in parallel.



This would mean you choose inductors that are twice the inductance and this has a net benefit because, for a given ferrite size/mass, getting twice the inductance only needs 1.414 (sq root of 2) times the number of turns and flux saturation is driven by amperes x turns.


So you started with 1 x 10uH inductor saturating at 10A and you end up with two parallel inductors of 14.14uH each saturating at 7.07A but because they are in parallel the net saturation current is 14.14 amps.


Small print: Assumes that the two inductors are well-matched i.e. reasonably share the load current and that they don't leak enough flux to each other to make calculations more complicated.


power supply - Distance and voltage/watt loss?



I have read multiple posts on here regarding voltage/watt loss but I wanted to see how it would apply in this situation that I can not seem to solve using available resources. Maybe I just do not understand too well.


If I have a surge protector 10ft that has 15a 125v 1875w that is plugged into another surge protector that’s specifications are 15A 6ft and that’s all I could find. Lastly this second surge protector has an extension cord 13a, 10ft 125v and 1625watts. That the end is the units power cord about 8ft that needs 110 watts at max power consumption .


Note: that the I am not going over the rated amount of watts this circuit can handle.


Using the specifications above if I have an appliance at the end of the surge protector + surge protector + extension cord + units power cable that max power consumption is 110 watts do I risk under powering it? Does the voltage/ watt loss for that much cable length affect the amount of power this tv will receive that it will not be able to have the required power it needs?


Thank you for helping me understand.




Why does an inductor behave as a capacitor at high frequencies?


In truth, I've only been told this anecdotally by an instructor, but can someone explain the physics at play?


I have been told that if an inductor is driven at a high enough frequency, it will begin to behave as an capacitor, but I cannot figure out why.



Answer



An ideal inductor would not behave like a capacitor, but in the real world there are no ideal components.


Basically, any real inductor can be though of an ideal inductor that has a resistor in series with it (wire resistance) and a capacitor in parallel with it (parasitic capacitance).


Now, where does the parasitic capacitance come from? an inductor is made out of a coil of insulated wire, so there are tiny capacitors between the windings (since there are two sections of wire separated by an insulator). Each section of windings is at a slightly different potential (because of wire inductance and resistance).



As the frequency increases, the impedance of the inductor increases while the impedance of the parasitic capacitor decreases, so at some high frequency the impedance of the capacitor is much lower than the impedance of the inductor, which means that your inductor behaves like a capacitor. The inductor also has its own resonance frequency.


This is why some high frequency inductors have their windings far apart - to reduce the capacitance.


Tuesday, 27 September 2016

What's the actual difference between Edge sensitive and Level sensitive interrupts


Currently I'm working on a C8051F120 MCU where External Interrupts can be defined in two ways:




  1. Edge sensitive (Falling)

  2. Level sensitive (low-level)


In level-sensitive interrupts as soon as the MCU detects a low level at the external pin it will execute the ISR which is the same as detecting a falling edge.


I know I'm wrong as both can't be the same. Hence I'm asking this question: what's the actual difference between the two, in their detection procedure or in the execution of the ISR?



Answer



Its exactlly what is says.


If edge interrupt is set, the ISR will only get fired on falling/rising edge of a pulse. While if level sensitive interrupt (as you say) is set the ISR will get fired everytime there is a low-level/high-level signal on the corresponding pin.


In short, edge interrupt gets fired only on changing edges, while level interrupts gets fired as long as the pulse is low or high.


So if you have low-level interrupt set, MCU will keep executing the ISR as long as the pin is low.



proximity sensor - Using 24 V PNP switch on NPN input



I purchased a PNP sensor in error. I should have purchased an NPN version.


I'm stuck with this thing now and I'm trying to get it to work. All the guides online show circuitry from NPN sensor. I do however have multiple NPN transistor 2N2222A if that will help.


Can somebody draw up a quick diagram on how to do this correctly for my case?




Additional information:


Thomas' Auto Bed Tramming guide on how to wire it , I'm left with the ground wire that is to be used as the Z signal...i guess.. here is a pic that i got from instructibles that matches my setup: http://i.imgur.com/cxJdbYO.jpg


I've noticed that even though i followed the wiring guide for an NPN inductive sensor, the light from the inductive sensor does turn on when it's near the aluminium heated bed, and turn off when it is away from the aluminium heated bed.


However the wire i'm left with to use as a signal to the RAMPS 1.4 board from my inductive sensor appears to be a negative terminal. As I undertstand it, I need to send a positive signal, and I'm not sure how to invert a negative/ground signal to positive.




Answer



Your question is quite garbled but if I understand correctly what you are asking is:



How can I adapt a 24 V, PNP proximity switch for an NPN machine input.



schematic


simulate this circuit – Schematic created using CircuitLab


Figure 1. Adding R1 and a small signal NPN transistor should do the trick.


If your machine input requires a "pull-to-ground" to activate it then the NPN transistor configuration of Figure 1 will do the trick.


eagle - Creating an Assembly Drawing for Fabrication Houses


I have a design for a PCB that I have been thinking about producing. One thing that I have found is that I need is something called an assembly drawing. So far, all I have been able to come up with is that they are used to describe which components go where for PCB assembly. But I think they are also used for turnkey supplying as well.



What are the key things that fabrications houses look for in a good assembly drawing?


If I am using turnkey manufacturing, how do I describe what parts I want, and how specific do I need to be for things such as capacitors, resistors, and IC's?


What does a good assembly drawing look like? And is there an easy way to create them with Eagle?


If I order, say 500 PCB's, it is common practice for a supplier to create the first 10, ship them, make sure they work as required, and produce the rest?



Answer



Assembly drawings are the master prints to completely assemble a unit.


They should contain (at a minimum):




  1. The quality standard to be used for assembly and inspection (usually IPC-A-610 class 2; class 3 is difficult to achieve unless you are willing to pay a premium).





  2. A reference to the schematic with current revision (which you should also supply).




  3. A reference to the Bill of Materials with current revision which, once more, you should supply. The Bill of Materials should specify the bare board and revision information.




  4. Any special instructions (not everything required to completely assemble the board will be in the normal tool outputs):





Bonding of components perhaps for high vibration environments where you should also specify the material type (at least the standard to which they must be made). I usually specify a particular bonding agent. You should clearly identify on this drawing which components are to have instructions applied to (using a callout)


Any modifications to be performed - we do not spin a PCB for every modification which may require a wire or two.


Any conformal coat requirements, including masking information (you can do this on a fabrication layer, but that layer information needs to be called out).


Any test requirements (you may need to provide test equipment or work with the assembler to define the tests).


Any other information: perhaps some Kapton (r) tape needs to be applied to avoid short circuits.


A view of any surface with components with reference designators clearly visible.


An isometric view is useful for some information.


The applicable standard is IPC-D-325.


I usually require a certificate of conformance to the instructions provided and that assembly has been carried out to the quality standard referenced.



Note that I also generate fabrication master prints in addition to gerbers / ODB++ and the other various outputs; that is a subject in its own right.


There are other things that may end up on the drawing, but this should get you going; I do not use Eagle, so I do not know if there is a simple way of doing this (I use Altium with the drafstman tool)


Edited for comments. Most passives are commodity parts; it is your responsibility to identify the parts that can be eaaily changed.


communication - Is CAT5 cable good enough for RS-485 vs "true" RS-485 cable


I have a serial comms project coming up. A number of boards with RS-485 interfaces need to communicate. Date rate is 57600bps and cable length will be less than a few hundred feet.


Will shielded CAT5 cable work well enough in this situation or should I pay the extra for "true" RS-485 cable such as this one?


enter image description here



I cannot easily visit the install site ahead of time as it's interstate. I do have the same boards here in the lab I can test with however.



Answer



While often shielded, CAT5 can be of the UTP type, meaning unshielded twisted pair. The "true" RS-485 cable you link to has two twisted pairs and a shield. If I remember right, CAT5e (and above) has a shield, at least most cables I have seen have - the exact standard can vary. I guess those would do the job just nice. Just make sure you use the twisted pair like in the original RS-485 cable (your data sheet looks like [1 White/Orange Stripe] and [2 Orange/White Stripe] are a twisted pair, and [3 Blue/White Stripe] is a third, untwisted wire.)


There seems to be a small impedance mismatch (100 Ohms for CAT5, 120 Ohms for RS-485). This will cause reflections at the driver and at the receiver, but I am pretty sure your application will still work. While you may read that 120 Ohms is typical for RS-485, the termination network uses 120 Ohms between the differential pair and 2 * 680 Ohms to VCC and GND.


RS-485 termination, source: wikipediaSource


Thus, the value of the termination that the cable "looks into" is smaller than 120 Ohms anyway: (120||(680+680)) Ohms = 110 Ohms.


If you have the chance to test, you could go for it. I would probably not even hesitate and use STP CAT5(e). If your contract says you pay money for every minute your installation fails, you probably want to use cables with the proper specification. (The latter will still not make sure nothing ever fails, but you're probably in a better position if you can blame it on the "true" cable instead of having someone else blaming your "wrong" cable. But you see how this last paragraph has nothing to do with physics...)


Monday, 26 September 2016

microcontroller - Graphics LCD - how to avoid flicker?


I have a generic question about Graphic LCDs with built-in controllers and RAM. I observe that whenever I change a large portion of the screen with say a new image or a object (or just clear the whole screen with a new color), there is a noticeable flicker. Is there any way to avoid this? I am using the 8080 mode to update the display controller's RAM. The problem occurs because the refresh rate of the LCD is faster than the speed that I am writing into the diaplay's RAM.


I imagine that it should be easy to do if there were an option to update only the RAM of the controller (while the LCD panel retains the old display) until I set a bit to tell the controller that RAM update is complete. Once that's set the controller should output the contents of the RAM on the physical LCD. Is there any way to achieve something like this? The controllers I am referring to are of the class of HIMAX 8232 that come built-in to LCDs.




Answer



While some display controllers cause flicker any time they are written, this particular controller shouldn't have that problem. I would guess you are having flicker because on each update you are writing parts of the display with one value and then rewriting them with another. To avoid flicker, don't do that. Figure out what the correct value should be for each pixel before you write it. If your display consists of various non-overlapping rectangles that could move around, and if you're presently erasing the whole screen and then drawing your rectangular objects, you may be able to improve both performance and appearance by only erasing regions where no objects are supposed to appear; depending upon the application, you may be able to improve performance further by only erasing regions where objects used to exist but have just "disappeared".


Addendum Looking at the supplied picture, what is happening is that the display pixels are being written to in one direction (I would guess top-to-bottom), and the display is scanning in another direction (I would guess left to right). This has the effect that the amount of screen data that has been written when the hardware starts scanning a frame is much less than the amount which has been written by the time the hardware scan reaches the right edge. Consequently, the lines which are drawn near the right edge of the screen will have more data drawn on them than the lines near the left.


If you draw data onto the screen in a direction perpendicular to the display scan, you will get the type of diagonal lines you observe here. If you draw data linearly in a direction which is parallel to the display scan at a rate which is slower than the scan rate, there will be an observable "tear" each time the display scan overtakes your drawing. If you draw data at a rate which is faster than the scan rate, and do so in a fashion which is synchronized with the display scan, you can avoid having any kind of display artifacting, but I have not observed any color LCDs (and very few monochrome ones) with a CPU interface which would allow a connected CPU to synchronize updates with the display scanning. That's too bad, because such an ability would allow cleaner display updates than are possible otherwise. A nice easy technique which was used in many arcade games designed by Eugene Jarvis in the early 1980's was to have the display scanning process interrupt the processor when the scan hits the middle of the screen and again when it hits the bottom. When the scan hits the middle of the screen, everything above the current scan line may be safely updated without flicker provided the updates happen before the scan reaches the bottom. When the scan hits the bottom, everything below the middle may be updated without flicker, provided the updates happen before the scan reaches the middle. It looks as though this controller chip does provide a function to output a pulse when the scan reaches a specified point ("tearing effect line") but I would conjecture that the output is probably not wired to a pin on the display's connector.


I don't know exactly what you're trying to display, but I would suggest that you either work to ensure that any time a pixel is written at all it's written with its "final" color or, failing that, minimize the amount of time between the first and last write to each pixel. For example, if you don't have enough memory to buffer anything externally, you might clear 32 rows of pixels, and then draw everything which should appear in those 32 rows, then clear the next 32 rows, draw everything which should appear there, etc.


Addendum 2


If you have a 16-bit data bus which connects to both the display and the SRAM, and if you have at least one address bit coming out of the CPU that doesn't connect to the RAM (e.g. A18), a useful technique would be to connect that extra address bit with some logic so that any read or write access will be handled by the SRAM as normal, but if that bit is "1" it will also hit the "write data" strobe on the display. If you do that, reading a word of RAM at its normal address will behave as it normally would, but adding 0x00040000 (assuming you use A18) to the address and then performing the read would cause that word of data to be sent directly from RAM to the display (the processor would also read the data, but it wouldn't have to do anything with it). If you don't have an extra address bit available, there are other techniques you could use instead, but I'd have to know more about your hardware to know what to recommend.


arduino - When should you use a fuse?


When is it actually practical to use a fuse? Like lets say your building a robot using an Arduino.....what area would you want to protect the most with a fuse?


I mean do they even make fuses that small (5v's and such) and how do you go about "connecting" them to wires, since the smaller ones seem to be a solid cylinder



Answer



You need a fuse if you want to limit possible damage if something got shorted. This is defenetly possible with non-protected LiIon batteries for example.


For low-voltage applications there are self-healing fuses (often found on motherboards, especially for USB protection).


For non-autonomous robot I would just have 1 fuse on battery, so that it would not burn.


For autonomous one you might need one per each power consumer + sensors to react on shorted engines e.t.c.



Why is this Arduino RF Receiver changing value back and forth so much?


So I have a 315Mhz receiver hooked up to an Arduino, and constantly printing the value of the A0 Analog in pin over to the Serial Plotter that is built in to the Arduino software.



Arduino Graph This is the graph. You can see at the end there is some data from another 315mhz transmitter.


My question is, why is there so much noise when something is happening? Is this normal? Maybe a bad receiver chip?



Answer



Cheap RF receivers don't understand whether data is present or not. They cannot distinguish between noise or data. They don't use a protocol, they don't recognize data frames, payloads or baud rate.


So, when there is no data (aka no strong desired signal) present, the AGC circuit (Automatic gain control) in the receiver keeps raising the gain until something is found and, in the your case it is noise.


When "strong" real data does come along, the AGC rapidly backs-off to avoid saturation of the RF circuits and you get a data output.


Here's an idea of what happens in an FM receiver after the demodulator: -


enter image description here


This uses the terminology of an FM system (data slicer) but applies equally well to an AGC circuit that is constantly trying to find the correct level and only being able to do so after a few bytes of preamble have been received.


For an AM receiver I'd expect a picture like this: -



enter image description here


The left edge of the picture is when the receiver is switched on and the AGC rapidly boosts gain to try and get a decent signal. Noise is dominant here because there is no RF transmission. Along comes a transmission and it takes a little while for the AGC to settle down. Towards the right hand side of the picture, the AGC has stabilized to suit the amplitude of the data carrier and, as you can hopefully see, the noise superimposed on the data has been significantly attenuated due to the AGC.


There are 2 faint dotted lines across the middle of the picture - these are idealized threshold points for reconstructing the data with a comparator using hysteresis.


impedance - Shunt capacitor as discontinuity in transmission line


As in the following circuit


schematic


simulate this circuit – Schematic created using CircuitLab


suppose that an infinite transmission line (with characteristic impedance \$ Z_0 \$) ends upon a capacitor \$ C \$, then another infinite transmission line (with the same characteristic impedance \$ Z_0 \$) begins.


Suppose that a step signal of amplitude \$ V^+ \$ is going from left to right: it will charge the capacitor. The charge process can be described by the following equation


$$V_C (t) = V^+(1 - \exp{(-t/\tau_C)})$$


where \$ \tau_C = CZ_0 / 2 \$. So there is a delay before \$ V_C(t) \$ can reach the value \$ V^+ \$: this expression is exactly the same as an RC circuit.



These are all the informations I have. My considerations are the following:


The key fact in the charge of a capacitor in a normal RC circuit is the equation


$$V_g - V_C (t) = R I(t)$$


But here it can't be written, because there's not a resistance! The only constraint imposed by the transmission line is that


$$\frac{V^+}{I^+} = Z_0$$


The right line can be represented by an impedance \$ Z_0 \$ in parallel with \$ C \$ (considering that it generates no reflections): this could be the load of the left line. But I don't know how to represent the left line with the incoming \$ V^+ \$.


So, how is \$ V_C (t) = V^+(1 - \exp{(-t/\tau_c)}) \$ obtained? And why is \$ \tau_c = CZ_0 / 2 \$ and not \$ \tau_c = CZ_0 \$?


The circuit should be


schematic


simulate this circuit



but I don't know why and if a transmission line (the left one) can be represented by a Thèvenin equivalent circuit.



Answer




So, how is \$ V_C (t) = V^+(1 - \exp{(-t/\tau_c)}) \$ obtained?



Your schematic model is correct. The left transmission line can be modeled with a Thevenin equivalent as you showed and the right transmission line can be modeled with just a resistor equivalent to its characteristic impedance.


You seem to understand why the right-hand model works, so I'll focus on the left one.


First, why \$Z_0\$ in series? Imagine that there was actually a wave propagating from the right. Then the model of the left-side transmission line would have to look (to that wave) just like you've done for the model on the right (by superposition, you can ignore any sources on the left when working out how the circuit responds to this hypothetical signal arriving from the right). So you'd have an equivalent input impedance (looking in from the right) of \$Z_0\$. The \$Z_0\$ in your schematic represents this.


Second, why the source? Imagine there was no capacitor and you were just looking for the signals (\$V\$ and \$I\$) at an arbitrary point in an infinite transmission line. You'd be able to work out the behavior of the waveforms. To make your Thevenin equivalent, you just need to choose a voltage source that would give the same behavior. You can continue to use this same model after adding the capacitor, because the presence of the capacitor doesn't change the model of the portion of the transmission line to the left of it.


Note: you should actually have \$ V_C (t) = \frac{V^+}{2}(1 - \exp{(-t/\tau_c)}) \$




And why is \$ \tau_c = CZ_0 / 2 \$ and not \$ \tau_c = CZ_0 \$?



You have \$Z_0/2\$ instead of just \$Z_0\$ because your schematic model is correct and both "resistors" (actually equivalent circuits of transmission lines) are in parallel with the capacitor.


Sunday, 25 September 2016

avr - Using the ATMega328 with the internal oscillator?


I have a project that I think would be best suited for an ATMega328P. However, in every simple project I've seen, people always hook up a 16MHz external oscillator. From what I can see, it should have an 8MHz internal oscillator. My project doesn't require a lot of processing power, nor does timing need to be very precise(other than for a UART and I2C). I have a programmer also, so I don't need to worry about bootloaders.


Is there any reason for me to use an external oscillator?



Answer



What you don't say is what the accuracy of this internal oscillator is. It took me some time to find it in the datasheet, on page 369.


10%. Ten percent! And that for a calibrated oscillator? This is awful. It isn't unreasonable to expect error as low as 1% for this. Microchip/Atmel provides a document for calibrating the oscillator yourself to 1% accuracy.


I2C is a synchronous protocol, and timing accuracy isn't relevant as long as minimum and maximum pulse times are respected.

UART on the other hand is asynchronous, and then timing accuracy is important indeed. Most UARTs allow a half bit error in the last bit (the stop bit), so that's 5% for a 10 bit transmission.


The factory calibrated oscillator won't do here. You'll have to go through the calibration procedure to get to 1%. In that case you can use the internal oscillator. Otherwize you'll have to use a crystal.


frequency - QAM modulation - how data in different frequencies are laid out?


I know that QAM modulation uses a change in phase and amplitude to send data. But We use a series of frequency spaces as bandwidth to send data.


However, we know that different frequencies oscillate differently. So, if we modulate data using several frequency spaces together, how are data laid out?


Is it that size of data in each frequency is different? Or is it something different?


Thanks.





Saturday, 24 September 2016

Does AC Power have Polarity?


When I run 24VAC into a full wave bridge rectifier followed by a 220uF electrolytic capacitor to turn it into ~32VDC, the source has two wires. Does it matter in what order I connect the AC wires to the input to the bridge rectifier? If so how do I determine which wire goes where? I suspect that it's totally symmetric on the input side, but I'm am full of doubt when it comes to AC. Sorry if this is just a really dumb question.



Answer




When you're looking at an AC source in isolation such as in your question, indeed there's no polarity and you can connect the wires either way round.


When combining two or more AC sources in series or parallel, the relative phasing is very important.


FM Radio transmitter and receiver circuits



I'm planning on building a FM transmitter and receiver circuit for an electronics project. I was just wondering if these two circuits would work together. Also would they be suitable for transmitting and receiving audio?


The transmitter circuit uses the ba1404 chip, link to circuit info here: http://www.circuitstoday.com/stereo-fm-transmitter-using-ba1404


The receiver circuit can be found here: http://circuits-projects.blogspot.co.uk/2014/07/simple-and-mini-fm-receiver.html


Any other advice would gratefull



Answer



The BA1404 does transmit audio, in stereo.


Whether they are suitable for use together depends on the frequency you use; on whether the receiver circuit will handle the +/-75kHz modulation that the BA1404 will do to the carrier; whether it uses the same time constant for de-emphasis that the transmitter uses for pre-emphasis; whether has a stereo decoder; and of course on whether they are located close enough together for the power of the transmitter to excite the sensitivity of the receiver.


NB The link is incorrect in saying that C13/14 are part of the pre-emphasis circuit. They aren't. It is a simple RC high-pass formed by R6/C15 and R7/C16 respectively. These values will give you 50uS pre-emphasis.


As the receiver is built for 88-108MHz I think it is safe to assume it will handle the modulation, but I don't see any stereo decoder in the receiver circuit. So the answer is 'no' unless you arrange to broadcast in mono, by killing the 19kHz pilot tone in the transmitter, or append a suitable decoder, e.g. the one at http://www.fmmpx.com, which I've built many times for modernising several brands and models of FM tuner.


I would add that the receiver looks pretty basic. I would expect high distortion and poor stereo if any. There are better circuits around. Indeed you don't even need one: just use an old FM tuner. This one talks about component numbers in the text but doesn't show them in the schematic, which isn't too encouraging.



resistors - Circuit changes, what is the input high and low given when the circuit is lit and not!


This is the circuit One change in the circuit, the R1 is not 4300 ohms but instead 4700 ohms. The voltmeter is the input into the raspberry pi GPIO board. What would be the input (voltage) when light gets to the phototransistor and when not? PT0 is the ir phototransistor (my real circuit has no base, only two leads.) For any more information please ask for clarification. Thanks



Answer



A phototransistor works exactly like a regular transistor would, except instead of a base powered by an input bias current, it is turned on and off by light. A NPN type phototransistor will, when lit, turn on, connecting the collector to the emitter.



R1 is a pull-up resistor. It is used to bring a node up through the pull-up resistor to a certain voltage. In this case, the node is the connection between R1 and the Phototransistor's Collector, and R2.


R2 is a series resistor. It will simply limit current flowing through it, and in this case completely optional/unnecessary.


When the phototransistor is on, as mentioned, the collector and emitter are connected in a very low resistance connection. As this is the path of least resistance compared to the high resistance of R1, the node at the Collector pin, will be pulled to it. Since the Emitter is tied to ground, that makes the node tied to ground.


arduino - How to 'de-mux' a tri-state pin?


I would like to use a single pin (tri-state buffer, 3.3V logic in case this matters) to drive two P-channel MOSFETs as high-side switches. Only one of them will be 'on' at any time. When the pin is in the high-impedance state (hi-Z), I would like both turned off.


The solution I came up with is to pull-up the hi-Z state (to 0.2*Vcc, see comments) and use two comparators (open collector type) to drive the FETs when the pin is in either the Lo or High state:


schematic


simulate this circuit – Schematic created using CircuitLab


I wonder: is there a better, easier or more elegant approach to this? Is this solution suitable for fast switching?




Friday, 23 September 2016

pic - How can anyone use a microcontroller which has only 384 bytes of program memory?


For instance a PIC10F200T



Virtually any code you write will be larger than that, unless it is a single purpose chip. Is there any way to load more program memory from external storage or something? I'm just curious, I don't see how this could be very useful... but it must be.



Answer



You kids, get off my lawn!


384 bytes is plenty of space to create something quite complex in assembler.


If you dig back through history to when computers were the size of a room, you'll find some truly amazing feats of artistry executed in <1k.


For instance, read the classic Story of Mel - A Real Programmer. Admittedly, those guys had 4096 words of memory to play with, the decadent infidels.


Also look at some of the old demoscene competitions where the challenge was to fit an "intro" into the bootblock of a floppy, typical targets being 4k or 40k and usually managing to include music and animation.


Edit to add: Turns out you can implement the world's first $100 scientific calculator in 320 words.


Edit for the young 'uns:




  • Floppy = floppy disk.

  • Bootblock = 1st sector of the floppy read at bootup.

  • Demoscene = programming competitions amongst hacker groups.

  • Assembler = fancy way of programming a device if you're too soft to use 8 toggle switches and a "store" button.


How would you detect vampire/standby power?


Is it possible to detect when a device is consuming power in a stand-by or nominally off state? For example if I leave my charger plugged in, detect that a small amount of current is being drawn and stop the flow. What about turning it back on? For example, plugging in my phone it could detect the demand and turn the flow back on.


How could you create a device which could turn an outlet on or off depending on the load?




Why is main's neutral tied to earth?



My dad is an Electrician and I myself am an Electronics Design Engineer, and to this day he still hasn't been able to give me a good reason for this.


Consider the two following pictures/situations - both the same case, but with neutral not tied to earth in the second. Apologies for the poor diagrams, but imagine they are sticking a fork in a plug/knife in a toaster/etc. in order to touch active.


enter image description here


In the first picture, the person gets an electric shock. Classic case. This is because there is 240VAC difference between the person's hand, and the earth at their feet. The key thing to note here is that it was the 240VAC difference that caused the shock.


In the second picture, the person is touching the active wire again - however, since earth is not tied to neutral, there is no guaranteed 240VAC difference. None. Like hooking up only 1 end of a battery to a light, this situation has no closed circuit. Thus, the only way to receive a shock is if a person held active and neutral at the same time - which you would have to be trying to kill yourself if you did that somehow (i.e. my point is, most electrical shocks are caused by active -> earth potential, not active -> neutral - and, tieing neutral to earth does nothing to prevent active -> neutral potential shocks).


Yes, earth might be floating and could be "any" potential with reference to active, and it's nice to tie it to neutral at power stations, transformer outlets, and outside our house with an earth stake so "we know" what potential it sits at. But you could make that argument that it could rise to some dangerous potential about any isolated power supply. So I don't think that's a solid argument and the only reason. On top of this, isolated transformers/power supplies are sometimes used for the sole purpose of protecting from shock - so why don't we just isolated the whole earth from our power grid? Haha.


Obviously, earthing chassis would no longer be necessary either if neutral was not tied to earth - because touching the metal casing would not be dangerous if for some reason the device became live (i.e. same as situation 2).


TL;DR: is the only reason we tie earth to neutral so that we know the ground beneath us is 0V with respect to active? Or is there some other reason?



Answer



There are four reasons for grounding the neutral.



1. Grounding neutral provides a common reference for all things plugged into the power system. That makes connections between devices safe(r).


2. Without a ground, static electricity will build up to the point where arcing will occur in the switchgear causing significant loss in transmitted power, overheating, fires etc.


3. With a floating system it is possible to have a short between both in-house and neighboring systems via the ground path as shown below. Turning a light on in your house can cause a light to go on in your neighbors house too. This characteristic is highly unpredictable.


schematic


simulate this circuit – Schematic created using CircuitLab


4. Finally, by giving ground a return path to neutral, a short to the grounded chassis of an appliance causes a predictable outcome in terms of a fuse or breaker response. This provides a great deal of preemptive protection to the user.


In Summary


In a simple model it appears that not tying ground back to the neutral would be safer. However, in reality, in a distributed power system there is no guarantee of this since you have no way to know if there is some other path back to the transformer via a different route. That is, in point 3 above, you may be in danger of being electrocuted just as much as if your neutral was grounded.


In the end the other benefits of tying ground back to neutral outweigh the one possible, but unreliable, isolation benefit.





NOTE: From point 4 there is a paradigm shift in the way you need to think about the neutral-ground connection. Do not think of neutral connected to ground, but instead think of ground being connected to the neutral to allow the current from a short to ground to return to the transformer.


Is it possible to make current flow through a transistor from the emitter to the collector without supplying voltage to the base?


I've started studying bipolar junction transistors, and I'm trying to understand how they work.


When learning about how a transistor work, you always see it connecting 2 circuits, the smaller one involving only the emitter and the base, and the largest one with the collector too.



According to what I understood current flow in the largest, only if it flows in the smallest.


enter image description here


If I disconnect the base and the smaller cirucuit, or remove the voltage generator from that circuit, current stop flowing in the largest one too.


For this reason a transistor in a circuit if no voltage is supplied to the base (or the base not attached to anything) is said to be "off".


As my current understanding (it may be wrong), in this scenario, however you put the voltage generator the current can't flow due to the presence of an electric field inside the transistor ( depletion layer).


But what would happen if I increase the voltage?


Is there a trashold limit where the depletion layer is overcomed? Or is, more generally, possible to make electricity flow from the emitter to the collector without supplying voltage to the base?




Using a transformer to step down 230V to 12V


My circuit uses main electricity in parts of the circuit. However my AVR and other components only need 5V. So I'm using a step down transformer to generate 12V. It's then regulated to 5V.


The transformer won't convert it to dc for me will it?


It just steps it down then outputs a certain voltage depending on it's coils. So I would need to convert it to dc myself right?



Answer



You are correct. The transformer will only reduce the voltage (and increase the available current), so you need to add additional circuitry to rectify, smooth and regulate your 12\$V_{AC}\$ transformer output to 5\$V_{DC}\$.


This is the type of circuit you should be looking to build:


AC to DC PSU




  1. The transformer reduces the voltage from mains to 12\$V_{AC}\$ (RMS).

  2. The Diode Bridge (known as a bridge rectifier) will convert 12\$V_{AC}\$ to 15\$V_{DC}\$. The voltage is \$\sqrt{2}\$ times minus two diode voltage drops higher than the input voltage because the rectifier output is the peak AC voltage, not the RMS AC voltage.

  3. The first capacitor will smooth out the ripples that come from the output of the AC to DC bridge rectifier.

  4. The LM7805 regulator will maintain a constant voltage as the load varies. For example if you are switching a light bulb on and off, the current will go up and down, and if you didn't have a regulator then the voltage would drop as the bulb is switched on. The regulator keeps it at the 5\$V_{DC}\$ your microcontroller needs.

  5. The final small capacitor filters out any noise or interference on the regulated side of the circuit.


power - Buck Converter won't switch properly


I'm trying to use TI's LMR16006 Simple Switcher Buck Converter to regulate 48V down to 5V on my circuit.


I used TI's WebBench tool to calculate component values for their reference design, and had a board fabricated according to the design:


Buck Converter Circuit Schematic


I hand-soldered a prototype of the board, and was able to get it working after some finicky hand-soldering. I had some trouble, but assumed that it was just due to poorly soldered joints (since I was hand-soldering a bunch of small parts for the prototype).


Then I had 10 boards professionally made, and I'm finding that they don't function at all. V_out (across C6) is 1.26 V, and I'm expecting to see 5V!


I checked a couple of obvious things on the nonfunctioning boards:




  • I checked connectivity across the board to see if there were any bad joints and/or if anything was wired incorrectly, but that doesn't seem to be the issue.

  • The bootstrap capacitor (C4) needs to have a voltage of at least 3V; in both of my boards (working and not working), the voltage is around 6-7 volts.

  • I was concerned that perhaps the SHDN pin was being pulled low, but on both boards the value is hovering around 5V, which should be high enough to ensure that the regulator itself isn't shut down.


After looking at them on scope, it looks like the on the working board, the SW pin is switching at the correct frequency (~700 kHz), while on the non-working board, the frequency is MUCH slower (~150 kHz).


I'm trying to figure out why the converter's not working as expected, but I'm honestly not sure what to investigate next. Any suggestions for how to proceed troubleshooting would be super helpful.


Edit: Board design uploaded below. enter image description here



Answer





I used TI's WebBench tool to calculate component values for their reference design, and had a board fabricated according to the design:



Allow me to express a serious doubt about the board fabrication statement. Here is your layout, and the recommended layout, side-by-side:


enter image description here


Their layout is done that way for a reason, and the reasons are explained in many places, e.g. here. All MHz-range switchers are fundamentally sensitive to implementation of "high-current" loops. You can't get decent (advertised) efficiency (nor even basic functionality, as this example shows) without reasonable implementation of these loops. Especially in a 10:1 design. Manufacturers spent a lot of application resources to make right layouts, and design of internal pads on IC are usually optimized for particular fan-out. There is no reason whatsoever to deviate from the reference designs unless you can propose a better layout (sometimes it may happen). In this design the most glaring mistake is the routing of high-current switch node (around SW pin). Huge parasitic inductances of skinny traces likely change the switching curve of internal transistor, which likely causes some odd internal behavior and refusal to start the switcher properly.


Also note the tight low-inductance placement of Cin and Cout caps. And the designs usually use no thermal relief, only solid connections, all for the same reason - to exclude any parasitic inductance in high-current switching loops.


I am afraid this construction can't be salvaged and needs total re-design, preferably in full accord with manufacturer's suggested layout.


What is the most common type of high voltage cables?


I'm building the model of an admittance matrix for the German Grid, most specifically the Transmission grid. I only have characteristics of cables as number of cables, wires and voltage (I'm working with 110kV, 220kV and 380 kV). I would like to know what are the more common types of cables used in order to be able to assign them electric characteristics, as for example, resistance, inductance, etc.



As an example, for 110 kV I have somecables already: N2XS(FL)2Y / NA2XS(FL)2Y


Ideally a link with the norm or a list of them would be perfect!.


Thanks!



Answer



A bit late, but;


As far as overhead (aerial) conductors go - who knows?


There are copper conductors (hard-drawn bare copper conductor, HDBCC), various kinds of aluminium alloy of which AAAC 1120 is the most common these days, and various mixes of aluminium with steel strands (for tensile strength.)


Copper isn't used much these days. Aluminium conductor is cheaper and lighter (which reduces the demands on the overhead tower structures) so it is used for nearly all new overhead lines.




As far as solid insulation goes, for cables you could bury in the ground;



Up to the 1980's or so it was common to use paper-lead insulated cables. That is, layers upon layers of brown kraft paper, wound up to the required thickness, and impregnated with oil, wax, or resin di-electric; then, over-sheathed with lead sheeting to provide waterproofing and stop the oil/wax/resin from leaking out.


In Australia paper-lead cables were called 'PLA' or 'PLY' or 'PILC' (paper insulated, lead covered). There is also the acronym 'PLYSWAPVC' standing for 'paper lead y(?), steel wire armoured, PVC sheathed.'


Starting in approx the 1990's, it is more common for HV cables to have solid plastic insulation. The particular plastic in question is called 'XLPE', cross-linked polyethylene. This stuff had some early failures caused by a susceptibility to water damage, but that's mostly fixed now.


As far as 'non-solid' insulation goes - there is one kind of cable where the insulation is liquid oil. The "cable" looks more like a pressurized water pipeline than a cable. There's another kind of "cable" where the insulation is SF6 Nitrogen gas.


Here is an entertaining story about the failure of an oil-filled cable in Los Angeles. And another story about the failure of a gas-filled cable in Auckland.




For power system analysis purposes, where you often don't know the age of the cable, the safest assumption is that it's all paper-lead (which has the lowest current-carrying capacity.)


XLPE would be common for newer cables. Due to the amount of special care and handling for oil-filled and gas-filled cables, I think they were only ever used for short runs when very high capacity is required, i.e. in dense city centres. These days, for a new installation, I think you would install XLPE instead.


Thursday, 22 September 2016

lm317 - High Side Constant Current Source


I am trying to create a constant current source of 100mA to charge a single cell Li-ion battery. I see the LM317 thrown around a lot as a solution, but I'm looking for something that does not require a 1.2V drop (Due to the Vref=1.2V for a LM317). The problem is when I look at more modern LDOs, they tend to have a ground as well as a ADJ pin, and I'm wondering if these can be floated the same way the traditional LM317 regulators could. Once such device I was looking at was a ADP123AU due to it having a Vref of 0.5V.


enter image description here


So looking at the block diagram they do not mention what the 0.5V is ref to but it would have to be ground as far as I can understand, so if you float ground as shown, would it work? Or does anyone know another small regulator / specialty IC that can do this?


schematic



simulate this circuit – Schematic created using CircuitLab


EDIT: Thanks for the input, it is interesting but I may not have been clear in the initial question. I am looking to do this as simple as possible, something such as the LM317 with a single resistor. Multiple op-amps and transistors is something I would like to avoid.


Does anyone have an opinion on if what I proposed in my question would work?



Answer




So, I downloaded LTSpice, and found an appropriate LDO Regulator made my LT that met my specifications of a low dropout and low Vref. I created the example circuit from above and simulated it.



After testing the circuit shown below with both a small Rload and large Rload (full and empty battery) I discovered that 'any' adjustable regulator even with a ground can be floated as the old LM317 could. I suspect that this is due to the small Quiescent current that can be sunk by just about any load.


The image shows a 20mA current source that is comprised of 2 components, a LDO and resistor.


enter image description here



soldering - Sizing SMD components for Hobbyist Kits


More components are only available in SMD packages. For hobbyist assembly the options are to buy breakout boards or solder SMD.


Since components are usually packaged in a couple of SMD package types I am trying to put together a set of guidelines for choosing packages that are compatible with hobbyist skills and tools. I would consider hobbyist level tools for SMD assembly as -- soldering iron in the $50-$100 range (new), for magnification a $40 visor (like the B&L) and tweezers.


For the kits I make now I use the following guidelines --



  • Passives 0805 or larger


  • Min Lead Pitch for SOIC or QFP -- 0.5mm

  • No QFN, LGA or BGA

  • Prefered package for gates, BJT, FET --- SOT23

  • Diodes SOD123 (or larger)


I am interested in recommendations on component selection, minimum tool requirements and assembly issues. Specific tool changes (like solder tip size) that enabled you to do SMD assembly with your existing tools would be useful too.


Thanks.



Answer



0603 isn't too bad to solder by hand (I won't do 0402 or smaller though).


SOT23 is probably a good guideline (for diodes too, not just transistors); there are some SOT323s that are smaller that are a pain.



I would avoid certain SOT23-6 parts because it can be very difficult to determine which way the package is supposed to go. (For some dual MOSFET packages it doesn't matter.) We had one where there was a slight bevel along one edge. Grrr.


I would also avoid SOD123 because of the backwards nature, if possible. SMA/SMB/SMC aren't as much of a problem.


And avoid those cylindrical diodes (LL-34 / MELF) like the plague! they will roll off the board.


What is $V_{ADJ}^{+}$ and $V_{ADJ}^{-}$ for this adjustable delay schematic?


Here is the adjustable delay schematic,and as i know,the \$V_{ADJ}^{+}\$ and \$V_{ADJ}^{-}\$ is off chip for testing flexibility.


But i'm curious that the delay is for the time delay,why should we feed the voltage to it?If we don't feed voltage to \$V_{ADJ}^{+}\$ and \$V_{ADJ}^{-}\$,is this schematic still a delay schematic?but if we don't feed it,where should i connect the gate of \$M_{PGm}\$ and \$M_{NGm}\$ to?


enter image description here


enter image description here


blue wave is \$V_{DLY}\$,output.Red line is \$V_{CP_PK}\$,input.


\$V_{ADJ}^{+}\$ connect ground,and \$V_{ADJ}^{-}\$ connect \$V_{DD}\$




power - A question about earth ground and current loop



enter image description here


If the live wire in above illustration touches to the metal case, a high short circuit current will flow to the earth through the safety earth wire and the fuse will trip.


Now imagine a 9V battery staying on a wooden table. If now its plus terminal is tied to the earth through a wire almost no current will flow.


Above two points shows that it is not the case that the earth is a reservoir that sucks all electrons, but simply current needs a loop to flow.



In the battery case it is obvious that there is no loop because the negative terminal is floating.


But what is the loop in the first AC case? Is that the AC generator star connection? Can you draw this loop to illustrate better?



Answer



What is different is that for a battery there is not other connection to ground, this is not the case with the mains.


In the mains, the neutral connection is actually grounded as it enters your building, or at the transformer.


As such shorting the live wire to the case is really shorting the live wire to the neutral side of the transformer through the ground line creating a loop, and, as you have expressed, large current flows till the fuse of breaker trips.


schematic


simulate this circuit – Schematic created using CircuitLab


Which is why this is dangerous...


enter image description here



With an isolation transformer you isolate the power from ground and there is no return path.


enter image description here


What is the significance of Common Mode Signals?


I don't understand the physical significance of Common Mode Voltage.


It is arbitrarily defined as the average of two voltages and is expected to be rejected by a differential amplifier. Why? What is its physical significance?


EDIT my question was specific to differential amplifiers. Both inputs to the differential amplifier need not be equal and opposite. What would be the meaning of common mode voltage in such case?



Answer



For common mode signals you get two wires: one with a signal and one with the inverse of that signal. If you add them you'll get zero, if you'd take the difference you'll get the signal.


What's the cool thing about this. If the two wires (the pair of wires) picks up some noise. Than the noise will be added on both wires. If you add the two signals you only keep the noise.. But if you take the difference you'll get the signal without the noise.



Signal is S (without noise)
Cable a => S
Cable b => -S


The Difference is S - (-S) = 2*S


Signal is S (with noise)
Cable a => S + noise
Cable b => -S + noise


The Difference is (S+noise) - (-S+noise) = S+S+noise-noise = 2S


So the noise will be cancelled.


example image: enter image description here



When Common mode signals are used they are mostly transferred with twisted pair cables like this: enter image description here


power - Max current draw from a UK Phone Line?


Reading a question on SuperUser where someone received an electric shock from a modem made me curious, how much power can a phone line provide?


(I'm not looking to do anything dodgy like try to power something, this is just out of curiously/amusement; in the UK phone lines operate at ~50v (up to 100 with an incoming call) enough to overcome the resistance of human skin in the right conditions. 10mA would give a nasty shock but 100-200mA has a high chance of fatality - in theory could someone actually be electrocuted by a phone line?)



Answer



This source states that BT provides 40mA when the phone is off the hook.


This other source talks about the expectations of the ringer circuit:



  • less than or equal to 5mA draw at 35V/25Hz ring signal

  • less than or equal to 10.5mA draw at 75V/25Hz ring signal



PowerDsine's North America ring module generator appears to be limited to 3W, so I would expect the PSTN provider's capabilities to be similar. This signal gets shorted out when the phone goes on-hook, so the source can't be too stiff.


Common Source JFET small signal equivalent circuit


This circuit is equivalent to small-signal common source JFET amplifier:


enter image description here



If you look at the input and output impedance you can see that Zin = R1 || R2 and Zout = rd || Rd || Rl. It can be seen from the small-signal model.


But shouldn't small-signal model look like this?


enter image description here


I just want to understand these models and maybe derivate input and output impedance myself.



Answer



The ideal DC voltage source has 0Ω internal resistance. And that's why AC-signals are shorted by DC voltage source. DC voltage is always constant so for any change in current there is no change in the voltage. So there is 0 Ohm internal resistance. Additional in real life circuit we always uses a bypass capacitor connect parallel to DC Voltage. And this capacitor will short all AC-signal to the ground.


For example if we have a 9V DC voltage source, now if we smoothly change the current that is draw from this DC voltage source, from 40mA to 20mV (we change the resistance from 225Ω to 450Ω). We create AC-current. But the DC voltage do not change (0Ω internal resistance). So the dynamic resistance of DC-voltage source is equal to rd = 0V/20mA = 0Ω And this is why we say that DC-Voltage is a short for an AC-signals.


arduino - Speed problems in homemade RS232-to-TTL converter board


I'm still trying to debug this RS232-to-TTL converter board that I've made, shown below.



My RS232-to-TTL board and my setup


Now I think I've narrowed down the problem to speed:



  • it works fine at 57,600 baud;

  • but it inserts some errors during comm at 115,200 baud.


This time I tested the board with a simple echo firmware below, which basically echos back whatever comes into the serial port.


void setup() { 
Serial.begin(57600);
}

void loop() {
if (Serial.available() > 0) {
Serial.write(Serial.read());
}
}

At 57,600 baud, it returns a series of B chars without errors, as below.


BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

At 115,200 baud, a few errors make into the output.


BBÂBBBBBBBBBBBBBBBBBBBBBBBBBBBBBÂBBBBBBBBBBBBBBBBÂBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBÂBBBBBBBBBBBBBBBBÂBBBBBBBBBBBBBBBBÂBBBBBBBBBBBBÂBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBÂBBBBBBBBBBBBBBBBÂBBBBBBBBBBBBÂBBBBBBBBBBBBBBBBÂBBBBBBBBBBBBBB
BBBBBBBBÂBBBBBBBBBBBBBBBBBBBBBBBBBBBBBÂBBBBBBBBBBBBBBBBÂBBBBBBBBBBBBBBBBBBBBBB

The error rate seems to be fairly constant and it's always the same. Note that the difference between B and  ASCII char codes is just one bit negated and another one shifted one position left.


B - 01000001

 - 11000010
^ ^

The MAX232 datasheet says it works up to 120 kbps, so I think my board is causing the problem.


So, that's the new evidence I've got so far. My question is: What would be the likely reason for the problems with my converter?


Here's a picture of my board design, if that helps. Disregard the TX and RX LEDs, I've disconnected them.


enter image description here



Answer



It is probably the crystal on your target board.


A 16 MHz rock probably can't generate a clock for 115200 baud exactly enough. Over a long enough continuous stream of characters, the clocks on the two devices will slide out of sync. Eventually, you will get a framing error and a bad character, and the devices will resynchronize on the next falling edge (START bit).



The fact that your errors are roughly periodic tends to support this hypothesis. I saw a similar problem (at much lower speed) on a modem line to a minicomputer many, many years ago.


If you can feed your UART with a clock that is exactly correct for 115200, do that, and see what happens. (If you have access to a really good, EXPENSIVE, signal generator, use that.)


Wednesday, 21 September 2016

data - NAND flash retention using USB charger?


NAND-based digital flash data storage devices such as SD,SSD,USBstick,eMMC,UFS,etc. do have transistors, where the small amount of electrical charge does slowly leak over time, resulting into data loss when inactive for excessive time spans. Heat does accelerate that process.


In order to recharge the transistors, do I need to actually read the data like on HDDs, or does the storage just need electrical power supply?


And if the latter one is true, how many seconds or minutes does the NAND storage need power supply? Does 5.3V instead of 4.9V make any difference?




Tuesday, 20 September 2016

wave - Changing a Signal's DC Offset


I have a square wave being generated from a waveform generator oscillating between 0 V and 5 V. The generator does not support negative DC offsets. I need to shift this signal down to be centered about the 0 V value, i.e. oscillating between -2.5 V and 2.5 V (AC Coupled?).


What are ways of doing this?



(Forgive me if I mess up any terminology I'm a software engineer by trade.)



Answer



What you need to do is simply remove the DC offset all together, not supply a negative one. This is known as AC coupling. If you run the output of your square wave generator through series capacitor, it should do what you need. This will however be at the expense of making the square wave less square.


An example circuit is shown below for you:


Example Circuit


And the output would look like this (Green Trace = Generator Output, Blue Trace = Voltage Across Resistor):


Green Trace = Generator Output, Blue Trace = Voltage Across Resistor


You will probably get a little voltage loss (meaning your peaks will be a little less that +/- 2.5V) since no capacitor is ideal, but you can get a pretty good square wave output if you get the right value capacitor. You'll have to experiment and see. Usually, the larger capacitor value you choose, the closer your output waveform will be to the original for any frequency a benchtop square wave generator is outputting.


Why off-line power supplies are called so, like they are "off the line"?



My understanding is that "off the line" means "not on the line". For example an internet user is offline, meaning "not connected". However "Off-line power supplies" are directly connected to the grid (without line frequency transformer). Who coined this strange term?




reference materials - The Art of Electronics - differences between book versions?


http://www.barnesandnoble.com/w/art-of-electronics-paul-horowitz/1100491782?ean=9780521370950


There appears to be a couple of versions of the 2nd edition of this book. I noticed US and International editions and a Hardcover or Paperback versions.


Are there any contents differences between the versions?


[editor's note: The third edition of this title is now available]



Answer




International editions are substantially cheaper, in both meanings of the term. They are printed on lower-quality paper, with smaller print, and black-and-write ink. (But AoE has no color sections anyway.)


Hardcover and paperback versions refers to the binding. I don't think there are any differences in content.


Before buying the book, take note that a 3rd edition will be published Real Soon Now: http://www.eevblog.com/forum/chat/the-art-of-electronics-3rd-edition-finished-writing-and-copy-editing/


[Editor's note: The third edition is now available]


ground - Why is an Ethernet cable not grounded?



There is no dedicated GND in the classical Ethernet 8P8C ("RJ45") pinout.[1]


Why does the Ethernet spec not include a ground, unlike many other cable types used for interconnecting devices that may both have its independent power source as well, e.g. RS-232 or USB?




STM32 reset not work


Background: 1.5% of products which use STM32F107 didn't work after using 3 months; Lithium battery is the power supply source. The products were used in car. This phenomenon suddenly occured without any pridication. According the record in product, the temperature is normal(25 Centigrade).



Problem Analysis: The voltage at VDD is 3.3V. The NRST reset do not work. After disconnecting the power and connecting again, the chip could recover and work again. And this problem could not be reproduced in our lab condition.


Additional information: the chip use STANDBY mode to shut down and use WAKE UP pin back to work.


The schematic is attached below.(Only the core components displayed)


Is the schematic wrong or did I missed something? schematic picture




How are current and voltage related to torque and speed of a brushless motor?


I know that electric vehicles have different performances depending on battery and motor, but it's not clear how electrical and mechanical units are related.


Can anybody please help?


Will a 100V motor raise against slopes better than a 50V motor?




circuit analysis - Why superposition theorem fails here?


I have a simple circuit consisting of 2 ideal voltages sources (each 5V) parallel to a resistor of 5 ohms. The current along the resistor is 1A, right? But by applying the superposition principle (i.e. considering individual sources), I am not getting this result. Am I doing some blunder?


enter image description here



Answer



Ideal circuits with two voltage sources in parallel lead to contradiction, unless they are equal and can be simply replaced with a single one. Note that potentials \$ \varphi_1 \$ and \$ \varphi_2 \$ in your circuit must be equal, since there is no impedance of any kind between them, nor do ideal voltage sources have any internal resistance:


Ideal circuit with three equal potentials


In your case, luckily, these sources produce the same voltage, so the simplest thing to do is to simply remove one of them from the circuit. If you had two ideal sources of a different voltage in parallel, that would lead to contradiction.



In a real circuit, connecting two sources in parallel would lead to a circuit with a very small, but still non-zero resistance between them, which would result in one of the sources (the one with a slightly lower voltage) actually sinking current, but the current through the 5 ohm resistor would only depend on the voltage of the right source.


If you want to put some actual numbers, you can try something like this:


Real circuit with non-zero resistance between sources


Note that if the sources are again ideal and have completely equal voltages, there will still be no current flowing through the tiny resistance between them, but you should be able to apply the superposition principle.


For a circuit like this, the mesh current method should provide the simplest solution and show that the current through the resistor only depends on the right source.


cmos - Binary counter and load capacitance


Im desiging a circuit with a binary counter which rates it's maximum count frequency in terms of load capacitance.


Im quite confused and having a lot of trouble wrapping my head around how to calculate this.


The input to the counter im using is a typical CMOS Inverter Oscillation Circuit shown here, with the output connected directly to the clock input of the counter.



The data sheet of the particular inverter im using specifies the input capacitance as 3.5pf, and the load capacitance of the crystal can be tuned (currently 8pf), but I cant work out how to determine what the total output capacitance of this circuit is? Which im assuming is what the load capacitance to the counter will be.


I plan to use a SN74HCU04 inverter and this binary counter. The binary counter specifies the maximum frequency in terms of load capacitance on page 6.



Answer



The CL on page 6 of your counter datasheet refers to the load capacitance on any relevant output of the counter. See page 8, section 7, that defines how CL is used. Notice how as well as defining a minimum fmax, there are two sections in each table for detailed propagation delays input to output for the different output loadings.


CL is there so that IC speeds are measured and specified in a reproducible way, that's appropriate for real life circuits.


50pF is a fairly typical industry standard loading, it's not far from a bit of trace, a bit of cable, and the 30pF of an oscilloscope input. Many manufacturers also quote into a lower capacitance like 15pF as it improves the timing, and is representative of a a bit of trace and a couple of CMOS inputs.


Your design breaks down into two independent sections.


The first is the oscillator. The crystal must see appropriate capacitances to ground on both its leads, in order to oscillate properly. Use the HCU04 specification to adjust those. Use another of the inverter sections to buffer the oscillator output, so the crystal only 'sees' one inverter load, and not whatever you are driving.


The second is the counter. As long as the buffered oscillator is producing a clean logic swing, and a frequency less than the fmax of the counter, you can connect the oscillator to the counter and can expect it to work.


The fmax of the counter is dependent on what sort of loads you want it to drive. If it's only a few logic gates, then use 15pF and fmax is 40MHz. If you want to load any output directly with an oscilloscope, then it may not work at 40MHz, and you'll need to drop to 25MHz. That's what x10 scope probes are used for, they drop the possibly 50pF of cable+scope capacitance down to the 10-15pF range.



You can always make the CL that your counter sees be less than 15pF by buffering the loads, if you find the load capacitance that you want to drive is excessive.


How to avoid damaging relay used for controlling motors?


I've got a circuit with two DPDT relays controlling a motor - the diagram below is borrowed from a related but different question. RLY1 turns everything on and off, RLY2 switches the direction of the motor.


I've found that after a brief amount of use the relays are damaged. Both relays have the same problem - on one set of contacts common/NO/NC are all connected, even when the relay coil is unpowered. (The other set of contacts is as expected - ie. common/NC are connected, NO is connected to neither of the other two - so only "half" of each relay is currently damaged).


Questions: what is likely to have caused NO/NC terminals to be connected, and how should I have avoided that problem?


Gory Details (possibly not needed):



  • motor runs on 30V


  • PSU that came with the motor is rated 30V/2A

  • relays are rated for 2A/30VDC (model Meishuo MCB-S-205-C-M)

  • relay is controlled from an ATMega MCU

  • relays both have an IN4001 protection diode across the relay coil - not shown in diagram


  • I did manage to "fix" one relay by tapping it on the table. Unknown if that will stay fixed or if permanent damage is done. The other relay doesn't respond to this treatment.


    enter image description here






Monday, 19 September 2016

signal - Time domain reflectometry (TDR), initial pulse slope


A ~100kHz square wave through a 100m open end coax (RG-58) produces a slightly sloped shoulder during the time from initial pulse until reflected pulse (A-B), and from initial pulse drops until reflected pulse ends (C-D).


What are the correct explanations for these slopes [not being flat]?


(Scaling: 2.0V/ 2us/) enter image description here enter image description here EDIT: enter image description here



Answer



The slope on a shoulder (first plateau) is defined by interplay of resistive and dielectric losses in the transmission line (cable), see the iconic source, by Howard Johnson. In your case the resistive loss effect seems to dominate.


There are also 13,000 hits on Google for [tdr lossy transmission line], from Tektronix and Agilent and other good places.


Switching a Step Up Converter with Mosfet


Im trying to switch this common converter:http://www.ebay.com.au/itm/281807832840?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT enter image description here


With: https://www.fairchildsemi.com/datasheets/2N/2N7000.pdf


Connected direct to battery it works fine and does not pull a great deal of current.


But when switched with a mosfet, loads, such as an LED, cause the voltage coming out and into the converter to drop and the current consumed by the converter to increase to compensate. (I figure with these things the larger the voltage gap to get up to 5v the greater the current it pulls)


The reason I need to switch (eventually with a micro) is to get around its idle current because running off batteries.


Direct to batteries, measurement at Step-Up:




  • No load: 3.7mA, inV: 2.48v outV: 4.98v

  • With LED: 7.4mA, inV: 2.48v outV: 4.98v


Via Mosfet:



  • No Load: inV: 24mA, inV: 0.38v outV: 4.34v

  • With an LED: 24.4mA, inV: 0.36v outV: 3.44v


As far as i can tell this mosfet should be suitable for this sort of voltage and current range. But I am new to mosfet, so not sure how to work out what the problem is.



outputoutput voltage of mosfet at turn on


Eventually I want to drive a 5V sensor that pulls more current than an led ~ 10mA idle and a 3v3 voltage regulator that drives a rf module (~20mA). But the more load i add the worse this situation gets very quickly to the point that the step up is pulling like 80mA and only putting out about 3V.


schematic


simulate this circuit – Schematic created using CircuitLab


**Update" From the data sheet would this be the graph of interest to me, showing that with the voltage range i have i cant pull much current ?


enter image description here



Answer



There are two issues with your design. First and most important, replace that 100 Ohm resistor which is way too small with 10K. Second, the Vgs On of the mosfet could be bigger than the battery voltage. You may want to use another battery or another FET


Any advice on reading datasheets


After my embarrassing mistake by having the component in backwards, I'm wondering if anyone has advice for the newbie (or expert) on reading datasheets.


What conventions are there which aren't obvious.


What's the first thing you should check when something's not working.


What can I safely ignore and what should I worry about?


Anything else?



Answer



Look hard at where pin one is. Make sure you understand if the diagram is a top or bottom view (top is I think most common).


To put this another way, some datasheets give you the dimensions of the part itself, and some datasheets give you the recommended land pattern (aka footprint, solder pads).


If they give you the dimensions of the part, they usually give you a top view and then bottom view. When you're looking at the bottom, imagine you flipped the chip over with your hand.



fpga - Validity of AWADDR once AWREADY is asserted in AXI4-Lite interface


This question is a follow-up to Relationship between AWVALID and WVALID in AXI4-Lite interface, from which I learned that AWVALID and WVALID have no specific timing relationship.

Now I have a slightly different question. If AWREADY is asserted in response to AWVALID, is there any guarantee that AWADDR will stay asserted till WREADY, BVALID, or BREADY is asserted?
I'm only asking this because I have seen some codes that look at WVALID alone for completing the write operations. They totally neglect AWVALID and keeps AWREADY=1 at all times, with the assumption that AWADDR will be valid. Is this perfectly fine to do?



Answer



No. When AWREADY is asserted with AWVALID high, AWVALID must be deasserted on the next clock edge, or the other signals must be updated to reflect the next transaction. With AWVALID deasserted, AWADDR can take on any value. You cannot rely on the value of any of the AW* signals after completing the handshake by asserting AWREADY.


A module that assumes differently will then depend on the specific implementation of whatever component is upstream, something which could lead to hard to find bugs and compatibility issues. I also think it is a violation of the spec to do something like that.



You have two options here: either store the value you need and complete the transfer immediately by asserting AWREADY, or hold off on asserting AWREADY until you no longer need the value.


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