Sunday 31 May 2015

ground - Should a soldering iron have a grounded plug?


I'm talking about the plug--not the tip so it's not a duplicate question.


I'm interested in buying the folowing soldering iron (https://www.amazon.de/VicTsing-einstellbarer-Temperatur-Entlötpumpe-verschieden/dp/B01HTIY61E/), however I noticed it's using a Europlug without ground (only 2 pins). Would that be fine or dangerous?


Thanks for the info!



Answer




This might not be dangerous to you, but it might be dangerous for static-sensitive components you will try to solder. Although the AC is isolated from soldering tip, it is not a good practice to leave the iron tip floating. Upon handling and cord movement, the tip might accumulate electric charge, and then will discharge into ESD-sensitive component during solder touch. Normal (even cordless, like Weller WSMC1) irons do have a special provisions for a lead to have the iron grounded. The iron you are considering is not listed as "ESD safe".


power - How to carry high current on PCB


I need to pass high current on some part of my circuit. I used an online PCB track width calculator to see that required track width is about 5mm and minimum clearance is 1mm, which makes it about 7mm width at total just for one track. I need several of these high current carrying tracks on my PCB which will consume too much space to afford.


I am thinking of soldering copper wires on the top side of the PCB which will be parallel to the thin and symbolical tracks on the bottom side. But I would like to know if there is a more professional way of overcoming this problem.



Answer



High-current PCB bus bars are available from several suppliers, such as:


http://www.espbus.com


and are an ideal solution. A quick search for "PCB bus bars" will yield a number of suppliers.


documentation - What should a contract Electrical Engineer deliver once a project is complete?


I'm getting ready to hire an electrical engineer for a small contract job - creating a prototype. What I'd like to know is, what should I have him deliver to me when the project is complete?


I imagine schematics, the prototype, parts list would be standard, but what am I missing? Should I ask for an auto-cad file - not sure what this is yet... Are there other things that I would need in the future for a different engineer to take over the project?


Simply, what should I be asking for?





Saturday 30 May 2015

Cat 5 cable 100MHz bandwidth meaning



Category 5 cable on Wikipedia:



The bandwidth of category 5 and 5e is the same (100 MHz) and the physical cable construction is the same, and the reality is that most Cat 5 cables meet Cat 5e specifications, though it is not tested or certified as such.



So what does cable bandwidth mean? is it correct to say that cat 5 cable frequency response is almost flat in a region with 100Mhz width and 3-dB attenuation? Something like this with B=100Mhz:


                         Cable frequency response


If correct, what is f0 frequency for cat 5 cable?


And how the cat5 max speed, i.e. 100Mbps, is related to 100MHz bandwidth?


If we want to send digital signal with some simple line code such as NRZ, what will be the duration of a bit (bit time) in milliseconds?



Answer




Basically the quote you have shown was written by someone who either didn't understand what they were talking about, or oversimplified it.


The bandwidth of the cable is a result of the resistance of the cable and the fact that it is capacitive. These act like an R-C low pass filter limiting the bandwidth. Additionally the distributed inductance and capacitance of the cable are frequency dependent so have a more complex affect on the bandwidth.


The "insertion loss" which is a measure of the gain of the cable is dependant on both frequency, but also on length. The longer the cable, the more lossy it is.


Here is one example of the insertion loss of a CAT5e cable, this for a 100m length:


Insertion Loss vs Frequency
Image Source


Here we see that at 100MHz, the loss is actually more than 20dB - a lot more than the 3dB (power gain) or 6dB (voltage gain) point that would be used to specify the bandwidth of a first order low-pass filter as the quote implies.


Further up the Wikipedia page more accurately explains where the 100MHz figure comes from:



The specification for category 5 cable was defined in ANSI/TIA/EIA-568-A, with clarification in TSB-95. These documents specify performance characteristics and test requirements for frequencies up to 100 MHz




Basically, the requirements in terms of insertion loss that must be met for a cable to be classified as Cat5 are only specified up to 100MHz. Beyond this point the specifications of the cable are undefined by the standard - though manufacturers may well provide data at the higher frequencies.




In terms of how the Ethernet speed relates to frequency, that is a touch more complex. The raw data is encoded using various schemes which are described in brief in the wiki page here. For 100BASE-TX, several encoding schemes are used which result in a maximum fundamental frequency of 31.25MHz through the cable itself.


How is it possible a dead old Lithium battery becomes charged after opened?


I opened a lithuim battery salvaged from my old laptop battery pack. I checked million times that it is 0V and it was by the time i was opening it. For some reason i would love to know, it is now MAGICALLY charged up to 3.99V and that scared me so i left it aside keeping it cool. It has no protection circuit. So is oxygen reacting with Lithium metal and creating such voltage? Or is it really charged?enter image description here


Update:


I'm charging the battery that was spot welded in parallel to the battery #1. Just for tests and observing its temp. The battery #2 also holds 0V (which also assures that bettery #1 was definitely 0V) so if it stays like that I'll open it and see if it suddenly charges as well up to 4V and what is the reason. Also I sealed up bat#1 Here's bat#2: battery #2


I did a 100R load on the battery #1 and here's the data:


-T=0                        3.96V



-T=10 min              3.91V


-T=20 min              3.91V


-T=30 min              3.90V


-T=1 hr                    3.87V


-T=1 hr 30 min       3.86V


-T=2 hr                    3.84V


-T=4 hr                    3.78V


-T=6 hr 30 min       3.72V


-T=9 hr                    3.67V


-T=11 hr 30 min    3.61V



It took a long time so i stopped at 3.6V enter image description here


Graphed by T. Stewart using data above Using Ic=CdV/dt \$C=V/R*dt/dV~\$ with units \$~= [F]=[V/Ω*[s/V]]\$ for R=at 10k load 11h


Next test 100 Ohm load to 3.0V (faster test) taking two measurements; with load and without. This will measure C2 and ESR. Voltage readings were unstable at first ( double layer effect) but averaging 20 F rising to 40 Farads.


Note that a fresh 18650 cell ranges from 5000 Farads to 10kF so this dead battery will have much higher ESR and C1 <1% of it's initial capacity (unknown).


However it still useful for Volatile Memory backup.
Momentary short circuit current will also measure ESR.



Answer



There is a protection current interrupt device under the positive terminal. Inside, the battery is still charged. See the structure in this article.


Interfacing Raspberry PI to HoneyWell alarm system (3V vs 12V)


schematic


simulate this circuit – Schematic created using CircuitLab


I've been working on a similar project as this but with a HoneyWell alarm system. I've managed to lower the voltage from the 12V or so down to 3v (approx) using a resistor bridge. I now have the leads from the bridge plugged into the GPIO pins on the raspberry pi. I'm reading the pin input via Pi4J and it seems to give me a HIGH and LOW respectively for the 2 pins. This value does not change even if there is an event that occurs in the alarm panel(opening doors etc). Can anyone tell me how to read the data and clk inputs correctly?


Notes:In the circuit diagram below the voltage source is pretty much the data and the clock lines coming out from the Alarm Panel. I'm feeding the GPIO pin of the pi with a jumper wire to the end of the R1 resistor. I had to use a bunch of 1k and another 300Ohm resistor because I didn't have a 3300K resistor in my small kit. The clock and data lines are both being downgraded to a 3v input line by passing through this circuit (2 circuits on a bread board). The model of the Alarm panel is a Honeywell Vista 20p. Circuit Diagram of the panel attached below.I'm feeding the pi with the wires attached to PIN 6 and 7 as shown in the circuit.


[HoneyWell Alarm panel circuit diagram]


The following image is of the wires connected to the breadboard.The breadboard is then connected to the pi via a cable ( not sure what the cable is called). cables from alarm panel connected to a breadboard




transistors - Why is saturation region called so in BJT characteristics?


enter image description hereI understand base-collector (current) linear relationship is lost in saturation region and collector current will be lesser than \$ \beta * Ib \$ . Hence,at max, we can call such a region as non-linear region.



Saturation literally means something remaining constant and not increasing further (upon variation of another quantity). Which quantity is getting saturated in so called 'saturation region' of BJT ?



Answer



The NPN transistor consists of two diodes the B-E diode and the B-C diode.


Assuming a B-E voltage of 0.7V the B-E diode is forward biased and electrons are injected from the emitter into the base region.


For a collector voltage of, say, 1V the B-C diode is reverse biased, a field exists in the depletion zone that pulls the electrons into the collector. If the voltage at the collector terminal is reduced fewer carriers are removed from the base and for some voltage the collector is unable to remove all the carriers from the base region. The base region is saturated with carriers.


The transistor is said to be saturated.


oscilloscope - Peak to Peak vs. Amplitude


For a sine wave,




  • Amplitude is the fluctuation or displacement of the wave from its mean value.




  • Peak-to-peak (pk-pk) is the difference between the maximum positive and the maximum negative amplitudes of the wave.





Then why oscilloscopes display almost the same measurement values for both Amplitude and Peak to peak of a sine wave?


Here is my test screenshot on Agilent InfiniiVision MSO-X 3014A oscilloscope:


Pk-Pk and Amp measurements screenshot


Here is the oscilloscope manufacturer's definitions for the measurements "Peak to Peak" and "Amplitude" in their user manual:



Voltage measurement points according to the manufacturer Peak-Peak


The peak- to- peak value is the difference between Maximum and Minimum values. The Y cursors show the values being measured.


Maximum


Maximum is the highest value in the waveform display. The Y cursor shows the value being measured.



Minimum


Minimum is the lowest value in the waveform display. The Y cursor shows the value being measured.


Amplitude


The Amplitude of a waveform is the difference between its Top and Base values. The Y cursors show the values being measured.


Top


The Top of a waveform is the mode (most common value) of the upper part of the waveform, or if the mode is not well defined, the top is the same as Maximum. The Y cursor shows the value being measured.


Base


The Base of a waveform is the mode (most common value) of the lower part of the waveform, or if the mode is not well defined, the base is the same as Minimum. The Y cursor shows the value being measured.


(Content from the user manual © Agilent Technologies, Inc. 2005-2013)




I know oscilloscopes are not all about symmetric signals. But I can't understand the following.


What are the two separate different quantities that the manufacturer intended to measure from these two measurements?


What are the applications of measuring those two quantities? Please explain.



Answer



I think that the historical definition of amplitude comes from nature. When Earth was young, most things that were wavey tended to oscillate sinusoidally about a middle point. Think sea waves or a tree swaying in the wind.


When man emerged he invented violins and tuning forks and they too oscillated symmetrically about a mean point. They called it a sine wave. So the scale of the oscillation became to be known as the distance from the mean point to the extreme, ie. amplitude. This is what's taught in schools. (They also teach kids that the 741 is a good example of an op amp, but that's a story for another time).


But then electrical engineers evolved and everything got complicated. They built amplifiers to make the violins sound louder and they used oscilloscopes to look at the wave forms. This is what you're taking about with a perfect sine wave.


Sometimes bad engineers built bad amplifiers that distorted the output, so a perfectly symmetrical sine wave might end up looking like:-


bad sine wave


It's no longer symmetrical, and by that definition there are two distances from the mean to the extreme points of the wave. You can no longer use a single amplitude value as which one would be appropriate? So to measure this bad sine with a single value, you can only use the peak to peak distance.



Then the engineers got even cleverer and developed wave forms like:-


noise


which is quite asymmetric abut 0V, and again unable to be described with a distance from 0V as there are two distances. Or like:-


comparator


Here you'll notice there is a DC offset. The entire wave form is above 0V. Even the mean point or an RMS point is difficult to determine. This one's more complicated, as a modern oscilloscope will automatically subtract the DC offset (even if DC coupled) in the amplitude measurement. So the amplitude will be the peak to peak of the top of the wave to the underside, but excluding 0V.


Those pesky electrical engineers further complicated things with wave forms like:-


ringing


This shows ringing at the transitions of a square wave. A good oscilloscope will be able to identify the additional wave form riding atop the square one. So now you'll have an amplitude reading that is from the top to the bottom of the square wave, and a peak to peak reading that includes the extremes of the ringing. I'm not entirely certain (and expect others to weigh in here) as to how the oscilloscope identifies ringing from the predominant wave form. It's probably some form of percentage like the 5% rise time thing.


Confused? Me too and you'll find that some of these measurements are used interchangeably. The same mess occurs with the 10x and 20x thing in decibel calculations that can be very confusing. Some of it ultimately comes down to experience and being one of the few good engineers. Be an painter, it's simpler.


PS. I have no experience of such, but it would be interesting if someone added what happens in the case of an old analogue & semi digital 'scope like a TAS 465.



Power LED from headphone jack


I'd like to hook up an LED to a cell phone's headphone jack. When there's audio, turn on LED, when there isn't, turn it off. Is the best way to go about this just using a npn transistor? Any links to a complete circuit? I know I probably will have to supply external power using 5v.




Friday 29 May 2015

arm - STM32 Interrupt Priority (preemption) Problems


I have another problem (High resolution system timer in STM32) which I have tracked down (mostly) to this issue, and have created a test case here for the simplest STM32 processor I could find (on the STM32VLDISCOVERY board).


The problem is that I cannot get a higher priority interrupt to interrupt a lower priority one.


In the example, LED1 is flashed slowly by the SysTick interrupt, LED2 is flashed by the main loop.



Expected outcome


When BTN1 is pressed, the EXTI0 interrupt is called, it flashes LED2 quickly until the higher priority SysTick interrupt is fired, and then it exits. LED1 keeps on flashing as before.


Actual outcome


When BTN1 is pressed, the EXTI0 interrupt is called, it flashes LED2 quickly. The higher priority SysTick interrupt is never fired, LED1 never flashes and the LED2 continues to blink quickly.


Any ideas? Is interrupt preemption something that has to be turned on somehow?


#include "stm32f10x.h"

typedef char bool;
volatile bool toggle;


void delay(void) {
volatile int i = 100000;
while (i-- > 0) {
}
}
void delaySlow(void) {
volatile int i = 1000000;
while (i-- > 0) {
}
}


// Toggle LED1 on SysTick
void SysTick_Handler(void) {
if (toggle = !toggle)
GPIO_SetBits(GPIOC, GPIO_Pin_8);
else
GPIO_ResetBits(GPIOC, GPIO_Pin_8);
}

// On EXTI IRQ, flash LED2 quickly, and wait for a SysTick

void EXTI0_IRQHandler(void) {
bool lastToggle = toggle;
GPIO_SetBits(GPIOC, GPIO_Pin_9);
while (lastToggle==toggle) { // wait for systick
// Flash LED2 quickly
GPIO_SetBits(GPIOC, GPIO_Pin_9);
delay();
GPIO_ResetBits(GPIOC, GPIO_Pin_9);
delay();
}

GPIO_ResetBits(GPIOC, GPIO_Pin_9);

EXTI_ClearITPendingBit(EXTI_Line0);
}


int main(void){
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;


RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE, ENABLE);
// set preemption
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_Init(GPIOE, &GPIO_InitStructure);
// button
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// leds
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
// systick
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
SysTick_Config(0xFFFFFF); // 24 bit
NVIC_InitStructure.NVIC_IRQChannel = SysTick_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; // Highest priority
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

// exti 0
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; // Lowest priority
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_Init(&NVIC_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
EXTI_InitTypeDef s;
EXTI_StructInit(&s);
s.EXTI_Line = EXTI_Line0;

s.EXTI_Mode = EXTI_Mode_Interrupt;
s.EXTI_Trigger = EXTI_Trigger_Rising;
s.EXTI_LineCmd = ENABLE;
EXTI_Init(&s);

while (1)
{
// Flash LED2 slowly
GPIO_SetBits(GPIOC, GPIO_Pin_9);
delaySlow();

GPIO_ResetBits(GPIOC, GPIO_Pin_9);
delaySlow();
}
}

Answer



I just found the answer from a very helpful poster on the STM32 forum


The following isn't correct. SysTick is a 'System Handler', and as such the priority isn't set in this way at all:


  NVIC_InitStructure.NVIC_IRQChannel = SysTick_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; // Highest priority
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

It's actually set with:


  NVIC_SetPriority(SysTick_IRQn, 0);

Calling that code instead solves the problem!


schematics - Newbie: resistor and capacitor symbols meaning


I found a project I'm interested in on the Internet ( http://linnix.com/udip/ ). However, I'm a total beginner to electronics, and I'm not sure about the values of the elements as described in the schematics (see below):



  1. Does a "R220" resistor here mean 22 ohms, or 0.22 ohms? [edit: solved, 22 ohm +/- 5%, see below]

  2. Does a "C180" capacitor mean 18pF? In some articles I read that a capacitor symbol contains a letter after the number, meaning tolerance of the capacitor. Here, I don't see such a letter — is it important? Or does the "C" letter mean it here (+/- 0.25pF)? [edit: solved, 18pF, "+/-10% should be fine", see below]

  3. Similarly, "C105" = 1µF? (and what about the tolerance?) [edit: solved, 1µF +/- 10%, see below]

  4. I believe I can assume the board is powered by the UVCC line (from USB), so VCC doesn't need power, only the capacitor to GND? [edit: partially solved, "yes"; but what about GND vs. UVSS?]



I'd be very grateful for help!


UDIP project schematics


Edit: Wrote some answers above, based on answer by @markrages, and on some more info from atmega32u2's reference (20.3.3 Design guidelines).


Edit 2: Moved questions 5, 7 into: "how to ground?" and "which variant of bus-powered?". Also, deleted question 6, I hope I'll be able to solve it myself later.



Answer



First of all, this is a nonstandard and unhelpful way of calling out component values. Don't do this on schematics you draw! (In normal practice, "R220" means "resistor number 220" and the value is shown separately.)


But somebody with experience might be able to figure it what's going on. Let's see how I do...


C180 must mean 18 pF. Those are crystal load capacitors, which are commonly in the 10 pF - 20 pF range.


C105 means 1 uF. These are bypass capacitors and 1 uF is a common value and the datasheet-recommended value.



R220 probably means 22 ohms, from the example circuits in the 32u2 datasheet.


I found this drawing in the datasheet:


enter image description here


Also notice the supply connections. The micro has its own internal regulator, so the Vcc doesn't need to be connected to anything else (except its bypass capacitor.)


None of the components are super critical. 10% tolerance should be fine.


Once again, don't use this as example of how to draw schematics.


(edited to revise 0.1uF guess to 1 uF.)


circuit analysis - Current and voltage sources?


schematic


simulate this circuit – Schematic created using CircuitLab


From what I understand, the magnitude and direction from an independent current source is constant. What would happen in the circuit above? If currents flow they way they're supposed to from the current source, KCL is violated. So how would the circuit above behave?


How about this one?


schematic


simulate this circuit




Answer



In circuit 1 you get infinite voltages and in circuit 2 you get zero current.


EDIT due to wrong circuit posted in question - circuit 2 takes 45mA and I'm not inclined to feed the reasons on a plate to the OP because this sort of stuff should be reasoned through.


How is xΩ impedance cable defined?



This is probably a really simple question, but I can't seem to find a definite answer anywhere. I'm guessing 50Ω cable means 50Ω per unit length.


What unit length is this? If this is not how its defined, how is it?




Thursday 28 May 2015

led - POV globe speed questions


I am planning on creating a RGB LED POV globe only physically larger then that one.



I am planning on using 64 RGB LEDs, requiring 3x pins per LED for a total of 192 outputs. Obviously I am going to need some shift registers. I have looked in to 74HC595 (8bit) and it would require 24 of these chips to handle all of these LEDs.


I am planning on putting these shift registers in series with 6 per channel from my micro-controller.


The 74HC595 has a switching frequency of 100 MHz.


I been told that I will need to spin the Globe at around 1500 RPM (25 per sec)


The plan is to use a Arduino for the micro controller but I am open to suggestions.


My questions are:



  • Is there a better suited chip then the 74HC595 for this project?

  • Besides the Arduino is there a better suited micro controller for this project?

  • I don't want to power the LEDs off of the micro-controller So I am going to need external power. How would I go about doing this?


  • With 6x 74HC595 in series, How fast could I switch all of the LEDs colors on this channel?

  • With 12x 74HC595 in series, How fast could I switch all of the LEDs colors on this channel?



Answer



1. A bunch of 74HC595 chips will work great. Other chips that would also work just as well and perhaps slightly better are listed at: Which SIPO chip is better, 74HC4094 or 74HC595 or something else?


2. The Arduino is an excellent choice for prototyping, especially if you are comfortable using gcc. Perhaps it would be quicker to use one for now. Alas, I suspect you will soon write code for this POV display that needs more RAM than the Arduino has available -- at that time, either (a) use one or more of tricks to reduce the RAM needed, or (b) add some external RAM, or (c) port the code to some other microcontroller with more RAM (perhaps the ATMEGA1284 ?).


The Parallax Propeller is an excellent choice for a high resolution POV display -- it has an order of magnitude more internal RAM (32 KB RAM) than the ATmega238 in the Arduino. (Is there anything I can do to support porting gcc to the Propeller?)


Some people prefer "square pixels". I'm sure you already know that the distance around the equator of a sphere is twice as long as the distance from pole to pole (Earth's equator is a little more than twice as long). Since you have 64 pixels from the south pole to the north pole, you might choose to reload a new vertical "line" of pixels 2*64 = 128 times per revolution in order to get 128 "square pixels" at the equator. The simplest way to do that is to store the full frame uncompressed in RAM. That requires 64*128 pixels * 3 bits/pixel = 24 576 bits = 3 072 bytes, plus a few bytes of RAM for other program variables. Alas, the Atmel ATmega328 in the Arduino only has 2 048 bytes of RAM.


Earlier POV displays used microcontrollers with an order of magnitude (!) less RAM than this. So people have developed a variety of tricks you can use to work around this. One trick: Only lighting up the "front" half of the globe turing the time you can see the LEDs, then turning off all the LEDs (or leaving them on some constant color) during the "back" half that you can't directly see the LEDs. That halves the amount of RAM you need, so then it fits in the Arduino. If you don't like that trick, there are other tricks you can use that are less obvious. Another trick: Store the image in the flash program memory. The Arduino has enough flash program memory to store several 3 072 byte frames. Yet another trick: use ASCII text to store the text you want to display, then use flash program memory to store the "character generator ROM" data. I'm pretty sure there are other POV tricks ...


3. If I were building it, I would power the Arduino and the 74HC595 chips from one big power supply, and power the motor that spins the POV from a separate power supply.



Only after I got all that working would I even consider a more complicated separated power supply system. (In principle, if you have a separate "red" switching power supply whose +V is only connected to 74HC595 chips which in turn are only connected to red LEDs, you could independently tune its output voltage to minimize the total power and heat production of the system. But it seems unnecessarily complicated.)


4. and 5. Perhaps the simplest way for the Arduino to drive the POV display is to daisy chain all 24 74HC595 chips in one long single string, and then use the Arduino SPI library. That requires 192 clock pulses to clock in the new column of data, and then a pulse on the RCLK (aka framing pulse, SS, etc.) to start displaying that new data. According to one Arduino to SPI interface tutorial, the fastest SPI clock rate is system speed / 4. So the 16 MHz Arduino can put out a SPI CLK of 4 MHz. If you upgrade it with a 20 MHz crystal, you can get a SPI CLK of 5 MHz. If you can get your program fast enough to keep up with the SPI hardware, you can put out a new column, at best, in 5 MHz / 193 pulses, so the maximum theoretically possible speed is 25 907 columns/second.


At the standard cartoon film refresh rate of 24 frames/second (which flickers noticeably -- you would like something better), and at 128 columns/frame to get "square" pixels at the equator (you might want more to get better resolution), that gives 24 frames/second * 128 columns/frame = 3072 columns/second.


There's nearly an order of magnitude of breathing room between "the speed you want": 3072 columns/second, and "the speed that is completely impossible on Arduino hardware": 25 908 columns/second. Hopefully that gives you enough room.


Some people think you can get a faster column refresh rate by re-arranging the 74HC595 chips into 2 or more chains and loading all chains in parallel. Some people are like that -- they see unused pins on the Arduino, and they are itching to use them for something. But it may be counter-productive -- the SPI hardware is only connected to one set of pins on the Arduino, and so chains hooked to any other pins must be loading with emulated "bit-banging" software, which will invariably be slower and use more CPU time than the built-in SPI hardware.


Wednesday 27 May 2015

Why is PWM used to control DC motor speed instead of using a variable resistance?


My question is at the end (to change the speed) we are controlling the input voltage of a DC motor in both PWM (pulse width modulation) and variable resistance cases. Is the only reason for choosing PWM to obtain a better precision or not consuming extra power? If it is the only reason it seems odd to use PWM equipment for simple demonstrations.



Answer




Power efficiency The induction of the motor will cause the current to average. At the same time the transistors in PWM mode have very low impedance and therefore a low voltage drop and low power dissipation. In case of a series resistor a lot of power is dissipated in the series resistor.


Speed control behavior With PWM the motor will 'see' a very low power supply impedance, even though the power supply is constantly switching between high and low voltages. The result is that the motor has a much higher torque. With a series resistance the motor will experience a very weak power supply and it will be easy to stall the rotor.


Control circuit For a control electronics (eg. a microcontroller) it is very easy to switch on/off transistors. Outputting an analog voltage or controlling a series resistor requires much more expensive circuitry and in turn will cause more power dissipation.


led - Low loss current sink


I'm working on a battery powered device that has 4 individual LED drivers. The output from the LEDs are controlled with separate PWM signals from a small MCU.


This has to be low cost, and a low cost way to regulate the current through the LEDs is to use current sinks but I have trouble coming up with a good circuit.


Current sinks


Circuit 1 is simple, cheap and robust, and it is independent on the level of the PWM signal as long as it is high enough to turn on the MOSFET. The disadvantage is that the voltage drop over R(set) has to be 0.5-0.7 volts before Q2 starts conducting. The LED with the highest Vf has a forward voltage of 3.6V (max). A constant 0.5-0.7 volt loss is fairly high when using 4 AA cells.


Circuit 2 is potentially more efficient as there is no diode drop. I can use a small R(set), say a voltage drop of 0.1 volts. Since both op amp terminals has to be at the same potential, I'll have to drive the op amp with a 0.1 volt PWM signal and that seems awfully small. A big disadvantage as I see it is that the current is directly related to the input voltage on the non-inverting pin. I'm worried about noise on the PWM signal.


Any ideas for a high efficiency low cost current sink? Either an improvement on the above, or a different approach?


EDIT: To clarify, "efficiency" may not be the right description, the goal is to get more power out of the batteries. A 0.6 volt difference means more power over the life of the batteries.



Answer



What comes to my mind for minimum headroom is a current mirror circuit:



mirror circuit


Caveat: I haven't tried this myself.


This should work for battery voltage down to 3.8 V or a little bit more.


It probably works best with a matched transistor pair. These are available under $0.40 each in small quantities (I found NXP's BCM61B in a quick search), so this is fairly low cost.


The resistor in the emitter on the left is there so that the LED gets some multiple of the current driven in on the right (roughly (2.5 - 0.7)/R ), which will improve the power efficiency of the circuit. I suspect, though, that it will contribute some variability in the LED drive current from location to location, so you'd need to do some experimentation to see if this is a problem.


integrated circuit - Do ICs have a shelf life?


I understand that many components, such as electrolytic capacitors (Do electrolytic capacitors have a limited shelf life?), have a limited shelf life if not used. Other components, such as carbon resistors tend to change values over time while sitting on the shelf.


What I would like to know is if ICs also have a limited shelf life and if so, do some types suffer more than others?



Answer



ICs as such dont have a shelf life, like milk or so. They do age on the shelf, though, but generally not as fast as when in use. What happens is you have a rising probability of ICs being dead when unpackaged, or dying earlier when used.


Oxidation, radiation (both natural and man-made), and chemical degradation of the dielectric, and probably several other aspects, degrade the ICs over time.



The effect of these influences largely depends on the manufacturing process and the quality of the IC. A well made IC may be less prone to oxidation, for instance. Older ICs (aka larger structures) have more material to be eaten away. Some ICs have dielectrics than can be more prone to aging. Modern ICs seem to be built with thinner, but more robust dielectrics.


All told, the ageing through technology means more. I do have perfectly working 74ls00 that is over 30 years old in an apparatus that is mostly turned off. Would I use it to build something today? Probably not.


But then again, from a museum perspective, it is quite important to know how to preserve ICs: Dry with a desiccant, in a metal container which is not radioactive seems to be the best bet.


See Aging of Integrated Circuits


bjt - Transistor working with unusual biasing



What would happen to a BJT if both junctions of the transistor are forward biased? Is there any literature on this? By literature I mean characteristics/equations. Any links would help. I have also drawn circuit diagrams to make my point clear.


schematic


simulate this circuit – Schematic created using CircuitLab


Where I was taught in college, we worked on



  1. active region (BE-forward biased, CB-reverse biased)

  2. cutoff region (BE-reverse biased, CB-reverse biased)

  3. saturation region (BE-forward biased, CB-on the verge of a reverse bias)

  4. What happens if CB and BE are both forward biased? Is there any literature or quantitative analysis method for that? What happens if BE is reverse biased and BC is forward biased? Is there any literature or operation zone defined for that.



The reason I want to inquire is because I was recently working on an Op-amp circuit attached to a BJT and there was a case where both the junctions were forward biased and I could not fathom how to analyze it because of basic complexity, in fact I did not even consider the case that both the junctions could be simultaneously forward biased and I only came to that conclusion when I simulated my circuit, hence I want to know how the regions operate so that in future I would not face problems with my circuits.




Tuesday 26 May 2015

parallel - Is paralleling diodes a bad idea?


I'm trying to repair an 800W power supply (see my previous question on this.) One thing that gets me is that the design has two schottky diode packages (in TO-220) in parallel. I was always told this was A Bad Idea, but since they are thermally coupled to the same heatsink, does it present a problem in this instance? I've also noticed the same for the input bridge rectifier, two are used in parallel.



Answer



The issue with putting diodes in parallel is that as they heat up their resistance decreases. As a result, that diode ends up taking on more current then the other diode, resulting it in heating up even more. As you can probably see this cycle will cause thermal run away causing the diode to eventually burn if you give it enough current.


Now the fact that you couple them to the same heatsink will reduce this effect some, but I still would not recommend it. There are far too many unknowns that will effect this to not ever trust it, especially in a commercial product.


Now for the case of this power supply you are looking at, it may very well be that they spent the time to get the diodes matched as closely as possible and allow the heatsink to keep them at about the same temperature.



It may also be that they are running the diodes far under their capacity and they put the second one in parallel so that they aren't always running them near max capacity, but I find this unlikely.


power - Best method to route high current PCB with in a tight space constraint



I was wondering if someone can give me advice in routing this PCB.


enter image description here


The PCB contains several triacs driving AC loads and digital end which contains a micro and several digital I/Os. So far, I have decided on the following:



  • Use 18 AWG wire to connect the LIVE via the spade terminals.

  • Use 5oz copper on the top layer to reduce the track width for the high current tracks for triac output to AC load spade terminal.

  • Solder Y caps underneath the board with insulation and hot melt glue.

  • Use 4 layers

  • First layer contains AC tracks on the mains side and DC signal tracks on the digital side.

  • Second layer contains ground layer on the digital side with some signals.


  • Third layer contains digital VCC layer on the digital side with some signals.

  • Fourth layer contains signals on digital and secondary voltage from the transformer.


I have few constraints in the design like the placements of the headers and AC spade terminals cannot be modified plus the board size cannot be changed. I have placed the heatsink/triacs and spade terminals so I can route the signal tracks to the optocouplers and secondary output of the transformer via the middle of the PCB. I am trying to ensure there is a least 2.5mm separation for the AC tracks.


Do anyone see any issues or problems with this layout or have any suggestions?


Regards Paul



Answer



On 15A/230V you need 2mm track width and 2mm of clearances (5Oz/ft2 Cu and 20*C temperature rise).


Although, IMO, using 0.2mm copper PCB is pretty over engineered. The same results can be reached with more careful trace design.


Is there any Phase difference between the current in primary and secondary coils of a transformer?


Is there any Phase difference between the current in primary and secondary coils of a transformer?


If I draw the diagram of a transformer, and try to find-out the direction of current using Lenz's law; if I keep the coiling-pattern of primary and secondary coils Same (Say both as righthand-screw, or both as Lefthand-screw); I'm getting an 'opposite', i.e. 180-degrees phase-shifted currents in the 2 coils.


is it the case indeed?


However I do-not know, in which-way Lenz's law acts in transformer; because the law states the induced current will try to hinder the cause. but when the secondary circuit of a step-up transformer turned On (closed) , so-far I've know , the current in primary-coil goes-up


Tried finding out the direction of current in transformer coils


P.S.



However, since Amount of Induced-current depends upon CHANGE-rate of magnetic field (Faraday's law), => Amount of current induced in a secondary coil (at a moment), is proportionate with CHANGE RATE of current of the Primary coil;


&


NOT on the CURRENT in primary coil directly (though it apparently seems from the graph). So, same phase-state of primary coil and secondary coil means, in AC, the Graph for Current, and the graph for Change-rate of current, is same. I want to know also, am I right? because, if it was not, then surely a phase difference would found.



Answer



This answer explains that for an unloaded secondary, the natural phase relationship between primary voltage and secondary voltage is is zero degrees.


It therefore follows that if there is a secondary load current (due to a resistive load), the current in the primary due to that secondary resistive load must be 180 degrees out of phase with the secondary load current i.e. as current flows into the primary, current flows out from the secondary.


This of course is for an ideal transformer and a resistive load.


If you ignore the leakages and magnetization inductance of the transformer, and the load is reactive, then there will be a 90 degrees phase shift.


Bringing in leakage inductance and DC coil resistance will/can muddy the waters. Bringing in magnetization inductance muddies the water a bit more.


The low frequency transformer equivalent circuit is this: -



enter image description here


As you should be able to see, if you considered all the leakages, magnetization inductance and losses and then added a semi-reactive load, the phase angle is quite complex to calculate.



However I do-not know, in which-way Lenz's law acts in transformer; because the law states the induced current will try to hinder the cause.



Strictly speaking, it is voltage that is induced and any current that flows is subject to the that voltage, the load and the leakage inductance.



but when the secondary circuit of a step-up transformer turned On (closed) , so-far I've know , the current in primary-coil goes-up



In normal usage, for a voltage transformer it is non-ideal to consider the secondary being short circuited. However, it makes no difference to the phase angle providing you obey the rules inherent to the model.



integrated circuit - FT232R chip and capacitor


The question is basically: why use capacitor in this particular DC circuit? Generally, as I read in the thread below, using a capacitor in DC circuit may have different reasons and purposes. Given my lack on knowledge in the topic I do not know what is the reason for using it here.


What is the role of capacitors in DC circuits like motherboard, graphic card etc?


test


Here I am talking about the 10nF capacitor right after USB GND. Basically it connects USB GND with USB VCC. Given that USB is DC isn't it just a break in the circuit? Or, if we assume that some significant current can actually flow there, wouldn't we be causing s/c?


I understand that that this partial circuit shown at the bottom of the picture is something we could use instead of this 10nF and ferrite bead setup. So my thinking is that all these capacitors are here only for some EMI filtration. Is that correct? If yes, why is it so important to filter it here on the power terminals rather than maybe data terminals? Will it cause problems if we skip it completely? And why we are doing nothing with the data terminals? Thanks.


The picture comes from http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232R.pdf



Answer



The data terminals in USB are high speed differential lines, you don't want to put any capacitance on those lines (it would kill your signal basically). You want to use some ESD protection devices on the data terminals though, to protect the data pins from getting destroyed by static discharge.



The 10nF capacitor on the 5V line together with the ferrite bead will filter out some noise picked up from the cable but also coming from the FTDI chip. So it will improve the EMI performance and will not disturb your USB host.


I don't think the bottom part is optional but mandatory as well. The 4.7µF capacitor will store some energy which will acts as a pool the FT232R can take from without the parasitic inductance and resistance of the wire affecting it much. The 100nF capacitor is just your standard value decoupling capacitor to improve the noise performance of the FT232R.


The 10nF capacitor is not a break in the DC circuit. As you can see the GND node is also on the GND pins on the FT232R, so the current will gro from VCC through the FT232 to the GND node and back to the host.


operational amplifier - Determining amplitude of a 2 MHz sine wave


I'm designing a class E resonant inverter at a switching frequency of approx. 2 MHz. I need to control the inverter so as to maintain a constant current at the load. My strategy would be to put a current sense resistor in series with the load to convert current to voltage, rectify and low-pass filter it, then read the essentially-DC value with an ADC -- I can take it from there.


Just to get a sense of the values involved, my nominal current is 0.17 A RMS, and I have determined that a 1 Ω current sense resistor is about the maximum value I can use. Hence the voltage drop on the current sense resistor is 170 mV RMS. I can tolerate at most 1% error on the amplitude of the sine wave at the output of my circuit. The circuit must work with a single power supply (say 3.3 V); no bipolar supplies.


Obviously this voltage is too low to rectify with a diode directly. My first thought was to use a precision rectifier; the following circuit, taken from a TI application note, might do the job, and it works for a single supply:


Precision rectifier circuit


Yet, certain performance demands are made of the op amps in this circuit, so as to meet my requirements above, that narrow down choices considerably:





  • The GBW product must be significantly higher than 4 MHz (twice the sine wave's 2 MHz frequency since this is a full wave rectifier); otherwise, the signal will be attenuated. I have determined that, if the 3 dB cutoff is one decade above the signal frequency, the amplitude will be attenuated by 0.5%, so a 40 MHz GBW amplifier is the bare minimum I'm looking for.




  • Since the amplitude of the sine wave is 240 mV, if I impose a maximum of 0.1% error due to the op amp's input offset voltage, I need a part with at a maximum of 240 µV offset.




  • Assuming a value of 10 kΩ for \$R_1\$ and \$R_3\$, the circuit should have an input impedance of 5 kΩ. Given the source impedance is 1 Ω, this by itself is not a problem, but op amp bias current is. Again imposing a maximum of 0.1% error due to the input bias current of the op amp, the maximum input bias current must be 240 µV/5 kΩ = 48 nA.




The cheapest (Digi-key qty. 1) op amp from a reputable manufacturer that meets these specs is the OPA2365 at $2.73. This would easily account for more than 10% and closer to 20% of the cost of my inverter, so I keep thinking there must be a better way. If it helps, this can be viewed as a peak detection or AM demodulation problem.



So the question is: can anyone suggest a cheaper circuit capable of measuring the amplitude of a ~240 mV, 2 MHz sine wave?


Edit: this circuit will be employed in a portable device, so power consumption must be kept in check.


Edit 2: As per @SpehroPefhany's answer, I'm trying to design a BJT circuit now. It goes something like this:


schematic


simulate this circuit – Schematic created using CircuitLab


Yes, I know I cheated there by using a 10 V supply -- I have batteries on my system that can provide this voltage if necessary, which is something I forgot to mention above. Also, I've omitted the filtering part of the circuit; that should be easy after rectification takes place correctly. I can add back the diode drop voltage digitally after A/D conversion of the signal, and since it's amplified (I'm shooting for say 4.5 V amplitude now), I can easily tolerate 50 to 100 mV variations on diode voltage drop in manufacturing without violating my revised accuracy target (5% now, again as per @SpehroPefhany's suggestion).


The problem with this circuit is that, with no load (assuming R6 were taken out of the circuit) the DC voltage on the diode's cathode drifts up until rectification no longer takes place. If R6 is sufficiently low, the rectification effect is maintained, but at the cost of unduly loading the circuit, with a corresponding effect on the DC level seen on the load resistor.


This seems to be the most promising avenue of investigation until now. I welcome any suggestions to improve it.




Monday 25 May 2015

design - Does an overvoltage TVS for USB hot-plugging connect to shield ground?


I am designing a keyboard which will connect to the computer via usb-miniB to charge a LiPo battery. The datasheet for the charging IC I am using specifies overvoltage protection on the USB power line, and I have been looking into various TVS diodes. I am finding differing information about where to connect the TVS diodes to:



This FTDI doc provides an example to shield ground, and also advocates and RC filter connecting shield ground and signal ground.


This TI part, which is advertised as for USB, provides an example to signal ground.


I am wondering which is the better practice, and whether that practice changes depending on whether it is a TVS intended for OVP rather than ESD protecton.




inductance - LTSpice: simulate transient voltage and current in RL-circuit


My goal is to calculate transient current and voltage in a following circuit:


enter image description here


Also, immediately after the switch is closed, initial current is 0 and then it exponentially increases until the value reaches the value defined by the steady state. Mesh analysis gives 5mA for the mesh which contains an inductor and 1.75 mA for the other mesh. LTSpice transient analysis confirms these values.


Next step is to define the voltage and the time constant. For the simple circuit (voltage source - resistance - inductance in series) the voltage (immediately after closing the switch) is equal to the source voltage. Since this is the complex circuit, the Thévenin equivalent must be found. Here is the resulting circuit: enter image description here Now the voltage across the inductor immediately after closing the switch is equal to 90 V. Time constant


tau = L/R = 0.36/18k (s).


However, LTSpice shows that the voltage across the inductor is something below 60 V:


enter image description here


What is wrong with my assumptions and calculations?



Answer



You should not use the startup option.
Do measure the voltage source V1 with this "startup" option and plot/see what happens to the voltage of the voltage source.


Use initial conditions instead, like .ic i(L1)=0.


Why is Full-speed USB considered differential and what is its common mode?


I am reading USB 2.0 standard, particularly about High-speed part, and I can't understand why do we consider that HIgh-speed USB uses differential signaling. Or at least why it is balanced? For transmitting logic 0 or 1, USB transmitter drives either one line or another with 17.7mA, and if said differential, I would expect currents with the same intensity but opposite directions. Because of my previous problems to understand this issue, i am not able to understand what is than a common mode on the USB bus in High-speed mode.




transistors - Need a little help with a Chinese tesla coil


enter image description here enter image description here enter image description here I bought a little tesla coil kit that can play music. I soldered it all up, and a friend of mine distracted me at the last second when I was hooking it up...

I blew the original "BD243" transistor up on accident, at this point, by mixing up positive and negative leads while using a laptop power supply (rated at 19v by 3.8Amps).
I replaced it with a tip31ag transistor. It has 30% less gain, and I assumed that it would just throw slightly weaker sparks; it however barely mak3s a spark more than a few millimeters when fully amplified by my sound equipment.
I am just looking for some advice to amplify it more. The schematic says that the primary is 1 wrap, and the secondary is 350. I would like to make it better. Any help would be great. I can take extra pictures if needed.
I have so many extra components. I can make do; if I have to desolder some old stuff lying around, then so be it. Any help is appreciated.




arduino - What's wrong with my simulation for Bi-directional logic level converter?


I am trying to make a simulation by using Multisum 14 for i bi-directional channel for Logic level circuit from SparkFun which use Philips AN97055 IC as a Bi-directional level shifter...


The shcematic for one of it's four channel is shown below


enter image description here


The circuit design in Multisim is shown below


enter image description here



in this design im trying to simulate the situation of using 3.3v sensor with 5v MCU by make the switch on to send the 3.3v from sensor to logic level circuit then the circuit convert 3.3v to 5v and send it to MCU i use Multi meter to read the final Voltage, but as you see the voltage is still 5v either switch in circuit is "ON" or "OFF" why?


Q2/ why use resistor in the design of chanel one and each channel in sparkfun logic level converter what is the purpose of register also when I compare the Bi-Directional logic level converter to the one direciton


So can someone explain the schematic and how to use the bi directional chip and how it's work without forget the purpose of resistor.


Thanks for everyone shearing his knowledge in this site,



Answer



That kind of logic level converter circuit requires an active pull-down on the input when you're intending to feed it a 0 level.
Simply floating the input will not work since (as you can see in the schematic) it has a pull-up resistor to the supply.
To get your simulation to work there are 2 things you can do:



  1. remove the 3.3V source on your input and simply tie the switch from the input to ground


  2. replace the DC voltage source & switch with a square-wave source


Sunday 24 May 2015

audio - What exactly does Watts and dB signify?



Now this is confusing.
At some point i read that higher watts does not neccesarily signify high volume sound. An amp rated at 100w and other rated at 50w dows not mean the former is 2 times louder. Only slightly loud by 3dB which is nothing. To make the latter twice as loud, i should pump the wattage 10x.


Now there is also one thing to consider. SPL.
If i connect a lower SPL speaker to 100w amp and a higher SPL speaker to the 50w amp, the 50w amp will be actually louder than 100w.


Now you tell me, if I am designing an amp, what Wattage amp am i supposed to make. All the time i was looking looking for a 200w ic. After all this literature i went thru, I can also do with a 15w ic and connect a high SPL rating speaker to it. That will suffice?


What does the amp Watt actually tell me?
When am i suppose to use a higher or lower watt amp?
What does it mean to the battery, and speaker?

And ultimately to the listener?


And talking about speakers, i also read somewhere a high end speaker has more impedance than a low end one. Most of the ic datasheet lists for a low impedance ones' - 4ohm. All the while i thought the amp was powerful enuf to drive such speakers? So for high impedance it wont be useful?




comparator - Battery charging and discharging problem


I have designed a battery charging and discharging circuit. The main purpose of this circuit is to charge the battery and then discharge, one operation at a time. I have also added a hysteresis of 3.4V and 4V.


Battery voltage is compared with the set hysteresis voltage and when the battery voltage reaches 4V, the charging is then stopped and then the battery is discharged to load; this is controlled by MOSFEST as a switch. When the battery voltage reaches 3.4V the switch is then turned off and then charge the battery.


It works in the simulation and it also works when I use power supply as a battery. The problem is when I connect the real battery the following things happens,




  1. When the battery is charging and its voltage is around 3.97 the discharging takes place. At this point it is charging as well as discharging, why doesn't it reach it 4V?




  2. Then I checked the output of the comparator which controls the switch, then I noticed that the output of the comparator is going crazy on and off (5V and 0V).





Why is the hysteresis not working and is there any way I can solve this?


this is my schematic enter image description here


this is the new schematic, easier to understand :) enter image description here




VHDL that can damage FPGA


I read somewhere that bad VHDL code can lead to FPGA damage.


Is it even possible to damage a FPGA with VHDL code? What kind of conditions would cause this and what are the worst case scenarios?



Answer



Adding to @Anonymous's answer, there are designs you can build which can damage the fabric of an FPGA.


For starters if you build a very large design consisting of huge quantities of registers (e.g. 70% of the FPGA) all clocked at nearing the FPGAs maximum frequency, it is possible to heat the silicon considerably. Without sufficient cooling this can cause physical damage. We lost a $13k FPGA because it overheated due to the dev-kit having a terrible cooling system.


Another simpler case can be combinational loops. For example if you instantiate three not gates chained together in a ring, and disable or ignore the synthesizers warnings about such a structure, you can form something which is very bad for an FPGA. In this example you'd make a multi-GHz oscillator which could produce a lot of heat in a very small area, probably damaging the ALM and surrounding logic.


amplifier - Should I use a passive or an active filter?


schematic


simulate this circuit – Schematic created using CircuitLab


I need to design an am receiver as a project. On the front end I have three modules; BPF1 the "roofing filter" or the "pre-select filter", BPF2 to further "protect" the demodulator, and an RF amplifier between these two filters. Should my filters be passive or active?


The block diagram above shows what I am designing.





relay - How to have a micro-controller detect doorbell?


I live in an apartment were everyone has an individual doorbell on the front gate. When the button is pressed for my apartment, 21VAC rings a bell in my unit. I would like to have a micro-controller detect when this is happening.


My initial thought was to put a reed switch next to the bell, but it seems the reed switch is too sensitive and would get triggered when my bell was not on. My guess is that this is due to interference on the line from other apartment's doorbells, but I have not been able to verify this.


Now I'm thinking of using an AC relay, but I'm having some trouble finding one that would work with my voltages. I'm also looking into using an optoisolator, but know very little about them and am not sure of the pros/cons vs. a relay.


So my questing is, should I use an AC relay, an optoisolator, or something else? And for whatever solution, which part would be best?


Thanks.



Answer




From what you've said, you'd want the detection circuit to reject false triggers. Let's consider those to be voltages below around 15 Vac, to allow for voltage drops in the line.


The circuit below should do that. It should result in pulses around 1 ms for every AC cycle that the switch is pressed. Your MCU can do more false trigger rejection by only acting on (say) 4 trigger pulses within (say) 25 ms of each other.


Your final circuit values may vary a little but the principle should be sound. R1 reduces the strain on D1 when the door switch is pressed in mid-cycle and it has an uncharged C1 loading it.


EDIT: Added R4 to discharge C1 down below the D1/D2 cut-off of 21-odd volts promptly when a Vac pulse is removed. Discharges C1 from 21 V to flat in something like 30 ms. Made zener voltage visible.


schematic


simulate this circuit – Schematic created using CircuitLab


Saturday 23 May 2015

charging - Ultracapacitor initial voltage drop during discharging


I've been building a test stand for ultracapacitors, with very simple schematic looking like this:


schematic


simulate this circuit – Schematic created using CircuitLab


The resistor on the bottom is to enable the source to push the load through the cap while it's discharged as it's internal resistance is too low for short-circuit-protected source to work. Programmable load is also further connected to a PC that lets me read the current and voltage values during discharge. The ultracap is Maxwell's BCAP3000 2,7V.


I discharged the ultracap with stable 10 Amps and what I've noticed is that there is a voltage drop immediately when discharge starts. My question is what is the cause of that voltage drop? Voltage drops from 2,7 to about 2,45 V. The characteristic of discharge looks like this: 2,7V discharge



Also, should I be concerned about the linearity of the characteristic? I think it is linear because I used the CC method rather than CV where it would drop exponentially.



Answer



Using only the ESR from the datasheet (ideal wires...):


enter image description here enter image description here enter image description here


Current is practically zero before discharging and jumps to 10A, hence the drop. Initial linear discharge is expected due to constant current.


The larger drop you see is certainly due to wires, switches etc.


To be more specific, let's consider 3 steps:



  • charging: capacitor practically reached its max. voltage, current through ESR, from the voltage source, is mainly due to leakage (max 5.2 mA in the datasheet)

  • both switches opened: current through ESR is zero but capacitor is self discharging due to leakage (could be modeled by a 520 Ohm in parallel with the cap)


  • discharging: current through ESR follows the load current


arduino - SPI and pull-up resistors


I have a breakout that comes with two 10kOhm resistors: one on the SDA and one on SCL. The chip takes a max of 3.6V. AFAIK, I2C needs pull-ups on its pins, but could SPI be used on this module? I'm powering it with an Arduino and SCL seems to be around 4.5V - is it too high or is the pull-up going to shift it down?


Thanks



EDIT


The schematic of the breakout is essentially this:


enter image description here



Answer



If you want to use the SPI bus, you need to remove the pull-up resistors.


You need to connect all wire lines like SDI, SDO, SPC and CS to the master device.


The LIS3DH is not 5V tolerant and the maximum voltage is 3.6V. If you put higher voltage, you will damage the chip inputs.


You can put logic level translator between the Arduino card and your LIS3DH card.


batteries - Is fast charging a Lithium-Ion battery from 0% to 30% better or worse for the battery health than fast charging at 30% to 70%?


According to this answer, fast charging is only recommended for the battery from 30% to 70% instead of 0% to 70%, while I thought that the emptier the battery is, the higher of a C rate it can handle.



So, is what he mentions in his answer correct?




Why does the voltage across the DC-link capacitor in a boost PFC circuit usually equals 400 Volt?


In a boost PFC circuit connected to the grid (230Vrms,Europe) the DC-link voltage is usually regulated to 400 Volt. Why is that? Is that because it is efficient to boost it to that particular voltage? If so, why then?


https://www.allaboutcircuits.com/uploads/articles/Williams_power_factor_6.jpg



Answer



As it works as a boost converter, output should be higher than input. For Europe grid voltages, maximum value is 265Vrms. So the output should be higher than 265 × 1.414 = 375Vdc. 400V is well above this and a good rounded number.


One more thing: Generally an isolated DC/DC converter follows PFC pre reg, so a higher voltage will increase the stress on the switching transistors (both PFC pre reg's and DC/DC converter's), and also increase the number of turns of the power transformer.


Friday 22 May 2015

Voltage regulator circuit, efficient, low necessary drop



I want to get a 4v supply from >=5v. (I.e. as little as 1v drop)


The load current will vary by a factor of 10,000. (From 5uA to 50mA).


I need the circuit to be really efficient when there's a small load.


I wanted a darlington pair set up as emitter-follower following a zener diode regulator. The problem being fairly obvious, the 1.4v drop exceeds the 1v I have available, so it's not usable.


Instead, using a single NPN follower following a ZD in isolation would give an hfe of about 500 say, meaning the current taken by the ZD with the supply at 5v would have to be 20 times greater than the load is using in standby, in order for it to be able to supply the load's peak current! And significantly greater when the supply is say 8v, the current taken through the ZD would be 200 times the load's standby current!


Is there a better way?



Answer



A zener diode is absolutely no good for very low power (for the 1N4732A the zener voltage is specified at 53mA), and even LDOs often have ground currents 10 times your 5\$\mu\$A load. You want an LDO with a < 1\$\mu\$A ground current, like Seiko S-812C40. Output voltage is 2.0 to 6.0 V, selectable in 0.1 V steps, so there's also a 4V type. You get 65mA out. Dropout as low as 120mV, and stable even without output cap. The S-812C is available in SOT-23.


edit
I just discovered that there's also a version with a shutdown. That S-812C is even cooler than I thought! :-)



load - Can a solar inverter be damaged if installed capacity is much larger than demand?


I had a dispute with my fellow. In his opinion, a power inverter can be damaged if the load is much lower (e.g 100W) than installed capacity (e.g. 10kW) of the solar system.


I am of the opinion that even in case of zero load, the inverter will not be damaged. Because as far as I know, power is "pulled" from the system and the current is not "pushed" from PV panels to inverter. The lower the load on the power inverter, the lower the load will be on PV panels. Right?



Answer



An inverter can indeed supply a lower current than the solar panel rating without any system damage to the system.


If an inverter is not supplying as much power as the panels can deliver it will simply draw less current from the solar panel. If you follow the IV-curve of the solar panel you will see that lower current from the panel allows the voltage to increase toward the panels open circuit voltage. The solar panel is not damaged by sypplying no current, and providing the inverter can withstand the maximum ("open circuit") voltage the panels produce it will not be damaged.


enter image description here Image taken from this question


The solar panel output voltage varies both with load current an temperature. The colder the panels, the higher is the output voltage. But in a good design the panels should be chosen and connected to the inverter in a way that they can never exceed the maximum voltage rating of the inverter.


eagle - How to add vias and more traces?


enter image description here


I am getting a Drill Size error and overlapping errors because I added a new via and a wire to my PCB. I'm not really sure why I am getting these errors. Is there a way to add a new wire and get it to connect to a wire that was already there without getting an overlap error? Also, do I need to make that via bigger in size? If so, how? I attached a picture that shows the area I need help with.




SPI Seems garbled on MSP430



I'm trying to get sensible bits out of a Bus Pirate hooked up to a Launchpad board (Using the Sparkfun cable: Orange goes to P1.6, Yellow to P1.5. This should be correct, unless I have MOSI and MISO confused...). I don't have CS hooked up, since I'm just using the bus pirate to monitor anything.


The bus pirate is set up for SPI, 125KHz, Clock polarity Idle low, output clock edge Active to idle, input sample phase middle, /CS, output is normal.


On the Launchpad, I have a MSP430G2231 with no external crystal. Using Code Composer Studio, I have the following:


#include  "msp430g2231.h"
volatile unsigned char value=0;

#pragma vector=USI_VECTOR
__interrupt void universal_serial_interface(void)
{
value+=1;

USISRL=value;
USICNT=8;
}
void main(void){
WDTCTL = WDTPW + WDTHOLD;

BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ;
BCSCTL2 &= ~(DIVS_3);


USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIMST + USIOE;
USICTL1 |= USIIE;
USICKCTL = USIDIV_3 + USISSEL_2;
USICTL0 &= ~USISWRST;
USISRL=value;
USICNT = 8;

__bis_SR_register(LPM0_bits+ GIE);
}


Most of this is cobbled together from the various samples. After much reading of the data sheet, it does seem that the USI clock is set to run at 125KHz (SMCLK of 1MHz, divided by 8), although I do not have a scope to measure this.


When running, I get what is essentially garbage out of the bus pirate. P put a breakpoint on the first line of the USI interrupt vector, and had it go through three times, so I should have gotten 0, 1, 2 from the bus pirate


0x00(0x00)0x00(0x00)][0x40(0x00)]

And letting it free run, I just get stuff like this:


[0xFF(0x00)][0x3F(0x00)][0x7F(0x00)][0xBF(0x00)][0xC0(0x00)0x00(0x00)][0x40(0x00)0x80(0x00)]

Which still looks nothing like what I'm expecting.


I've spent most of the evening going through the users guide for the chip, and I'm still stumped.


While writing this, I discovered that I can use the Bus Pirate as a logic analyzer (using LogicSniffer), and set it up to do so. And modified the program to write 0x55 to USISRL, and change the USIDIV to USIDIV_4 to slow things down a bit more, and here's the results: enter image description here



The clock signal looks good, LogicSniffer reports that it's about 285KHz... and MOSI is... special. I would expect a nice alternating pattern, since I'm writing out 0x55, and that's anything but.


Any one have any thoughts on what I might be doing wrong? Defective chip? Something else?


EDIT: Ok, minor amount of idiocy on my part. I didn't change the value that gets written to SPI in the interrupt. Doing this results in the expected pattern:


enter image description here


However, going back to attempting to write out an incrementing byte gets me garbage: enter image description here


So, I still have a problem, just not as big of a one as I thought...


EDIT 2: Thanks to the comments below, I tied the ground wire off the Bus Pirate cable, which was previously unconnected, to the ground off my power supply (Sparkfun's breadboard power supply). Previously, the closest ground they shared was back in the USB hub I'm hanging all this equipment off of.


This removed the glitching on MOSI when running the counter program, and LogicSniffer can now decode the bytes correctly on its own: enter image description here


The bus pirate in monitor mode still reports odd results:


[0x00(0x00)][0x04(0x00)][0x06(0x00)][0x10(0x00)][0x10(0x00)][0x10(0x00)][0x12(0x00)][0x18(0x00)]


It does seem better able to detect the ends of the writes (I'm assuming that's what the square brackets delimit), but the data is decodes is still off. I'm not quite as concerned now that the waveform looks better, but it would still be nice to know why the Bus Pirate is getting confused.




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