Wednesday, 24 August 2016

Protecting USB hub from ESD



I am working with a robot that uses USB (not by choice lol) in a very static-prone environment, and I'm having problems with ESD locking up my USB hub. I found an "Industrial" USB hub that claims it can withstand a 15kV shock through air and an 8kV direct contact shock. I'm wondering what the effectiveness of that would be as compared to using USB Surge Protectors inline between a standard USB hub and the slave/master devices? What about using both at the same time? Would that actually help at all, or just introduce weird problems due to capacitance and whatnot?


Edit: I should mention that non-COTS PnP solutions are not an option unfortunately (for example I can't solder a special ESD protection chip to the data lines)




memory - What happens when microcontrollers run out of RAM?



It may just be a coincidence but I've noticed the microcontrollers I've used rebooted when they ran out of RAM (Atmega 328 if hardware specific). Is that what microcontrollers do when they run out of memory? If not, what happens then?


Why/How? The stack pointer is certainly blindly increased to a non-allocated memory range (or rolled over), but what happens then: is there some kind of protection that makes it reboot or is it (among other effects) the result of the overwriting of critical data (which I assume different from the code which I think is run directly from flash)?


I am not sure this should be here or on Stack Overflow, please let me know if this should be moved although I'm pretty sure hardware has a role in that.


Update


I should point out I am particularly interested in the actual mechanism behind memory corruption (is it the result of the SP rolling over -> does that depend on the uC's memory mapping etc.)?



Answer



In general the stack and the heap crash in to each other. At that point it all gets messy.


Depending on the MCU one of several things may (or will) happen.



  1. Variables get corrupted


  2. The stack gets corrupted

  3. The program gets corrupted


When 1 happens you start getting strange behaviour - things not doing what they should. When 2 happens all manner of hell breaks loose. If the return address on the stack (if there is one) is corrupted, then where the current call will return to is anyone's guess. At that time basically the MCU will start doing random things. When 3 happens again, who knows quite what would happen. This only happens when you're executing code out of RAM.


In general when the stack gets corrupted it's all over. Just what happens is down to the MCU.


It might be that trying to allocate the memory in the first place fails so the corruption doesn't happen. In this case the MCU might raise an exception. If there is no exception handler installed, then most often the MCU will just halt (an equivalent of while (1);. If there is a handler installed, then it might reboot cleanly.


If the memory allocation does go ahead, or if it tries, fails, and just continues with no memory allocated, then you're into the realms of "who knows?". The MCU might end up rebooting itself through the right combination of events (interrupts caused that end up resetting the chip, etc), but there's no guarantee of that happening.


What there can usually be a high probability of happening, though, if it's enabled, is the internal watchdog timer (if one exists) timing out and rebooting the chip. When the program goes completely AWOL through this kind of crash the instructions to reset the timer generally won't be run, so it will time out and reset.


Tuesday, 23 August 2016

current - electric chewing gum prank circuit diagram


I'm new to electronics.


I'm trying to find out how this works out of curiosity.



http://www.amazon.com/gp/aw/d/B0050UNNQS


Does anyone have a circuit diagram for the circuit? Is the current safe for such a prank?


Internal picture: enter image description here




EDIT: Merged question from Trever Thompson


Help here would be greatly appreciated: This question has been asked several times on this site and elsewhere, and it seems as if the posters became satisfied with inaccurate answers.


How on earth do the electric shock prank pens/bubble gum work?
I have no intention of shocking anybody or recreating this circuit, I am simply baffled by how it operates. I have verified that all purported explanations readily available online are inaccurate or incomplete.


The above image shows the only two components in the circuit. I do not know for a fact what the white component is, but I have to assume it is a high value capacitor.


enter image description here



The above image is a literal layout of the circuit. The 50k load is the user's hand. Both switches are closed upon pressing the button. The switch is before the capacitor. This is based on closely observing the circuit and is 100% accurate unless someone can prove otherwise. I tested this with varying capacitance and inductance values and was unable to induce a significant current in the load for more than dozens of miliseconds. When testing I moved the virtual switches from the ground to the positive wire. When I move the switch after the capacitor I can have a long lasting current through the load, but the voltage/current are very low.


Edit: It is beginning to appear as if the white piece (Shown as cap above) is an active component/IC. There may not even be a capacitor in this circuit.


What I know:



  1. The device behaves as follows: When the pen is held and the button is pressed a mildly painful electric shock is felt. After about 3 seconds, the pain gradually decreases until it is not longer felt. Upon releasing and pressing again the full shock is felt once again, even if only released for the slightest moment. The button and grip are the electrodes.

  2. It uses 4 1.5V button cells in series (with high internal resistance)

  3. The shrink wrapped component is a tightly wound step up transformer. The secondary uses extremely thin wire. It apparently is an autotransformer, as it has three leads and is wrapped around one ferrite column.


What I think I know:




  1. I measured the frequency on the primary with a primitive oscilloscope. It was equal to a couple hundred hz, which is reasonable considering the pain of the shock.

  2. If the frequency is ~200hz, the capacitor (if the white component is a cap) would have to be over 100uF non polarized. This may be possible as I have discovered high capacitance low voltage smd caps. The primary inductance would have to be several mH.

  3. The turn ratio would (I believe) have to be at least 1:90. This surprised me because I read that most autotransformrs have a low ratio. I then encountered higher ratio custom ones (which is more reasonable if varying wire gauges are used).


What I want to know:



  1. What the white component is. Is it merely a capacitor? Does it serve other functions?

  2. How on earth does this circuit work. It seems so simple and then again I can't explain or emulate its behavior accurately in a simulator...


Help will be greatly appreciated, as this has kept me occupied for a long time.




Answer



Here's a little circuit that might fit the bill


enter image description here


The battery charges the capacitor (C1) through a resistor (R1). When the switch is operated the charge from the capacitor is dumped into the primary of the transformer. This produces a damped oscillation (LC circuit). The transformer secondary has a lot more turns than the primary and so the VOLTAGE part of the short burst of alternating current in the primary will be magnified by the turns ratio. The current part will be diminished. The total energy delivered to the 'shock' can be estimated from the energy store in the capacitor. (0.5 * C *V^2). For the values given = 0.5 * 22 * 10^-6 * 9^2 Joules or 891 micro joules - pretty harmless. The transformer is a small audio output type but others can be used such as the trigger transformer for a flash tube (hacked from a cheap camera) or you could even wind you own on a ferrite ring.


Connecting two Ethernet PHY without magnetics?


In a (tentative) new design I want to connect two 100 Mbit/s Ethernet PHY similar to LAN8270a, separated by few inches on the same PCB, with same ground plane (but different power supplies). I have the choice of one of my PHY, but the other is embedded in an as-yet-unspecified PCIe to Ethernet IC (perhaps Gigabit but used in 100 Mbit/s mode), and it is critical that this PHY thinks there is a bona fide 100 Mbit/s Ethernet connection.


I could use the following


schematic


simulate this circuit – Schematic created using CircuitLab


but I would like to achieve the same without the magnetics, in order to save on cost, purchasing headaches, and if at all possible power consumption.


I can imagine an RC network, perhaps as simple as in this appnote, found thanks to a similar question; or maybe engineered with attenuation and lowpass, but that will not emulate the fact that with real magnetics, when there is a negative pulse on TX1P, there is a positive pulse on TX1M and RX2M. I am uncertain about if that would prevent some PHYs from working normally.


Anything to suggest that one is confident will work for practically any PHY around?




Answer



You might be interested by these Application Notes about transformerless/magnetic-less ethernet application



They both have an example of transformerless operation on a PCB, with a capacitor in place of a transformer. In a case where you control both side of the connector, only one capacitor on the line can be mounted. But if you control only one side you have to put a capacitor two, in case the other side has nothing or has a transformer.


I had to work on a 1000Base-KX backplane connection, and its problem is this standard is not very well known and you can have difficulties to implement it, have information about it, etc.


In my case I needed to have an oscilloscope pattern to observe the signal. After few email to the oscilloscope company and few phone calls I had them understood that I was talking about 1000Base-KX and not 1000Base-CX (Ethernet over Coax).


The 1000Base-KX was "retro-implemented" in the IEEE802.3 when the 10GBase-KX was created. So the 1000Base-KX is a standard derived from 10G and officially become a IEEE standard years after the adoption of the Gigabit standards.


Also 1000Base-KX only need 2 pairs (Full-Duplex) but the operating frequency is around 1Ghz which involves signal integrity issues where 1000Base-T and 100Base-T(X) stays at 125MHz.


pullup - Distance problems with I2C connection for multiple devices


I'm considering using the I2C bus protocol to connect up to 100 devices (worst case scenario) to a motherboard to avoid using serial-port connection with each one.


The problems I face are:




  • I need them to be at a distance as far as 3-5 m

  • The maximum voltage should be 5V


I've tried to find an answer to the problem and I've come across a couple of solutions such as setting pull-up resistors to counter the increase in capacitance, but I've found mixed opinions and articles and I can't reach a solution.


Do you think this is viable? What other options do I have?



Answer



IIC is fairly high impedance due to being passively pulled up and that the pulldown current must be rather small. The pullups are usually a few kΩ minimum, which is the impedance of the lines when idle. This is usually fine on a single board above a consistent ground plane, but extending such lines 5 meters is asking for trouble. If you really have to do this, make the data rate low and encapsulate every packet with a checksum.


Ultimately you end up trading data rate with reliability. You can probably get away with 100 kBit/s or so (just guessing). That would give the lines 5 µs to settle after each edge before they should be looked at.


A probably better option would be to use CAN. 100 devices is getting near the limit but is still within spec. The common MCP2551 is specified to support 112 devices, for example. CAN is a differential bus with 120 Ω pull-together resistors at each end. The differential nature and much lower impedance (60 Ω) make is suitable for going off board. It was initially designed for use in cars, which are notorious for being electrically noisy.


5 meters is short for CAN. If you use the right twisted pair, daisy chain topology, and properly terminate the bus at each end, you should be able to do 1 MBit/s without problems.



Another advantage of CAN is that silicon to implement the low levels of the protocol is built into many microcontrollers. The lowest level firmware sends and receives whole packets. The hardware takes care of encoding the data onto the wire, collision detection with backoff and retry, and checksum generation and validation.


7segmentdisplay - Why do 7 segment LED displays break apart when I brush my teeth?


This question might sound silly, but it is very serious (although geeky, I must admit). When I use my electric toothbrush in front of my alarm clock (one of those with a big red LED display), the numbers seem to break apart. Why?



With my current alarm clock the first 3 segments (a,b,c) make one group and the other 4 make another one. The striking thing is that both groups seem to slowly oscillate, in anti-phase. I cannot affirm that the grouping is the same for every display of the kind -- and I cannot check now because I only have this one LED display at home -- but I've seen this illusion on many different displays in the past.


I think this illusion is fascinating (told you I'm a geek) and I would like to understand why it is...


I believe that it has something to do with 1) the vibrations of the toothbrush making my eyes oscillate in their orbits so the image seems to move (a bit like when you touch your eye on the side with your finger and the whole image seems to move), 2) with the periodic refresh of the segments. I suspect that the two groups I'm seeing actually correspond to two groups of bars blinking in sync, so there really are two groups, (but why do they dislocate like that?) 3) with our periodic perceptual "refresh rate". Something similar to what makes us see car wheels as stationary when they rotate at a certain speed.


I must say my competence in electronics is close to zero, so my questions might be trivial to you guys. How does the refresh of the line segments in a 7 segments display happen? Is it cycling (a,b,c,d,e,f,g,a,b,c...)? How come I see two groups, then? At what frequency are the LEDs blinking? I understand some of these questions depend on the specifications of my alarm clock, but since I've seen this illusion on basically every type of LED display I passed by with my toothbrush (microwave, VHS video recorder (yes the story started long ago. I bought the toothbrush I'm now using just for understanding this silly illusion, but it was actually as a teenager that I noticed it)...), I guess there is something constant there...



Answer



Yes, it sounds like you are seeing artifacts of toothbrush frequency vibrating your head and therefore your eyes, and that beating against the LED refresh frequency.


This is a similar effect to eating potato chips (actually anything crunchy) while watching the LED display. In that case the head vibrations are more random, so parts of the LED display will appear to jump around randomly. Some segments will be displayed during a head-high part of a vibration, and others during head-low. These will appear in different locations.


LEDs are refreshed all kinds of ways. A lot has to do with how clever or competent the engineer was that wrote the firmware. I've seen naive refresh algorithms that simply do each digit in order. Those have the most apparent flicker for any one refresh rate. Better means interleave digits, sortof like interlacing of old TV scans lines. The whole display is still refreshed at the same rate, but the apparent flicker is at least in part related to the interlace rate. There are fancy schemes which interleave both digits and segments, but these are often not possible with common displays where whole digits are already partially wired together.


What are the behaviors of capacitors and inductors at time t=0?


Do capacitors act as an open circuits or closed circuits at time t=0? Why? What about inductors?


I tried it out, and what I got was this: Initially when I opened the switch, the capacitor acted like a short circuit. That should not be happening, right? A capacitor should block DC. I tried with a couple different caps. I am very confused.





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

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