text
stringlengths
83
79.5k
H: How can I build a voltmeter / logger? I want to build a device whose primary function is a voltmeter without a display. Instead of having a display I want it to interface with a smart phone via bluetooth to read the voltage. Optionally I would like to be able to press a button on the phone and shut off the circuit for a couple of seconds and turn it back on, all while still sending the readings to the phone. I need millivolt resolution with a range of ±5V How could I go about doing this? I'm a programmer that's pretty new to EE, so please dumb it down if you think I won't understand. Thanks! AI: Without any of those specifics and with your statement that you are pretty new to EE you might want to start by taking a look at Arduino. There are a lot of examples, modules, and a great support community our there in the Arduino world and it is great for people learning the EE side of things.
H: loudness of speaker Given a speaker is 30 watts, which is louder, the one with higher current through it or the one with higher voltage across it. Lets say both speaker has variable impedance (so we can vary both current and voltage). According to my research and analysis, the current is what drives the coil to produce vibration and thus rarrifying the air molecules around, so it turns out that a larger current would mean larger loudness. So is it safe to say that current is directly proportional to loudness? In other words, which is louder, a speaker that is driven by a 3 Ampere current back and forth oscillating at high frequencies but with low voltage or a speaker that has very large full swing peak to peak voltage from up to bottom but low current? AI: All else being equal, neither. It's the product of voltage and current that matters, i.e. power, which you have fixed at 30W.
H: voltage level of mp3 mobile phones What are the voltage level (pk to pk, both average and the maximum voltage output) of a music player from Samsung mobile phones, Apple iPods, iPhones etc. I dont have a multimeter here and those devices above. I cannot find on the internet the device specifications that list those voltage levels. Ill be designing an audio preamplifier and so we need these data to aid in dc biasing calculations. If have oscilloscope, that would be better and a graph for it AI: This blog post may help you out some. It states that the output voltage from an iPhone is about 0.95 Vrms.
H: current in audio amplifier We know that bjts operate in the principle of base current controlling the collector current. If there is more base current, then more collector current flows. Now going to the input part of a amplifier, when designing the input side (preamplifier), do we need to consider the base currents, Max Ic collector current and stuff during deaign phase (computing bias calculations,etc) since what were concerned of is only the input voltage? As far as i know, what the pre amplifier cares about is the input voltage and output voltage and it doesn't care about base current, Max collector current, and the like(anything that has current). AI: You must give it some consideration. As a first step, here's how it might work. Specify the input voltage you need to give full output (a typical value is 1V rms) - this lets you work out the voltage gain of the amp, but that's another matter. Also specify the input impedance (10kilohms is a typical value). Divide, and you have the input current (in this case, 0.1ma rms). Now, the AC component of the BJT base current cannot exceed this, and really should be much lower (or the amplifier will be non-linear, i.e. have poor distortion). A suitable value for the base current might be something like 0.01ma, until we have better information (like, the distortion is worse than we want). Now you can combine this info with the current gain of each stage of the amp, and see if you can meet this requirement AND supply the output current you need, or if you need more gain. If the first stage has a current gain of 100, then it can supply 1 ma to the next stage, and so on.
H: Running the linux kernel and ubuntu on a custom processor This is hardly a theoretical question as many have done this, albeit there's very little information on the underlying processes. I'm developing a custom MIPS-based processor on which I would like to run ubuntu. I'm quite baffled as to what to do next after you've designed the instruction set and the computer architecture itself. I need to be able to run a kernel and OS but how does it all tie in? At the moment I'm researching into designing a compiler for the linux kernel to generate the appropriate assembly language. Is that a good way to go? What do I need to do after that? AI: Yes, to program it satisfactorily, you will need a compiler. One way to get one is to adapt a code-generator back-end for GCC. But then you need at least a bare bones runtime system. Here's a page on starting to develop one, using GCC as the compiler. http://wiki.osdev.org/Ada_Bare_bones
H: LCD modules with I2C or SPI interface I would like to add an LCD to my current design (a project that is to be produced in low volume, around 50 to 100 units). A small display size (around 8 or 16 characters) should be plenty since it is for measurement readout, and I would like to keep the price around 4 USD or less. But most importantly, I would like to use I2C/SPI if possible, so as to minimize the number of pins used on my microcontroller. Do pre-designed LCD modules/types of this kind exist (it seems to me they should be!)? Or am I stuck with using modules with parallel-8bit-pinouts, or using raw glass panels and adding on my own in-between interfacing circuitry? AI: Price point is something you'll be hard-pressed to negotiate without serious volume. If the price is not something that can slide, you're likely to be stuck buying raw panels and adding the controller ICs / communication ICs to a custom designed board. If you can let the price slide, there are some nice pre-made modules you could look into. Adafruit has "backpacks" that are designed to solder to the back of the common LCD displays and handle the parallel control logic while giving you an I2C/SPI interface. Those are here. They also have fully-packaged LCD modules with the backpack already attached. Here is an example of one with a basic 16x2 LCD.
H: Increasing speakers impedance by adding resistors I've got a (pretty dumb) radio which increases volume by digital dB, and not some analog device. Thus it goes something like { Mute, -75db, -65db, -56db, -49db, etc }. Now I use this radio basically only at night, and the problem is, -75 is too silent, it's hard to hear that, while -65 is too loud again. The radio is a stereo setup, with the speakers having 6 Ohm impedance. If I introduce for each speaker lets say a 6 Ohm resistor, would that half the volume, and just that, or would it have some sort of effect on the sound I am getting? I only found (http://www.tdpri.com/forum/amp-central-station/200037-changing-impedance-speaker-resistor.html) as reference, and did not really find an answer to that. AI: If you wanted to over-engineer the problem, you could look up "resistive pad". These are combinations of resistors that will present the same impedance to the amplifier and the load, and therefore would not alter the sound quality. In your case, it's not likely to matter. But there is one other effect. Many amplifiers put out a fixed amount of noise regardless of where the volume control is set, and it's quite audible at low sound levels. Adding an attenuator (such as you want to do) will cut down that noise as well as the volume. Then, when you turn up the volume, the noise doesn't come with it. In that case, your sound quality will have actually improved.
H: Debugging I2C bus using an oscilloscope Is it possible to debug an I2C bus effectivaly with a two channel (plus an external trigger) oscilloscope? I've been trying to do it, to catch a single transaction starting from the start until the end, but I find it hard to set a trigger properly on the scope. Is it possible to build some kind of logic AND gate with SCL & SDA as inputs, and feed the output to the external trigger ? Note: I have a simple 2 channels digital scope, with no extra features. AI: If you can control the code in the i2c master (I presume this is related to your previous question, using a MCU), I can see two easy options that do not require any hardware outside of your current setup to generate the trigger: Use any extra pin you may have (or temporarily repurpose an existing one): Assert it right before i2c transactions, deassert it right after. Insert a known delay between transactions, and trigger on pulse longer than said delay on the scl line.
H: PIC 18F2550 USB Dual Power Example In the PIC18F2550 datasheet, there is an example about how to dual Power it in the figure 17-12. I understand the whole circuit, I am just not sure why there is this diode after the Vself? AI: Ok, I got it figured...If there is power on the Vbus, and there is no diode, the PNP transistor will shut off, since there will be a V+ in its base terminal, and then there will be no energy in the PNP, so it will turn on again, because this time the base terminal will receive a 0V level, and this way sending a V+ to the PNP again, turning it off again, making it into a cycle, causing an erratic behaviour...the capacitor will even make things go slower.
H: Meaning of symbol on LED screen price tag I wanted to know the meaning of a particular globally-used standardized symbol printed on the price tag of every led screen. Here is the symbol: AI: It is a quality mark, certification mark, introduced by an American organization called Underwriters Laboratories. UR is an abbreviation for UL Recognized. I know too little about it myself so I can only refer to a Wikipedia article on it: Recognized Component Mark
H: do power amps need regulated power supply Does a power amplifier needs a voltage regulator since it needs to draw current around 2 A depending on the wattage and speaker impedance. If we try to use a zener regulator, notice that a zener diode's maximum current is only at 200 mA which is way lower than the 2 Ampere current requirement to drive a speaker. Or will a plain unregulated dc supply will work (no more zener but we risk getting variable supply voltage)? AI: A power amplifier does not need a regulated supply depending on how it is specified. Some may need a regulated supply to meet their stated power line noise output limits. Others may need a regulated supply to deliver their maximum rated power without overheating. It is certainly possible to design a audio power amplifier to a useful set of specifications while allowing its DC power voltage to fluctuate over some limits. Allowing the power supply to ripple introduces two design challenges, to not let the ripple get into the output signal, and to make the amp work as specified over the full range of minimum to maximum power voltage. Keeping the power supply noise out of the output signal is quantified as power supply rejection, usually expressed in dB. Negative feedback is one important way to increase power supply rejection. Take a look at the feedback equation and see how it inherently does this. However, you don't want global feedback too high because you otherwise get into other problems, like transcient intermodulation (TIM) distortion. The circuit topology is also important. As a simplistic example, consider a emitter follower. Changes in the collector voltage are greatly attenuated onto the emitter voltage output. Making the amp work over a range of DC input voltage is mostly about being careful about dissipation. Assuming the amp can only drive the output within its power supply range minus a little headroom, the lowest power voltage therefore dictates the maximum output power. However, the most dissipation will occur at the highest power voltage. You need to make sure the amp can handle the rated output power at the highest power voltage without overheating. A class D amp deals with this issue nicely in that it is essentially a switching power supply that runs at audio rates.
H: q point keeps shifting when there is input signal Why is that, even at transistor idle conditions, where my q point is exactly midway in the transistor loadline, when i start to inject ac signal at the input, the q point starts to shift somewhere else, therefore causing clipping. So this means that the act of inputting an ac signal sometimes causes the q point to shift naturally? Are there any counter measures against this? (Like compensating by means of finding a new q point wherein at idle conditions, it is exactly not at the middle anymore) I have a 12 Vcc supply, emitter voltage is at .97 Volts, and so the collector voltage should be at (12-.97)(1/2) = 5.5 V which is in accordance here in my simulation Here is the schematic AI: I think that the correct Q-point is 6.5V, not 5.5V. The Q-point should be roughly halfway between Vcc and the DC emitter voltage. Halfway between 12V and 1V is 6.5V, not 5.5V. At 5.5V, the negative swing is just 5.5V - 1V = 4.5V while the positive swing is 12V - 5.5V = 6.5V. This is why the negative peak clips first. UPDATE: I wrote the above under the assumption that, as in the previous circuits the OP has asked about, the emitter resistor is AC bypassed. Now that the schematic has been posted, I see that there is no emitter bypass capacitor in this circuit. With the emitter resistor bypassed, the emitter is at AC ground and this simplifies the Q-point calculation. Without bypass, the calculation is more complex. When the transistor is saturated, the voltage between collector and emitter is roughly zero. Thus, the emitter current is: \$i_{E(max)} = \dfrac{V_{CC}}{R_5 + R_7} = 17mA\$ Thus, the lowest voltage the collector can fall to is: \$v_{C(min)} = i_{E(max)} \cdot R_7 = 1.56V \$ So, a rough estimate of the Q-point collector voltage is: \$(12 - 1.56)/2 + 1.56 = 6.8V \$ However, this is an iterative process. When you change the value of the collector or emitter resistor, the above calculations change so the idea is to calculate a reasonable starting point, simulate to see where you are, and adjust / tweak as necessary. UPDATE 2: For a detailed analysis of the calculation of clipping levels, see Single Stage BJT Amplifier Clipping Levels by W. M. Leach.
H: How to use a SN75441 h-bridge (not working as expected) I am trying to figure out how to use an SN75441ONE h-bridge. I have it hooked up like this: Pins 1, 8 and 16 are connected to the positive rail (+5 V). Pins 4, 5, 12 and 13 are connected to ground. Everything else is left alone. My expectation is that since all the input pins are LOW (here unconnected), the output pins should also be LOW. However, the output pins are all HIGH. What is going on here? AI: From the input circuit show in the datasheet I expect a non-connected input to behave as a 1 (current must be sunk to drive it low), exactly what you are experiencing.
H: Testing the condition of an old sealed-lead-acid (SLA) battery I have a small 3 year-old 6V 1.2Ah SLA battery that is used in a solar powered burglar alarm sounder box. The sounder recently stopped operating and the battery shows a voltage of about 4V so I am recharging it (using a charger designed for this purpose). I will clean the solar cell and replace the unit's 9V PP3 battery which is really only for initial start-up. However I know that SLAs have a finite lifetime and are typically replaced every five years. I also have a spare 6V 1.3Ah battery that is probably of similar age but which has not been used for 3 years (1V shown). After charging them back to 6V, is there some way I can test these batteries using a multimeter, a load such as a light bulb of known wattage (and possibly other components) to see which battery is in best condition or whether I really should buy a new one? AI: It sounds like both batteries are likely end of life, but testing them is a great way to determine if there is useable life remaining. I'm assuming that you don't consider the burglar alarm to be mission-critical, as using a marginal battery in applications that really need reliable power is a bad idea. First, measure the terminal voltage during charging (but after they've been on the charger for at least 24 hours). The terminal voltage should be between 6.0V and 7.5V. If it's less than 6.0V, you have a shorted cell and should recycle the battery; it's done. Next remove the cell from the charger and measure the terminal voltage. If it is 6.0V or greater, there may be some useful life remaining in the battery. Reference a typical VRLA battery terminal voltage vs SOC curve below (note that this is for a healthy battery). Finally, connect a load such as a 6V light bulb across the terminals while measuring the terminal voltage. If the battery lights the lamp and the terminal voltage stays above 5.8V or so (assuming a ~500mA load), you're probably OK given the caveats about not using marginal batteries in important applications.
H: If A=0, B=1, and x=0 what are A' and B' in the logic circuit below? The following circuit diagram what are A' and B'? The question in the slide asks what happens if A=0, B=1, and x=0. I understand what it means when x=0, but what exactly does this mean when A=0 and B=1? The way A and B are labeled in the diagram it appears like they represent the hardware device, not an input. Can someone explain to me what A and B are exactly? In the following diagram we are given the answer if A=0,B=1,and x=0 in red. Can somebody explain how they arrived at this answer? Trying to make sense if it myself, here is my train of thought: Input x is fed into a NOT gate, making it x'. x' is fed into an AND gate with Q', thus making the output (x'^Q'). Which is then fed into an OR gate with Q, giving you Q OR (x' ^ Q') = (Q OR x') AND (Q OR Q') = Q OR x'. This is fed into both inputs of B, which doesn't make any sense to me. At this point I am lost, so I would appreciate some guidance what happens to Q OR x'? AI: A and B are D latches; on the clock edge, the value on the input is latched to the Q output. A = 1 means that the Q output associated with the A latch is high (the complementary output is thus low). A = 0 means that the Q output associated with the A latch is low (the complementary output is thus high). A' is the value of A after the next clock edge. This is a state machine. A and B represent the current state. The current state, along with the input x, determine the next state denoted by the primes on A and B. So, for example, the input to the A latch is x so, if x = 0, on the next clock edge, 0 will be latched, i.e., the Q output of the A latch will be low; A' = 0. Following the logic, the input to the B latch is: \$(\bar x \cdot \bar A) + B \$ So, for x=0, A = 0, B = 0, the input to B is 1 and thus, after the next clock edge the Q output of B will be high; B' = 1. UPDATE: a closer look shows that the schematic does not match the state transition table. It's obvious that the input to the A latch is x and so, A' = x according to the schematic. However, the 5th row in the state transition table has A' = 1 when x = 0. That's not consistent.
H: output signal now became smaller Why is that without the power amplifier block connected to the output of preamplifier, the output signal is ok around 17 volts peak to peak, but if i now connect the power amplifier, the signal somehow attenuates down to around 75% smaller. This is schematic from pre amplifier block and the power amplifier block notice that they are connected by the "ww" connector AI: Just a quick note of an answer: the small-signal impedance looking into the base of Q4 is roughly \$(\beta_4 + 1) R_L\$. This in parallel with the impedance looking into the base of Q5: \$(\beta_5 + 1) R_L\ \$ So, for example, assuming \$\beta = 30 \$ for each transistor, the input impedance of the power amp is roughly \$60 \Omega \$. The output impedance of your preamp is roughly \$180 \Omega\$. By voltage division, the loss in the output impedance, due to the input impedance of the power amp is: \$\dfrac{180}{60 + 180} = 75\%\$ Note: you can determine the exact AC input impedance of your power amp by driving (just) the power amp with a 1A AC current source. Plot the AC voltage across the current source. The value of the voltage is the magnitude of the input impedance. Note 2: if, after verifying the input impedance of your power amp, you find it is too low, consider trying a Darlington output stage to increase the input impedance: Alternatively or in conjunction, add a common-collector stage to the output of your preamplifier to lower the output impedance. Note 3: To see an example of a real amplifier design, take a look at The Leach Amplifier.
H: Microcontroller with a long wire for digital input I have the doorbell button on my house wired into a GHI EMX dev board. The software evaluates the time of day and determines whether or not the doorbell should ring. Side Note: This was implemented as a way to deal with ding-dong-ditch pranks that I was receiving. This all works great except for one problem, the wire connected to the EMX board is around 50 feet (~15 meters) long and generates enough interference for the board to think that someone has pushed the button and thus my doorbell rings at random intervals throughout the day. Both my wife and my dog do not appreciate this (but the kids think it's great fun). I've tried fixing the problem by following the advice found in this article and implementing the following circuit: This didn't fix the problem, but I did find that putting a 3k resistor in the for 1k and replacing the .01uF capacitor with a 40uF worked a little better, but anything more than 3k causes a noticable delay when pressing the button before the bell rings. The difference for my circuit is that the board runs on 3.3V instead of 5V (which I assume makes the problem worse) and instead of connecting to ground the switch completes the circuit (i.e. two wires go between the microcontroller and switch). The wire that runs between the switch and the microcontroller is standard doorbell wire which isn't shielded or twisted. Replacing the doorbell wire with shielded wire is, unfortunately, not an option since that would require that I tear drywall off. I've looked at the following question here, but that seems to be dealing with a ADC which might be a little different from my problem. Any help would be much appreciated. Update After reading more of the documentation, it appears that although the microcontroller is powered by 3.3V it is 5V tolerant on it's I/O pins. I can adjust to a higher resistor value if I use 5V, but will this help anything? AI: What the schematic does not show is the huge common mode 60Hz hum and how the grounds are interconnected with proximity to AC lines & power line transients. Your example is a good example of how not to interface long wires. May I suggest in future; prefer twisted pair prefer balanced lines avoid high impedance inputs prefer matched impedances avoid excessive LPF ( long time constants) include RF cap to suppress transients. use ferrite beads (CM choke) avoid ground loop (ie. direct untapped connection to circuit) use contact wetting circuit ( correct polarity 10uF cap across contacts that are not gold plated) prefer coax for very harsh EMI environment. Since many options are not avail. Do these; remove big cap on board and move to remote switch contacts. (must) remove 3K(1k) series resistor and add ferrite CM sleeve or similar add small RF cap on board across input. e.g. 0.001~0.01uF or any low inductance type. Replace 100K with 1k~10K. add large ferrite beads with multiple turns to both wires. (CM filter) With this solution, the switch circuit impedance will low impedance on closure and low impedance with elect-cap across switch when open. CM hum will be absorbed and differential RF noise is suppressed. -pullup to same supply voltage as uC with good RF cap across chip.
H: Which part of a pnp-transistor is the buried layer connected to? I am preparing for exam and one of the questions is this: "Which part of a pnp-transistor is the Buried Layer normally connected to?" According to the lecture notes handed out, the correct answer is: base According to the IEEE (the title being "p-n-p heterojunction bipolar transistors with buried subcollector layers"), the correct answer is: collector Which answer is correct? AI: The Wikipedia article has a nice illustration of the structure of a typical npn transistor. The structure of a typical pnp transistor has many similarities. In particular, both of them have: A thin surface layer acts as the emitter. A thin layer buried under the emitter acts as the base. The substrate -- the bulk material all the way to the bottom surface -- acts as the collector. As The Photon pointed out, the vast majority of PNP and NPN transistors are planar transistors made entirely of doped silicon. So any question that asks about "PNP transistor", you are safe to assume unless the question specifically says otherwise that it's not talking about the rarely-used heterojunction bipolar transistor.
H: Triangular waveform shown by DSO for DC output. Is this usual? Found this, confusing picture on a popular ecommerce site, shows an extremely economical DC-DC (step-down) adjustable voltage converter (based on LM2596S), which apparently works for upto 2Amps of current, and usable on breadboards. The part which is confusing is the DSO display, which is giving me the impression that this isn't DC, but dirty (triangular waveform) AC, possibly with the DC component bias. My initial thoughts were that this is a switching regulator (which it might very well be), but should the output stage waveform look like this ? PS> If someone thinks that this is a shopping question, do advice on how to rephrase, because I am trying to make this a generic electronics fundamentals question. AI: From the text at upper-left, it looks like the 'scope is meant to show that the output ripple is 50 mV peak-peak. (I can't read the Chinese, I'm just guessing from the units). That's a fairly small ac signal, which might be acceptable in many digital applications, or which could be further filtered by the user.
H: DVI-D Single Link to FPGA I'm using LatticeXP2 family FPGA. DVI-D Single link operating at 720p is connected to FPGA. I somehow need to read RGB and XY coordinates of pixels. I know I need TMDS decoder, but I'm not sure how to write that and some sort of clock sync in VHDL/Verilog. I know there are dedicated chips designed to do that, but I can't afford extra cost to the board. AI: You will really want to consider using a dedicated DVI or HDMI receiver chip if you need to use the lattice XP2 family. (Both DVI and HDMI use the TMDS protocol.) Alternatively, you could use an FPGA with a built in TMDS receiver, such as the Spartan-6. I did not see any indication on the Lattice web site that XP2 has TMDS capability. Building a TMDS receiver requires some complex clock/data recovery (CDR) capability, as well as fast deserializers and a good bit of decoding logic. Doing this on your own would be non-trivial. The PLLs and/or DLLs used for CDR in TMDS receivers are typically customized to be a good match with the TMDS protocol and TMDS transmitters. A "generic" PLL on a FPGA may not be a good match for TMDS CDR.
H: What is this adhesive tape that comes in some parts? I think this is a Mylar tape, but why they come with it? I guess its so to make the Pick and Place machine job easier? And why is so common to find them holding cables inside some laptops? Just because they are fire resistant? AI: Its kapton tape. It has two very interesting properties - its a great insulator, and its heat resistant - to the point where flexible circuit boards are made from it. You can solder without melting it (or even solder it), which makes it great for protecting parts from shorting when wave soldering.
H: Use a 15µf capacitor instead of original 12.5 µf for a water pump? I have a 0.5 HP water pump. It's having trouble in starting and I have noticed the capacitor is damaged. It had a 12.5 µF 450V capacitor. When i went to buy a new capacitor the seller gave me a 15 µf 450V condenser and he said we can fix a 15 µf in place of 12.5 µF and nothing will go wrong. I just want to make sure that this will not be a problem. AI: Most capacitors are labeled with tolerances. You will find the AC motor start capacitors that you are using are typically +/- 20%. That means the recommended 12 μF capacitor can be as high as 14.8 μF and as low as 9.6 μF. The purposes of the capacitor is create a second phase to help one phase AC asynchronous motors start (instead of pulsating you get a rotating magnetic field). Once the motor has started rotating the capacitor is no longer required as these motors can, and do, operate off one phase. The capacitor achieves this by lagging the current which is connected to the second phase for starting. Having a larger value capacitor will enable more current to flow due the lower impedance. Having slightly less impedance will mean you have slightly more voltage drop across the motor. Given the motor is mains rated this will never pose a problem. So the short answer is you will not have a problem. Just double check the new capacitor has the same size mounting stud, terminals and diameter as your original capacitor to ensure installation is straight forward.
H: put more juice in the speaker Above is a push pull Amplifier. As we all know the 8 ohm speaker is not receiving enough juice from the supply rails, in fact its only getting around 16 watts of power, how can we double that amount to make it like 40 watts. It appears that varying the resistors value has no effect. How can we make the speaker receive more current (we can make it absorb more current by lowering the speaker's impedance but let's say the impedance is fixed at 8 ohms). AI: The amplifier shown is a pair of emitter-followers used to boost the current available to the load; it has less than unity voltage gain. The only way to increase the power (voltage) to the speaker is to drive the input with a higher-voltage signal.
H: Spring probe center dimension Im looking at some spring probes, such as are used in test fixtures (NOT on multimeters or scopes). All the catalogues (Ingun, Coda-Pin, etc) seem to organise by a dimension they call "centers" but never seem to show a matching dimension on diagrams... what is a "center" in this context? Ta AI: I think it's how close together you can crowd the pins in your test fixture. If your test pads are 2mm apart, you need probes that work at 2mm centres or smaller. The max diameter has to be somewhat smaller than this...
H: Criteria for gyroscope export restrictions Recently I tried to purchase a gyro for a GPS car tracking device I'm designing and Digi-Key refused to sell me since I'm outside US and that specific part (L3G4200D from STMicro) is export-restricted. I imagined that it was due to its precision (maybe high enough to be used in a weapon guidance system) but every alternative I found was restricted too. Anyone knows what are the specific criteria for making gyros export-controlled, and if that really affects all of them? If not, what would be the maximum allowed for the relevant parameters (precision & etc.)? AI: From the Bureau of Industry and Security: Section 742.6 of the EAR requires a license for RS reasons to export certain image-intensifier tubes, infrared focal plane arrays, certain software and technology for inertial navigation systems, gyroscopes and accelerometers, to all destinations except Canada. All license applications for these items are reviewed on a case-by-case basis to determine whether the export could contribute, directly or indirectly, to a country’s military capabilities in a manner that would destabilize or alter a region’s military balance contrary to U.S. foreign policy interests. (emphasis mine) Basically, it's a pretty good gyroscope. In theory, you could use this to make a weapon that is as good as or better than something that we have. So of course we can't let you have it. As mentioned above, "these items are reviewed on a case-by-case basis". So there are no published criteria that I could find. But a quick search on Mouser showed that there are a couple with a "EAR" tag in the description indicating export controlled. But there are plenty that don't have this tag. Such as the A3G4250D which seems to have very similar specs to the L3GD20.
H: Speaker BJT amplifier function I'm trying to understand the below circuit: I have to analyze an amplifier circuit from a microphone to a speaker and don't understand how it works. I know that the first stage is a voltage divider, but I can't figure out what the second stage is or how it works? In which stage does the amplification take place? I would really appreciate any help! AI: Let's put some part reference designators on your diagram. Always number all the parts. Then it is easy to discuss the diagram. Instead of "the emitter resistor of the second transistor" we just say R5. C1: This is a coupling capacitor which allows the AC signal to pass but blocks DC. It protects the microphone's coil from receiving a DC current from the amplifier's bias circuit and protects the amplifier's bias circuit from being disturbed by the impedance of the microphone. C1 transmits the voltage fluctuations from the microphone, superimposing them upon the bias voltage between R1 and R2. R1 and R2: These resistors form a voltage divider, establishing a voltage-divider bias for the base of transistor Q1. From a 9V power supply, R2 will develop about 1V. That's enough to forward bias the base junction of Q1, turning the transistor on. Q1: This BJT is the heart of the first amplification stage, a common-emitter (CE) voltage amplifier. Its job is to transform variations in the base current caused by the microphone voltage variations arriving over C1 into current variations through the collector-emitter circuit R3, R4 and C2. R3: This is the load resistor for the CE voltage amplification stage. Variations in current controlled by Q1 cause R3 to develop a voltage. This voltage is the output of the Q1 stage, directly conveyed to the base of Q2. The voltage is inverted with respect to the microphone signal. When the signal swings positive, more current flows through R3, developing a greater voltage drop. The top of R3 is pinned to the 9V power rail, so more voltage drop means that the bottom of R3 swings more negative. R4: This emitter resistor provides feedback to stabilize the DC bias of Q1. The bias provided by R1 and R2 turns on Q1 using a voltage of about 1V, mentioned above. This causes current to flow through the transistor. This current causes a voltage in R4. The transistor "rides" on this voltage. So the voltage opposes the 1V of bias. According to some rule of thumb calculations, R4 will develop about 0.3V, which is the voltage that is left over when we take the 1V bias voltage between R1 and R2, and subtract the base-emitter voltage drop of 0.7V. This 0.3V over 1500 ohms means that about 0.2 mA of collector current will flow through the transistor, at quiescence. This bias current also flows through the 10K R3 resistor, where it gives rise to a voltage of 2V. So the output of Q1 is biased approximately 2V below the 9V power rail. C2: This capacitor bypasses the R4 resistor for AC signals. The R4 resistor has the effect of feedback. The amplified current passes through R4 and develops a voltage, and Q1 rides on top of this voltage. The voltage being amplified is the difference between the input and the emitter. So R4 provides negative feedback, which reduces gain. By introducing C2, we get rid of this feedback for AC signals. AC signals do not experience negative feedback, and so the gain is much higher for those signals. R3 and R4 provide a stable DC bias for Q1, and C2 "cheats" around it, creating a higher gain for AC, so that the amplifier has a wider swing around the bias point (which, recall, is about 2V below the power rail). A lot of voltage gain is needed because microphones put out a rather small signal, and all the amplification is being done by a single stage. Q2: This transistor is set up as a current amplifying emitter-follower stage. Note that there is no load resistor similar to R3 in the previous stage. Instead, the output is taken from the top of the emitter resistor R5. R5: What happens here is that the top of resistor R5 follows the voltage applied to the base of Q2. It is simply that voltage, minus 0.7V. As the voltage at the base swings, the voltage at the top of resistor R5 goes through the same swing. This voltage is applied to the speaker through C3. C3: Another blocking capacitor. It prevents DC from flowing into the speaker, which would damage the speaker and also cause a lot more bias current to flow through Q2, since the speaker's impedance is a lot lower than that of R5. C2: This is a power-supply decoupling capacitor. In several places in the circuit, AC signals return to the power supply either through the 9V rail or through the common return (ground). These currents can develop a voltage across the internal impedance of the power supply. C2 provides a short circuit for these AC signals. Without power supply decoupling, current variations in Q2 could feed back into the Q1 stage, giving rise to oscillations. C2 also helps to keep stray noise from the power supply, such as power supply ripple, from affecting the circuit. Another way to look at it is that the capacitor provides current in response to sudden demands by Q2. The Q2 stage is needed because, even though it does not amplify voltage, it amplifies power. It does that because it is able to deliver more current than Q1. Q1 has load resistor R3, which gives it a rather high output impedance. If the speaker were connected to the Q1 stage output, hardly any sound would come out of it because the Q1 stage cannot maintain its voltage into just an 8 ohm load. Q2 has no collector resistor, and so the output impedance is low. Current flucutations flow freely from the power supply, through the transistor's collector and across C3 to the speaker. The Q1 stage is needed because a current driving stage like the one built around Q2 doesn't have any voltage gain. The Q2 stage alone could take the voltage from the microphone and put it across the speaker. Now it would be better than connecting the microphone directly to the speaker, because the microphone would be isolated from driving the low impedance of the speaker. But, in spite of that, would simply not be loud enough. Getting a reasonably loud sound out of the speaker requires a much higher voltage level. The jobs of amplifying voltage, and then amplifying the current which enables that voltage to be put across a low-impedance load such as a speaker, are best implemented separately.
H: Help with oscilloscope I'm little bit confused. Help me please to make everything clear. I want to buy oscilloscope and found two models suitable for me. Rigol DS1102E Rigol DS1102CA But I don't understand the difference between them. I read that DS1102E has 1 GSa/s sampling rate and DS1102CA has 2 GSa/s. OK. But what does it give in practice? Both oscilloscopes have a bandwidth of 100MHz, so I won't find a difference in picture of signals on screen. Am I right? So could you explain me what is the meaning of 'sampling rate' and 'bandwidth' for modern oscilloscopes? And what is the difference between these things? AI: The same bandwidth means they'll both have the same attenuation for signals. It basically means that 100MHz is the cutoff frequency for both scopes. The samples per second is the resolution of the scope. If you zoom in on a signal the non-interpolated data points will be 0.5 ns apart for the 2GSa/s scope and 1 ns apart for the 1GSa/s. The rule of thumb ere is you can fairly accurately measure a 100MHz signal with the 1GSa/s scope and a 200MHz signal with the 2GSa/s (~10 samples/Hz) Obviously the more samples then the better representation of your original signal. You'll just have to weigh that with the cost difference.
H: What type of electric motor drive can be used for keeping a load at specific heights? We are planning to adjust the level of a load (around 50 kg) by using an electrical motor. Now we are using a hand crank and we want to get rid of this manual process. For example we want to implement a control where one can adjust the height of the load. The load is hanging down on a pulley. We want to keep the load at 4 different fixed heights by using an easy push button system or a computer. When one sends signal to the motor the motor will adjust the load to a particular height depending on the signal and then will stop there. What type of motor and electronic control can be used? AI: This is typically done with an electric brake attached to the motor. The brake mechanically keeps the motor from turning when not energized. When you press the button and the motor starts to turn the brake is released so the motor can turn. If you want finer control over the speed of the motor you can use a Variable Frequency Drive (VFD). This would still use the same motor brake arraingment. VFDs in lifting and hoisting applications almost always have a braking resistor to counteract the ability for the inertia of the load to overdrive the motor.
H: reading the position of a switch using a microcontroller I would like to use a micro controller to read the position of a switch. The example and image below is for illustration purposes only. For example if a switch is at Position A, a 5V signal might feed DIGITAL INPUT 1. Similarly if the switch is at Position B, a 5V signal might feed DIGITAL INPUT 2. To make the signals useful, they would be on exclusivity to the other. i.e. Position A Position B | DIGITAL 1 DIGITAL 2 --------------------------|---------------------------- ON OFF | HIGH LOW | OFF ON | LOW HIGH The circuit is powered by the micro controller's 5V supply, and shares a common ground with the micro controller. Thank you. EDIT: changed R1 (1 kOhm) to a DC motor, to better represent the actual circuit. Also, the input voltage has an error or +-0.5V. The resistors have a 5% error tolerance. https://www.circuitlab.com/circuit/wec9n2/switch-sensing/ AI: While I was drawing the schematic with a DPDT switch, Pete had beat me to the answer.
H: AVR Serial communication using DB9 Connector I was using a PL2303 chip before to perform serial communication with an atmega128. It recently started getting hot and was not being detected by the computer anymore. These chips are not readily available so I was wondering if I can purchase a usb to serial cable and somehow use that to do serial communication. I spotted a serial to usb cable that even uses the PL2303 converted. Any help is appreciated. AI: To use a USB serial cable intended for RS232 devices (as those with the 9-pin connectors are) you will have to adapt your device to within arms length of the RS232 standard. This generally means two differences from the logic-level serial communications performed by most microcontrollers, and bare USB-serial chips: the sense of the signal is inverted the voltage is much higher (around 12-15v) and (at least formally) ranges below zero. Fortunately there are ICs which implement both the voltage conversion and the inversion. In the old days, these were the 1488 and 1489 used as a pair. But for a long time now, all-in-one devices with charge pumps to produce the higher voltages from a logical supply have been available. The MAX232 is the most famous of these, though some of its many descendants would be more likely to be found in a modern design. There are various crude things you can do in a pinch as well; disassemble the cable and tap in before its level translator IC, or build a voltage divider/limiter and try to use an ordinary logic inverter. And there are also many other varieties of USB-serial chip to chose from, if you want to make a custom circuit or buy a cable designed for use with embedded boards and other logic-level devices.
H: Data processing vs instruction processing in processor What a processor does with instructions and with data using examples. Why does it need data if it is processing an instruction? AI: Let's take an example of MOV Instruction. MOV A,#01 ; Move 01 in Acc In this case, "MOV" is an Instruction and 01 is data for it. MOV A,R0 ; Move contents of R0 in Acc Here we "Data" is content of R0. To Summerize, Processor executes instructions and for that it requires certain Data. In C, You pass paramters to functions. It can be treated as "Data" required to process "Instructions".
H: A question on Simulink I've done a simulation with Simulink. Now I want to do the next thing: extract the specific graph that I want and to mark some point on the graph that it will be displayed. like in the next pic: Thanks in advance. AI: Use the block named "to workspace" and record the interesting input/output signals. Then use the regular plot functionality in Matlab.
H: PCB trace inductance I am planning to do a high current (200 A+) PWM in a PCB and I am afraid the PCB traces inductances will be a huge problem... so I have some questions: How may I calculate the trace inductance? The wider the trace the less the resistance, but does this work also for inductance? I know there will be problems with the frequencies but I just want to get the feeling... AI: What are your specs for resistance of the copper? If you can meet the resistance specs the inductance problem WILL BE REDUCED to the same range of impedance as the resistance for flat copper. If the Length, l, to diameter, d, ratio is known, you can calculate the Inductance, L, series resistance, Rs and the aspect ratio l/d is related to Q = L/Rs for a given conductor material. Let's consider the impedance for copper at 1 MHz. aspect ratio = l/d = 5 10 125 1250 12,500 Impedance quality = Q = L/Rs 2.6 4 8 12 16 where Impedance, Z = ZL + ZR For flat copper tracks the aspect ratio is quite different and lower Q but you will need very thick copper to reduce the ohmic loss @ 200 A. I would suggest you use thick braided wire from the board edge and make the copper loss and inductance less than the Ron of your switches and not rely on copper traces. Thick tracks would make the cost of etched copper loss too high (unless you consider solid busbars added to board...)
H: adding bass to an amplifier How does one add bass to an audio amplifier? Assuming we have a basic pre amplifier and power amplifier in hand, and we have an ordinary speaker at the load. Do we need to buy another specialized speaker for bass since last time I went to an electronics store, they sell tweeters. AI: You say you want to add bass to the amplifier and then mention speakers. Do you want better response in your entire sound system? When we talk about the amplifier, we are only talking about the power amp and possibly the pre-amp. The speaker is a separate entity. When we want to add bass to the signal, generally some form of equalization is used before the power amplifier stage. If you want to add bass response to your speaker, you will generally either use a better speaker (usually larger with a better enclosure and better materials), or you can add specialized speakers for each frequency range. Many speakers have multiple drivers in a single device, like this studio monitor: Notice the smaller and bigger speaker. These speakers separate the frequencies using an internal audio crossover and play certain frequencies from the appropriate driver. If you want you can buy separate sub-woofers for your music, which will play only the lowest frequencies. Depending on the system you use you may need to make a crossover yourself. Please go get a book on some of this material and try to cement your fundamentals. For the audio specifically, I like Thompson's Understanding Audio. For the circuits, I learned on Sedra and Smith, but there are tons of good books out there. You can learn all this stuff independently if you put your mind to it. Good luck!
H: Arduino/Raspberry Pi 2 LED Matrices Does anyone know if I can use a single Arduino or Raspberry Pi to control two 32x32 LED matrices as sold on the Adafruit website? Here is a tutorial where you can wire the 32x32 matrix. Ideally, I'd like to be able to control them separately, but if the wiring only allows simultaneous control of the two, then that is ok. Than you for your time. AI: These panels inherently need A LOT of refreshing, due to their design. It's going to kill the Arduino if you want to do a lot of colors, especially if you'd like to chain these panels. I wrote up a fairly generic explanation on how the 16x32 display works, and you can extrapolate that to the 32x32 panel, which basically just adds another address line. Basically, you can drive a panel as big as you want as long as you can parallel up the data, and blip thru the address lines quick enough. This is why Adafruit makes multiple mentions of using an FPGA to drive these displays - they are perfectly suited with fast clocking and parallel data outputs. How the 16x32 RGB Adafruit (and possible others) displays work: This display draws picture information via multiplexing, which basically means updating the rows and columns of the display faster than the eye can process. If updated fast enough, the eye sees a complete picture, without flickering or artifacts. First, the row to update must be selected. On this display, this is done by using a 3-to-8 address decoder (74HC138D). There are three address inputs to the display marked A, B and C. Based on the truth table, you can see only one input is active (low) at a time. Fig 1. 74HC138D truth table You might be wondering how the 8 bits from the decoder can be used to select 16 total rows. The trick used here is to select rows in parallel. For example, when the 1st row (Row 0) is selected, also select the 9th row (Row 8). Using this technique implies that we must supply data for the columns for two unique rows at a time. (More on this later) The outputs of the decoder can only handle low currents and cannot drive a row of LEDs directly. To remedy this, a P-Channel MOSFET is used as a switch, providing us the high current we need to drive a row of LEDs. You can see that the decoder outputs are shared between every 8 outputs (0 and 8, 1 and 9, repeating that pattern until row 7 and 15) Fig 2. 74HC138D schematic showing output MOSFETs Now that we have our rows sorted out, we need to store the column data. The column data is stored in a 16-bit serial-in, parallel-out shift register. Since the display is 32 pixels wide, two shift registers must be chained together. The shift register is designed to work with LEDs and implements a constant-current system that ensures the LED brightness remains uniform. There are 12 of these shift registers on the display. 3 each are used to hold the Red, Green, and Blue data for 1 of 4 quadrants of the display. (3 colors * 4 quadrants = 12 chips) Fig 3. 16x32 RGB LED display grid, showing the 4 quadrants Where do the quadrants come from? Recall our method for drawing 16 rows using the 8 outputs of the decoder, and how it implies we must have unique data for each row pair. When Row 0 and Row 8 are selected, we must provide each row with unique data. This forces us to use two different shift registers for each row pair, an upper register and a lower register. Because of this, the display is divided into an upper half and a lower half. The data is shifted into the top half via the R1, G1 and B1 signals on the connector. The bottom half’s data is supplied by the R2, G2 and B2 signals on the connector. Then, since our display is 32 pixels wide, we must use 2 shift registers to hold all 32 bits of pixel data for a single row. This creates the left and right halves of the display. (Of course, I am talking about a single color for simplicity’s sake – each color has its own shift register, so we actually need 6 shift registers for a single row.) You will notice that if we wanted to have a shift register for each row, that would require 16 rows * 2 halves of the display = 32 shift registers, just for one color! You would need 96 shift registers for all colors if you used one per row. Obviously this is very unfeasible, on both design and cost fronts. To remedy this, we basically go back to the multiplexing idea – if we do it fast enough, the display will appear seamless to the eye. Each quadrant of the display is controlled by 3 shift registers, one for each color. First, Row 0 and Row 8 are selected. 32 bits of data are shifted into each color’s shift register (R1, G1, B1), and then latched. At the same time, 32 bits of data are also shifted into each color’s shift register for the bottom half (R2, G2, B2), and then latched. The process repeats 7 more times, each time incrementing which rows are selected, until every line has been updated. Fig 4. Diagram indicating the operation of the shift registers. Each quadrant is controlled by 3 shift registers – one for each color R,G,B. These displays are described as having a “1:8 scan rate” and now you can see that it takes 8 very quick updates to draw 1 screen of data.
H: Graphics LCD - how to avoid flicker? I have a generic question about Graphic LCDs with built-in controllers and RAM. I observe that whenever I change a large portion of the screen with say a new image or a object (or just clear the whole screen with a new color), there is a noticeable flicker. Is there any way to avoid this? I am using the 8080 mode to update the display controller's RAM. The problem occurs because the refresh rate of the LCD is faster than the speed that I am writing into the diaplay's RAM. I imagine that it should be easy to do if there were an option to update only the RAM of the controller (while the LCD panel retains the old display) until I set a bit to tell the controller that RAM update is complete. Once that's set the controller should output the contents of the RAM on the physical LCD. Is there any way to achieve something like this? The controllers I am referring to are of the class of HIMAX 8232 that come built-in to LCDs. AI: While some display controllers cause flicker any time they are written, this particular controller shouldn't have that problem. I would guess you are having flicker because on each update you are writing parts of the display with one value and then rewriting them with another. To avoid flicker, don't do that. Figure out what the correct value should be for each pixel before you write it. If your display consists of various non-overlapping rectangles that could move around, and if you're presently erasing the whole screen and then drawing your rectangular objects, you may be able to improve both performance and appearance by only erasing regions where no objects are supposed to appear; depending upon the application, you may be able to improve performance further by only erasing regions where objects used to exist but have just "disappeared". Addendum Looking at the supplied picture, what is happening is that the display pixels are being written to in one direction (I would guess top-to-bottom), and the display is scanning in another direction (I would guess left to right). This has the effect that the amount of screen data that has been written when the hardware starts scanning a frame is much less than the amount which has been written by the time the hardware scan reaches the right edge. Consequently, the lines which are drawn near the right edge of the screen will have more data drawn on them than the lines near the left. If you draw data onto the screen in a direction perpendicular to the display scan, you will get the type of diagonal lines you observe here. If you draw data linearly in a direction which is parallel to the display scan at a rate which is slower than the scan rate, there will be an observable "tear" each time the display scan overtakes your drawing. If you draw data at a rate which is faster than the scan rate, and do so in a fashion which is synchronized with the display scan, you can avoid having any kind of display artifacting, but I have not observed any color LCDs (and very few monochrome ones) with a CPU interface which would allow a connected CPU to synchronize updates with the display scanning. That's too bad, because such an ability would allow cleaner display updates than are possible otherwise. A nice easy technique which was used in many arcade games designed by Eugene Jarvis in the early 1980's was to have the display scanning process interrupt the processor when the scan hits the middle of the screen and again when it hits the bottom. When the scan hits the middle of the screen, everything above the current scan line may be safely updated without flicker provided the updates happen before the scan reaches the bottom. When the scan hits the bottom, everything below the middle may be updated without flicker, provided the updates happen before the scan reaches the middle. It looks as though this controller chip does provide a function to output a pulse when the scan reaches a specified point ("tearing effect line") but I would conjecture that the output is probably not wired to a pin on the display's connector. I don't know exactly what you're trying to display, but I would suggest that you either work to ensure that any time a pixel is written at all it's written with its "final" color or, failing that, minimize the amount of time between the first and last write to each pixel. For example, if you don't have enough memory to buffer anything externally, you might clear 32 rows of pixels, and then draw everything which should appear in those 32 rows, then clear the next 32 rows, draw everything which should appear there, etc. Addendum 2 If you have a 16-bit data bus which connects to both the display and the SRAM, and if you have at least one address bit coming out of the CPU that doesn't connect to the RAM (e.g. A18), a useful technique would be to connect that extra address bit with some logic so that any read or write access will be handled by the SRAM as normal, but if that bit is "1" it will also hit the "write data" strobe on the display. If you do that, reading a word of RAM at its normal address will behave as it normally would, but adding 0x00040000 (assuming you use A18) to the address and then performing the read would cause that word of data to be sent directly from RAM to the display (the processor would also read the data, but it wouldn't have to do anything with it). If you don't have an extra address bit available, there are other techniques you could use instead, but I'd have to know more about your hardware to know what to recommend.
H: Using an LM34 temp sensor, how can I limit the range of temperatures? Over the next two weeks, I'm going to be building a greenhouse fan system. It's not for a real greenhouse, though. It's just for fun. Anyway, my plan is to use the Dragon12+ board that I have, an LM34 temperature sensor, and a little 5V fan. My goal is to read the temperature, convert it with the A to D converter, calculate the actual temperature from the values in the conversion registers, display it on the onboard LCD, and when the temperature reaches 85F, turn on the fan. Once the temperature gets back down to 80F, the fan would turn back off. So, really, the only temperatures I care about are from about 70-90F (Giving some extra room on both sides of the scale). How could I build a circuit to limit the temperatures that the sensor reads? Would it be better to just implement it on the software side? My problem is that the A to D converter is 10 bits, so the resolution is (roughly) 5mV (5 volts over 1024 bits), and the sensor increases 10mV/degree. I know that it should be fine in theory, but will such a small step size of the sensor be a problem? AI: You don't limit what the sensor sees. The sensor reports what it sees. Your question is kind of like asking "I'm only interested in hot women. How can I adjust my eyes to not see ugly women?" You have no control over what the sensor sees. Similarly, the ADC resolution (and sensor accuracy/resolution) will determine how fine-grained your temperature readings are, and how accurate they are. Generally this is never an issue unless you are specifically trying to save code or data space by looking only at 8 bits, for instance. Even in that case, you can always just read the upper 8 bits of the ADC (effectively making it an 8-bit ADC). If you really feel you need to limit the range coming into the ADC, you can use an op-amp to shift and amplify the sensor signal so that 70-90 fits into 0-5 instead of the normal -55-150, but that's almost always not what you want to do because it's actually quite difficult to scale analog values without introducing noise or offsets. It sounds like what you're after is something like this: main_loop() { while(1) { int temp; temp = read_temp(); if (temp >= 85) { turn_fan_on(); } else if (temp <= 80) { turn_fan_off(); } }; } You should add some code in there to only process that loop every second or so, and maybe check for out of range values to trigger an LED or something so you are informed when the sensor is detecting a bad condition. Maybe another check which reports a probable fan failure if the temp is above 95? Sounds like a fun little project to get started with these concepts. Good luck!
H: avr attiny84: wrong delay I'm pretty new to avr programming. I'm facing a strange problem that I can't solve so far. I've wrote a simple code: #include <avr/io.h> #include <util/delay.h> int main(void) { DDRA = 0XFF; for (;;){ PORTA = 0xFF; _delay_ms(1000); PORTA = 0x00; _delay_ms(1000); } return 0x00; } I'm setting the F_CPU (the value used by _delay_ms() ) trough the Makefile I'm using to compile and upload the code: DEVICE = attiny84 CLOCK = 20000000 PROGRAMMER = -c usbasp -P /dev/tty.usb* -b 19200 OBJECTS = main.o dallas_one_wire.o FUSES = -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m ###################################################################### ###################################################################### # Tune the lines below only if you know what you are doing: AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) COMPILE = avr-g++ -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) # symbolic targets: all: main.hex .c.o: $(COMPILE) -c $< -o $@ .S.o: $(COMPILE) -x assembler-with-cpp -c $< -o $@ # "-x assembler-with-cpp" should not be necessary since this is the default # file type for the .S (with capital S) extension. However, upper case # characters are not always preserved on Windows. To ensure WinAVR # compatibility define the file type manually. .c.s: $(COMPILE) -S $< -o $@ flash: all $(AVRDUDE) -U flash:w:main.hex:i fuse: $(AVRDUDE) $(FUSES) install: flash fuse # if you use a bootloader, change the command below appropriately: load: all bootloadHID main.hex clean: rm -f main.hex main.elf $(OBJECTS) # file targets: main.elf: $(OBJECTS) $(COMPILE) -o main.elf $(OBJECTS) main.hex: main.elf rm -f main.hex avr-objcopy -j .text -j .data -O ihex main.elf main.hex # If you have an EEPROM section, you must also create a hex file for the # EEPROM and add it to the "flash" target. # Targets for code debugging and analysis: disasm: main.elf avr-objdump -d main.elf cpp: $(COMPILE) -E main.c Regarding the attiny84's data sheet, it should run at 20Mhz under 5 volts. Unfortunately the led isn't blinking at a rate of 1 every second but somewhat really longer around a 10 secs rate. By tuning the F_CPU value, I've reached the 1 second blinking rate by using F_CPU = 1000000 (1Mhz) Does that means that the attiny84 is running a 1Mhz or am I wrong somewhere else ? AI: Assumption: You are driving the ATTiny84 with its internal RC clock. In order to have the ATTiny84 running at 20 MHz, the microcontroller will need to be provided an external 20 MHz clock, typically achieved by a 20.0 MHz crystal or resonator and two load capacitors. From the datasheet: Also, you will have to set the fuses appropriately for the microcontroller to use an external oscillator instead of the internal one. You can calculate the fuse setting bits you need for external crystal, by selecting the specific AVR here. Additional useful information in this answer to a related question on this site.
H: Software suggestions for electronic simulations? I am a beginner in EE engineering and want to use a software where I can analyze signals or even motor speeds, power electronics ect. But the Spice programs looks so boring and detailed for me. Maybe it is because I'm new. Is there an interactive easier software where I can for example feel like I am really using an oscilloscope on the screen? I would appreciate your suggestions. AI: Renan hit most of the big ones. I like to use this site when I want to throw together a quick circuit. It lets you see the scope in real time and is pretty intuitive, not to mention web based. However, it's no substitute for a real simulation package. This question has (kind of) been asked before, you could see if this question has any that suit your fancy: Good tools for drawing schematics
H: Controling a regular residential 110V/15A circuit switch (or relay) from a PC I am a software engineer by trade and also a rather skilled and well rounded (residential) builder with a special interest in wiring. I have rewired my entire two-unit house, panels included and seen it all. In the course of home remodelling, I was wishing to be able to control every single electric control on every circuit in my house remotely using an Android app. To make that possible, I would need every single switch/thermostat to be upgraded into a relay and have cat5 cable run alongside every Romex cable to each control on one side and into a PC (or some other cheaper form of a CPU hosting device with a modem) which has a static IP online, on the other side. Of course, that is a huge project, whose biggest parts would be making relays that can be controlled from a PC and writing software to control it all, web services, mobile app etc. So the first step in R&D would be to actually make something like that -- unless, of course, it exists already. Is it possible to buy a relay that, on one side controls a regular 110V residential circuit, and on the other can be flipped using a PC? A residential feature like this could be used to, e.g. report and control temperature at home remotely, turn the heat on 30 min before arriving home etc. You could even mount a web cam and watch your pets remotely. AI: There are a number of home automation solutions that may meet your needs. Current technologies include both PowerLine Communication (PLC) and RF. They typically consist of a relay or Triac-based controller that mounts in the place of a traditional light switch. There are appliance modules that plug between outlets and appliances (and some that replace the actual receptacle themselves). There are also PC-based systems that interface via USB and transmit/receive the necessary PLC/RF to support full-duplex communication with each of the individual switch modules. These systems are nice because all of the modules that touch line voltage are ETL recognized (superset of UL). This mitigates the safety and insurance liability aspects of a homebrew solution, though you should still have a qualified electrician install them. I believe there are also thermostat modules in the same line, though I have no experience with them. They're sold under the brand names X-10 and Insteon to name a couple, though there are others.
H: Why do I get a Top Level Design Entity undefined in my VHDL I'm building an 8-bit register from d-type flipflops in VHDL for a lab exercise but I can't seem to diagnose a problem. Firstly I can't get it to compile because of the difference in types for the input clock. My project is called eightBitRegister so its not because my definition uses a different name. So if I change this to the correct type I get the error: Error: Top-level design entity "eightBitRegister" is undefined The VHDL when this occurs looks like: LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY eigthBitRegister IS PORT ( Clock: in BIT; Data: in BIT ; Q: out BIT) ; END eigthBitRegister ; ARCHITECTURE Behaviour OF eigthBitRegister IS COMPONENT flipflop is PORT ( D: in BIT ; Clock: in BIT; Q: out BIT) ; END COMPONENT; SIGNAL QOut: BIT_VECTOR(7 downto 0); begin Stages: for i in 7 downto 0 generate LowBit: if i = 0 generate ff:flipflop PORT MAP(Data, Clock, QOut(0)); end generate; OtherBits: if i /= 0 generate ff:flipflop PORT MAP(QOut(i-1), Clock, QOut(i)); end generate; end generate; Q <= QOut(7); END; However if I change it to this: LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY eigthBitRegister IS PORT ( Clock: in STD_LOGIC; Data: in BIT ; Q: out BIT) ; END eigthBitRegister ; ARCHITECTURE Behaviour OF eigthBitRegister IS COMPONENT flipflop is PORT ( D: in BIT ; Clock, Q: out BIT) ; END COMPONENT; SIGNAL QOut: BIT_VECTOR(7 downto 0); begin Stages: for i in 7 downto 0 generate LowBit: if i = 0 generate ff:flipflop PORT MAP(Data, Clock, QOut(0)); end generate; OtherBits: if i /= 0 generate ff:flipflop PORT MAP(QOut(i-1), Clock, QOut(i)); end generate; end generate; Q <= QOut(7); END; It can find the top-level identity and get the error: Error (10476): VHDL error at eightBitRegister.vhd(22): type of identifier "Clock" does not agree with its usage as "bit" type So whats going wrong? AI: Your error says: eightBitRegister, but your code says: eigthBitRegister. ( ht vs th ) So you are probably trying to instantiate an entity that does not exist as spelled. The second error is just a type error you introduced (bit vs std_logic), but the entity has not been found yet either, the compiler is just now stopping at this new error, before it gets a chance to get to the other one.
H: Arduino and Backup Battery Power I have a very simple project that is working off of an external "wall wart" power supply and I would like to add a back up battery in case of power failure. I have breadboarded a backup power supply with two DC barrel jacks and 2 diodes and it works, supplying the higher of the two voltages. My question is: do I have to use this circuitry to connect to Vin, ignoring the already in place barrel jack on the Arduino board; or can I eliminate the second of my barrel jacks and diodes and rely on the on-board jack for the wall power and simply take the batteries voltage through my extra jack and diode and then into Vin? I.e., can the Arduino handle power supplies from the on-board jack and Vin simultaneously -- switching back and forth as needed -- or will it just use Vin if it detects an input there? The Arduino docs don't say this specifically and the question Arduino backup power supply seems to indicate that this is the case, but I just want to ask the question simply and decisively. AI: If you look at the Arduino Uno v3 schematic, you'll see that the onboard jack has a series diode between it and VIN. If you've got a series diode between your battery backup and VIN, then you are replicating the dual-diode configuration that you're already using...you'd just be leveraging one of the diodes on the Arduino PCA. Note that this doesn't address charging of your battery, but it doesn't sound like that's addressed in your current arrangement, either.
H: I2C Communication Speed across Sensors I'm curious as to how fast I can communicate between multiple sensors. I have a board with an adxl345 digital accelerometer and an itg3200 3-axis MEMS gyro on I2C. I'm trying to build an IMU which requires fast polling of both sensors. The faster I try to poll, the more error codes I get. How can I calculate the optimal delay required for simultaneous communication? Also how fast can I2C really communicate between multiple sensors? PS. Im on an atmega128 chip @16MHz. AI: \$I^2C\$ is a clocked serial protocol, which in general means that there is very little which limits the speed electrically. Most \$I^2C\$ busses run at 100kHz or 400kHz, which will far outstrip most IMUs' ability to output data. For example, I was on a robotics team which used a Memsense nIMU and if you look at the datasheet, it says that the bandwidth is 50Hz, and it outputs 34 bytes in a packet. This means that you could theoretically pull up to \$50*34*8=13,600\$ bits per second or 13.6 Kbps. The chip we ran with could run up to 400kHz so it could handle quite a few of these on the bus at maximum data throughput. Looking at the datasheet for the atmega128 you provided, it says the "TWI" or two-wire interface is limited to 400kHz. Knowing the \$I^2C\$ protocol, this will be 2 clocks for the start condition, 1 clock for the stop condition, and 9 clocks for the address, and 9 clocks per byte. So using the nIMU I referenced before, this gives a virtual \$34_{bytes}*9_{clocks per byte}+9_{address clocks}+2_{startbit}+1_{stopbit}=318\$ clocks per packet. This means that there was no limit on the sampling rate, we could read \${400,000/318}=1257\$ packets per second. Since we're limited by the sampling to 50 packets per second, we could instead have 25 IMUs sending out data. Looking at the ITG datasheet, you'll need to do some math to calculate exactly the maximum sampling rate, but I think 125Hz looks like a good baseline (see section 8.2). It outputs 3, 16 bit numbers giving 48 bits per sample. \$48*125=6,000\$ bits per second. Well within range of the 400kHz you has access too. With the adxl345 it looks like the maximum data output rate is 3,200 bits per second (I think?). So from the looks of it, the combined maximum throughput of the two devices you've picked is 9,200 bits per second, and the atmega128 has a throughput of ~400,000 bits per second. I don't think you need to worry about the ability of \$I^2C\$ bogging down the system.
H: PIC18F2550 or PIC18F13K50? The PIC18F13K50 is a lot cheaper than the PIC18F2550...but it seams to be smaller, newer, same speed, just has less RAM. Why is it cheaper? Just because it is a new one and Microchip dont like to produce the older ones, or because it has less RAM? AI: The PIC18F13K50 is just newer, and is intended as replacement for the '2550 series. feature-wise, they are more or less on par, except for the different RAM size. I presume that the 13K50 is easier to manufacture, since it is the newer part, and comes in a smaller package (20 vs. 28 pins). But it might also be that this pricing is intentional to phase out the older parts - Microchip seems to streamline its MCU series.
H: How to build a SoC computer? I've found my self very interested on Raspberry Pi. Although, I think it's not powerful enough for my project, so I was wondering how could I build a more powerful SoC computer, with a bigger board, more RAM memory and an ARM chip as powerful as current tablets and smartphones. Is that possible? Do they sell those chips to normal people? How can I build a SoC computer? AI: It's certainly possible - the Raspberry Pi team were self-funded, and did the design themselves. However it is neither cheap nor easy to do it yourself. 1) Cost is much greater for small production volumes. Getting 1 SoC computer PCB made might cost you $100. 2) Not all the chips are available to the public, especially the more cutting-edge ones. The normal purchasing process for the Broadcom chip used in the Pi involves buying thousands. The "stacked RAM" process used isn't friendly to small volumes either. 3) If you think the Raspberry Pi doesn't have enough computing power, you may be misunderstanding your project (you haven't said what it is).
H: Burnt AC Bulb Failover I have a 60W, 120 VAC incandecent bulb used as a heater. Today it burned out and resulted in a water system freezing. I would like to be able to hook up a spare bulb that can come on if the first bulb goes out, or some similar system of redundancy. Unfortunately I work with DC more than AC, so I'm not sure how I can do this. Is there some easy way (a relay or something) that I could use to detect when bulb goes out? AI: Rather than "backing up" one unreliable component with another one, why not just replace the lamp with a 240Ω, 100-W power resistor attached to a heatsink? It will be much more reliable in the first place, and will also reduce the risk of starting a fire, since its operating temperature will be much lower.
H: exact copy of amplifier stages My stage 1 amplifier alone is perfectly bias and the q point is in the middle of the load line. The collector voltage is around at the middle of the supply voltage (to be precise, around 24 volts and supply voltage is at 48 volts). Now when we add another exact copy of stage 1 and attached it to stage 1, the q point of the stage 2 suddenly misaligned from the middle point of the load line (it went from 24 volts to 11 volts). Why is that so? It should be that the original bias condition and q point must be inherited since both stages are exact copies of each other (like identical twins) which results to severe distortion AI: The Q point is the quiescent point, i.e., the operating currents and voltages when no signal is present. A simulator should give you the DC solution for the circuit. Check that to see if the collector voltages are equal. Or, zero the signal source and check your collector voltages. They should be the same. If they aren't, check your net list for an error. When there are large signals present, the DC (time average) voltage on the collector can be very different from the Q point voltage due to non-linearity, clipping, etc. UPDATE: Re the bias network others are pointing out, in a previous post, I provided you with an equation for the bias current and we specifically talked about bias stability against variations in beta. Let's check your circuit against that. Recall the equation: \$I_C = \dfrac{V_{BB} - V_{BE}}{\frac{R_{BB}}{\beta}+\frac{R_{e}}{\alpha}}\$ The key for stability is to have the right most term in the denominator much larger than the leftmost term. According to your schematic: \$R_{BB}= 28k \Omega \$ So, the leftmost term is: \$\dfrac{28k \Omega}{200} = 140 \Omega \$ But the rightmost term is just about 82 ohms when it should at least 1400 ohms for a roughly 10% variance of DC collector current due to variations in transistor beta. A simple partial fix is to try using 43k and 3k in your divider circuit. You've been given the tools to use so use them!
H: TCP/IP stack in Verilog I am about to write a TCP/IP stack in Verilog. I would have thought this was a relatively common thing, and that implementations would readily be available online. The obvious Google search for a TCP/IP implementation in Verilog does not point to many solutions. Are there ready and tested TPC/IP implementations written in Verilog for FPGAs? AI: They exist, but aren't likely to be free. Typically a processor handles TCP/IP. It may get a hardware assist from hardware, for example the checksum. An example of a non-free one is from Hitech Global. It is available in Verilog or netlist. Comblock has one too, but in VHDL, not Verilog.
H: Sampling a signal in Matlab I have the next signal $$x_1[n]= 1 \ |n|\leq N_1; \ 0 \ otherwise$$. Now I am given some points of sampling of the frequency of the fourier transform of the above signal. \$\omega_0 =\frac{2\pi}{5}\$, and \$\omega=k\omega_0\$ for \$k=-2,-1,0,1,2\$. Now I am defining a periodic signal \$x_2[n]\$, which is given by: $$x_2[n]=\sum_{k=-2}^{2} a_k e^{jk 2\pi n /5}$$ Where \$a_k\$ is given by the synthesis formula: $$a_k=\frac{1}{5} \sum_{-2}^{2} x_1[n] \exp(-jk\frac{2\pi}{5}n)$$ I want to plot \$x_2[n]\$ in the \$n\$ space, but I don't want to calculate the \$a_k\$'s by hand, is there a way to do this by matlab, I mean without writing the full expression in paper and then typing it in matlab? Is there such functionality? Thanks in advance. AI: What you have appears to be a Fourier series pair, over a very small number of samples. Probably, by looking at the definition of the Fourier series (which may be different depending on the conventions you choose), and maybe a table of results in a mathematical handbook, you can solve this by inspection. I'll call \$x_2[n]\$ the "time domain" signal and a[k] the "frequency domain" signal. For example, when \$N_1 \ge 2\$ then you have a pure complex exponential in the frequency domain. Therefore you know you'll have a delta-function in the time domain. If you considered the case \$N_1 = 0\$, you'd have a delta function in the frequency domain and you'd get a pure complex exponential in the time domain. The case \$N_1=1\$ is slightly more complicated -- that gives a complex exponential windowed by a boxcar in the frequency domain. So you know you have a sinc() (possibly offset in time) in the time domain. But your concern about the effort involved in "writing the full expression in paper" indicates you already know how to solve the problem and you are hoping there is a shortcut or easier solution. To me, working out these Fourier relationships on paper (carefully enough to be sure of the answer) would probably be more effort than just doing the calculation in Matlab.
H: Change output depending on State in VHDL My output has to be high if my state is either F or H, i've written this: z <= '1' WHEN y = (F OR H) ELSE '0' ; But this doesn't work. I've also tried writing it like: IF y = F THEN z <= '1' ; ELSIF y = H THEN z <= '1' ; ELSE z <= '0'; END IF ; But now get Error 10500 in Quartus 2 so whats wrong with my syntax or is there a better way to write it? AI: My best guess given so little information, like what "not working" means... F and H are of some type that does not have boolean operators defined on it; therefore (F or H) is meaningless. Now ... Y = F is a boolean expression, so is Y = H so you can say z <= '1' WHEN (y = F) OR (y = H) ELSE '0' ; and (assuming this is outside a process) it might do what you expect (assuming Y, F,H are the same or compatible type) The second form will also work, but only as part of a process...
H: Pulse Plethysmograph Help I have a question about the following Pulse Plethysmograph Diagram: This diagram was taken from the project page. But that website explicitly states: Components are not critical but the two 2.2 µF capacitors must be able to stand some reverse bias so they should be non–polarized or tantalum. My question is: Should I use non-polarized or polarized 2.2uF capacitors? (The diagram and the above description seem to contradict themselves), How about the 68nF ones? AI: Polarized capacitors can handle about 10% of the rated voltage in the reverse direction. Tantalum tend to have lower Series resistance such as 10 ohms in this small value in a small size. Since the capacitor has a high impedance load (47K in parallel with + OpAmp) any capacitor will work. use any Ceramic, alum, tantalum and may vary in price from 10 cents and up. /1pc) choose a voltage rating >2x what you need for margin. e.g. The smaller caps can be ceramic. If you want to prevent minor reverse leakage of a polarized cap in this circuit, the + side would be on the input which is pulled up to 6V than it sees - 1V across it when the optotransistor clamps to 0.3V while the two diodes are 1.3V. The design is not optimal, but should be enough to drive a small LED and pulse with the heart rate. ( eg RED LED and 470~ 1K ohm ) Editorial note: I agree the comments are confusing considering no polarity given and actually irrelevant since ESR is not important so it reflects a weak design skills. Also the IRT photo-transistor does not have a dark daylight blocking filter tint, so the design will be sensitive to flicker of bright 120Hz fluorescent lights. I would suggest a different part in surface mount or thru hole. You can use any IR LED that comes in remote controllers. The 6V battery may drain quickly and need a switch and perhaps a large cap across to suppress ripple that the weak battery may create. This improved design uses reflective light rather than transmissive IR light. It uses photo diodes instead of transistors so no pot is needed as the tolerances are much tighter. Same gain and filter is used but different values. It uses operational amplifier MCP602 which operates rail to rail without bias diodes and can run on 6V easily or 5V if you prefer. In any case, the leads must be short or else you must use ferrite choke around the twisted pair to suppress 60Hz hum interference on the detector & the hand acts as an antenna to this signal. **
H: How to hand drill PCBs? Drilling 300 holes in fibre board is tedious, difficult to do neatly and prone to snap bits. What simple methods and tools are available to the home user to drill PCBs effectively? In my case it's only going to be used occasionally and then on a kitchen table. Apparently a Dremel won't be accurate enough. AI: If you're looking for a drill press for this purpose, remember that the smallest drill bit sizes require the highest spindle speeds, a general purpose drill press won't run fast enough to be ideal. It'll work for a few boards if you're patient and have enough drill bits. This little one from Proxxon and some carbide bits would be a step in the right direction with 8500rpm top speed, but below 1mm even faster would be better. Just to clarify I'm not endorsing this specific model (though it looks OK), but it's an example of what you're looking for.
H: What would be the cheapest way to get video signal? I have an OSD that I would fiddle around with till I'll get new camera. For OSD to work, I need PAL video signal, it may be anything, like black only. I was thinking may be test video signal generator would help, but those things are way too expensive for such task, may be it is possible to make something simple using arduino? I don't have any analog video source at home, like VCR, my notebook does not provide S-Video. AI: You can use an Arduino to output NTSC/PAL Video. See: http://code.google.com/p/arduino-tvout/ I have used this and it does work, easy to set up too.
H: Is there a way of telling if the connector is male or female on a schematic? For example, in the RS232 here: or here: AI: No. Different people draw schematics differently. Sometimes it is obvious, but usually not. In the examples you gave, it is not obvious. When it is marked, it is usually a text note next to the connector. Or sometimes it is in the part number, like "DB-9F" for a female connector.
H: Solving a transistor circuit and determine the base current I need to determine the base current of the circuit I have attached below. Given: current amplification \$B = 500\$ \$U_{CC} = 12V\$ \$U_{BE} = 0.7V\$ \$R_C = 3.2k \Omega\$ \$R_E = 9k \Omega\$ \$R_1 = 47 \Omega\$ \$R_2 = 19 \Omega\$ What we need to get: base current \$I_B\$ in $\mu A$ (2 decimals) My attempt: (feel free to correct me if I use the wrong vocabulary to describe my attempt, thank you!) At first I introduced a new current \$I_q\$ which flows through \$R_2\$. Having that done I know that \$I_q = \frac {U_{BE}}{R_2}\$. Since \$U_{BE} = 0.7V\$ and \$R_2 = 19 \Omega\$ are given I calculated the value for \$I_q \approx 0.03684210526A\$. Now I looked at the top left part of the circuit. We know that \$R_1\$ must be \$R_1 = \frac {U_{CC} - U_{BE}}{I_q + I_b}\$. Well solve the equation for \$I_b\$. We then receive \$I_b = \frac {U_{CC} - U_{BE}}{R1} - I_q\$. If we fill the equation with the given values and \$I_q\$ we get: \$I_b = \frac {12V - 0.7V}{47} - 0.03684210526 = 0.2035834267A\$. Now we need to convert \$I_B\$ to \$\mu A\$ which should be \$203583,43 \mu A\$ (rounded). AI: At first I introduced a new current Iq which flows through R2. Having that done I know that Iq=UBE/R2. This is incorrect; the voltage across R2 is \$U_{BE} + I_E R_E\$ Also, I suspect that the values of R1 and R2 should be in \$k\Omega\$ and the value of \$R_E\$ is suspiciously high. Regardless, there's a step by step approach to finding \$I_B\$. Form the Thevenin equivalent circuit looking out of the base: \$U_{BB} = U_{CC} \dfrac{R_2}{R_1 + R_2}\$ \$R_{BB} = R_1 || R_2\$ Now, write the KVL equation around the base-emitter loop: \$U_{BB} = I_B R_{BB} + U_{BE} + I_E R_E\$ Using the relationship: \$I_E = (\beta + 1) I_B\$ Substitute and solve: \$I_B = \dfrac{U_{BB} - U_{BE}}{R_{BB} + (\beta + 1)R_E}\$ You can ignore this if you like, but you ought to, before turning in or publishing an answer, do a sanity check to make sure that, on the face of it, your answer isn't hopelessly, impossibly wrong. For example, consider the answer you give for the base current and the implication of it. If the base current were 0.2A, as you've calculated, the emitter current, which is 501 times the base current, would be an enormous 102A. It's always good to do a sanity check on your answer. Even if \$U_{CE}\$ were zero, the emitter current could not be any larger than: \$I_{E_{max}} = \dfrac{U_{CC}}{R_C + R_E} = 984\mu A\$ This places an upper bound on the base current which is: \$I_{B_{max}}= \dfrac{I_{E_{max}}}{\beta + 1} = 1.96\mu A\$ So, by making a very quick calculation, you have a good sanity check for any answer you may come up with.
H: Storing An Led's Previous state when power is removed with eeprom now A while ago I asked a question about having 2 push buttons, and an LED and you set the led to an on or off state with the two buttons, and then remove the power, and when turned back on, the led should stay in the state that was set when the power is on. I realized that I couldn't do it with any of the components that I had, and the best solution was a mechanical 2 button switch. Now I have the 24c00 EEPROM chip, 40 and gates, 40 or gates, 60 inverters (not gates), a few 555 timers, 4 NAND gates, an 4 NOR gates (I am not counting the amount of chips, just the total amount of gates). So now with EEPROM, I know that with its floating gate MOSFETS, it can store electrons by tunneling, so I am wondering if there is a way to store an led's previous state with these components. AI: With the components that you have listed, you will not be able to build a system that will remember the state of a LED after power-off. The EEPROM that you listed can hold a value without any power, but the problem is that it has a (relatively) complex input/output protocol (I2C) compared to the other parts you have on hand. I think you will find that there are very few methods for storing data that are both persistent while power is removed, and electrically simple enough that you could build it with the parts you have. Given your requirements, a toggle switch is still probably the simplest method for storing a state, followed by some arrangement of latching relays. If you wanted to store the LED state on the EEPROM you purchased, then the easiest way to interface with that device is to use a microcontroller. For example, you could get Texas Instrument's Launchpad board for around $5. But, many microcontrollers have built-in storage that would be more than adequate for storing the state of a LED. You could "fake" your requirements by making a small, 1-bit memory cell (SR-Latch) and powering just the latch with a coin-cell battery. When you remove power, you would then only remove the power to the LED, not the SR latch, and this could last a long time. You would need to use low-current parts (CMOS), but this would be a very easy method as well.
H: Cloverleaf possibly blew out transmitter? I went ahead and built a Cloverleaf antenna, right-hand polarized, for a video transmitter, transmitting @ 1280MHz and 800mW. After about a week, however, the transmitter stopped transmitting. I'm wondering if it's possible that the cloverleaf "overloaded" it somehow? I made it with rather thick, 18AWG wire. From the shield to the pin on the connector, I measure 8 Ohms resistance. If it helps, I'm using a RangeVideo transmitter. Is this a possibility? My only other option is that the antenna broke off in a quadrotor crash, leading to the "no antenna = letting the magic smoke out" situation that the manufacturer warns of, however, I don't remember this happening... Secondly, is there any way to test if my antenna is built "correctly" (whatever that may mean, I'm new to radio transmission and reception) without expensive test equipment? Thanks! AI: It's possible that the transmitter was damaged by reflected power from a poorly matched antenna. That's the scenario the manufacturer is warning about with running the transmitter with no antenna. Without a well-matched load on the transmitter output, the RF power reflects from wherever the discontinuity is and back into the output of the amplifier. This can cause the amplifier to operate incorrectly or even destroy it. Antennas look simple, but there's a lot going on electrically, and matching an antenna's impedance to the system impedance at the operating frequency can be a bit of a challenge. Although impedance is measured in Ohms, it is not a resistance, and can't be measured with a DMM. Instead, impedance is the relationship between voltage and current through a circuit, and it depends not only on the resistances in the circuit, but also the capacitances, inducatances, and the measurement frequency. An RF network analyzer could do the job, but those instruments are indeed quite expensive. You may be able to make friends with someone who has access to one and could help you tune your antenna. For an idea of what's involved, read The Dropout's Guide to PCB Trace Antenna Design. Amateur radio operators use SWR meters to measure the ratio of the power going towards the antenna to the power reflecting back from it, and make adjustments to minimize the reflected power. While those SWR meters aren't extremely expensive, they are designed for much lower frequencies than 2.4 Ghz, and it is useless to match an antenna at a frequency other than its operating frequency. I've never seen an SWR meter in the microwave range that could reasonably be bought or built by the casual hobbyist. Other options: Buy an antenna that's already well-matched Buy a transmitter that is more robust against poorly matched loads.
H: What application do you use for plots? What application do you use for creating plots? Years ago, I was using gnuplot and then matplotlib (which is just Python library). But none of those were perfect. For example, I was unable to create Smith chart in gnuplot or two Y axes in one plot. And matplotlib is too unfriendly, everything takes hours of reading documentation (but result is very nice and professional). So is there any other good application for electronic engineers? GUI or CLI. Note: I am using Mac/Linux and I do not have Matlab license. AI: My favourite free maths software is Scilab - it's numerical and matrix based like Matlab, so if you know Matlab you should have little trouble getting started with it. It has a thing called Xcos which is like Simulink, and various modules you can add on. The downside is the documentation is pretty rubbish, but there are plenty of tutorials out there if you do some Googling. Plotting is done with Gnuplot plus another option I can't remember the name of. It supports Latex, and can convert (Matlab) M files to Scilab scripts. Smith chart in scilab (very basic version) More examples of plotting in Scilab (vector, contour, bode, 3d, etc) On the CAS side, I love Maxima (the wxMaxima version), it's great to use side by side with Scilab (or Matlab) Even though you can do symbolic stuff in Matlab/Scilab, it's so much faster in Maxima, and all the output is in Latex/Mathjax format, so stuff looks nice. It's workbook format, so you can add titles, section headers, and embed your plots (or other images) into the workbook too. Example of ODE direction field plot in Maxima, with slider so you can adjust the amount of drag (the plot is of a free falling object m=10kg, drag = 2kg/s) Euler is worth looking at too, and if you are on linux there is Sage, which is gathering quite a reputation (I'm on windows so it's too much of a pain to use a VM, although I tried it and liked the look of it, but I have all I need with the above mentioned tools)
H: Single floating gate transistor On a previous question I just asked it was about storing an led's previous state with the eeprom. Without a microcontroller, it seemed not possible, so now Im asking if you can buy single floating gate transistors anywhere, because I have searched, and nothing showed up. Do they even make this? AI: Buy a normal FET, leave the gate unconnected. You now have a floating gate transistor :) Less flippantly, this is actually one of the answers suggested to your previous question: connect a capacitor to the gate of a FET with some way of charging and discharging it. If you design the circuit to minimise the current leakage off the capacitor and use a large capacitor, you can store a bit for a long time.
H: How do I decople a microcontroller with odd number of ground pins? I'm building a DIP adapter board for MSP430FR5739 and I want to include the decoupling capacitors on the adapter board itself. From what I can see, I'll need a capacitor on the analogue and digital ground pairs plus one on the Vcore pin whose other side I'd connect to DVSS. This leaves me wondering what to do with pin number 38, the second AVSS pin. What would be the best way to decouple it? AI: The intent here is probably to allow a low noise ground region around the crystal oscillator, so run AVSS from pin 3 to 38 and right round any components connected to Xin/Xout in a full loop (aka a guard ring) if you aren't using a full ground plane. And of course it must be joined to DVss somewhere... preferably in just one place to avoid loops, perhaps under the chip to pin 33. You need a cap from AVCC to AVSS as close to pins 3 and 4 as possible, there is no need for one close to pin 38 but there should be a large (47uf) cap on AVcc to AVss somewhere (ditto for DVcc,DVss)
H: Verilog: Escape non-printable characters in string initialisation I am trying to escape non-printable characters in string initialisations in Verilog. In C, one can escape non-printable characters as described here. In Verilog, there is an escape mechanism, but strangely seemingly only for printable characters: 2.7.1 Escaped identifiers Escaped identifiers shall start with the backslash character (\) and end with white space (space, tab, newline). They provide a means of including any of the printable ASCII characters in an identifier (the decimal values 33 through 126, or 21 through 7E in hexadecimal). Neither the leading backslash character nor the terminating white space is considered to be part of the identifier. Therefore, an escaped identifier \cpu3 is treated the same as a nonescaped identifier cpu3. Can I escape non-printable characters in string initialisations in Verilog? I'm looking to do something like: reg [6 * 8 - 1:0] test = "Hello\x01"; // Here, \x01 would be replaced by the SOH non-printable ASCII character AI: The section you quoted refers to identifiers, so you can have a named item with non-word characters in: reg [6 * 8 - 1:0] \test"string = {"Hello",8'h01}; Yes, that's a legal identifier; don't do that unless you have to, though. That snippet also shows how a Verilogy way of embedding non-ascii in strings with concatenation. A little experimentation shows that \xnn doesn't work but \nnn (octal) does. This may be tool-dependant.
H: I2C EEPROM with non-standard address? So I know that almost all I2C EEPROM ICs use 0xAh (or 1010) as the top four bits of the slave address. I currently have a 16 kbit EEPROM on my I2C bus that uses the lower 3 bits of the slave address for block addressing. This means that it co-opts all addresses starting with 0xAh. I need to put a second EEPROM on the same bus, but I am having an extremely difficult time finding one that will not conflict with the existing chip (for design reasons, that chip cannot change). A smaller capacity EEPROM is fine, but I can't use any of the myriad 8 kbit/4 kbit/2 kbit devices out there because their slave addresses all start with 0xAh. The only thing I was able to find was this chip from NXP, which uses 0x2h as the top four bits of the slave address. But it does not work in fast mode (400 kHz) and only comes in DIP or SO packages, both of which are much too big. Is there an I2C chip that operates in fast mode, comes in a reasonable package, and, most importantly, uses a slave address not starting with 1010/0xAh? AI: While not specifically the answer to your question, in a similar situation faced on one of our product upgrades, we used a workaround: An identically addressed I2C device needed to be added to the design, but conveniently the parts had Chip-Enable lines. So the design simply added a CE off one of the controller GPIOs - actually we added 2, so that we could potentially stick in 2 more of the parts when inevitably the software team outgrows the additional 100% capacity we've just provided them.
H: Basic Question Regarding Programming in CodeWarrior I have basic knowledge of C++ and MicroControllers. Please Consider the following code excerpt from the header file of MC9s08aw60(freescale), i am working with Codewarrior V5.9. typedef union { byte Byte; struct { byte PTFD0 :1; /* Port F Data Register Bit 0 */ byte PTFD1 :1; /* Port F Data Register Bit 1 */ byte PTFD2 :1; /* Port F Data Register Bit 2 */ byte PTFD3 :1; /* Port F Data Register Bit 3 */ byte PTFD4 :1; /* Port F Data Register Bit 4 */ byte PTFD5 :1; /* Port F Data Register Bit 5 */ byte PTFD6 :1; /* Port F Data Register Bit 6 */ byte PTFD7 :1; /* Port F Data Register Bit 7 */ } Bits; } PTFDSTR; Now, as far as i understand its defined as a struct and an object names "Bits" is also created but when i try to use the object in the CPP file, it shows an error such as: Bits not declared. Classname not specified. ';' missing. Please tell me a simple reason for the same. And if this is not the right forum it,advise about an alternative. Edit: Sorry for the obtuse expectation: this is how i used the code stated above; Bits PTFD0 = 0x00; //considering logic 1 is low. Thanks in Advance. AI: First of all make sure that you are including the header file where the structure is defined in your file. The way to access it would be: PTFDSTR example; // access the byte example.Byte = 0xA5; // access a bit in the byte example.Bits.PTFD5 = 1;
H: Verilog: Break an always block Can I "break" an always blocks in Verilog? I would like to rewrite always @(posedge clk_i or posedge rst_i) begin if(rst_i) begin // Do stuff end else begin // Do stuff end end as follows (which I find cleaner): always @(posedge clk_i or posedge rst_i) begin if(rst_i) begin // Do stuff break; end // Do stuff end AI: Yes, you should name your begin-end block and then use disable statement like this: always @(posedge clk_i or posedge rst_i) begin : block_to_disable if(rst_i) begin // Do stuff disable block_to_disable; end // Do stuff end Though, this is probably non-synthesizable, so you can do such tricks only in simulation (testbenches, etc.).
H: SDRAM chip selection I need to buffer 1.5Gb/s of video data through SDRAM, which works out to be 3Gb/s total in and out combined. This is my thinking so far: Write/read burst length is set to max (16 clock cycles), and CL is 3 clock cycles, that means for every 16 clocks, I need at min another 3. So 19% overhead for just CL between bursts. Changing banks/rows is another 15 clock cycles (RP + WR + RC). The max number of burst writes I can make without changing rows is 64 (according to the Xilinx spartan 6 MCB user guide page 17). This takes 77 clocks (64 writes of 16 bits * 1.19 for CL overhead) and requires an additional 15 clocks for config (or 20%) between rows. 3Gb/s * 1.19 * 1.20 = 4.28 Gb/s. I'm considering clocking a LPDDR device at 166Mhz, which gives 332Mhz for both clock edges. If I use a device with a 16 bit word length, i get 332Mhz * 16 bit = 5.3 Gb/s, within my spec quite comfortably. Perhaps this device? My main question is: Am I on the right track here? This is the first time I've had to design a board containing SDRAM, do these numbers look right? Is there any way I can configure the chip to further minimize the overhead? Is there anything else I need to consider? The last thing I want is to select a device, build the board and then discover that my choice is too small/slow for my application. AI: You can do a little better than this; because burst transfers only use the data paths while in progress, you can overlap bursts with address signal transfers. So you can get ready to transfer the next burst while the current burst is in progress; likewise you can open the next bank and set RAS for it before the current bank's transfer is done. Start the next actual transfer, then come back to precharge this bank. It's more complex, and you'd have to read the Spartan-6 MCB docs in case they don't allow this stuff; I was rolling my own controller when I did this. In any case it sounds like you won't need it, but its nice to know it's there. A bigger problem is that it will want to stop every 8 us and spend a chunk of time generating a refresh pulse (and precharges around it). I could tell it not to in my own core, (until a convenient break, but no longer than 70 us) and later added a similar hack to the Virtex-5 MIG core for this purpose but I don't think you can control refreshes on Spartan-6. So, if this is a problem, you'll need an elastic buffer somewhere to take up the slack.
H: What are the advantages of including mounting holes in a schematic? I've seen some designs which have mounting hole included in the schematic. Are there any good reasons of doing that? I can see one advantage of doing so when you want to connect your mounting holes to some nets (e.g. GND). But what if the holes aren't supposed to be connected to any net? AI: Some people/places like everything to be schematic driven. That way the only changes to the design come from one guy/department. So even though you could add mounting holes in layout and connect them to a net, you put them on the schematic instead. That way you don't have to rely on a note to the layout guy to "add four holes and connect them to GND net". You may also have a bunch of predefined holes and you want to make sure that version gets into your layout. In the case where you are not connecting the holes to any net then you might want to make a mounting hole as a mechanical part (no nets), just so when you push from schematic to layout the mounting holes automatically get pulled in. This is useful not just for board mounting holes but also for say a heat-sink that goes with an IC. Really it's just a way not to forget about them or to make sure the right holes are associated with the part or board. You might make the decision on what holes to use well before you get into layout so why force yourself to remember. Especially when your boss is screaming at you to get it released :)
H: Know any hardware for the PC to act as USB_device? We manufacture electronic devices. Some of them has USB_host functionality. In order to test them for this functionality, we need another device (maybe pseudo device like PC) to act as the USB_device. Currently, we only support MassStorage class devices but we are not comfortable with the idea of inserting a USB memory to our device for Q/C operation. There won't be any feedback to our automation system and we want to be able to test other kind of devices. Is there some kind of hardware that we plug into a PC and with its certain API, that device acts as a USB_device. We will have to implement the needed protocol by utilizing this API and we are OK with this. Any chance ? AI: The Facedancer lets you emulate USB devices with host-side Python code.
H: Verilog: Can I omit the length of a register that is initialised to a string? In Verilog, one can work with strings as follows: reg test [12 * 8 - 1:0] = "Hello world!"; Is there a way to tell the compiler to simply have a reg of the appropriate length similar to C? reg test [] = "Hello world!"; AI: In SystemVerilog, we can simply use the string data type: string hello = "Hello world!" But in Verilog your first line is still the best option: reg test [12 * 8 - 1:0] = "Hello world!"; EDIT: For synthesis, even in SystemVerilog, it is much safer to do something like this: parameter CSIZE = 8; parameter CCOUNT = 80; reg [CCOUNT * CSIZE – 1 : 0] heythere = “Hello, world!”;
H: Can a motor driver for 5V be used for a 24V motor? I’m controlling a 5V motor with Arduino but need more torque which means a more powerful motor. Here is my scheme. (I took it form a tutorial): Here Arduino is controlling a 5V unipolar stepper motor through a Darlington transistor. My question is if I just change this motor with a 24V one and feed the new motor with an external 24V power supply and remain the rest configuration same would the motor still be controlled? Or do I need another configuration? AI: From the datasheet, the UNL2803A has a Vce (sustaining) of 50V. Provided that the max current for your 24V stepper is 500mA or less and you are careful with your grounding, it should work for you. Be sure to only supply the motor and 2803 with +24V (and not the Arduino!). EDIT: Your circuit will look something like this. Note that there is only one place where the 24V return and digital ground are connected together. The 24V wiring will carry more current than the digital wiring; take this into consideration. Also, Richman's comments about power dissipation are spot-on. You'll need to take this into account as you select a motor. (Apologies for the hack diagram)
H: What's the difference between linear and audio tapers, and why should I care? I'm stocking up on a variety of potentiometers to keep on hand for my audio projects, and I'm trying to figure out what to buy. The projects I'm working on seen to call for either linear & audio taper pots. I know the difference between linear and log, but where does audio taper fit into the mix? Here's what I've researched so far: No schematic or parts list has BOTH linear and audio. Looking at the Bourns pot spec sheets, they seem to be using linear and audio taper synonymously, but they have different part numbers. Sites like mouser and digikey often have, say, a 10k linear and a 10k log, but no 10k audio pot in a search. However, when I search on the Bourns part number for an audio taper, the part is described by mouser as linear taper. A lot of audio forums I've been trolling talk about pots as either audio or linear, but they don't appear to be synonymous in the discussions. See why I'm confused? So once and for all...can someone school me on the difference between linear and audio taper? I'm also interested to know how to decide which to choose for a particular application, and if they are different enough to have distinct uses, what types of interesting and unexpected results will I experience if I substitute one for the other? AI: Some rotary Pot's com in Linear, Audio and reverse Audio (where audio=log taper) Actually it is "quasi"-log scale and not precision logarithm. Notice it has a rapid transition from two different linear slopes. which gives you more sensitivity over a wider range of audio inputs rather than an apparent Off to ON effect if using a linear pot. If one adjusts audio equipment over a 30 dB range, that might occur in the 1st 5% of a Linear pot. Such as Many options may be selected when you order. Precision Log pots would be mcuch more expensive than
H: How to remove 20MHz SPI signal noise? I did some SPI software configuration for my DSP board. Then I soldered several missing 0 ohm resistors onto the board so I can tapping the SPI signal from pin headers. Then I measured the SPI Chip Select and SPI Clock signal. To my surprise, there are very large noise in both signals. And the noise is there regardless whether there are SPI transfers. For the Clock signal, the noise is a roughly regular sawtooth shape with a frequency of 20MHz and 1V amplitude, when it should be a constant voltage of 3.3V. What might be the cause of this noise and how to remove it? Thanks. (Edit: I found the noise coming from another chip driving SPI clock line with 20MHz clock. That chip is not using SPI protocol. Instead it's using other duplexing functions so the clock is always there. After disconnecting that chip from contaminating SPI, the signal becomes clear. Thanks for the help of you all, especially @gl3829, @FakeName.) AI: 1V isn't just simple noise, something is really inducing it. Here are the steps I would take to solve it: 1) Take a look at the power supply to the DSP and whatever else is communicating and see whether they have any kind of noise on them. It's likely the noise you see is induced on VCC and this might be going to the DSP I/O. 2) if you have any kind of switching regulator, try and use an LDO and see if it makes a difference 3) Attempt to use a good clean lab power supply to the board if you can 4) Isolate other board parts, turn off everything you don't absolutely need. If the issue disappears, slowly bring up each part until you can nail down what it is that is causing it. 5) Take into account any other strange symptoms. Given the large voltage, it's unlikely that the SPI is the only thing affected. We might be able to help more if you post a schematic and give more details to the parts and whether you have any kind of switching supply
H: Sensory Chess Board Possible Duplicate: Detecting object placement on a grid How could a checkered chess board be built so that it knows the location of the pieces? What options are available? Probably RFID chips? It'd have to be sensitive enough to detect movement from one square to another. Please order the options from cheapest to most expensive to mass produce. Thanks! AI: You have tower, horse, knight, king, queen and pion. That 6 figures in black or white variant give you 12 figures which is a number that can fit in 4 bits. You will need 5 contacts on the bottom of each square. One with constant voltage source (like +5V or +3.3V, depending on your MCU), and four contacts that go into digital inputs of your MCU (probably via some GPIO extender chip). Each figure will then internally electrically connect +V to those 4 pins, making for each figure type a binary unique number that can be read by MCU. Polling these 4 bits in all 64 squares MCU will exactly know what figure is on what square. Everyone is licensed to use this idea for non profit goals. Commercial use of this idea costs 5000 dollars. Your move. ;-)
H: Stellaris TCP/IP I have Stellaris LM3S6965 Microcontroller from TI, and i want to run an embedded web server on it. Is it possible to achieve that without additional hardware(ethernet/serial). Thank you. AI: It appears that the LM3S6965 integrates both the Ethernet MAC and PHY; but will still require the ethernet isolation transformer (and RJ45 jack unless you solder the cat 5 right to the board).
H: L298 overheating issue I'm trying to build a motor driver which can supply ~3A per motor. Only cheap IC I could get my hands on was L298, so I decided to parallel its channels. But for some reason that I can't understand (I'm merely an amateur hobbyist), L298 and its diodes are getting too hot in just a matter of seconds. I'm using a 12V (max 40W) power supply for my circuit, and its reduced to 0.95V when I check VCC/GND pins (how is that even possible ?) This is my PCB design. 47uF capacitors, 1N5819 diodes, L298N Edit: Schematics AI: You haven't labelled + and - on your battery! Assuming that battery pin 1 is positive, because it's connected to VS of the L298, then your diodes are the wrong way round in the schematic. Edit: the 0.9V is exactly as expected, as that's the forward voltage of the diode. You're sinking the full current of your power supply through a diode and the L298.
H: Transistor circuits: NOR and short I've two short questions regarding circuits with a transistors or diodes: 1) The following circuit with two diodes: Does it produce an electrical short for B=1 (5V) and for B=0 there is V[out]=1? Is this correct? 2) Does the following transistor circuit represent a logical NOR (all resistors are equal)? Thanks in advance! AI: Does it produce an electrical short for B=1 (5V) I'm afraid this is an example of muddled thinking about short circuits. For clarity's sake, assume the diodes are ideal, then, the input B can never be greater than zero volts; B will never = 1. The input B is a short circuit for current into the anode and an open circuit otherwise. With a real diode, B may rise to a few hundred millivolts. Regardless, B cannot affect the rest of the circuit. Vout is independent of whatever is connected to B. Does the following transistor circuit represent a logical NOR I'll answer with a question: If, as is shown, the base of the right most transistor is connected through a resistor to ground (0V) along with the emitter, is there any way to turn on that transistor with A and/or B?
H: Physical address vs virtual address Physical address is hardware address of physical memory and virtual address is the one the processor will be seeing, it has it has a tag and offset. I understand this. Can any one describe it with an example, like how the MMU does this operation (what it adds to the physical address) and what's memory mapping? And what is physically addressed physically tagged, virtually addressed virtually tagged? AI: Address translation is handled through a translation lookaside buffer (TLB), which is just a cache of translation information (and some metadata like permissions, cacheability, etc.). The TLB works by substituting the physical page number (the address bits above those used to index within a page) for the provided virtual page number (i.e., the virtual page is mapped to the physical page). (Since virtual pages are aligned with physical pages at page granularity, the bits indexing within a page match for virtual and physical addresses of a given page.) Typically, to reduce delay in retrieving data, the cache is indexed with the virtual address in parallel with the TLB lookup; this would be a virtually addressed cache, but if only index bits within a page are used then it is also a physically addressed cache (because those bits of the virtual address match the bits of the physical address). (A cache might be physically addressed at least partially in parallel with TLB access by predicting the extra non-virtual bits or by feeding in the extra bits after partially indexing the cache, but the tradeoffs seem to favor virtually addressed caches.) (Using non-physical address bits in indexing the cache can introduce complexities since another mapping of the page might not use the same virtual indexing bits.) Currently, physical tagging is preferred where a cache hit is determined by comparing the tag at the appropriate index with the requested physical address. Coherence with other devices accessing memory (I/O devices or processors), which provide physical addresses to the system, is easier with physical tags (avoiding the need for a physical address to virtual address translation mechanism, though physical tags could be provided in addition to virtual tags by duplicating the tag storage or by using of an inclusive L2 cache). As an example, with an 8KiB, two-way set associative cache with 16 byte blocks using 4KiB pages in a 32-bit address space, there would be 256 sets (groups of cache blocks sharing the same index)--requiring 8 bits to index. A load of the 32-bit word at 0x00ab_1134 would index the sets with 8 bits (0x13), read the two tags for that set, and read the words at offset 0x4 in both data blocks for the set. (Reading both blocks reduces delay.) While indexing the cache, the page number, the top 20 bits of the address (0x00ab_1) is presented to the TLB (usually with an address space ID appended); assuming the information for that page is available in the TLB (a TLB hit), the translation is sent to be compared with both tags resulting in either a match against one of the tags (in which case the data corresponding to that tag is selected) or no match (in which case there is a cache miss). (The TLB will also check to see if the process has read permission for that page.) With a virtually tagged cache, the TLB can be taken out of the critical path (potentially reducing cache access delay with a larger TLB) since it is only needed for permission checks not for tag comparison. (Permission information could even be included with the cache tags.) Typically a system has a larger virtual address space than physical (cacheable) address space, so virtual address tags would require more storage space; this storage demand is increased by the addition of address space IDs to avoid having to flush the cache when a different process is loaded (a Single Address Space OS would not need such a flush). The wikipedia article for "CPU cache" might be helpful.
H: Should old electronics be polarized? On old electronics that don't have a polarized power cord, what would be the benefits of adding a 2.2Mohm resistor from one side of the a/c to the chassis and switching out to a polarized cord (specifically on a vintage receiver)? A stereo tech recommended it to help eliminate a ground loop but I don't understand why. AI: Old Audio equipment used conventional AC transformers to isolate and protect users from high voltage. Is also improved CMRR of the high impedance phono inputs IF the transform also had low leakage. The capacitive coupling or leakage at 50/60Hz may introduce hum if another AC powered device such as a turn-table generated common mode stray hum and the combination of the two may permit nuicance hum in the phono pickup. In some cases the coupling of AC may be more pronounced on the line or neutral side depending on winding style so simply reversing the plug would determine if this is the case. If hum is not a problem, there is no advantage to grounding the unit and for long wires there is more of a risk due to ground faults in residential and commercial installations, meaning that you might get a shock connecting a long coax plug holding onto the sleeve and destination case. If hum still is a problem after reversing the plug, then shunting the stray floating CM AC magnetic fields with a lower impedance such as 1Mohm resistor may help a bit but it might be better to use ferrite CM chokes for the cable to pass thru such as those used on VGA cables and DC charger cables or better, specifically rated for high permeability and low frequency.
H: Is it OK to run a signal junction at a "do not use" pin on a solid state relay DIP package? I am attempting to retrofit an LCA710 solid state relay into an exiting PCB that has a mechanical relay. I will need to cut some traces and run some fly wires, but there is one IO line that would "pass across" pin 3, marked "do not use". Would this pin be a dead pin inside the IC package? Or, is it likely connected to something that would cause problems? Does anyone have any idea if it would be OK to use this pin as a junction point? AI: Unless you can get the manufacturer to make a statement on the subject, I'd assume the worst and not go near it. It may well be dead, but it could just as easily be connected to ground or something. If you're cutting traces and running wires anyway, is there a reason you couldn't just cut the pin off of the DIP before installation? That would let you use the existing point on the board as a junction without having to worry about what's in the DIP package.
H: Understanding metal oxide semiconductor gas sensors' datasheet. I just need some help understanding how a circuit that I already built works. I am using the the Figaro TGS 2201 air quality sensor. The datasheet for it can be found here: tgs 2201 datasheet from manufacturer Currently, my sensor setup is as follows: I am not using R2 but only using R1, which makes the air sensor targeted at gasoline exhaust rather than diesel. My R1 is equal to 10k ohms, as specified as the minimum value in the datasheet. From my understanding, as the concentration of the gas that the sensor is targeted for increases, the conductivity across pin 3 on the sensor increases proportionally (logarithmically) to the concentration of the gas in the air. I have a micro-controller read the DC voltage from pin 3, and i measure between 420 and 410 milivolts. In order to translate this value into parts per million (concentration of the gas), the data sheet provides the following equation for calculating Rs: Rs = (Vc - VRL)/VRL *RL How do i measure RL and VRL? I assume that Vc is 5 volts because that is what my voltage regulator outputs. Furthermore, in order to obtain Ro, do i need to run a control, and record RL in clean air and assign Ro to that value? AI: How do i measure RL and VRL? They're noted on page 2 of the datasheet you linked. RL is your 10k resistor. VRL is the voltage developed across it. VC is the sensor's supply voltage (note that the heater (VH) must be 5V +/-5%, but VC can be up to 15V max per the datasheet). Furthermore, in order to obtain Ro, do i need to run a control, and record RL in clean air and assign Ro to that value? The datasheet defines Ro as "Sensor resistance in clean air". So if you require Ro, it would appear that you need a sensor exposed to clean air. I'd suggest chatting with the manufacturer as to whether your application requires a) continuous operation of a clean air reference sensor, b) if it's just a one-time calibration step, or c) if it can be done empirically.
H: Circuit diagrams for LED Chaser Christmas Lights I'm looking for circuit diagramS for ~50 LED strip with lights running* repeatedly from the bottom to the top of the Christmas tree. I found simple solutions with only 13-15 LEDs, but this is, obviously, not enough for a big Christmas tree. The circuit must be DC driven. Thanks. *By "running lights" I mean this: https://www.youtube.com/watch?v=9CCWvKmVIug AI: You may want to try searching for "LED chaser". From a few minutes of searching, this site has an example of 3 cascaded 4017s. You should have no problems extending it to 50+ LEDs per your requirements:
H: Type of cable to use for long > 100m serial connection I am starting a project where I have two arduino-based devices positioned about 100 meters apart. The secondary device will be controlling a solar charging array and relaying stats to the main device. The main device will display stats to the user and send control commands to the secondary device. I plan on using a RS485 shield on each device. Because I will be burrying the data cable(s) underground I am wondering what I need to consider when choosing a cable type to run the distance in a cost effective way. Can anyone recommend a wire to use? AI: From TI's RS485 design guide, RS485 can support: 10-Mbps maximum data rate (at 40 feet) 4000-foot maximum cable length (at 100 kbps) The following, from the same document, appears to conflict with the above: Reading the fine print of (1), it looks like they dropped the somewhat important "M" from "Mbps" on the X-axis of the chart. Perhaps most useful for your application is the equation: Line length(m) X data rate(bps) < 10^7 At 100m and 9800bps, it looks like you've got an order of magnitude margin on the guideline. As for environmental protection, I'd recommend burial-grade PVC conduit rather than direct burial-rated cable. Laying the conduit might be a little more work, but you'll 1) be able to use much less expensive cable 2) be protected against errant shovels and 3) have the ability to pull additional conductors in the future if your application requires it. At the length and baud rate you're contemplating, nearly any available twisted pair cable should be adequate.
H: PCIe Prototyping Backplane I am trying to interface a TI c6678 8 core DSP evaluation board to a USB camera. The TI chip / board does not have USB, it has 1 SPI, 1 UART, 1 PCIe (2 lanes), and SRIO. The eval board only has an AMC connector, but there is an add on that breaks out the PCIe to a male edge card connector. I also have a USB -> PCIe bridge evaluation board (TUSB7320) that has a male PCIe edge card connector. I need to connect these together so I can interface the USB camera to the c6678. I started out trying to find a direct female -> female PCIe connector, without any luck. Next I soldered up some jumper wires between the edge connectors. Besides the obvious issues of impedance matching and length matching, noise, etc, this approach will not work because the c6678 EVM does not support generating a PCIe reference clock, although it does support acting as a Root Complex. I now have a PCIe reference clock IC that I am trying to get working on a protoboard without any significant luck. The 100 MHz clock signal is absurdly noisy with a ton of jitter on my scope (not surprising). I am now out of options for trying to prototype something with what I have. I have not been successful at finding a PCIe backplane that connects two slots together, the ones I have found go from each female slot to a PCIe switch and then out to a system board connector. My options at this point seem to be Find an off the shelf backplane that connects slot to slot directly AND has a reference clock generator on it. (backplane may be the wrong word for this) Design a simple PCB with 2 female PCIe connectors and a reference clock generator on it. I have been unsuccessful in accomplishing #1, so I am now moving on to #2. Since I have no capability to prototype the design, I am very nervous about the PCB I design functioning properly. I have Altium and can match the trace lengths, what are some other considerations I should take into account when routing this PCB? Datasheet links: TI c6678 EVM TUSB 7320 EVM AI: Looking through the datasheet it looks like the CC6678 can operate in root complex mode so you should be able to connect the two. I did a similar board for testing a large batch of pcie cards. Lanes If I were going to try it I'd start with a 4 layer board. You're going to want nice 100Ohm differential pairs to connect your lanes together. It only supports 1 or two of them so that shouldn't be a problem. Just run them over a GND plane on layer two. Just follow good practice here for routing HS signals. Oh and Tx -> Rx, and watch your polarities :) Clock I saw the clock generator you picked from your other post, I'd probably put a 1->2 fanout buffer and drive one to each of your pcie slots. Reset You're going to need to generate a reset pulse for the cards as usually the mother board would do that. You could just slap down a simple supervisor that monitors 12V and tie it's reset output to both connectors. Maybe add a pushbutton too so you can reset manually during debug. I used a Linear LTC2916CDDB-1#TRMPBF. Power You're going to need 12V and 3.3V to power the connectors. I just used a standard desktop pc power supply because I had a bunch and they're easy to get. I just used a standard mother board power supply connector (Molex 44206-0007) and I put a little toggle switch from PS_ON to GND to turn things on and off. Oh and throw in a few 100uF tantalums on each rail for good measure. Don't be nervous keep the lanes short, match the impedances and you should be fine. Here's a pinout if you need one:
H: Part to use for solar charging terminal I would like to use an arduino device to control a 12V 17W water pump and filter, what type of part to I need that can switch the 12V power on and off? AI: If you have only 3.3 or 5V logic high to switch on a 12Vdc motor, You may want to consider short circuit overload, thermal overload and inductive turn off effects. The better FETs with low Ron resistance usually require a bigger gate voltage to perform this. There are some chips which generate this internally using a voltage pump (MOS charge pump cct) to generate this higher internal gate voltage. Conclusion I recommend the TPS2204 chip, capable of 2A sustained in an 8 pin DIP package. Additional precautions are given here and buy here for $2 /1pc or $1 /1kpc You can put an Alum.elect. cap. (>=16V) on the output to suppress commutation noise and use twisted pair wire. This driver can handle large capacitance and surge currents.
H: Measure 12V 35Ah battery level in arduino I am building an arduino device controlling a solar power system. I am a beginner and would like to know what kind of part I would need to connect to the board to acheive this. AI: If all you want to do is simply measure the battery voltage, then you just need to scale the voltage down with a simple resistive divider, then feed it into your ADC. You can add a zener to ground, or schottky to the 5V rail for input protection if you wish (assuming your Arduino runs from 5V, which I believe they do). Basically it would look something like this: Simulation: Note the resistor values are not set in stone, they just need to be the correct ratio of 7:5. So you could pick 7kΩ and 5kΩ if you like, or similar. One thing to watch out for is the maximum input impedance your Arduino ADC can handle, which will be given in the datasheet - some are quite low (e.g. 10kΩ) The maximum output impedance of your divider is the parallel resistance of both resistors, so with e.g. 10kΩ + 10k&omega the output impedance (at the divider centre) will be 0.25 * 10kΩ = 2.5kΩ. With 7kΩ and 5kΩ the output resistance will be 1 / (1/7Ω + 1/5kΩ) = ~2.9kΩ (with the 70kΩ and 5kΩ it will be ~29kΩ)
H: How do I implement Lights-Out game using logic gates or flip flops? First, for those unfamiliar with the game, this is how the game works, The goal of the game is to turn off all the lights, hence called "Lights Out", and each press of the button/light inverses its state as well as its north/south/east/west adjacent neighbors, and that's pretty much it. Now, what I could think of is by using SR flip-flops, or JK flip flops. This is due to its ability to act as storage element (the initial state and next state). But I can't seem to think of ways to actually implement them. Another idea is that each set of button and its adjacent (NSEW)button/lights will have its own truth table, like this: but, is it possible to have the input variables be the same as the output variables? Are there any other ways to do this? AI: The obvious approach would be to use a processor and do all this in firmware. However, if I really needed to do this with stone knives and bear skins for some reason, I'd dedicate a toggling flip-flop to each square. The flip flop of each square would be toggled by the press of its button or either of the four neighboring buttons. Of course those button presses need to be de-bounced. Again, this would be easier in firmware. A hardware solution wouldn't be all that complex, but everything would be replicated 25 times, making it large and tedius to build. Added: Apparently the description above is not clear enough. Here is a diagram of what is in each cell: The other 4 inputs to the NAND gate are driven from the debounced signals of the 4 surrounding buttons that are also supposed to toggle the state of this square. Likewise, the debounced signal from this button also goes to one of the NAND gate inputs of each of the 4 surrounding cells.
H: Designing State Diagram for a 2 input sequence detector For a lab exercise I have to design a 2-input sequence and Im struggling with the state diagram, as It has 2 inputs, i've designed it with one input before. the sequence to be detected is 1032 which can be written as: \$ A_{0} \text{ | 0 0 1 1} \$ \$ A_{1} \text{ | 1 0 1 0} \$ So how should I go about designing this state diagram? AI: You need five states: Nothing detected (initial state) Detected 1 Detected 10 Detected 103 Detected 1032 Some hints: Each state has four possible state transitions corresponding to inputs: 00 (0), 01 (2), 10 (3) and 11 (4). Most of these transitions will lead to state one. 01 input will always lead to state two.
H: device for outputting HIGH when input have been HIGH? I am looking for a device or circuit that outputs HIGH when a pushbutton has been pressed (if the button is pressed again it is supposed to still output HIGH), also, if possible, another pushbutton to make the output LOW. Is this possible without an IC? How to do it? AI: What you want is called a set/reset flipflop. Various flipflops have R and S inputs, but you can also make a primitive one out of two NAND gates. For example: Follow the logic signals thru the circuit to see how it works and how it has memory.
H: Making a schematic in KiCad; how to represent connections from another circuit board? I'm using KiCad to design a circuit for my latest project. This board includes a number of transistors whose bases are connected to off-board signals. What's the proper way to represent this, so when I build the netlist and PCB, these off-board signals become header pins or pads. Yeah, newbcakes here... EDIT - I found a 12x1 connector which does exactly what you think it does. Now, that happens with this when I convert the schematic to a PCB, I don't know. Stay tuned... EDIT 2 - I have learned nothing happens to the 12x1 connector automatically. Instead, on the next step towards pcb-ing, you have to tell KiCAD what everything is. I did and it worked fine, though there weren't many options so I selected a 7x2 DIP. I'm 95.982% sure I can make what I need, however. This is the least of my worries, lol. AI: You can split your design into a hierarchy (e.g. multiple pages), then have local nets to each page and also global nets. You can also use specific page to page connectors (so the page symbol is like a component you can drop into another page (over on the right hand icon set you will see an icon labelled "Place hierarchical pin in sheet" and another named "Place a hierarchical label" and a couple of other related icons) Have a play around with the demo projects to see how it works. There are also some good tutorials out there that go through this stuff. Tutorial 1, Wiki Kicad, Hierarchy Tutorial. Go into wherever Kicad is installed (e.g. Program Files/Kicad/Share/Demos), and look in the Demos folder for plenty of examples of different ways of doing things.
H: Help find data sheet for micro-controller? I found a packet of 10 micro-controller in my brother's electronics stuff. It reads "Atmel ATMEGA168A-PU". I looked at Atmel's website but could not find any such product. I need it's data sheet to know that it is capable of ? I would like to play with it. AI: Here you go. Datasheet for the ATmega48A; ATmega48PA; ATmega88A; ATmega88PA; ATmega168A; ATmega168PA; ATmega328; ATmega328P - Atmel 8-bit Microcontroller with 4/8/16/32KBytes InSystem Programmable Flash This microcontroller can be used to make your home-grown Arduino clone, among other things. The DIP part lends itself to making the Really Bare Bones Board quite well.
H: common collector amplifier In common collector amplifier, we know that the collector is commons since it is connected to AC ground. Now, the characteristics of a common collector amplifier is that it has unity voltage gain, to be exact, it is less than 1 due to internal resistance of the transistor, and has high input impedance and low output impedance. Now, the problem is, whenever i try to add a 8 ohm load (my speaker), the voltage gain drops drastically. I thought common collector amplifier is immune to loading effects since it is use as a buffer. What is happening? (It appears to me that it is suffering the same fate as common emitter (which drops voltage when a load is connected to it directly)) AI: I thought common collector amplifier is immune to loading effects A CC is not immune to loading since it has a low, but non-zero, output impedance. The small signal output impedance of a CC amplifier is roughly: \$\dfrac{V_T}{I_E} + \dfrac{R_{tb}}{\beta + 1}\$ where \$V_T \approx 25mV \$ (assuming room temperature) and \$R_{tb}\$ is the equivalent AC resistance connected to the base. For example, if \$I_E = 1mA\$, the output impedance is at least 25 ohms. So, while the output impedance of a CC amplifier is much lower than a CE amplifier, it is not immune to loading effects.
H: Understanding CPU clock signal processing Although I have a pretty good background in math/cs, I don't have much experience with circuits and their functionality. I've browsed the internet and looked at some books on integrated circuits, but I still have yet to find an answer to a simple a question: how do CPUs process memory/signals. A lot of answers tend to reduce to analogy: typically, the answer is of the form "it's like a low of switches." Yeah, yeah, I get that. I understand how a transistor works. What I'm trying to understand is how these signals are actually relayed in, say, electron form. If I just randomly (and wrongfully) assume it's a pulse of electrons carried along s conducting wire to the transistors, how does this get processed? More directly, how is a binary signal actually read by the cpu? No need to get complicated with modern cpus: a simple example/computer would be excellent. For direction, let's say we have a bunch of transistors that are storing some level of electrons to represent a simple byte. How is this then passed to a crude cpu? Any links, would be helpful. Sorry if I seem a bit direct: brevity and polish don't always go hand in hand. AI: Your basic synchronous digital design is a sort of discrete time feedback loop. One or more registers made of flip-flop like storage elements hold values. These flow onto buses, possibly through path selectors called multiplexers and various combinatorial logic circuits which perform a logical or arithmetic operation on the value represented by some number of signals (typically each signal being a binary digit, or bit). Over a short period of time, the result flowing through the paths and logic to circle back to the inputs of the registers stabilizes. After an interval calculated to safely allow the worst case time needed for this, another active clock edge occurs, which causes one or more of the registers to replace the current values they have been holding with the updated values being fed back to their inputs. In the case of something like a (synchronous) a counter, the logic circuit sitting between the outputs of the registers and the inputs would add one, so each active clock edge would see the stored value increase by one. More complicated operations such as performed by a CPU might select two source numbers from a register array from which two locations can be simultaneously accessed through two separate read ports, add them together, and write them back to somewhere in that same register array through a third writing port.
H: MOV in series with the VCC-IO pin of FT232R Could someone explain to me why there is a MOV in series with the Vcc IO? Is it to cut power if the pin falls below a desired voltage? (Here's the application note for the circuit.) AI: If you're referring to F1, it's not an MOV (though the symbol does look like it). In USB designs, it's a ferrite bead used to filter the USB 5V line and also incidentally to have a fuse to protect the USB port from the circuit drawing too much current. Since 500mA is the max to be draw per the spec, so the fuse limits the current in case. Unfortunately most USB ports don't have any real provisioning for limiting the current drawn. Although the USB standard requires the device to inform the host if it will need more than the standard 100mA, the reality is that many devices don't do so and just draw whatever they want(fans, lights and other little USB gizmos come to mind). So the port doesn't limit anything and runs the risk of shorting if the board you connect needs more than it can provide. Many ports can provide more than 500mA, and I've read that some apple computers provide more than 1A, but you should never count on it. The FT232 does provide the amount of current it needs (you can change it with the EEPROM programmer), but F1 is there to ensure that the rest of the circuit doesn't do anything.
H: How do I measure startup/inrush current? I have some small devices that draw 20mA. I'd like to add a resettable (PPTC) fuse to them but I am not sure what value to select. My thought is I need to find a value that will tolerate the startup or inrush current when the circuit first turned on, but I don't know how to measure that. (My meter isn't that fast, but I do have an analog 100MHz oscilloscope.) The devices have a capacitance of about 122μF. AI: LittleFuse provides a very nice app note with a lot of details for the design of these kind of devices. As for measuring the current, you could use a very small resistor (1 or 0.1 ohm resistor) and use an oscilloscope to measure the current. Be careful not to ground the device. You need to use two probes for doing this measurement and subtract the value of one from the other - DO NOT CONNECT THE GND OF THE PROBE TO EITHER SIDE OF THE RESISTOR- you will in effect cause a short circuit if you do this. Just get 2 probes, connect the tip to each side of the resistor, and the grounds to the actual ground. use oscilloscope math capability (or just yourself) to do a difference between the two channels and this will be your current.
H: Time parameters of pressing a tact button by people Sorry for bad English. How fast people can press a tact button? I.e. what is minimal time of holding a button pressed people can get? What is typical bouncing time when people press tact button? I have no oscilloscope to check it, but maybe anyone already did it and public in the Internet? AI: I am not sure how fast. It's likely few hundered miliseconds. 2) Here are some nice resources about the topic. It highly depends on the type of switch and how it's built, but 10's of miliseconds is the norm. http://www.ganssle.com/debouncing.htm http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC0QFjAA&url=http%3A%2F%2Fwww.picotech.com%2Fexperiments%2Fswitch_bounce%2Fmeasuring-switch-bounce.html&ei=lPG6UOeaOsG82wXgrYGYDQ&usg=AFQjCNHB902_WMeWA-7odiuq6gCt1rEciA&cad=rja http://www.eng.utah.edu/~cs5780/debouncing.pdf
H: Reading datasheets and applying Ohm's Law I have a CPLD that wants +3.3v and has a maximum allowable current per pin of 8ma. I need to supply a clock signal. The oscillator I selected accepts 5v and outputs 5v-ish levels. I'm finding it challenging to internalize the datasheets of the CPLD and the oscillator. Now, the oscillator's datasheet says for my clock speed (1MHz), it typically likes 10ma (Supply Current, typical). Which means that as long as 10ma are available at 5v (Supply Voltage, typical) we're gonna have a lot of wiggly fun. This is where I get confused. Since the output of the oscillator is up to 4.5v (Output Voltage Levels) and this exceeds the 3.3v required by the CPLD, I need to add a resistor. But I don't know what the current should be. I arbitrarily decided that I will allow 4ma to reach the CPLD. This will prevent the smoke from coming out of it. The oscillator will source 16ma (Output Current) so I believe this isn't a problem. Ohms: (4.5v-3.3v) = .004R 1.2v = .004a * R 1.2v/.004a = R 300 ohms = R So a 300 Ohm resistor between the output of the oscillator and the CPLD's clock pin will prevent damage to the CPLD by limiting the current and reduce the voltage to the limits required by the CPLD. Q1: Does any of this make any sense? Q2: I assume that when the datasheet says the output current for "1" is -16ma, this means it will source 16ma. Why does the oscillator's datasheet say the oscillator's "0" current is 16ma? I'd have expected 0. EDIT - Wow, thanks for the great feedback. I will look for a 3.3v-compatible clock. While in retrospect it's just a better idea, I am surprised that adding a resistor would be so problematic. They seem to be used frequently in digital circuits. Reference circuit... here's the datasheet for the CPLD. I have not seen a reference circuit as such. However (boy am I dumb!) I do have a working dev board 3' from me that sports an oscillator having "8.000 G MEC AL8GS" stamped onto the tin. (It's my assumption that's the oscillator. Looks like one. The only other thing nearby is a tiny Atmel chip of some sort that I suspect is related to JTAG programming.) Edit 2 - I'm not married to any particular brand or type of oscillator; for my purposes a low frequency clock is ok. I believe anything over 500KHz would be fine. Back to DigiKey and Mouser! AI: I highly recommend that you find the reference design for the CPLD and if possible, recreate it and even use the same components. The reason companies provide this is that they want you to get started using their device and unless you have some exotic requirements, it usually does the trick. You didn't provide the datasheet for the CPLD or the name, but I can tell you that you should choose another oscillator that is 3.3V compatible. CPLDs don't typically operate at 5V and this will likely violate the specs in the datasheet. As I said above, selecting the same as in the reference design (or find any other board that uses the same chip online and see what they're using) will be the best. Trying to reduce the signal level of the oscillator is a very bad idea because you'll introduce all kind of issues such as capacitance, frequencies, noise, etc that are bad bad bad. Even just using resistors will introduce issues that can cause the CPLD to malfunction due to all the capacitance and perhaps loading. You must make sure that the power supply you have can provide plenty of current for the worst case of the CPLDs. From my experience with FPGAs, the inrush currents are very very large and quick, and you should plan for this. Again, the recommendation is to use whatever a reference design uses and perhaps tweak as necessary.
H: How Can I Program an LED Matrix I got this really cool idea the other day. Sitting in my Computer-Sci Lab at school I saw the binary clock on the wall. As a "watch guy", I immediately wanted a watch like it. I've always had a DIY attitude, so I looked in to it, and I was wondering: How can I program an LED Matrix? I know I would have to use some kind of arduino, but I am very unfamiliar with all the lingo. I was wondering if there is some kind of set up that allows me to program one of these in a way similar to programming a computer? AI: Hack a day has a list of all kind of similar projects. Many of them you could clone and make it your own: http://hackaday.com/category/led-hacks/
H: Determining which pin triggered a PCINTn interrupt? Am I correct in thinking that if you have two pins causing the same AVR PCINT interrupt, (e.g. PCINT0 vector caused by either PCINT0 or PCINT1 pins -- I think the naming overlap of vectors and pins is confusing) the only way to determine which pin(s) caused the interrupt is to record their state after each interrupt and compare the previous and current values of all the pins which are enabled in PCMSKn? AI: I think the naming overlap of vectors and pins is confusing It is! The reason there are 8 different external pins for an interrupt vector is to make it easier to layout the PCB or to use a different pin if there is a conflict with another pin function. Am I correct in thinking ... the only way to determine which pin(s) caused the interrupt is to record their state after each interrupt and compare the previous and current values of all the pins which are enabled in PCMSKn? Pretty much, lets say you only care about PB0 (PCINT0) and PB1 (PCINT1). So the pin change enable mask PCMSK0 would be set to 0x03. // External Interrupt Setup ... volatile u_int8 previousPins = 0; volatile u_int8 pins = 0; ISR(SIG_PIN_CHANGE0) { previousPins = pins; // Save the previous state so you can tell what changed pins = (PINB & 0x03); // set pins to the value of PB0 and PB1 ... } So if pins is 0x01 you know it was PB0... And if you need to know what changed you need to compare it to previousPins, pretty much exactly what you thought. Keep in mind in some cases, pins may not be accurate if the pin has changes state since the interrupt but before pins = (PINB & 0x03). Another option would be to use separate interrupt vectors with one pin from each vector so you know which one is changed. Again, this also has some issues, like interrupt priority and once the CPU enters the ISR, the global interrupt enable bit I-bit in SREG will be cleared so that all other interrupts are disabled, although you can set it inside the interrupt if you want, that would be a nested interrupt. For more information, take a look at Atmel's app note Using External Interrupts for megaAVR Devices. Update Here is a complete code example I just found here. #include <avr/io.h> #include <stdint.h> // has to be added to use uint8_t #include <avr/interrupt.h> // Needed to use interrupts volatile uint8_t portbhistory = 0xFF; // default is high because the pull-up int main(void) { DDRB &= ~((1 << DDB0) | (1 << DDB1) | (1 << DDB2)); // Clear the PB0, PB1, PB2 pin // PB0,PB1,PB2 (PCINT0, PCINT1, PCINT2 pin) are now inputs PORTB |= ((1 << PORTB0) | (1 << PORTB1) | (1 << PORTB2)); // turn On the Pull-up // PB0, PB1 and PB2 are now inputs with pull-up enabled PCICR |= (1 << PCIE0); // set PCIE0 to enable PCMSK0 scan PCMSK0 |= (1 << PCINT0); // set PCINT0 to trigger an interrupt on state change sei(); // turn on interrupts while(1) { /*main program loop here */ } } ISR (PCINT0_vect) { uint8_t changedbits; changedbits = PINB ^ portbhistory; portbhistory = PINB; if(changedbits & (1 << PB0)) { /* PCINT0 changed */ } if(changedbits & (1 << PB1)) { /* PCINT1 changed */ } if(changedbits & (1 << PB2)) { /* PCINT2 changed */ } }
H: Amplifier capacitors Why is that when I use electrolytic capacitors (the cylindrical ones) and measure the end with respect to ground, there is some DC voltage appearing (where in fact it should be 0 volts since capacitor passes only AC signal but blocks DC signal), but when I substituted a non electrolytic capacitor, like tantalum capacitors, they work well. In a simulation program, electrolytic and tantalum shows no difference and they block DC, but in real life, electrolytic fails to function correctly. What's happening? AI: Electrolytic capacitors are well known to pass a small DC current. How much they pass is a complex function of temperature, capacitance, the age of the capacitor, and the DC voltage across it. This is because the insulating film is formed by electrolysis; as the current flows, it electrolytically deposits an insulator on the anode (which is aluminium : this is the same process as anodised aluminium) and the insulator eventually stops the current flow. So for example an electrolytic that has been unused for several years will draw quite a large current (milliamps) for a while, then the current will reduce as the insulator re-forms itself. The capacitor is healing itself. The result of this is: do not use electrolytics in series with high impedances (say, as coupling capacitors between amplifier stages) do not use them with no (or reverse!) DC across them (they will not heal, and reverse DC will break them down) Ideally you want 2/3 their rated DC voltage across them to keep them formed (at least 50% anyway) do not use them in circuits like R-C timer circuits where leakage will change the time constants remember that at high temperature (usually 85C) their lifetime is rated at 8000 hours - which is only a year! Tantalums can be a better choice but have their own problems Don't use them across a high current supply. Across a low current supply they can self-heal too, but across a high current supply they can turn into fireworks...
H: Something I am stuck in matlab I want to write down the Fourier series for \$x(t)=1\$ for \$|t|\leq 1\$ and zero otherwise (which is expanded periodically to other intervals with this period of 1), and compare it graphically with \$x(t)\$, for different values for \$N\$, where \$x(t)=\sum_{-N}^{N} a_k e^{ j k\Omega_0 t}\$. Here's the code I wrote, basically the interval should be between -2 and 2, but I get all the time an error, I hope someone can correct me or find a better way to do this. n=linspace(-2,2,5); x=abs(n)<=1; y=symsum(exp(-1i*k*pi/4)*(sin(k*pi/4)/(k*pi))*exp(1i*k*pi*n/2),k,-1,1); y2=symsum(exp(-1i*k*pi/4)*(sin(k*pi/4)/(k*pi))*exp(1i*k*pi*n/2),k,-3,3); y3=symsum(exp(-1i*k*pi/4)*(sin(k*pi/4)/(k*pi))*exp(1i*k*pi*n/2),k,-7,7); y4=symsum(exp(-1i*k*pi/4)*(sin(k*pi/4)/(k*pi))*exp(1i*k*pi*n/2),k,-19,19); y5=symsum(exp(-1i*k*pi/4)*(sin(k*pi/4)/(k*pi))*exp(1i*k*pi*n/2),k,-79,79); I get the following error: ??? Undefined function or variable 'k'. Error in ==> AS at 3 y=symsum(exp(-1i*k*pi/4)*(sin(k*pi/4)/(k*pi))*exp(1i*k*pi*n/2),k,-1,1); AI: add syms k; at the beginning sin(k*pi/4)/(k*pi) should be sin(k*pi/4)/(k*pi+eps) to avoid division by zero. legned should be legend you can't place 5 subplots in a 2x2 figure
H: audio jack ground weirdness Above is my circuit. If the audio jack's (from my mobile phone) ground is not connected to the circuit's ground, the circuit itself functions normal (the collector emitter voltage is around 12 volts, everything is in good condition) but when i now connect the audio jack's ground to the ground of the circuit and i connect the jack to my mobile phone, the collector emitter voltage becomes around 24 volts, without any music playing.. What is happening? AI: Assuming there is no other connection to the mobile phone (it's not grounded somehow to the power supply of this circuit, for example), then it looks like C2 isn't really acting like a capacitor and is somehow passing DC. This could be because it is a bad part, installed backwards, or you didn't wait long enough for it to charge up. 1 mF is a very large value for coupling audio into this circuit. The input impedance of this circuit is about 1.5 kΩ. Even if this is supposed to be "Hi-Fi" audio and you therefore set the high pass rolloff at around 10 Hz, that would still only require about 10 µF capacitance. You have two orders of magnitude more than that, which will cause this circuit to take a while to settle when a change in input DC level occurs. It is also troubling that you show this 1 mF capacitor as being unpolarized and without a voltage rating. Almost certainly it is electrolytic, which is polarized and must be installed the right way around. If you installed it backwards, then it will leak excessively causing the symptom you see, and it will be damaged. The negative side should go to the input and the positive side to the base of the transistor. The maximum voltage spec of capacitors must always be kept in mind too. Replace C2 with a 10 µF ceramic with maybe 20 V tolerance. That should still pass bass well enough, but won't leak, and the polarity won't matter.