Friday, 31 July 2015

accelerometer - AHRS algorithm under continuous linear accelerations


I have tried several algorithms to get pitch, roll and yaw under continuous linear accelerations and vibrations (smaller than 0.4g, frequency lower than 10HZ). None of them give good results because the readings either drift or are affected too much by linear accelerations. What I want to achieve is when external acceleration is smaller than +-0.4g, the error on pitch and roll should be smaller than +-1deg.


I have tried these algorithms:





  1. Madgwick's algorithm. When Beta gain is set very high, the convergence is fast but angles are more susceptible to linear accelerations. I tuned it down and reduced the error under linear accelerations down to +-0.5deg. However, if the vibration is continuous, the readings will drift and it takes forever to converge to true values. It makes sense because under linear accelerations, gyro is trusted more and calculated angles drift as gyro integration drifts.




  2. Mahony's algoritm. On the contrary to Madgwick's, it doesn't drift at all regardless what values I use for Ki and Kp. However, it is always affected by linear accelerations. (Errors bigger than +-6deg)




  3. Traditional Kalman filter. Lots of time has been spent on tuning those huge R and Q vectors. So far it has the same performance as Mahony's.




I am using razor IMU. I know with cheap sensors it's impossible to achieve the same result as this one.



There are couple more options like UKF but it's a pain to understand or implement.


Any suggestion is welcomed.




probe - How do you attach an oscilloscope ground spring?



Sometimes you need to ensure that your oscilloscope probe ground lead is not creating measurement error such as ringing and overshoot. In various forms, I have seen (and successfully used) a ground spring for measuring a circuit. I have shamelessly borrowed AndrejaKo's image to make sure we're all on the same page:


Oscilloscope probe with spring-type ground connector


I have determined that this lead length is essential in some of my test configurations, but it requires constant attention to make sure I'm not shorting something out, loosing a connection, or probing the wrong thing. This limits my ability to do other tasks in the test setup, and makes it impractical for other setups that do not allow that sort of access safely (blind or hazardous conditions).


How do I attach a scope probe to the circuit under test with a 1/2" (1cm) ground lead, or otherwise get a hands-free high bandwidth setup?



Answer



The kind of tip you show is not intended for permanent installation.


If you need to have a scope hooked up to the device under test, with good high frequency performance, the only good solution is to design testing connections into your device.


I like MMCX connectors, because they're very compact, and you can get MMCX->SMA pigtails (and convert that to BNC) for cheap.


enter image description here


You do have to design testing into your project, but it's a good habit to get into anyways. I tend to try to scatter MMCX footprints around my board layouts, so I can get easy probe access to any nets I'm interested in. Plus, they make decent pads for probing with a spring ground clip if you don't want to solder connectors down.



You can also make a homemade alternative, if you have the board-space and patience:


enter image description here


As W5VO points out in the comments, using a test-setup like this for high-speed connections can be somewhat challenging. You would need to either construct a 10:1 probe adapter with a compensation capacitor, and mount it right on the mating MMCX connector, or properly ensure that your connecting cable is 50Ω, and the oscilloscope you're using is set to 50Ω input impedance to prevent reflections and signal distortions.


If you are interested in high-speed logic probing, a simpler solution then dealing with having to terminate the signal run to your scope would be to use a homemade inline termination as close to the MMCX connector as possible.


Basically, you can homebrew a 10:1 or 20:1 probe by simply inserting a series termination as close to the connector (the PCB-end connector) as possible. With a 50Ω scope imput impedance, a series resistance of 450Ω results in 10:1 attenuation, while maintaining proper impedance matching to the oscilloscope, and also loading the circuit under test much less.


A 950Ω resistor would result in 20:1 attenuation.


There are several homemade probes using this technique here and here.


For this sort of setup, I would take a male and female PC-mount connector, and solder the resistor in between the two, with some bare wire connecting the ground pins. It should be quite compact and structurally robust.


You can even add a compensation capacitors if you're interested in very high speed signals. There is a good resource about that here.


You then simply insert the series termination inbetween the scope lead and your board under test, and set your scope to the proper attenuation.



batteries - How much nickel is in a NiMh battery?


How much nickel is in a NiMh battery?


For example, how much nickel is needed for a 100Wh NiMh battery?
How much nickel is in a common AAA NiMh battery?


This question is equivalent to:
How much lithium in lithium polymer batteries.
It is also asked in:
chemistry.se




Thursday, 30 July 2015

arduino - How to create a locked door detector?


I'm trying to build a device that alerts me when I leave home without locking the door. I have a little space inside the door (width 8mm x height 130mm x depth 8mm) where I plan to install the microcontroller, a small button that gets pressed when the piece of metal of the door slides in (door locked), a battery and a rf transmitter.


The questions are:





  • push buttons can detect the pushed/unpushed state of the button, or they simply give me a single "one-time" signal when the button is pressed ?




  • do you think the space available is enough for this project ?





Answer



There are two kinds of push buttons. There are some with a lock mechanic (which will remain on the last state until it's pressed again) and there are some without this lock (which will remain open/closed while the button is pressed).


The problem I can see with the push buttons as sensors in this case is because they have limits of activation. Sometime they will wear and lose sensibility or even they will not switch anymore. Datasheets specifies it, usually is about hundreds of thousands or millions times.


I think the space is enough, but it will relies on your skills designing the PCB.



Why do some power adapters output an AC voltage?


Out of most of the electronics I use, I have two, both of them speakers, that use a power adapter that simply steps down the voltage without rectifying it. Why did the designers choose to put the rectification circuitry in the speaker instead of the power adapter?



Answer



One reason is that you usually need positive and negative voltage for audio amplifier. (Like +5, 0, -5 V).


Another reason: Some devices run directly on AC, e.g. Christmas light bulbs can do.


Yet another reason: Some devices need two different voltages, like 5 V and 12 V.


Yet another reason: An external step down transformer provides just safety. Voltages no higher than 50 V are usually accepted as safe (although not very safe with high current). So the transformer makes it safe, the rest is in the device.


pic - Reading frequencies without filters


Is it possible to read a set of frequencies with a PIC in such a way that for each frequency a different function is called?


The idea was to send multiple frequencies at different times (no overlapping or super positioning) over one carrier and reading them on the other end resulting in different outputs. I was hoping to avoid having to implement many band-pass filters to channel each frequency to a different pin allowing the PIC to distinguish between the inputs.


In the end there should be ~1000 different frequencies in the audible range, well distinguishable for a micro controller.


Thanks



Answer



As Brian mentioned, there is something called a FFT (Fast Fourier Transform). It takes a time snippet of signal and returns the amplitude of frequency components in buckets of predetermined frequency and bandwidth. The FFT algorithm is a computationally optimized general Fourier transform that operates on a power of two frequency buckets linearly spread from 0 to the high end of the frequency range it is configured for.


A FFT is computationally expensive, and can only be done on fixed chunks of time domain signal. If you want to get a general frequency content, then it can be appropriate. If you just want to detect the presence of a small number of specific and known frequencies, then it's probably not appropriate. A example of the latter would be DTMF (touch tone) decoding since there are only 8 specific frequencies and you generally want to do the tone decoding continuously, and the frequencies are fairly closely spaced.


To detect the amplitude of a specific frequency in a composite signal, multiply that signal by the sine and cosine of the desired frequency. Low pass filter each of these two product signals separately. The bandwidth of this filter is half the bandwidth the frequency of interest will be detected within. Another way of putting that is that this is the bandwidth of the resulting amplitude output. Now square the two low pass filtered signals and add them together. The result is the square of the amplitude of the signal of interest. You can see where I've simulated this with three adjacent DTMF tones:




The input signal was three adjacent DTMF frequencies for 50ms each with 50ms gaps between. The detection frequency was set up to match the center burst. The blue line is the resulting amplitude squared signal. The low pass filter time constants were adjusted to reject the adjacent frequencies, but still respond well enough within 50 ms (the minimum valid DTMF tone length).


If you need true amplitude, then you'd have to take the square root of the result shown here. For simply detecting the presence of a particular frequency, the magnitude squared is good enough. For other applications the true magnitude may be necessary.


Wednesday, 29 July 2015

Unusual harmonic data reading from phototransistor in a simple arduino setup


I have a very simple circuit for detecting ambient light readings with an arduino, but I'm noticing a sinusoidal pattern to the readings I'm getting that are hard to pin down the source of. How do I eliminate the noise so I get a more or less constant reading?


My circuit is:


schematic


simulate this circuit – Schematic created using CircuitLab


My code is simply:


int analogPin = 0;     


int val = 0;

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

void loop()
{

val = analogRead(analogPin);
Serial.println(val);
delay(33);
}

I graphed the results and it looks like this, oscilating between the values of 175 and 110, on a scale that goes from 0 to 1000 normally:


enter image description here


The period is about 8.5 seconds between crests, with downward blips about once every 1.4 seconds. Nothing in the light around me would explain this obviously... what's going on? How do I get more consistent values?


Solution


I took random samples over the course of the sample period and that seemed to help out a lot.



int analogPin = 0;     // potentiometer wiper (middle terminal) connected to 
analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
int maxwait = 200;
int varwait = 2000;

void setup()
{
Serial.begin(9600); // setup serial

}

void loop()
{
long sum = 0;
int count = 0;
int endTime = millis() + maxwait;
while(millis() < endTime){
sum += analogRead(analogPin);
count++;

delayMicroseconds(rand() % varwait);
}
Serial.println(sum / count);
}

Answer



The reason is probably an aliasing effect of your sampling frequency with the line frequency that powers some fluorescent or LED lights.


E.g. if the sampling frequency is alsmost a multiple of 50 or 60Hz (depending on your electrical power system), but not exactly: if the difference between sampling frequency and multiple of power line frequency is just 1/8.5s = 0.118 Hz you get this sinusoidal response.


See following image taken from Sampling sinusoidal functions: enter image description here


The red sinusoidal line represents the variation of light intensisty by line frequency (50/60Hz).
The blue sinusoidal line represents your output.

The black dots represent your sampling events (it works also if they are even more spread as shown in the image; i.e. e.g. sampling in every n-th period).


Algorithm for charging LI-PO batteries?



What is the algorithm used in charging lipo batteries?


From watching my charger, I see that the amperage is close to the maximum specified (i.e. what I keyed in) at the beginning and gets smaller as each cell nears its maximum charge, but I haven't noticed a direct correlation between the cell voltage and input amperage.


Is there some "standard" algorithm, or does each charger manufacturer implement their own?



Answer



Constant current of x amps (x is usually a fraction or multiple of capacity, e.g. 0.5C, 1C, 2C. Usually never any higher than 5C or cell heating results) until 4.2V ±0.5% is reached. This is called the "CC" stage.


Then a constant voltage of 4.2V ±0.5% is applied until charge current drops below a specific current, usually 0.2C to 0.05C. This is called "CV".


If cell voltage is below 2.8V, a precharge is performed at about 1/10 to 1/20 normal charge current until cell voltage reaches 2.8V; from then on CC takes over. Discharging a li-ion below 2.8V can usually cause a loss of capacity or permanent damage, so avoid doing it. Not all chargers implement pre-charging; some will refuse to charge over-discharged batteries.


This is for newer li-ion cells with 3.7V nominal voltages; for older ones with 3.6V nominal voltage, use 4.1V ±0.5% instead of 4.2V as the CV point.


This is per cell. For multi-cell packs at low charge currents, cells are charged in series. With higher charge currents, they are still charged in series but if they become out of balance, a balancer draws a small current from the appropriate cell to re-balance the pack. Some lower-current charges charge each cell separately, but this increases the cost.


FPGA: Bitstream vs. SRAM Object File


What is the difference between bitstream and SRAM Object File?


I understand that both are outputs of the FPGA design compilation. It seems to me that the SRAM Object File is what is loaded onto the FPGA for programming.


Then, what is the bitstream for? Or are those different names for the very same thing?



Answer



They are different names for what is essentially the same content.


There are three major "types" of FPGA, when dividing up how they implement their logic -- SRAM-based, Flash-based and anti-fuse, with the first being the most common (Altera and Xilinx primarily). SRAM-based FPGAs are 'blank' / un-configured every single time you power them up, and must load their configuration data from somewhere, usually an external memory IC, or an external processor. Colloquially, most engineers refer to the content to be loaded on there as the bitstream -- a binary blob of digital data that represents the connectivity and routing of the logic resources on the FPGA (and in more advanced models, it'll carry along the initial RAM contents, etc.). During development, engineers may use the JIC format (as an Altera example) more often, as they will dynamically load it over JTAG during development via a USB tool like a ByteBlaster. In production, we may use the binary formats to flash onto the SPI configuration device on the PCB.


This bitstream has many, many formats ranging from vendor-specific formats to somewhat standardized formats. If you check out your programming tool's options (Quartus II programmer or IMPACT for example), you'll see such options as JAM, SVF, STAPL, TTF, JIC, BIN, BIT, etc. Some of these are vendor-specific, others are standards (like SVF and STAPL). Formats like SVF are plain-text readable -- the configuration data is recorded as a sequence of macros, and are intended to be delivered over JTAG. Others, like a raw BIN or BIT file, is a binary blob that is intended to be flashed 1:1 onto a flash memory device.



Flash-based FPGAs are similar (ex: Actel IGLOO), but they store their configuration data on the FPGA itself -- the act of programming the array sets the design non-volatiley in the device. This data is also referred to as a bitstream, and for Actel devices at least, show up in SVF, STAPL and (proprietary) PDB forms. These FPGAs are considered 'live at power-up' as there's no need to load a configuration from an external source. Many CPLDs are flash-based as well, to reduce part-count on the BOM and to support their usage as low-power, brainstem like power-sequencing control for a more complex system.


Finally, just to complete the mention of it, anti-fuse devices can only be programmed once by a specialized programming devices actually fusing together links inside the device with high-voltage. They are always live at power-up and have generally high design-security since there's no configuration to be read or snooped -- the device is physically blown into the state it needs to be. I still refer to what I put on these devices as a bitstream, for what it's worth, but they are not re-programmable.


So basically, yes -- they are different names for generally the same content. Some are plain-text, some are binary. Some are intended for a flash storage device, others are intended for JTAG configuration at runtime (like JIC, JTAG Indirect Configuration). All of them can represent the design and state of internal logic elements or memory elements in the device.


Some common types in a non-exhaustive form:



  • SVF -- Serial Vector Format. Plain-text format that is very verbose and contains JTAG macros that walk a dumb programmer through the process.

  • XSVF -- improved version of SVF that allows for control-structures and other enhancments

  • STAPL -- initially Altera, now JESD-71. Allows looping, macros and control structures, reducing file size. Plain-text.

  • JAM -- Evolved / adopted as STAPL, plain-text.

  • JIC -- JTAG Indirect Configuration


  • SOF -- SRAM Object File, a binary file generally from Altera tools for SRAM devices

  • POF -- Program Object File, a binary file generally from Altera tools for flash devices (like their CPLDs)

  • RBF -- Raw Binary File, generally from Altera. analagous to the raw binary outputs from Xilinx or other vendors.

  • TTF -- Tabular Text File, a decimal/plain-text encoded version of the RBF.

  • BIN -- over-used extension that could be from any of a thousand tools, but is used by Xilinx design tools for a raw bitstream with no header

  • BIT -- (Generally) Xilinx design tool output in binary form, with a pre-amble / header

  • PDB -- Actel binary format


For configuring an actual memory device, many of the common formats may be used -- MCS, HEX, SREC (S19), etc. These do not target the FPGA directly.


analog - Questions on interfacing circuit for an NPN input


I have to use this sinewave outputting sensor with the NPN input of this converter. My previous question was related to the same issue but the question was about a totally different circuit design i.e. a single CE amplifier. Even the circuit was working in practice, from many expert comments I was suggested to make an interface with a comparator instead and use voltage protection.


Input is a sensor which outputs sine waves from 200mVpp to 12Vpp between 1Hz upto 100Hz. The circuit below I aim to convert these sinusoidal inputs to pulses and via comparator's open collector I want to pull down NPN input (Y1) of the F2V converter. Output impedance of Y1 is not given so I measured it with different resistors as around 2k (R1 in the circuit).


enter image description here


In simulation I get the following voltage output at Y1:


enter image description here


It seems this works in simulation for the desired input ranges.



Is my way of driving this sensor to the converter correct? Can this circuit be optimized or improved? Are the locations of TVS and diodes correct? I'm just wondering if there is fundamental error before I start soldering.


edit:


![enter image description here


Above is how I'm going to configure the setup. The points A, B, C and D are in question for protection. I was only thinking for the moment MOV or TVS for the point A.


EDIT2:


Corrected comparator circuit: enter image description here


Suggested self powered transistor circuit: enter image description here


I apply this noisy signal as an input to both:


enter image description here


With 100mV hysteresis the comparator circuit inputs:



enter image description here


Comparator circuit final output at Y1:


enter image description here


Transistor circuit's final output at Y1:


enter image description here




arm - CMSIS vs HAL vs Standard Peripherals Library


So I'm switching from PICs to ARM and I bought an STM32F4 discovery board. So far I understand that to program it you can either access all registers directly in memory (obvious way) and also there are 3 main libraries you can use to make your life easier. Now my question is, which one of those 3 (CMSIS, HAL, Std Peripherals Lib) is the most LOW level one? ie. the one with the less overhead. My goal is to learn the controller's inner workings and not make my life easier (only a little), so I would like to know which of these is closer to the core without resorting to use assembly.



Answer



Definitely the CMSIS. It is not exactly a library, it mostly contains definitions for the various registers.


It is exactly what one needs to access the microcontroller's registers easy, so as to implement his/her own HAL. It has no overhead, since you just access the registers.


Keep in mind that CMSIS, unlike the other two, is defined by ARM and not ST. This means that the various CMSIS libraries out there for the various microcontrollers are quite similar, which greatly aids in portability.


Furthermore, CMSIS is the simpler one so it is (IMO) the most versatile, and most reliable, with possibly fewer (or no) bugs. Some hal libraries for the various mcu's that I've used are quite infamous for their bugs.



On the other hand, CMSIS needs quite more work from you. It is however my personal choice, since I prefer to invest my time creating quality libraries, that suit my needs, and understanding how the chip works, that just spending time to learn just a new library.


motor - Need help with a simple solar battery charger


I need some help with a circuit that I'm trying to build for an engineering class. We are making these solar cars to practice soldering, and most people just used solar but I want to make it better. My plan is to add rechargeable batteries to it, so that the solar panel will charge the batteries. I don't know too much about electronics components and circuits, so I need some help.


I currently have




  • 1W, 6V, 167mA solar panel (I also have 2 cheap 1v panels)

  • 1N4001 diodes

  • 5v motor

  • 4 AA 1600mAh NiMh batteries

  • switches


However, I am not limited to these. I have a Radio Shack available to me.


I drew a picture of how I suppose it should look. I got a lot of the info from this article. One concern I have is, will the 6v from the solar panel destroy the batteries? Would capacitors work in place of that? Also, where would the ideal place to put the switch be?


Any help is appreciated, thank you!


Picture of Circuit




Answer



4 x NimH cells i series will work very well here. 2 cells are too low in voltage.
Full charge of a NimH cell needs about 1.45V so 4 x 1.45 = 5.8V.
IF the PV panel is 6V at full power (ie > 6V in full sun unloaded) then it is a good match to 4 x NimH cells.


A switch should be inserted between motor and battery so that the cells can still charge when the motor is not operating.


If you wanted to optionally operate the motor from solar alone you can add a second switch in the vertical wire from battery +ve to disconnect the battery and allow PV to motor direct powering.


If possible use a 1N518x Schottky diode.
Any of eg 1N5187 5188 5189


If not available a 1N400X is OK and VERY available and cheap
(x = any of 1 2 3 4 5 6 7)



The 1N581X will drop about 0.4 V at full current (1A) but drop to 0.2 - 0.3V as battery approaches full charge - and in your application at about 170 mA max the drop will be very low. .


The 1N400x will drop about 0.7V at full current (1A) but maybe 0.4 at full charge so in yout 170 mA max system it will work OK if Vpv = 6V LOADED in full sun.


Smaller capacity AA NimH are more robust and more able to withstand trickle charging. 1600 mAh AA are robust. 1600 mAh AAA are not.


If Eneloop are available they will work well - they keep nearly full charge for long periods.


operational amplifier - transimpedance op-amp wrong and random output




from my previous question (this link) i advised to using operational amplifiers to converting current changes to voltage changes then i followed the standard circuit for a transimpedance operation of amplifier with a piece of TLC272CP which you can see how i wired it :
enter image description here





my aim is measuring IR, so i connected a photodiode to the op-amp, i tried single supply because i cant make bipolar supplies +/-, then i create a virtual ground by simply dividing resistors to get a mid rail voltage between VDD(5v) and GND. then connect output (also divided) to an ADC.


unfortunately resaults from ADC are some random noises and IR does not affect them even a bit!!! they are near to 2.5 volt without output division.


also i disconnected +input of opamp (PIN3) from VGND and connected it to the physical GND but still sense less to IR, just get lower noises.




i think my circuit is just follow standards, so what could be wrong with it.

Answer



A photodiode is meant to be used with a bias voltage. This is typically achieved by using the "virtual short-circuit" of the input pins of the opamp in the TIA.


Like so:


schematic



simulate this circuit – Schematic created using CircuitLab


The best way to improve the output signal strength is to get more light on the photodiode.
You can also try increasing the feedback resistance at the expense of stability. If stability is an issue, you can add a feedback capacitance to make it stable again, unfortunately at the expense of bandwidth.


sensor - Samsung Galaxy S accelerometer details


I'm working on a project on the Samsung Galaxy S smartphone. I need to know some additional information on its accelerometer that I can't find. Accelerometer datasheet



I need to know following details:



  • which type of measurement range they use? +-2g , +-4g or +-8g ?

  • noise depend on the bandpass filter used by the smartphone: how much is the band?

  • there is some way to evaluate from this data sheet the standard deviation of drift process of the sensor?



Answer



All of those details are heavily dependent on the firmware setting up the chip, low level software (Android OS) massaging and delivering the sensor data, and finally the application-level software further massaging and delivering data. At the firmware level, it would be useful to get an SPI/I2C sniffer, like the Bus Pirate or Open Bench Logic Sniffer. I wouldn't be surprised if applications were able to access this level, as well. In other words, the initial or default state may change. It will be very difficult to attach probes, however.


The Android OS is largely open-source. Check it out and see if you can find the relevant blocks of code and libraries. It would at least set the initial state, and likely define an API to change it.


The wrong way to go about this is physical tests while taking measurements with an on-board application. There are at least 3 layers of algorithms fiddling with the sensor data.



You cannot determine drift from the datasheet. It is dependent on temperature, age, and batch/wafer.


Tuesday, 28 July 2015

Designing flyback converter - DZ snubber


In many examples for DZ snubber zener voltage is calculated from maximum MOSFET rating and some arbitrary choosen voltage leakage (usually a percentage of Vin). They don't even use leakage inductance (available in some transformer datasheets).


It seems rather wrong, I would expect it to depend on Lp and Ip somehow. Or maybe, they use something close to maximum FET rating because it indeed provides best performance?




Answer



Using your link and a specific circuit in the data sheet might help: -


enter image description here


The snubber zener is rated at 24 volts and the absolute maximum SW node chip voltage (from the DS) is 65 volts. Hence, with Vin at maximum (36 volts), the voltage that appears on SW is clamped to 36 volts + 24 volts + a bit more for luck + forward voltage of the schottky. I would say this will be no more than 62 volts and is inside the limit of 65 volts imposed by the data sheet.



It seems rather wrong, I would expect it to depend on Lp and Ip somehow.



Designers know that there may be 5% leakage inductance (worst case) and that there will be a back emf that needs to be quenched but knowing what the leakage inductance is is irrelevant to designing the snubber clamp voltage.


Sure there may be a peak current of (say) 1 amp in the primary when it gets open circuited and this (with a leakage inductance of 5% x 9 uH) is an energy storage of 225 nano joules that needs to be burnt by the snubber. It needs to burn it maybe 500,000 times per second and this results in a power dissipation of 112 mW.


So we do need to understand the leakage but only to determine the power of the snubber.



Very low stacking height PCB connector


I need to stack two PCBs together, but the stacking height is extremely critical. In terms of board-to-board connectors, the best I could come up with was SAMTEC GFZ series.



What other solutions can be recommended to stack two different PCBs? I need to have very low stacking height (less than 2 mm, the lower the better), and about 100 connections.



Answer



The SlimStack and/or PMC connectors might be useful alternatives, it depends a bit on the pin pitch that you can use:


http://www.molex.com/molex/products/group?key=board_to_board_connectors&channel=PRODUCTS&langPref=english


I have a card with the PMC connector, and it is really tiny:FOXg20 card with Molex PMC connector


2xAAA battery => 3.3v/250mA step-up converter with logic-driven power control [superseded]


EDIT: The requirements in the question below appear to be practically unsolvable, but happily after a bit of digging I actually found an alternative equivalent RS232 device which runs off a 3.7V Li-Po instead of 3.0V AAAs.
Moral of this story: hold off purchasing for as long as you can - it can prove extremely beneficial :)
I've asked a new question for my new set of requirements.




I need to connect a Wi-Fi/RS232 module to a low-powered monitoring device which needs to periodically fire up, "ping" a server, then shut down again. For maximum portability, I'd like to power the Wi-Fi module via the pair of AAA batteries built into the device itself.


This decision was considered viable based on the fact that the device in question is very low-powered and takes just over a month to drain its batteries under normal use, and the fact that the Wi-Fi module will only power on for a few moments at a time and will generally use relatively small amounts of power. I'm very confident that I'll be able to get at least a few days' worth of battery life with the Wi-Fi module attached, and it won't be a problem to put new rechargeables in the unit every so often.


Now, the Wi-Fi module I've selected draws 3.3v at a peak of 250mA, so I need a step-up converter to run it off two AAAs. However:




  1. The converter needs to fit inside a compartment 50x54mm in size, approximately 4-5mm thick. For what it's worth, this area is insulated, so insulation thankfully doesn't need to be taken into account.

  2. The unnecessity of insulation aside, the step-up converter needs to produce virtually zero EMI/RFI due to the electromagnetically sensitive medical environment the device will be used in, which won't tolerate even low levels of continuous EMI/RFI radiation particularly well (although short Wi-Fi bursts will be fine).

  3. I've never dealt with step-up converters before, and I'm unsure what effects the converter's electrical behavior/characteristics might have on the other electronics (a CPU, etc) in my RS232 device. What might I need to consider in this regard?

  4. The Wi-Fi module draws 8mA when idle, which would kill a pair of AAAs fairly quickly. I can control the serial device's DTR line like a GPIO, so it should be possible to set DTR high or low to electrically switch the step-up converter on or off. I have absolutely no idea how to go about this electronically however, although I can say that the RS232 device uses TTL signal levelling, instead of standard RS232 voltage levels.


I must admit that SMD component-based solutions wouldn't work out for me very well; I have passable non-SMD soldering skills, but I've never worked with SMD components, and if possible I would like to build this device myself, preferably successfully.


If an inexpensive premade power converter module exists that meets the above requirements, that would be a very attractive option.


Alternatively, since the adaptor/converter won't be being moved after it is fitted, directly soldering non-SMD components' legs to each other would also be an acceptable solution.



Answer



After learning how it's virtually impossible to obtain practically zero RFI/EMI from a switching design, I actually did a bit more research and turned up an alternative (equivalent) target device which runs off 3.7v instead of 3.0v, so all I need to do is remove 0.7v now.



I've asked a new question for my new set of requirements.


circuit analysis - Counter with 4 flip flops jk synchronous from 3 to 13!


I have to create a counter with 4 flip flops jk synchronous. The counter shall count in this order: 3 to 13 and then to 3 to 13 and so on..


I have to use logisim simulator.


Ok. So i think its solved. I realized that the circuit needs to start at 0 ou 1 and stabilize after the 13 and then it goes to 3. Thanks for your help. Hope this will help for somebody else too. Thank you all for your help!


enter image description here





Monday, 27 July 2015

operational amplifier - Finding Input Impedance of a Gyrator


I'm attempting to complete the question below.


Question from past test


What I understand so far: The circuit can be modeled with an 'equivalent inductor' and gain stage (not sure if this models the whole circuit or just one of the opamps). Leq is the equivalent inductance.


Equivalent Circuit


My confusion boils down to needing these two questions answered:




  1. Does this equivalent circuit model the whole gyrator or just part of it?





  2. How do I get started with showing that sLeq = R1R2C?




My course has given us no example answers, no similar questions in tutorials, and the lecture notes are not very detailed so I am a bit confused. Any help would be greatly appreciated.



Answer



For ideal opamps (infinite input impedance and infinite gain) the shown circuit has a pure inductive input impedance Zin=sR1*R2*C*(Rg1/Rg2).


Therefore, Leq=(R1*R2*C)(Rg1/Rg2).


The calculation is straight-forward:





  • Step 1: Find the output voltage Vo for the upper opamp;




  • Step 2: Find the output voltage Vo2=f(Vo, Vi) for the lower opamp;




  • Step 3: Combine both expressions (replace Vo by Vi);





  • Step 4: With i2=(Vi-Vo2)/R2 and Vo2=f(Vi) you can solve for Zin=Vi/i2




Comment: The whole circuit mimics an ideal grounded inductor. That`s all. No output voltage (the inductor is a two pole element). Hence, the equivalent circuit diagram consists of the inductor only!


attiny - Does anyone have code to emulate a 16-bit input shift register with an ATtiny2313?


I would like to use an ATtiny2313 to emulate a Super Nintendo controller because I have an ATtiny2313 but I do not have an input shift register and I don't feel like soldering wires onto an existing SNES controller board.


This application requires 12 inputs (bits 13-16 are always 1) and a latch, clock, and data out pin.


Do you have this code lying around? It can't be more than 20 instructions.



Answer



There's already an 8-bit shift register built into the Universal Serial Interface (USI). All you have to do is use it twice in a row.


voltage - Limiting Current interference in Photomultiplier Amplifier Circuit


I've been working on a circuit for a while now. It's a circuit consisting of 4 Silicon Photomultipliers, MicroFJ-60035-TSV, in parallel all going into an op amp circuit. I posted questions about it before regarding separate issues about it, and I learned a bit more about about it by studying how the circuit functions. You can see it in the image below along with one of my simulations. Apologies for the messy part layout.



Schematic and Simulation


In the circuit, I've connected the cathode to ground, and I'm reading the current from the anode. I wanted to get the correct pulse shape as shown in documentation, so I'm following the recommendation of reading from the anode. I am planning to read from the cathode once the circuit is finalized and not in simulation. I'm using voltage sources attached to the photomultiplier parts to control when they 'fire'. The 1 microOhm resistors are just there so that I can read the current coming from the sensors. I figured a low resistance wouldn't affect the circuit much, but ideally, there would be no resistance there.


I'm kind of facing two issues right now. The first issue is with the current coming from the photomultipliers. You can see in the simulation results on the left that when one of the photomultipliers fire, some current also flows back into the other photomultipliers. What can I do about it to remove it or control it so that this doesn't happen?


My next issue is with the feedback circuit. Through reading, I found that the op amp circuit converts the current signal into a voltage signal, and the feedback circuit acts as a low pass filter to hopefully filter out high frequency noise. You can see another test below where three photomultipliers fired at once.


Test Results with three SiPMs firing at once


I've increased the capacitance to try and reduce the noise from the 4 parallel photomultipliers, but I'm having issues with the rise time and clipping. The time where three were firing had a faster rise time compared to the one which fired only once. However, the voltage seems to have clipped, staying the same after a certain point. Is there anything that can be done about it? There always seems to be a trade off between the cutoff frequency and the rise time.


UPDATE: I changed my schematic so that I'm now reading from the cathode instead of the anode. The current from the sensors looks a little messier, but the output is now positive as I was planning. The circuit does not require biasing. It's already done in the model of the part. My team is now looking for better signal-to-noise ratio for the circuit, so what can I do in my circuit in order to improve the SNR?


Updated Schematic, Read from Cathode




hardware - How can I use my SMD Arduino to program a separate DIP ATmega328?


I have an arduino with a surface mounted (SMD) microcontroller:


Arduino SMD edition


I know how to use a DIP arduino as a programmer for a DIP ATmega328. It's easy --you just pop your microcontroller in the holder.


However, with a surface-mount Arduino, there's no obvious. Desoldering the microcontroller is one way, but that's icky and destructive.


Can I use this Arduino as a programmer for a DIP ATmega328 without mortally damaging the board? If so, how?



Answer




Check the Arduino site for instructions to use your Arduino SMD board to program another Arduino board.


Arduino ISP diagram


To extend this to programming a DIP ATmega328, you would translate the 6 wires pictured to the corresponding pins on the DIP module.



  • D13 = PB5, pin 19

  • D12 = PB4, pin 18

  • D11 = PB3, pin 17

  • RESET = RESET, pin 1

  • 5V = AVCC and VCC, pins 20 and 7, respectively

  • GND = AGND and GND, pins 22 and 8, respectively



The Arduino UNO schematic would be helpful for reference for verification.


As pointed out, you would also need to connect a 16MHz crystal with 22pF capacitors on the chip that is being programmed. You would need to connect this to pins 9 and 10 on the chip you are programming as seen here:


Using an Arduino board to burn the bootloader onto an ATmega on a breadboard.


operational amplifier - In an op-amp, why does Vn approach Vp until the difference is delta V / A? Why doesn't Vn just equal Vp?


In an op-amp (non-inverting), like this picture


when \$V_s\$ increases by \$\Delta V\$, \$V_n\$ approaches \$V_p\$ until the difference is \$\Delta V/ A\$ (where A is infinity).


Why is there the \$\Delta V/ A\$ difference and where does this difference come from? Why doesn't \$V_n\$ just equal \$V_p\$ (so that the difference is 0)?




resistors - Measure resistance accurately with an arduino?


I'm looking at performing accurate temperature measurements with a three wire RTD, and I'd like to be able to measure the resistance and thus the temperature using an arduino. The accuracy I'm looking for is better than 0.1Ω @ 100Ω.


I was told that to get good accuracy, I would first need a stable accurate low current source and very accurate low temperature coefficient resistors in a wheatstone bridge.


I was wondering if there was to better utilize the arduino's capabilities to perform this measurement, or is the external current source + wheatstone bridge the way to go?



Answer



enter image description here


Source: application note AN687 by microchip. It shows one of the methods of signal conditioning for 3-wire RTD. Notice that this method doesn't require a Wheatstone bridge.


mains - Where is the ground/negative for overhead power lines?


I recently learnt that ground can be used to complete circuits using high voltages.


I'd like to know if this is how overhead powerlines work, and if so where exactly do the cables/circuit terminate - at substations or something?


For that matter, the negative (black) mains wire in my house, where does that go?


I had a google around but I wasn't really sure what to look for, hence asking here. If someone can point me in the right direction I'd appreciate it!



Thanks!




symbol - Different grounds


What is the meaning of different type of grounds in electronic circuits? Can we use any ground in any circuit or not?


enter image description here



Answer




They represent different ground types.


The first is "circuit ground" and is a reference point in the circuit against which all voltages are measured.


The second is chassis ground and represents a connection to the metal enclosure the circuit is in.


The third represents earth ground and is a physical connection to the ground under your feet.


3 is often used in place of 1 though.


Also you sometimes get various different combinations of the three representing different ground zones in a circuit (digital ground, analog ground, power ground, etc) at the designer's discretion.


adc - Measuring voltage/current digitally on two separate power supply rails


I'm designing a dual-rail DC power supply, with the two rails completely separate (except for sharing a dual-secondary transformer). The main design should work as-is, only by adding a fuse + mains switch, but I want to add a voltmeter and ammeter to each output (and preferably a voltmeter before the voltage regulators, too).
The problem here is that the "meters" will be a microcontroller's ADC inputs (or external ADCs), and the microcontroller only shares ground with ONE of the two rails. I need some way to safely connect the µC to both rails, perhaps opto-isolation or somesuch, while keeping the rails separate.


Don't look too closely at the exact schematic (below), though, as it isn't 100% correct: I couldn't find a dual-secondary transformer in MultiSim; the LM317 package is incorrect and the µC will be AVR-based.
This is just to give the general picture.



Full size image


Now, the problem: I want to measure output voltage and output current for both rails, from the shared microcontroller, which is powered by one of the two rails.
It would also be great to have a voltage probe just before the LM317s as well; that way, I can both monitor the input voltage, and also calculate and display the approximate LM317 heat dissipation.



The voltage measurement would be easy, if it weren't for the floating rails... A voltage divider, perhaps followed by an opamp voltage follower to take care of any impedance troubles, connected to an analog input on the µC.


As for current, I'm not quite sure. An opamp would surely be needed to amplify the tiny voltage across the 68 mOhm shunts (68 µV - 102 mV for 1 mA - 1.5 A), but I'm not sure how to wire it up, since neither side of the shunt is ground. There's also the issue of offset voltage, not to mention the galvanic isolation issue.


Priorities are simplicity and cost, though needless to say some accuracy is also needed. It would be great to have 10 mV / 1 mA resolution, though something like 25 mV / 5 mA might be OK too.


Any advice on how to solve this? I'm unsure about much of it. I've considered external ADCs (shunt -> opamp -> ADC -> optoisolator -> µC), or shunt -> opamp -> optoisolator -> µC, but that doesn't appear to be a good idea since the optoisolator might muck with the analog reading. Frankly, I don't quite know what I'm doing (though I do feel safe about my knowledge about the PSU in itself), but I'm certainly willing to read up a little to learn.


EDIT: related to a previous question "Dual polarity vs dual rail power supply"



Answer



In addition to stevenh's answer, I'd like to suggest 2 more alternatives:



  1. You can have a separate ADC in each of the floating channels. The ADCs would be linked to the PIC through serial bus (such as SPI). The bus goes to the floating channel through digital optocouplers, which are cheaper than analog optocouplers. Once you have an ADC inside the channel, you can make as many measurements as the ADC has got channels without needing additional optocouplers. This approach was already mentioned in kenny's comment.

  2. Each channel could have a dedicated PIC. Each channel with its PIC (and its display, if there are displays) would all float together, and independently of the other channel. You wouldn't need to install a an analog optocoupler for each signal you want to measure. Furthermore, the PICs could talk to each-other through serial link (UART for example). The serial link would go through digital optocouplers.



Sunday, 26 July 2015

dac - Different decoupling capacitors in parallel


Page 29 of this DAC datasheet gives a typical operating circuit. I notice the power supplies have two decoupling capacitors in parallel: 100nF and 10μF.


What caught my eye is that there is a different symbol for each. (One has a curved edge, the other not.) As I understand, one is a "polarised" capacitor, and the other is not.


What is the qualitative difference between the two capacitors? Why are the types mixed in this application?



Answer



These are decoupling capacitors. They are there primarily for two reasons:




  1. Power supplies take time to respond to a demand for more current from the device. The capacitors act as a local reserve until the power supply responds.

  2. Digital logic devices demand current very abruptly (due to the steep logic edges). The inductance of the power supply traces makes it impossible to transfer a step in current from a power supply to the logic chip. To solve the problem, one places "decoupling" capacitors very close to the chip. As the remaining traces are very short, the edge problem is reduced.


The reason for the two different types of capacitors is as follows:



  1. The device apparently requires a 10µF decoupling capacitor. Capacitors of this size are typically electrolytic capacitors. The problem is: they respond quite slowly compared to the edge time.

  2. To solve the problem, one places a (typically) ceramic capacitor in parallel. To simplify the issue: they only exist in fairly small values.


Functioning: The ceramic capacitor (100nF) smoothes the edge time of any current requests from the device and the electrolytic capacitor (10µF) supplies the bulk of the current once it kicks in.


signal - Noise can be Differential or Common!


I have a basic understanding on this topic but i still have some doubts, my text books says Differential means it will have impact on one of the 2 signal nodes. and Common will have a common impact on both nodes. There is no picture to show what nodes it is talking about! (If possible a description with some basic picture would be easy to understand).



Answer



Imagine a perfect noiseless signal transmitted down two wires and you looked at what was received at the other end. Along the way, noise impregnates the two wires. What you might see at the receiving end is a noise voltage that exists between the two wires (differential). You will likely also see a noise voltage that affects both wires exactly the same with respect to ground (common mode).


The differential noise is effectively added to your signal and unfortunately, cannot be got rid of without special techniques. The common mode noise (both wires affected the same) can be eradicated by a decent differential amplifier i.e. it only amplifies the differential signal and is unaffected by common mode signals or noises.


Here's an example of a sudden spike of common mode noise affecting a differentially transmitted signal: -


enter image description here


The same noise signal affects both wires but, because a differential amplifier is used to receive the signal, that noise is cancelled out in the receiver.


However, if that noise affected one wire more than the other it would produce a differential noise and adds to the signal and cannot be eradicated easily. There are things that can be done but, I feel, it's beyond the scope of the question to go into these.



To avoid common-mode noises (the main source in a lot of installations) becoming differential noise, the following safeguards are observed: -



  • Differential signals are transmitted

  • Driving impedances (sending end) are matched

  • Differential amplifiers are used at the receiver

  • Receiving impedances to ground are matched

  • Decent twisted pair is used preferably with a screen


In addition to this, the cable at the receiving end may have a terminator to match impedances and prevent relections.


transistors - Finding current through an LED in an amplifier using a BJT


Suppose you have the schematic:


enter image description here


My job is to find \$I_{LED} \$ knowing that the impedance of the capacitor in negligible against \$V_s\$. Here's my attempt:


I intend to do an AC analysis followed by a DC analysis, and get both components of the current that goes by the LED. enter image description here


Where \$R_A=R_1||R_2\$


For the AC analysis: I did the schematic in the figure and with the following set of equations I get to the final result: $$ i_1=i_2+i_B \\v_s-i_1R_B-i_2R_A=0 \\ v_s-i_1R_B-i_ER_E=0 \\ i_C=\beta i_B \\ i_C\approx i_E \\ \therefore i_C=\frac{\frac{v_s}{R_B}}{\frac{1}{\beta}+R_E\bigg(\frac{1}{R_1}+\frac{1}{R_2}+\frac{1}{R_B}\bigg)}$$


For the DC analysis I use the following set, reaching the result: $$V_cc-I_1R_1-I_2R_2=0 \\ V_cc-I_1R_1-V_{BE}-I_ER_E=0 \\ I_1-I_2=I_B\\ I_B=\frac{I_C}{\beta} \\ I_C \approx I_E \\ \therefore I_C=\frac{\frac{V_{cc}}{R_1}-V_{BE}\bigg(\frac{1}{R_1}+\frac{1}{R_2}\bigg)}{\frac{1}{\beta}+R_E\bigg(\frac{1}{R_1}+\frac{1}{R_2}\bigg)} $$


Finally I get to:


$$ I_{LED}=I_C+i_c=\frac{\frac{V_{cc}}{R_1}-V_{BE}\bigg(\frac{1}{R_1}+\frac{1}{R_2}\bigg)}{\frac{1}{\beta}+R_E\bigg(\frac{1}{R_1}+\frac{1}{R_2}\bigg)}+\frac{\frac{v_s}{R_B}}{\frac{1}{\beta}+R_E\bigg(\frac{1}{R_1}+\frac{1}{R_2}+\frac{1}{R_B}\bigg)} $$



However the correct solution is: $$I_{LED}=\frac{\frac{V_{cc}}{R_1}-V_{BE}\bigg(\frac{1}{R_B}+\frac{1}{R_1}+\frac{1}{R_2}\bigg)}{\frac{1}{\beta}+R_E\bigg(\frac{1}{R_B}+\frac{1}{R_1}+\frac{1}{R_2}\bigg)}+\frac{\frac{v_s}{R_B}}{\frac{1}{\beta}+R_E\bigg(\frac{1}{R_1}+\frac{1}{R_2}+\frac{1}{R_B}\bigg)}$$


I know that this is a very long question and I don't ask for a solution to the problem, because I have one solution that leads to the correct result, however they don't do the DC and AC analysis separately and I was trying to do it because it should work, but I don't know where the mistake is, the answers are really similar and the AC analysis appears to be correct but the DC does not, and I can't find the mistake.


EDIT: I have found the mistake, In the DC analysis schematics I left out the resistance \$R_B\$, and if I leave it in the schematics connected to the ground then I can substitute, in the DC analysis only, all the \$R_2\$´s by the paralel resistance of \$R_B\$ and \$R_2\$ and the answers match. But a new question comes up, why do I have to leave \$R_B\$ connected to the ground? I thought that with a DC analisys capacitors would be replaced by an open circuit, therefore, no current should go through \$R_B\$, and that's why I ignored it. And this is just th case where I have a resistance \$R_B\$ there, if I didn't, but left that branch connected to the ground, then wouldn't it act as a short and we could ignore \$R_2\$?




i2c - Using internal pull-ups for TWI on AT32UC3B?


Does anyone know if it's possible to use the built-in pull-ups for TWI on the at32uc3b chips? I've been adding external pull-ups to my TWI circuits in the past because I couldn't find any concrete info about this. But if it's possible to just use the internal pull-ups, I'd much rather do that.


Thanks!





How does one compute the ripple currents seen by a boost converter output capacitor?



Suppose one is designing a boost converter, with a known maximum current load, and a known inductance:


enter image description here


The ripple current seen by the output capacitor is critical. If that current is too high, the capacitor will heat up, and its lifespan will be reduced. But how does one compute the ripple seen by this capacitor?



Answer



Assume the system is already precharged and operating in a steady state. The booster has two discrete states: either the diode is forward-biased (the booster switch is OFF), or the diode is reverse-biased (the booster switch is ON). Call the period P, and the duty cycle D. Thus the on-time time is from 0 to DP, and the off-time is from DP to P.


Assume that the output capacitance is large enough that its voltage ripple is small, meaning the current out of the cap during the on-time is fixed. $$ 1: I_{on}(t) = I_{load}\\ $$


During the off-time, we can approximate the current through the diode as a triangle, starting at a peak, and falling to a trough $$ 2: I_{off}(t) = I_{tr} + \frac{(I_{peak} - I_{trough})(P-t)}{(1-D)P}\\ $$


The current through the diode during the off-time is the choke current, which averages around: $$ 3: I_{avg} = \frac{I_{load}}{1-D}\\ $$


Define R to be the fraction above and below the average choke current that the choke current reaches. The peak current into the capacitor is thus the peak current of the choke, less the current going to the load. Similarly for the troughs.


$$ 4: I_{peak}=I_{avg}(1+R)-I_{load}\\ 5: I_{trough}=I_{avg}(1-R)-I_{load} $$



Computing the RMS: $$ 6: I_{RMS}=\sqrt{\frac{\int_{0}^{DP}I_{on}^2(t) dt + \int_{DP}^{P}I_{off}^2(t) dt}{P}} $$


Substitute and evaluate the integral: $$ 7: I_{RMS}=I_{load}\sqrt{\frac{R^2+3D}{3(1-D)}} $$


Consider the choke current during on-time. $$ 8: V_{choke} = L\frac{di}{dt}\\ $$ The voltage across the choke is the input voltage to the booster. The time this voltage is applied is DP. The change in current is the total ripple current seen by the choke. $$ 9: V_{input} = L\frac{2RI_{avg}}{DP}\\ $$


Solve for R, and substitute for I_avg: $$ 11: R= \frac{V_{in}D(1-D)P}{2LI_{load}} $$


Substitute this value back into (7) to find the RMS current seen by the output capacitor.


As a check, one can assume that L is very large, meaning R is negligible. Further suppose a 50% duty cycle and a fixed 100A load. If the diode is forward-biased, the choke is delivering 200A, 100A to the capacitor and 100A to the load. If the diode is reverse-biased, the capacitor is delivering 100A to the load. So for half the cycle, the capacitor is absorbing 100A, and for the other half the capacitor is delivering 100A. The RMS seen by the capacitor is 100A. This matches our computations.


Now, this assumes a purely resistive load. If a boost converter is driving a capacitive load, and there's wiring inductance between the converter and the load, you can get ringing effects that drive the ripple currents much higher. I've simulated as much as 1.7x the full load current, and I suspect 2x is possible with the right combination of capacitances and inductances.


raspberry pi - Calculate base resistor of PNP transistor in switching circuit with variable resistance


I would like to read analog input on my Raspberry Pi using various resistive sensors I represent in the schematic below as potentiometers (R5 ad R7). I need to be able to switch the circuits on and off (high-side) through GPIO pins. I am new to electronic schematics and figuring out how to build circuits on my own so I have a few amateur questions concerning the base resistors (R1 and R3) and the circuit in general.


Raspberry Pi specific information:
The wiper pins on the potentiometers go to a MCP3008 ADC as the Raspberry Pi does not have analog input pins. I am using a linear voltage regulator to provide 3.3V to avoid using the 3.3V rail which, I have read, can only provide 50mA. The ADC will also be powered by the 3.3V coming from the regulator.


General information:
I have been following a few tutorials which calculate the base resistors of the two PNP transistors (R1 and R3).


A Raspberry Pi specific video states that the base resistor must be calculated using the β value of the resistor and the current of the circuit after the collector (R2+R5 and R6+R7). This would put the base resistor past 3M ‎Ω assuming a β value of 75 and a current (Ic) of 0.06mA. Not that I have experience to judge, but this seems awfully high.


The tutorial on Sparkfun seems to contradict this and states that "1mA to 10mA will usually be enough" in terms of base current. If I use a 1K Ω resistor as the base, I will get 3.3mA to the base of the transistors.


The vast majority of Arduino tutorials, although they use NPN transistors, seem to have less than a 10K Ω resistor on the base of their transistors reguardless of what they are switching.


Questions:

The obvious question here is which calculation is correct? How would I find the amount of current needed to saturate the 2N3906 transistor by its datasheet? I'm not sure which number I'm looking for as I'm not used to reading datasheets or why each value is negative (I assume it's because the transistor is PNP although that doesn't answer my question).


Bonus: Will the circuit behave correctly if the potentiometers (R5 and R7) are replaced by a photoresistor that runs straight to the ADC? Does it matter that the digital pins are from the Raspberry Pi powered and the VCC in this circuit are powered from a different source although the voltage is the same(ish) and they share a ground?


Thanks.


schematic


simulate this circuit – Schematic created using CircuitLab



Answer



The Sparkfun tutorial is very bad. The biggest mistake, at least from your point of view, is using a relatively high (75 to 100) value for beta.


Because the transistors are being used as switches, they must be over-driven compared to "regular" linear amplilfier use. This is called being in saturation. The rule of thumb in such cases is to assume a beta of 10, since this will produce very low (0.1 to 0.2) voltages for modest current levels.


In your case, your 50k pots will limit the collector current to such low levels (65 uA or so) that in principle you only need base resistors on the order of 500k. However, at these low levels you'll start running into leakage problems.


You're probably better off replacing your pots with 1k units with 100 ohm limiting resistors, and using something like 10k base resistors.



Why is a capacitor used to protect CMOS chips?



I am studying digital electronics. A book says that "use a 0.1 μF capacitor between Vcc and ground for each IC".


What does this mean?


Why can a capacitor protect CMOS chips?


Does it mean that a capacitor should be added like in the figure?


update (7/21/2016): okay, maybe I was confused with the meaning. A chapter of the book was talking about static protection for CMOS chips and for an experiment it mentioned the quotation with a footnote. The footnote says, "In keeping with standard practice, capacitors are specified, particularly with CMOS devices, to return switching current 'spikes' to the source through the shortest possible path"


So, I thought a capacitor should be used to "PROTECT" CMOS chips.



As I said, I am studying digital electronics. I don't know about decoupling capacitors. So still I don't know if my question is duplicate :(


schematic


simulate this circuit – Schematic created using CircuitLab



Answer



That's not a protection device, if you intend "protection" as something that prevents the chip to die, but it serves as a so-called bypass capacitor.


It acts as a reservoir of energy whenever the chip draws pulses of current when switching occurs. If the power rails were truly ideal connections, with no resistance nor inductance, bypass caps wouldn't be necessary.


Since the rails have some resistance, whenever the chip absorbs a sudden pulse of current, a corresponding voltage drop develops along the rail, risking to bring the rail voltage out of specs. The bypass capacitor reduces this risk in a way similar a filter capacitor after a bridge rectifier reduces the ripple of a rectified voltage.


In other words, bypass caps help keep the voltage of the power rail constant at the chip terminals, which is what is needed for its correct operation.


Note that bypass caps need to be placed near the IC they are meant to "protect", in order to be effective. Here "near" means that between the terminals of the cap and those of the chip there must be the least distance possible along the copper traces, in order to minimize the resistance (and the inductance as well) that is not bypassed.


Dave Jones, of EEVblog fame, has made a nice tutorial about bypass capacitors (EEVblog #859).



EDIT (prompted by a comment by Floris)


In the explanation above I focused on the voltage drop caused by the resistance of the rails because it is the easier to understand, especially for a newbie. To avoid giving a false impression, though, I must emphasize that the resistive effects are not the principal cause of voltage drop during current spikes. The principal culprit is the inductance of the rails, especially in high performance circuits, where switching is very fast. In fact, an inductor of inductance L presents a reactance \$X_L = 2\pi f L\$ (if you don't know what I'm talking about, see it as a sort of "AC resistance") that is proportional to the frequency. Therefore current spikes with higher frequency components (i.e. having steeper edges) will cause a more substantial voltage drop.


How precise is the frequency of the AC electricity network?


If I make a digital clock which first detects the AC frequency roughly (whether it is 50, 60, 100Hz, etc), then uses it as its clock pulse source, how precise would it be? Would it work world wide precisely?


For instance, in USA, what is the mean and standard deviation of the 60Hz AC frequency?



Answer



Grid frequency will change throughout the day due to imbalance between electricity generation and consumption.


Grid frequency in time


Grid operator is obligated to keep the frequency within +/- 0.5Hz of 50Hz (frequency and range depends on the country's grid codes). When you measure time based on the assumption that every period is equal to 20ms you will have a time deviation error that. This error is kept within certain bounds by the network operators. If the time deviation is too big, a frequency compensation is scheduled to compensate it.


You can find public data about current grid frequency online e.g. Swiss and UK grids. The Swiss website also shows the current time deviation.



enter image description here


clock - Does this clipped-sine oscillator need a buffer?


I'm considering using an Abracon VCTCXO, the ASVTX-11-121-19.200MHz-T to run an AT89LP428. I'm trying to make sure that they're interoperable, but the Abracon device doesn't say anything about the slew rate of its output, nor how much clipping there is. (I realize that that particular Abracon device is listed "no last-time buy", but other devices and manufacturers suffer from the same issue.)


Reading an application guide for a similar product from a different company, Taitien, it suggests that a buffer is needed under some circumstances:



buffered clipped sine To convert the clipped sine waveform to a square waveform signal such as CMOS, an input buffer is necessary. Generally, ICs that TCXO’s output going into would have input buffer functionality integrated inside the chip. Oscillator circuit should have Rf feedback resistor connected in parallel with the inverter. [...]


If the IC does not have input buffer functionality incorporated, an inverter such as 74HC04 and an Rf resistor would need to be added in series between the output pin of the TCXO and the clock input pin of the IC to convert the clipped sine waveform to a square waveform



Of course, the clock fuses on the AT89 support both high-speed crystal and external clock mode. So far as I can tell, I should be using external clock mode, because the XO is an entire oscillator unit with its own power supply, not a passive crystal.


Based on these specifications:


external clock specs



and based on the supplies for my oscillator and MCU (3.3V and 3.6V, respectively), even in the worst-case scenario where the output from the XO is a pure, unclipped sine, the t_CHCX and t_CLCX requirements are met:


$$ t_{CHCX} = \frac 1 {19.2 \text{MHz}} \left( 1 - \frac 1 \pi \cos^{-1} \left( 1 - \frac {0.7 \cdot 3.6 \cdot 2} {3.3} \right) \right) \approx 16.8 \text{ns} > 12 \text{ns} $$


$$ t_{CLCX} = \frac 1 {\pi \cdot 19.2 \text{MHz}} \cos^{-1} \left( 1 - \frac {2 \left( 0.2 \cdot 3.6 - 0.1 \right)} {3.3} \right) \approx 14.9 \text{ns} > 12 \text{ns} $$


However, the rise and fall time are not:


$$ t_{CLCH} = t_{CHCL} = \frac 1 2 \left( \frac 1 {19.2 \text{MHz}} - t_{CLCX} - t_{CHCX} \right) \approx 10.2 \text{ns} > 5 \text{ns} $$


So it's difficult to tell whether it will work. Since the XO's slew rate is unspecified, should I add a Schmitt trigger to be safe? Or do I have this wrong, and should use the MCU's crystal mode instead?




varicap diode cutoff and breakdown voltage


BB 109 is a varicap diode and is used for modulation.


I'm going to use this for frequency modulation of voice signal . Since our voice signal is in range of millivolts. I need to know from which voltage they have response?


Like PN junction diode,Did they have cutoff or Breakdown voltage ?


From which voltage ,they have capacitance value ?




Answer



I think your questions are answered by this section of the BB109 datasheet: -


enter image description here


Capacitance varies with the reverse voltage across the device so that at 1V, capacitance is about 40pF and at 10V the capacitance is about 13pF.


Applying a small signal from a microphone will produce modulation. Let's say your voltage is 1Vp-p centered at a dc level of 4V. Nominal capacitance is 25pF and half a volt higher it is about 23pF. Half a volt lower it is about 27pF. This means your 1Vp-p signal varies the capacitance by +/-2pF. This will, in the appropriate oscillator, move the frequency up and down. How much? Frequency change is the square root of capacitance change in LC oscillators and the capacitance change is +/- 8%. This translates to a frequency change of approximately 4% up and 4% down.


If your microphone signal is much smaller than an expected maximum of 1Vp-p then you'll need to apply an amplifier to bring the levels higher. You'll also need an LC oscillator - look up "Colpitts" on the internet to uncover what your options are. Alternatively, here is a link to another page on Stack exchange that has a circuit


Breakdown voltage of BB109 is 28V.


Saturday, 25 July 2015

driver - Is it possible to run a stepper motor only with a L293D at reduced current?


I would like to drive my stepper motor (1.4A rated current, 3.5V, 2,5 Ohm coil resistance). I only own some L293D drivers but I think I will burn it if I just wire the motor to the driver without some sort of current limiting.


Obviously I will loose some torque but that's ok for the moment.




mosfet - Using a LED with an ESP8266 module


I'm building a project that uses a high power LED (3 Watt) in connection with an ESP8266 module using the module as an access point and connecting to it with my smarthpone. I've successfully managed to switch the led on and off with my smartphone and connecting the I/O pin to a logic gate MOSFET using a simple LED circuit with just a resistor and the MOSFET.enter image description here


Now though I want to have a better and more efficient circuit for driving my LED and came up with this the 1A constant current supply is supposed to be a 3.7v lithion ion battery but i didn't know how to use that with the program I used to make the circuit so by no means is the current supply constant(see image)enter image description here This isn't my own design, I found it online, the reason why it's better is this:


" Q2 (a power NFET) is used as a variable resistor. Q2 starts out turned on by R1.




  • Q1 (a small NPN) is used as an over-current sensing switch, and R3 is the "sense resistor" or "set resistor" that triggers Q1 when too much current is flowing.





  • The main current flow is through the LED's, through Q2, and through R3. When too much current flows through R3, Q1 will start to turn on, which starts turning off Q2. Turning off Q2 reduces the current through the LED's and R3. So we've created a "feedback loop", which continuously monitors the LED current and keeps it exactly at the set point at all times. transistors are clever, huh!




  • R1 has high resistance, so that when Q1 starts turning on, it easily overpowers R1.




  • The result is that Q2 acts like a resistor, and its resistance is always perfectly set to keep the LED current correct. Any excess power is burned in Q2. Thus for maximum efficiency, we want to configure our LED string so that it is close to the power supply voltage. It will work fine if we don't do this, we'll just waste power. this is really the only downside of this circuit compared to a step-down switching regulator!





setting the current!


the value of R3 determines the set current."


The problem now is I don't know how to use my ESP8266 again as a switch because I don't know where to connect the I/O pin where as previously I connected it to the MOSFET and basically used it as a switch but in my current circuit I don't know where to connect the I/O pin


This is my full setup for the project with the old LED circuit enter image description here


I have an additional question about this setup : is it the best way to power both the LED and the ESP8266 using a step down converter in the way I used it?




What is the advantage of non-metric units?



Why are non-metric units so widely used in elctrical designes?




analysis - Thevenin equivalent resistance of circuit with diagonal resistors


I'm trying to find the Thevenin equivalent for part A of this circuit: enter image description here



I begin by opening the circuit at the dotted line of part A. Then I try to find \$V_{oc}\$ across the two terminals that are open. I can see that the 47kΩ is in series with the 18kΩ since no current flows to the open circuit, and that the 15kΩ is in series with the 33kΩ. However I'm having a lot of trouble redrawing the circuit. Not really sure about how to make it look simpler. Any ideas?



Answer



You must redraw the circuit to obtain the Thevenin's voltage:


schematic


simulate this circuit – Schematic created using CircuitLab


Then you must find the voltage between node b and node c. Passivating the source Vi, you find the equivalent resistance:


schematic


simulate this circuit


Between node b and node c.


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