text
stringlengths
83
79.5k
H: External power for Raspberry Pi USB device The Raspberry Pi's USB ports can only supply about 100ma of 5V current; this comes directly off the 5V input power to the board. The usual solution is to use a powered hub to support devices that need more of that, but I have an application where I have a single USB device, and want to keep the setup as simple as possible, as it will be in an enclosure with other equipment. Comments in this question seem to suggest that a setup like this would work: since both devices were being powered from a common source; I'm planning to try this with a USB charger with two jacks and and a cable like this, hoping I can carefully open the cable and identify VCC and snip it. Is there anything else I should be aware of? AI: The connection scheme you are using will work fine even if you use two separate supplies, one for the board and one for the device (5v each). As long as the Vcc wire is not connected between the device and board you can power the board from the USB port of the PC and the device from a wall wart. When you are using the same PSU to power both the device and board (like in your image) there in no need to break the Vcc connection between them, they are connected in the PSU junction anyway so they may as well connect through the usb wire too. In other words you can use the Y cable you show to power the device and board without a need for any modification BUT while they are powered like that you can't connect the board to the USB port of the PC, if you want to do that then you should leave the Vcc connection open. The Vcc wires shouldn't be connected between devices that don't share the same power supply (unless there is a protection mechanism like a diode).
H: Using normal diodes to rectify high frequency waveforms Recently I was try to rectify the output of an “electronic transformer” using an ordinary rectifier diode 1N4007. The output of this device is bursts of frequency around 50kHz, with an envelope of 100Hz and RMS 15Volt measured by scope. Under these conditions, why does the diode become extremely hot even with a pure ohmic load that requires just 120mA? Also, what is the effect is we are use a fast-diode to rectify a low frequency waveform i.e. 50~160Hz. AI: Every diode needs some time to recover its reverse resistance after voltage polarity changes. During the recovery time there is high reverse current through the diode. This reverse current makes the diode to produce some heat. The higher the frequency is, the more time is spent in the recovery state and so the more heat is produced by the reverse-recovery process. Low-frequency diodes (like 1N4007) have relatively long reverse recovery time, and you've seen what it leads to. Higher-frequency diodes (like HER or FR series, for example) have much shorter recovery time which allows them to operate at about 300 kHz. Using a high frequency diode to rectify a low-frequency waveform will produce even less heat by reverse-recovery than in case with a low-frequency diode, but in both cases it will be negligable to heating by forward-current. So the only drawback of using a high-frequency diode to rectify a low-frequency waveform is the diode's price.
H: Logic phase shift detection I have two logic signals that can be in two different configurations as shown in the image below. I would like to output a third signal that is HIGH for case A and LOW for case B. How can I accomplish this? AI: XOR both signals, the pulse train and the state one. Use this result as the clock for a positive edge trigger latch and the state signal as the value to latch. In state A the latch output is high and in state B the latch output is low.
H: I know how to program, how do I learn how to wire things up? I'm computer science student, I know: some basic VHDL program in C or assembler basic electrical laws (ohm law, kirchhoff, ..) basic electronic parts (diode, tranistor, ..) What I don't know are those practical things like: where to put pull up resistor and why? What resistance do i choose? it seems like there are randomly putted capacitors all round circuits and i have no idea why i dont know what to do in order to not blow up processor that crystal trick that generates clock .. how do i compute the numbers? I have theoretical background, but that doesn't tell me anything about how to handle interference and those "practical" guidlines. Do you know any good youtube videos or books? I know i could just use arduino, but that's so expensive! And it's quite overkill for some basic projects like: light up led if cat passes laser latch for 1 minute. AI: where to put pull up resistor and why? What resistance do i choose? Pullup/Pulldown resistors provide default High/Low value for a signal, that would otherwise be floating (All it's drivers are tri-stated). We don't want floating signals, because when fed to digital inputs, they create spurious transitions, can put the logic into undefined states, and stuff like that... Generally, anything in the order 4k7 - 20k will be good enough. it seems like there are randomly putted capacitors all round circuits and i have no idea why Capacitors in most digital use-cases work for storing energy. Digital circuitry needs pretty stable power supply - the problem is, the switching inside these very circuits creates very rapid, short and repetitive power draw. This is dealt with using filtering, blocking and decoupling capacitors. They are all in parallel on the same power rail, but differ in size, ESL, ESR, capacitance, etc... i dont know what to do in order to not blow up processor You read the datasheets. Right pin connections and stable power supply is good for starters. that crystal trick that generates clock .. how do i compute the numbers? Crystals come in a) specific frequencies and b) specific load capacitances. They generally need a pair of load capacitors connected between ground and each end of the crystal in order to work properly. Again, the IC's manufacturer will likely provide you with equations/tables for getting these cap values.
H: Control RGB LED without microcontroller I have an RGB LED that I'd like to change from green to red when a circuit is completed. While I know this is very simple with tools like an Arduino, I'd love to not use a microcontroller. Would it be possible using basic components (which can certainly include transistors, diodes or even common ICs like a 555 timer) to achieve this? If so - how would I connect the components? Clarification: I'm using a common anode RGB LED (a lead for each color plus ground - four in total). I'd like to have it be green when a switch somewhere in the circuit is open (not connected) and red when the switch is closed. The switch is not connected to anything else. AI: This is the simplest circuit I can think of (2 parts):- simulate this circuit – Schematic created using CircuitLab Input = 5V Red Input = 0 Green The circuit works because the \$V_F\$ of a Red LED is generally much less than the \$V_F\$ of a Green or Blue LED. Here is a typical RGB LED datasheet: And here are the typical plots of \$V_F\$ vs. current: When the transistor is "off", the Green LED will have a forward voltage of about 3.0V at 10mA. When the transistor is "on", the Red LED will have a forward voltage of less than 1.9V. Referring back to the Blue/Green graph, little current will flow through the Green LED at that forward voltage. This particular arrangement shows a common-cathode arrangement, however it could be flipped and a similar P-channel MOSFET used. In that case, 0V would select the Red LED, and +V in would select the Green LED.
H: Detecting length of button-press using a microcontroller I'm interested in creating a seek button panel (2 buttons - back and forward) that will connect with my Android's native music player, similar to the CD player in my car. I'd like for the buttons to have dual-operations: Seek backwards/forward in the duration of a specific track Seek backwards/forward between tracks in a playlist I'm contemplating on how this works in my car, in order to build it on my own - is there: A different voltage going through the circuit when the button is pressed longer or Is there some sort of timer in the micro-controller's code that tells it to send a different order when the button reaches a certain period of time being pressed? Please pay attention to both parts of my question - how this actually works, and how should I go about building it on my own - preferably using Arduino, as per I've got one lying around. Feel free to correct me if I'm making terminology errors - I'm more of a web kind of guy, this hardware stuff is new to me. AI: To amplify Ignacio's comment The Arduino "Debounce" example shows how to use the time (milliseconds since AVR chip powered on) to determine how long a button has (probably) been pressed. if ((millis() - lastDebounceTime) > debounceDelay) { ... if (buttonState == HIGH) { The example does this because physical buttons typically bounce up and down several times when you press them, which can be read as multiple button presses. So you ignore any that happen faster than most humans can stab their fingers up and down. The same technique can be used to see how long the button has been in a "down" state. You may need to refactor the logic in the example software somewhat.
H: Best transistor to use for audio amplifier This term, we will be designing an audio amplifier. So far in our lecture, we are still at BJT and based from what I've heard, FETs will just be partly discussed unlike the thorough one on BJT. Anyway, I would like to have an idea this early so I can plan on what transistor to use for best audio amplification. I have read some threads how the other transistor (BJT/FET) is better, but other forums say that the performance relies not on the component but on how the transistor is properly biased and how the circuit is properly designed. In designing an audio amplifier, which of the four subtypes of transistors is the most efficient? (NPN/PNP/JFET/MOSFET) By the way, the requirement of my professor is just this: impress me. Right now my group haven't decided yet on the specifics of the circuit (wattage, impedance, etc). AI: You could successfully build a audio amp from many different types of BJTs. It will be the circuit, not the transistor, that makes the amp work well. I'd pick jellybean parts like the 2N4401 (NPN) and 2N4403 (PNP) and stick with them for everything except for the final power output transistors. Lots of parts could fill that role. If you have your own favorite jellybean small signal transistors, use them if you prefer. The ones I mentioned have reasonable gain and can handle up to 40 V, which should be plenty good enough to allow for a amp to impress your profesor with. There are lots of possible power transistors to use as the final output. If you are aiming for a few Watts, I'd probably go with basic parts like the TIP41 (NPN) and TIP42 (PNP). Again though, it's not the choice of transistor that will make or break this project. You can certainly create a impressive audio amp with the transistors I mention, but you can also make a mess. It's really up to the design. In audio, overall noise and harmonic distortion are high priorities. Those come from careful circuit design and attention to these parameters at every step along the way. You can also use other types of transistors, like JFETs or MOSFETs. Those would require a different circuit topology to utilize properly, but can be used to make a good amp too. Since you will be going over BJT details more thoroughly, I'd stick to them for now. This will be a great learning exercise. Designing a amp with very low noise and very low distortion is not trivial.
H: How can I simulate contamination delay in VHDL? Propagation delay is simple to implement: Out <= '1' after 3ns; I tried to add contamination delay as such: Out <= '1' after 3ns; Out <= 'X' after 1ns; so that Out would become undefined and then switch properly. However, in simulation I only observe the final assignment. [I'm using MultiSim to simulate, but this Quartus II link suggests it's normal to only observe the final assignment] Is there a good way to simulate contamination delay? AI: Out <= 'X' after 1 ns, '1' after 3 ns;
H: cross clock domain databus I asked a question some time ago about crossing clock domains Design practice crossing clock domains and async signals. One of the "rules" is to never synchronize multi-bit signal bit-by-bit, because of timing glitches between individual bits. I have now a design, where I need to cross a multibit signal from a 27MHz domain to a 54MHz clock domain. I have no more FIFO's left in my fpga, so is there any way to do this without using an async fifo? Is it possible to synchronize the multibit signal, and set some timing constraint, so I at least get an error if timing is not kept? AI: If the throughput of data transfers is low then you can use a simple handshake to perform the clock domain crossing: Your launch side places the data in a register and inverts a single bit flag. The flag is synchronised into your latch clock domain and the inversion is detected indicating that there is new data to be re-registered into the latch clock domain. The latch clock domain inverts another acknowledge bit which is then synchronised back into the launch clock domain, informing the launch side that it can send another word of data. You still have to take the necessary precautions on the single-bit synchroniser chain (at least 2 registers placed close together). You may also find that a greater number is required since the false path allows the fitter to physically place the two multi-bit registers far apart. You may need to use a delay constraint to limit the placement (set_max_delay on Altera or define_path_delay on Xilinx). Obviously the rate at which you can transfer words is much less than using a dual clock FIFO. You say you have 'no more FIFOs' left but remember that both Altera and Xilinx support small FIFOs composed from special logic blocks (MLABs in Altera parlance or SLICEMs in Xilinx speak).
H: Empty Netlist Vivado Design Suite I am dealing with synthesis of verilog sources using Vivado Design Suite 2013.3 tool for the first time. The behavior of my design is correct as verified by the pre-synthesis simulation. My problem is that once I perform the synthesis, the resulting netlist is empty and this is confirmed by the utilization report which shows that anything has been utilized on the board I previously chose. The only thing I can see from the scheme are the ports of the top module of my architecture: This is the utilization: I have been told that, since my data source is from outside of my device, I have to set the IOB option in the synthesis settings, but neither the official Xilinx guides are helping me on this. AI: It's possible that all of your logic is being optimized away. If your lop level module doesn't have any outputs or the outputs it does have don't change state, then all of the logic will be removed by the optimizer as it has no effect on the function. The solution is to route out outputs. For example, if you have an CPU core, try routing out the data bus. Or even just part of it - say, the lowest 8 bits. If there is an issue with the number of pins, simply XORing all of the outputs together and routing the result to a single pin is generally enough to prevent the optimizer from deleting everything.
H: Solving two op amps I have the following circuit: I have to solve for VO. I know that the input voltage to the left op amp is -1 at both terminals and -2 for the right op amp. I also know that the input current to both is 0. However, I don't know where to start to find VO. Can someone point me in the right direction? AI: First, the input voltages to the op-amps positive terminals are not -1 and -2 volts, they're +1 and +2 volts. In general, the process of working these is pretty straightforward. Start with what you know, solve for what you don't. You know that an op-amp with negative feedback (a path from the output to the negative input) tries to make its inputs equal. (In the real world there would be concerns about the voltage rails of the op amp, but this is obviously a textbook problem so we won't worry about such.) The positive input voltages are given to you, fixed by the voltage sources. From this fact, we also know the negative input voltages. So that means we know the voltage on both sides of the 10k resistor: 1V and 0V. There's 1V across this resistor, and it's 10k, so the current through it is 100 uA, flowing left. We have current leaving a circuit node. It has to also enter that node somewhere, and there are only two possible paths: through the 20k resistor, or through the input of the op-amp. Another assumption we make about op-amps is that current can't flow into or out of their input terminals. In the real world, that's not true, but for simple analysis of DC circuits with resistances in this range it's probably close enough. So we know there's 100 uA going through the 20k as well, flowing left. We know the left side of the 20k is at 1V, and it's got 100 uA x 20k = 2V drop across it, so we get a voltage of 3V on the right side of the 20k. Continue the process. The left side of the 30k resistor has 3V on it, and the right side has 2V. That means there's one volt across it, giving 33 uA through it, flowing right. That 33 uA can't flow into the input of the op amp, so it has to go through the 40k. 33 uA through a 40k resistor gives a voltage drop of 1.33 volts. The left side of the 40k resistor is at 2V, and the right side is 1.33V lower, giving .66 volts.
H: How a PC with an RS232 port read serial data coming from a device with an RS-485 output? We have a program in Windows OS which is capable of reading serial data from an RS232 port or USB ports. We have a device which is only using RS485 communication (2 wire-half duplex). Is there a way to use DB9 cable for reading data or should we convert RS485 to RS232 or USB? And if we do it is that enough for the program to read the data? AI: RS-485 is not compatible with RS-232 in voltage levels, so you'll need either a USB-to-RS-485 or RS-232-to-RS-485 converter. Beyond that, it's really impossible to say if it will work or not. The protocol might not be compatible since you are typically not controlling exactly when the RS-485 driver relinquishes the bus (it's usually done by some kind of timer in the unit). You might have to add some kind of delays at one end or the other to allow that to happen properly. Usually it will work out of the box, but there is no guarantee that just because the voltage levels and baud rates are compatible that the protocol will be compatible. With RS-485 data going both ways is transmitted on a single differential pair, so the possibility of collisions exists even with only two devices on the bus. Here is a white paper that covers the issues.
H: What benefit is there in synchronizing my switching supply to the system clock Working on a power supply design, some of these integrated buck/boost all-in-one dc/dc switching supplies have selectable switching frequency and some can synchronize to an external clock. What benefit can be found from synchronizing my switching supply to my system clock (or fraction of)?. For references there is only one clocked ic in my device (a DDS chip) and the rest are either asynchronous logic or just basic analog components. I'm specifically looking at the LTC3115(datasheet) as my master regulator, with daisy chained 79/78XX style linear regulators for the rails. AI: If your switching power supply frequency is close to your system clock but not exact, you could get mixing (from nonlinearities), perhaps causing interference in your signal band in analog circuitry. Usually it's the difference ("beat") frequency, not the sum, that can come to haunt you. Mixing is a nonlinear operation (multiplying) and the sum and difference signals derive directly from the trig identity: If they're synchronized, usually such problems will be minimized (perhaps a DC offset at worst).
H: Bidirectional 5 V to 3.3 V level shifter How do I interface 3.3 V Input/Output to 5 V Output/Input? I need it primarily for an Arduino Due but any general purpose bidirectional circuit (or IC) would work. Some people advised me to use the SN74AHC125 and CD4050 ICs, but I don't understand how they work or how to interface with them. AI: A very simple bidirectional level translator can be made with a single N-mosfet: The mosfet used should be a model with a low Vgs threshold, so that it can have a relatively low Rds-ON (ON resistance) at the intended input voltage level (3.3v in this case). BSS138 in one such example, it has a Vgs-th of 1.5v max and is specified to have a low drain-source resistance with Vgs voltages as low as 2.5v (maybe slightly lower too). The shown example uses 3.3v <-> 5v translation but it can also work with 2.5v <-> 3.3v or 2.5v <-> 5v, even between 2.5v <-> 12v. The range is only limited by the characteristics of the mosfet used. The shown circuit is based on an application note from NXP AN97055 Bi-directional level shifter for I2C-bus and other systems New shorter version: AN10441 Level shifting techniques in I2C-bus design When L1 is high (3v3) or floating R1 keeps the mosfet off so R2 pulls the drain side high (to 5v). When L1 is pulled low then the mosfet conducts and the drain becomes low. When a low level (0) is applied to H1 then that voltage is transferred through the substrate diode to the source side (L1) Please note that the resistance size can affect the speed (image source) Alternative transistor solution Relevant articles you may find useful: Don't pay for level translators in systems using multiple power-supply voltages - EDN 3V Tips 'n Tricks - Microchip
H: 0-12V Adjustable Home Made DC Source not working I have a home made dc source that is made a few years ago. Solders at the back of the board are very bad so I can not track the connections very good. But it's circuit diagram is very similar to the following diagram. Solders of connections of pot was broken off. I connected them randomly. I measured the output, the output voltage is 0 V. I changed the pin connections of pot but the output is still 0V. I did some measurements and saw the output of regulator is 0V while its input is approximately 17-18 V. Is it possible regulator is broken? What can be the reason of 0 volt at the output of the regulator? What can be the reason of 0 volt at the output of dc source? AI: With ABOUT 18V on LM317 input: Short ALL 3 pot connections together. You should get about 1.2V output. If not 1.2V check LM317 input. If LM317 input is ~= 18V and all pot pins are shorted and Vout not ~= 1.2V the LM317 is dead. If LM317 input is loaded down to << 18V something is wrong with cct shown. If LM317 output is ~= 1.2V then Turn pot to half position. Measure resistance between pins AB BC CA One pin will measure ~= 5k/2 to other two. Two pins will measure 5k between them (if 5k pot) ~= half R pin is wiper. Connect one end pin to known cct ground. Connect wiper pin with pot set to half setting to each of 3 pot pins on PCB in turn. When wiper is on correct pin Vout will be ABOUT (2500 + 220)/ 220 * 1.2 = ABOUT 15V. As pot may ne lin or log or ??? mid point may not be half Resistance position so Vout may be in 10-16V range probably. You now know wiper pin. Either of end pins can go to either of the remaining two positions. Swapping them reverse rotation direction for increasing voltage. If this is now not working there is something else wrong with your circuit. Added: Take a BARE LM317. Put a cap at Vin and Vout (anything - 1 uF, 100 uF,...) Ground ref terminal. Put 220R from Vout to ref (this is essential). Apply 18V to Vin. Measure Vout. If it is not ~~~= 1.2 V rejig brain and try again.
H: What is referred to as CMOS sensor rolling shutter width? I know what a rolling shutter is. But what is referred to as the "rolling shutter width"? Wikipedia: CMOS sensor: Active pixel sensor Rolling Shutter I don't think Focal Plane Shutter is related because I don't think a mechanical shutter is used. I am not 100% sure though. If somebody tells me that "rolling shutter width" is a term used with mechanical rolling shutter, that is fine. - Wikipedia Focal Plane Shutter AI: I would say its the width of the exposed part of the sensor: you can have a slit that is 1mm move across the sensors, or 10mm, etc. Probably useful to write as a ration, 10% of the sensor width/height. Added: RM What Sandos said above. Expanding on that. A rolling shutter (Wikipedia) is a camera (or image) sensor technique that produces exposure times that can be effectively far faster (shorter duration) than the response time that can be achieved with a shutter alone. This is achieved by exposing only part of the sensor at any one time. If eg 20% of a sensor is exposed to light at any moment but the whole sensor is exposed at some point then the effective speed is 100%/20% = 5 x faster than the actual shutter time. This is because 5 x less light reaches the sensor than if it was all exposed at once... Not exposing the whole sensor at once can cause some "interesting" distortions. Image below taken with an iPhone 4 with rolling shutter - from this superb description of rolling shutter distoprtion effects Alternative names are "roller blind" shutter and "dual curtain" shutter and "focal plane" shutter. (Their can be other forms of FPS but the dual curtain shutter is the most usual. These names derive from the use of mechanical "curtains which move to first open the light path and then to close it. In modern sensors it may be possible to replace one or both "curtains" with electronic turning on and off of the sensor elements. While a mechanical shutter will have a physical moving curtain the CMOS equivalent is simply active or inactive sensor elements. To date the industry tends to imitate the mechanical arrangement so that a "wave" of active sensing propagate across the sensor. If this "wave" occupies 20% of the total width then the rolling shutter width will be 20% of the sensor width. Once technology advances enough to allow the sensor portions to be enables and disabled semi randomly it will be advantageous to distribute the on and off areas. This would mean that there was no rolling shutter width per se. The image below shows 3 examples of a rolling shutter in action. In the left hand example the 1st curtain is falling and exposing the whole sensor area. It is not quite open as shown. The RSW (rolling shutter width) is the whole sensor width (5/6 as shown but it is likely to be going to fully open shortly). In the middle image the 1st curtain is descending but being followed by the 2nd curtain 50% of the sensor width behind it (3 of 6 bars). Any location on the sensor will be exposed for only 50% of the time that it takes either curtain to cross the sensor so the effective shutter speed will be doubled. The RSW is 50% of the sensor width. In the right hand image the 2nd curtain is following the 1st curtain only 1/6 of the total width behind it. Shutter speed will be multiplied by 6. The RSW is 1/6 of the full sensor width. Here is the same image as above but animated so that the dual curtain action can be seen. Wikipedia Focal Plane Shutter From the above page: Slow speed operation. 1st/red curtain opens fully before 2nd curtain starts. Rolling curtain width is whole sensor width High speed operation. Red / 1st curtain starts to expose sensor but green/2nd curtain follows it before it has crossed sensor so there is a window or slit moving across the sensor. The rolling curtain width is the distance between red and green edges.
H: How to get input voltage of 5 and 6 volts I have an interesting problem in building something with robotics. I am using a PIC16F877A micro-controller to control the robot. The motors of the robot require 6 volts and the PIC requires 5 volts. I was wondering if there was an easy way to get both of these required voltages from a common voltage source. The motors suggest running on 4 AA batteries, and I was going to just use a 7805 voltage regulator to than reduce the voltage to 5 volts, but the regulator requires at least 7 volts to function correctly. I also thought that I could use a voltage divider network, but none seemed to be convenient. AI: Chris Stratton's solution is the best, I think. Get a 3.3V LDO. The PIC16F877A (datasheet) will run happily from 3.3V, as will most of the usual transistorised H-bridges that you might use for motor drive. You can then run the whole thing from 4 AA cells, either alkaline or NiMH rechargeables. This avoids problems when the battery terminal voltage drops under load (which it will once you turn on the motors). It is not a good idea to run the motors and the PIC from the same power supply with no intermediate filtering or regulation, as the noise may cause the PIC to reset.
H: Resistance of a semiconductor diode When we calculate the dynamic resistance \$r=(\frac{dv}{dI})\$, for any n-p junction, how is it different from the normal resistance \$R=\frac VI\$? Does the equation for the voltage drop (The fermi potential drop, and not the absolute Galvani potential) work if we use the dynamic resistance with the instantaneous current (\$V=Ir\$)? Does the power dissipation relation, \$P=I^2r\$ hold in case of dynamic resistances? If it does, is power dissipated as heat even in case of the n-p junction? I think it is unlikely, as the hole-electron recombinations are the dominant phenomenon here, and I am unsure whether those can produce heat. AI: For the ideal resistor, the voltage across is proportional to the current through and thus, their ratio is the constant \$R\$: $$\frac{v_R}{i_R} = R $$ For the ideal (semiconductor) diode, we have $$i_D = I_S(e^{\frac{v_D}{nV_T}}-1)$$ Inverting yields $$v_D = nV_T\ln (1 + \frac{i_D}{I_S}) $$ thus, the diode voltage is not proportional to the diode current, i.e., the ratio of the voltage and current is not a constant. $$\frac{v_D}{i_D} = \frac{nV_T}{i_D}\ln (1 + \frac{i_D}{I_S}) \ne R$$ Now, the small-signal or dynamic resistance is just $$\frac{dv_D}{di_D} = \frac{nV_T}{I_S + i_D} \approx \frac{nV_T}{i_D} $$ how is it different from the normal resistance As shown above, the diode static resistance (ratio of the diode voltage and current) differs from and is, in fact, larger than the diode dynamic resistance by the factor of \$\ln (1 + \frac{i_D}{I_S})\$ $$\frac{v_D}{i_D} = \frac{dv_D}{di_D} \ln (1 + \frac{i_D}{I_S})$$ which is to say that, in typical operating ranges, the diode dynamic resistance is much smaller than then diode static resistance. Does the power dissipation relation, \$P=I^2r\$ hold in case of dynamic resistances? The instantaneous power associated with the diode is $$p_D = v_D i_D = nV_Ti_D\ln (1 + \frac{i_D}{I_S}) \ne i_D^2\frac{nV_T}{i_D} = nV_Ti_D $$ Since the power associated with a circuit element is always the product of the voltage across and current through, one would not use the dynamic resistance but, rather the static resistance.
H: Component polarity markings Ok, I have my capacitor 4700 mikes should more than do the trick. I have my diode, soldering iron, jumpers and leads. Then I realized its been so long since I've installed solid state components I forgot how to do it. So 3 quick questions for clarification. The painted end of the diode is the emitter so that end is connected to the cap and the other end to the source lead right? The Arrows on the Cap point in the direction of current flow so I solder the emitter of the diode to the "base" of the arrow and the other to ground.? Finally, I solder the diode/cap junction to the lead going to the voltage sensor right? AI: The painted end of the diode is the emitter The end with a line around it is the cathode. If the cathode is connected to a more negative potential than the anode, the diode will conduct. It's orientation depends on it's purpose. The Arrows on the Cap point in the direction of current flow Not all capacitors are polarised (care about +ve and -ve). Electrolytic capacitors typically are marked with a line next to the lead which should be most negative. I solder the diode/cap junction to the lead going to the voltage sensor right? This depends entirely on what you are building. Reading the schematics for the circuit will answer this. You may have had something like this in mind? simulate this circuit – Schematic created using CircuitLab
H: Question about analog and digital ground planes I am using a microcontroller with an integrated DAC. On my 4 layer PCB, I have connected the digital and the analog ground planes below the microcontroller. The microcontroller and the DAC are supplied by a 3.3V regulator. The DAC amplifier is supplied by a 5V regulator. See the following picture? Which ground plane (GND or AGND) should the 5V regulator be referenced to? Which ground plane should the DAC amplifier supply (and its decoupling capacitor) be referenced to? AI: In general, the point of separating ground planes is to reduce the influence of any noisy components on the noise-sensitive ones. Thus, the voltage regulators and primary micro circuitry should use the normal ground, and the micro analog, amplifier, amplifier decoupling capacitor and voltage divider resistors should use the analog ground. This is what you have already illustrated. (Note that the passive components in the analog portion can introduce noise as well, but there is little you can do to avoid that, since grounding them to the general plane will just couple in even more noise.) Another strategy that is often used for noise reduction is to group and separate the noisy components from the sensitive ones. This could be as simple as placing the power components on one side of the micro, and the amplifier and friends on the other side. Make sure the routing is direct and as short as possible, and decrease the impedance by increasing trace widths or copper weight wherever possible. Note that this can be used independently of, or along with, the separate ground planes. This e2v application note is a very good place to start when laying out out a mixed signal board.
H: How to calculate the Voltage on the scheme with inverted amplifier? Given input 1mA and resistances: 1kOmh and 100Ohm. Find the V[exit]. My try: V[on R1] = I[R1]*R1 = 1V As long as R2 "grounded" the I=0A and U=0V The difference in Voltage between "-" and "+" should be 0. How to solve it? AI: Given V- = V+ = 0V and no current flows into the opamp Then input current = output current 1mA = (0-Vout)/1000 Therefore Vout = -1V
H: Do high power through hole resistors need a heat sink I'm using the following resistor: click. To be precise, the MCKNP05SJ050KAA9 found here. From what I've been able to determine, my device is the MCKNP 500-S, measuring in with a length of 17.5 mm and diameter of 6.5 mm. Now, I'm wondering whether it is first of all possible, and second of all needed to put a heat sink on though-hole power resistors. At first I had found SMD Power resistors, though the only ones that could dissipate the required 4.5 W was a 35W. This one did have a metal plate on top for a heat sink. But for Through-hole components, I haven't got a clue. AI: Typically power resistors are designed to operate without a heatsink (or have one built-in). If the manufacturer recommended use of a heatsink, it would be covered in the datasheet. That said, they can get quite hot, so care should be taken to keep temperature-sensitive components away from a power resistor that is dissipating a lot of heat. Additionally you may want to ensure that the resistor is mounted with an air gap below it as well (not touching the PCB) to promote air circulation on all sides. A surface mount power resistor with a pad for heatsink may require a copper pour/heatsink or a physical heat sink of some kind attached (see the datasheet for the component in question). Typical power resistor Power resistor that incorporates a heatsink
H: Emulating 2.4 GHz transmission without ICs I'm looking for a way to emulate 2.4G transmission without using complex IC components like nrf51/24. I imagine a gramophone recording, but broadcasted on 2.4 GHz into space. No need to receive anything, just send into the wild. Is it technically possible to pre-record the transmission onto EEPROM and just read and send it to TX antenna with arbitrary intervals? Thanks! AI: Yes, it is technically possible to play back pre-recorded or pre-sampled signals at a baseband or a very low IF and upconvert them to 2.4 GHz. The upconverter could be built with analog electronics; potentially discrete though you may not want to rule out using MMICs. The bandwidth and center frequency of your baseband / low IF sampler would depend on the bandwidth which your system needs to access. Most 2.4 GHz systems hop frequently, but if yours does not you only need the bandwidth of a single channel. If it hops, you'll either need a wider band system which can encompass all the used channels, or to coordinate channel switching in the upconverter. For moderate bandwidth, an analog tape deck could be substituted for the sampled playback system. For really low bandwidth, a mechanical gramophone could. Note that building this system from general-purpose building blocks is likely to be much more work and expense than using an IC purpose-made to perform this type of function in low-cost consumer gadgets. You'd basically be building a software-radio transmitter, just without running the software modulator in real time.
H: CAN bus ESD protection For a CAN bus application, is it correct to connect an ESD protection IC to GND, or chasis of the device? AI: The point of ESD protection is to give high voltages an easier path to ground than through the sensitive components on the board. In general, the protection devices will thus be connected to the circuit's ground. If the case is solidly grounded (either to an earth ground or to another common ground, such as a vehicle chassis), a case may be made for including it in the ESD protection scheme. The idea is to dissipate as much of the power of the discharge as possible in a small amount of time, and the added metal and common ground will help that. However, when introducing an enclosure into a circuit, additional factors come into play: Ground loops - if you're not prepared for this possibility, the enclosure should not be considered as a ground Connection capacity - your connection to the chassis should allow for high (albeit momentary) currents Interference - if the design ends up connecting the ground plane to the enclosure, there is a new point of entry for undesirable signals that may disrupt the operation of the circuit The end result is that it's much easier to avoid involving the enclosure in any ESD protection schemes. There may be advantages to doing so, but there should be careful consideration involved. Here is an EDN article on ESD mitigation measures for high-performance serial busses: http://edn.com/design/analog/4314519/Maximizing-EOS-and-ESD-immunity-in-high-performance-serial-buses.
H: Reducing voltage for solid state relay I have a solid state relay which wants a 1.25-2.5V "activation" input, but my output from the micro controller is 5V. Is it possible to use a zener diode for this? Or do I need a buck converter? I don't know how small/big the resistance or current through the relay is, but if I knew that I could perhaps use a parallel resistor with a lower resistance? Perhaps there is a better way? AI: Solid state relays generally have LEDs on the input side. Sometimes they have resistors in series with these LEDs, sometimes not. Depending on the current requirement, you can drive the SSR input directly with the microcontroller output and a series resistor. Ultimately LEDs run on current, and have a fairly predictable voltage accross them when doing so. A resistor in series with a LED to allow driving it from a higher voltage is perfectly legitimate. If the microcontroller output can't source or sink (the SSR input can be between power and the micro) enough current, then you have to use a transistor somehow anyway. The simplest is: You have to look in the relay datasheet to see how much voltage the LED drops, what current it is intended to be run at, and what the value of the internal resistor in series with the LED is, if any. Then it's easy to determine the value of R1. For example, let's say the LED requires 10 mA to operate the relay, drops 1.2 V in the process, and the internal resistor is 100 Ω. The emitter of Q1 will be about 4.3 V when the digital output is high, so that leaves 4.3V - 1.2V = 3.1V for the combined resistance to drop. 3.1V / 10mA = 310 Ω, which is what the combined resistance should be. 100 Ω of that is already inside the relay, so R1 should be 210 Ω. The common value of 200 Ω would be good, and definitely provide for the 10 mA. SSRs usually have wide latitude in the allowed LED current. However, don't guess, look at the datasheet.
H: Mathematical proof that RMS voltage times RMS current gives mean power I know this is true because I read it in a reputable source. I also understand intuitively that power is proportional to the square of voltage or current for a resistive load, and that the "S" in RMS is for "square". I am seeking a hard mathematical proof. Let \$I_i\$ denote the current at instant \$i\$, and likewise \$V_i\$ denotes the voltage at that instant. If we can measure voltage and current at all the instants, and there are \$n\$ instants, then mean apparent power is: $$ P = \frac{1}{n} \sum_{i=i}^n I_i V_i $$ What is an elegant mathematical proof that $$ P = I_{RMS} V_{RMS} $$ achieves the same result for resistive loads? AI: Ohm's law $$ 1: V(t) = I(t)R $$ Instantaneous power dissipation is product of voltage and current $$ 2: P(t) = V(t)I(t)\\ $$ Substitute 1 into 2 to get instantaneous power through a resistor in terms of voltage or current: $$ 3: P(t) = I^2(t)R = \frac{V^2(t)}{R}\\ $$ Average power is definitionally the integral of instantaneous power over a period, divided by that period. Substitute 3 into that to get average power in terms of voltage and current. $$ 4: P_{avg}=\frac{\int_0^T{P(t)dt}}{T}=\frac{R\int_0^T{I^2(t)dt}}{T}=\frac{\int_0^T{V^2(t)dt}}{RT}\\ $$ Definition of RMS current $$ 5: I_{RMS}=\sqrt{\frac{\int_0^T{I^2(t)dt}}{T}}\\ $$ Square both sides $$ 6: I_{RMS}^2 =\frac{\int_0^T{I^2(t)dt}}{T}\\ $$ Multiply by R to find equation 4 for average power $$ 7: I_{RMS}^2R =\frac{R\int_0^T{I^2(t)dt}}{T}=P_{avg}\\ $$ Definition of RMS voltage $$ 8: V_{RMS}=\sqrt{\frac{\int_0^T{V^2(t)dt}}{T}}\\ $$ Square both sides $$ 9: V_{RMS}^2=\frac{\int_0^T{V^2(t)dt}}{T}\\ $$ Divide by R to find equation 4 for average power $$ 10: \frac{V_{RMS}^2}{R}=\frac{\int_0^T{V^2(t)dt}}{RT}=P_{avg}\\ $$ Multiply expressions 7 and 10 for average power $$ 11: P_{avg}^2=V_{RMS}^2I_{RMS}^2\\ $$ Square root of both sides $$ 12: P_{avg} = V_{RMS}I_{RMS}\\ $$ Q.E.D.
H: reason(s) to use a 10-bit ADC instead of a 12-bit ADC? I think this question almost answers itself, but I've learned that's not always the case. It appears from my somewhat brief googling and catalog-trawling that Microchip sells the 3008 and 3208 ADCs. Other than the resolution itself, are there any meaningful differences in these two parts? The price difference is $1 (in quantity) so I realize that if you're building something (or hundreds of them, really) where you only NEED 10-bits it might be worth saving a buck, but for general purpose / hobbyist type applications is there any reason NOT to just go with the 12-bit version? I assume that the interfacing code is all the same across these? AI: Cost is one factor, as you note. $1 is a big difference in price for a lot of people. Also consider the complexity in interfacing with the ADC. If it has a parallel interface, you need two extra pins for the 12-bit ADC versus the 10-bit. If it has a serial interface, then you don't need extra pins, but you need extra time to transfer two more bits1. If the serial interface is slower than the ADC, this limits the sample rate, since you can't start reading a new sample until you are done reading the previous. This is all assuming that everything else is equal. In reality, that's probably not true. A careful reading of the datasheets is necessary to understand all the differences. 1: assuming, as The Photon points out, that the serial protocol used by the ADC doesn't transmit the measurements in octet chunks, in which case either 10 bits or 12 bits requires two octects, or 16 bits.
H: How to place a 7805 voltage regulator on a breadboard? I have this breadboard and I have started experimenting with pic micros. In doing so I have needed a 5 volt power supply. I have seen several tutorials for wiring up 5 volt regulator circuits on a breadboard, however when I try to hook up the 7805 on the breadboard, the 7805 will not fit on the breadboard. With extra force I can force it on the breadboard, but I assumed this would damage the breadboard. What is a common solution to this problem? AI: You could solder #22 or #24 wire to the 7805 leads, then poke those wires into thte breadboard. Alternatively, build the voltage regulator on some perfboard (or just solder things together in mid-air), rather than trying to put the 7805 on the plastic breadboard.
H: Using the offset NULL on an omp amp I'm trying to get my head around how the offset NULL works for an op amp. I think i'm getting somewhere with it. The op amp i'm using is the TL081 from this datasheet: http://www.futurlec.com/Datasheet/Linear/TL084CN.pdf I understand that the input offset is the voltage of the output when the two inputs are equal and I also understand that when you use a set of resistors to get a voltage gain this offset is also multiplied by the gain. So my main question is by using a variable resistor on the offset NULL legs and getting this closer to 0v than the op amps current input offset does this mean I can use the op amp to amplify voltages in the range of mV now? So if i use a gain of around 1000 would this now be acceptable to use given that i null the input offset? Thanks AI: TL081 is not a particularly good choice for low DC voltages (it's better for AC coupled designs). Precision op-amps have offset voltages in the 10's of microvolts or lower, and there are even auto-zero op-amps that have negligible offset voltage, an drifts in the tens of nV/°C (at some significant cost in other characteristics). It's also quite noisy (25nV/\$ \sqrt{Hz}\$), but at least has a typical flicker noise corner frequency in the 1Hz range. Aside from high input Z, it has basically one really nice advantage, it's really cheap, and widely available, which is why I've actually designed such a 37-year-old op-amp into a new product recently. A good general purpose (low noise, capable of handling +/-15V supplies, low distorion for AC signals) precision op-amp suitable for mV levels might be the OPA209A. You can certainly null the offset voltage of your TL081 out using a trimpot as shown on the datasheet, but it won't stay that well nulled for long. A 10°C change will typically change the offset voltage by 100uV, and about one out of every two will be worse (there's no guarantee how much worse, but a guess would be most are better than +/-30uV/°C). An OPA209 is going to be roughly an order of magnitude better. There are probably going to be better (and many worse) choices for any given application, all things considered. It's amazing what performance you can get for a a few dollars, so it's worth looking around rather than trying to make a silk purse of a sow's ear. Just to give you an idea of the kind of (in) accuracy you could get, consider that the gain of the TL081 is only guaranteed to be >15,000, so a gain of 1000 amplifier could have a gain error in the 6% range even without the input offset error (which would be very temperature dependent, and has a -3dB corner of something like 20Hz. Cascading two \$\sqrt {1000}\$ gain amplifiers would help with that (null only the first one). If the range is, say +/-5mV input, frequency is 0.001 to 1Hz and required accuracy 1% of FS + 50uV**, it might be typically *** okay in a lab environment with a light output load, if you null it after warm-up. ** Instrumentation type specification- it means the output could be as much as +/- 100mV from the ideal value with any input, so a 1mV input could give you 900mV or 1100mV. *** "Typically" means that one chip might be okay, and the next might not meet the requirements. Guaranteed value is probably 10 times worse.
H: Are there other uses for the value of RMS current besides heating computations? For most purposes I've personally encountered, RMS current and voltage have been useful only for computing heat losses in a resistor. Do RMS current or voltage have other applications besides computing heat loss? AI: RMS is nearly always associated with power, but there are many times you want to know power that don't involve heating resistors. For example: The power sent to a speaker becomes sound waves. The RMS value of the waveform corresponds to the perceived loudness of the sound. Signal-to-noise ratios are power ratios. Therefore, you want to compute the RMS values of the signal waveform and the noise to get a SNR value. In electrical power transmission, it's the RMS values of voltage and current that correspond to the power delivered to, say, a motor (assuming the power factor is near unity, of course). There are many more examples. The point is, in most forms of AC signal analysis, the RMS value is nearly always the more useful value — although there are times when you need to be aware of the peak value as well.
H: Magic smoke released from DIY PSU... but why? I'm starting to learn what I can about electronics, and recently decided to follow this (and similar) guides to building a bench power supply out of an ATX PSU: http://www.instructables.com/id/Convert-A-Computer-Power-supply-to-a-Bench-Top-Lab/step3/Presenting-The-Power/ In this guide, there is a schematic to take the +12V and -12V lines and combine them with a potentiometer to output a range of voltage up to 24V. (source: instructables.com) I followed the guides and built the circuit as shown (using an LM317 voltage regulator) and the potentiometer shown here: http://www.amazon.com/gp/product/B009QFU9H4/ref=oh_details_o03_s00_i00?ie=UTF8&psc=1 Each of the 3 power rails (3.3V, 5V, +12V) are connected to a fuse, then to a binding post, while the negative binding posts go to ground. As an extra feature, an LED is wired in parallel with the binding post (and a current limiting resistor) so I have a visual indicator as to whether the fuse is blown. For the variable 24V output, there is an LED (with current limiting resistor for 12V) tied in parallel off of the +12V line used for the variable voltage. My questions are regarding the 24V output and... what I apparently screwed up. Upon testing the circuit, I connected a voltmeter to the 24V output and ramped up the potentiometer. It released its' smoke about halfway up, so I aborted the test and connected the leads that went to the (now dead) potentiometer to an ammeter. I figured maybe there was too much current for the potentiometer. Shortly after powering on the supply again, the voltage regulator in the circuit below fizzled out of existence and I killed the power before any further damage could take place. My theory is that I'm not understanding how this 24V is being produced properly, and that perhaps the ground from the LED on this connection is somehow causing everything else to fail. Or, that the potentiometer couldn't handle the amperage, and perhaps the LM317 died because there was no heat sink and it simply overheated. I'd like to know (a) if my theories are correct, and (b) if there is a way to fix this and allow it to function the way I am expecting. It's hard for me to understand how the 24V variable line is not grounded and can still work properly, and perhaps I shouldn't be attempting to build a circuit I don't completely understand. If I can provide any more details that will help, please ask away! I'm assuming that if I can't make this function properly, I could replace the potentiometer, remove the variable circuit below and simply use the +12V rail with the potentiometer in line to regulate from 0-12V. (I don't have anything that I could immediately imagine using 24V for anyway). Thank you very much for your time and insight! AI: Each of the 3 power rails (3.3V, 5V, +12V) are connected to a fuse, then to a binding post, while the negative binding posts go to ground. This sounds like the problem. Keep in mind, voltages are differences in potential between two points. There's nothing special about ground, it's just an arbitrary point which we pick. It's 0V because the difference of something with itself is 0. You can call anything you want "ground". That's why this circuit works. If you call the -12V output as "ground", then everything else is 12V higher. That's including what was previously called "ground": now it's 12V, because it's 12V more than what you are now calling ground. Now consider what you've done: simulate this circuit – Schematic created using CircuitLab The "ground" of the power supply connects all of the voltages supplied together (connections labeled B and C). The output voltages are relative to this. Notice how the -12V (V4) makes a negative voltage because it's positive side is attached to "ground". Then, you attached the negative binding posts of all the supplies together. Largely this is redundant: you are duplicating connections B and C. But you are also adding connection A. See the problem? You've shorted out V4. A wire has ideally zero resistance. By Ohm's law, the current that will flow is: $$ \frac{12V}{0\Omega} = $$ In reality, the wires used to make this connection actually have some very small resistance, and you get a whole ton of current. This far exceeded the current the voltage regulator can handle and the smoke got out.
H: What seven segment display do I have? I'm having a surprisingly hard time figuring out which seven segment display I have on a board I'm looking at. It is common anode, as there is one pin tied directly to Vcc. It's like this, except rotated 90 degrees (the pins are vertical, along the sides): Assuming pin 1 is in the top-left (at the f-a intersection), I know that the CA is at 3,8. But other than that I don't know which pin is which. AI: For practical purposes, you will never find the datasheet for the 7 segment display you have. Especially of one that's used in a random device you are just trying to figure out. They are rarely off the shelf parts. They tend to be custom designed, or at the very list, a standard one is marked with a custom part number. The specs are under NDA. Unless you work for the company that ordered the parts, you won't find it. That said, you can take first parts of the part number (if any is printed on the display), and look for similar ones. The pinouts are often identical or very similar. If no part number is listed, or you don't find anything, then you have to get your hands dirty. First, forget about a "standard" pinout. They don't exist. Get a 3v coin cell battery. They have high internal resistance, so they can be used without resistors. Taking advantage of the Diode part of the LED which prevents current from flowing the wrong way, and the low voltage of a 3v coin cell, connect one side of the battery to one pin. Then connect the other side to every other pin, one by one. Have a note pad handy. You can make your own schematic that way. The rest can be done by making a schematic of the board. Find the voltage source, find the inevitable resistors (with values if you can). Then use Ohm's law. I = V / R. By assuming 20mA and typical forward voltage drops for the color you see (~2v red, orange, ~3.2 green, blue, etc), you can figure out pretty much everything you need about it.
H: Reporting crashes/resets in Embedded Systems(8 bit) I'm using PIC controllers, and I have used watch dog timers to trigger a reset in case of the s/w gets stuck somewhere, and also to support in case of severe hardware crashes. I think that resetting the CPU is good, but reporting the crash should also be a very good viable option to help debugging. I'm currently searching a method to do so. I have an EEPROM with free space for such purpose. Is there any standard procedure for reporting crashes? What parameters shall I monitor / trace in such crash reports? AI: In addition to Nick's suggestion to use the RCON which is very useful here are a few other ideas / pointers that you should keep in mind: Make sure to check the endurance of the EEPROM if you're always writing data to the same location. Even if it has an endurance of 1,000,000 million cycles if your system can start up in 100ms it wouldn't take much over a day of constant reboots to cause an EEPROM failure if you get constant reboots due to flaky connections / power etc. Maybe consider a delay for non-watchdog restarts or introduce a delay on pupose to avoid that possibility. Another (probably easier / better way) to avoid that problem is to set aside an area of EEPROM into fixed size blocks and use a marker at the start of block to indicate if it's been used (non 0xFF value) and simply stop recording errors once the memory is full. Then after the error log has been read erase everything so it's good to go for next time. In the case of a watchdog reset the contents of RAM will still be intact. You'd need to test / verify / change this for the particular compiler you're using but for the case of a watchdog reset it would give the possibility of logging the value of some of the more important state variables as part of the error report. Many compilers zero the contents of RAM upon startup so you'll need to check into that side of things. You'll need to ignore the contents of the memory for other restart types though. Some sort of timestamp will be valuable in later analysis. Obviously an RTC go give an absolute date/time would be ideal but if not available maybe you could include some sort of tick counter to at least give a relative idea of the time span between failures. You could always read and record the value of I/O lines and analog inputs and record them upon reboot, but be aware their value may have changed since the initial condition that caused the crash. Depending on the code space and performance you have left to spare if you preserve the contents of a few RAM locations across a watchdog restart you could also consider adding an integer or bitmask to indicate what code / interrupts were called just before the error condition.
H: Subtraction using adder circuit I need some really basic help here. Can I use a 4bit adder chip as a subtracter by using the 2's complement for the number to be subtracted? AI: In 2's complement, negation can be achieved by inverting a number and adding one (ie -A = ~A + 1). To subtract a number B from A, invert B, add 1 to it, then proceed to add that sum to A. A - B = A + ~B + 1 In order to transform a normal adder IC into a subtractor, you need to invert the second operand (B) and add 1 (by setting Cin = 1 ). An Adder subtractor can be achieved by using the following circuitry. Note that when the control signal SUB is low, A = A B = B Cin = 0 Therefore, the computed sum will be A + B + SUB = A + B. But if SUB = 1 A = A B = ~B Cin = 1 Meaning the computed sum will now be A + ~B + SUB = A + ~B + 1 = A - B, hence achieving subtraction.
H: problems using atmega644pv jtag pins as gpio I've been trying to use port C pins on an atmega644pv as gpio, and have been running into some trouble. as far as i can discern, it seems like the middle four pins (PORTC 2,3,4,5) are stuck in a high impedance state (used a screwdriver to short them the outer four pins, and the later mentioned leds behaved as desired). digging a bit it looks like these are the JTAG pins, but i disabled JTAG via the fuse bits. the code below (should) make the attached leds light up sequentially, sort of like a cylon/knight rider project but only going in one direction, but when i run it the four middle leds only light dimly, whereas the outer ones hit full brightness. for reference, the leds are attached between PORTA and PORTC, and have a resistor series with them on the PORTA side. I can't use only PORTA and ground, because i need to reverse bias the leds in my actual code, and then monitor their voltage. -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m #include <avr/io.h> #include <util/delay.h> int setup(void) { DDRD = 0x7F; MCUCR |= (1 << PUD); MCUCR |= (1<<JTD); PORTD=0x00; DDRC=0xFF; DDRA=0xFF; } int main(void) { DDRA=0xFF; DDRC=0xFF; PORTA=0x00; PORTC=0xFF; while(1){ if (PIND&0x80){ PORTC=0xFF; PORTA=(0b11111110); _delay_ms(10); PORTA=0b11111101; _delay_ms(10); PORTA=~0b00000100; _delay_ms(10); PORTA=~0b00001000; _delay_ms(10); PORTA=~0b00010000; _delay_ms(10); PORTA=~0b00100000; _delay_ms(10); PORTA=~0b01000000; _delay_ms(10); PORTA=~0b10000000; _delay_ms(10); PORTA=~0b00000000; } else{ _delay_ms(10); } } return 0; } many thanks! EDIT: forgot to call setup() at the beginning of main() =( more coffee was required AI: Section 8.10.7 in the datasheet lists the following ways to disable JTAG Disable the OCDEN Fuse. Disable the JTAGEN Fuse. Write one to the JTD bit in MCUCR. You say you have disabled JTAG from the fuses but just in case, can you add the following at the start of main (or setup) MCUCR |=(1<<JTD); MCUCR |=(1<<JTD); The JTD bit needs to be written twice : In order to avoid unintentional disabling or enabling of the JTAG interface, a timed sequence must be followed when changing this bit: The application software must write this bit to the desired value twice within four cycles to change its value. I noticed that you have already included the following in setup() MCUCR |= (1<<JTD); but a single write will not have any effect as I explained above Adding to what Ignacio Vazquez-Abrams wrote in the comments, you may run into trouble with the read-modify-write operation as opposed to a write only operation. (using avrgcc) READ/MODIFY/WRITE with Os,O3,O2 optimization level the read/modify/write you get a code which is barely within the 4 cycle limit but will work: MCUCR |= (1 << JTD); 88: 85 b7 in r24, 0x35 ; 53 8a: 80 68 ori r24, 0x80 ; 128 8c: 85 bf out 0x35, r24 ; 53 MCUCR |= (1 << JTD); 8e: 85 b7 in r24, 0x35 ; 53 90: 80 68 ori r24, 0x80 ; 128 92: 85 bf out 0x35, r24 ; 53 With O1 optimization level you get a code which will not work (7 cycle between writes): MCUCR |= (1 << JTD); 94: e5 e5 ldi r30, 0x55 ; 85 96: f0 e0 ldi r31, 0x00 ; 0 98: 80 81 ld r24, Z 9a: 80 68 ori r24, 0x80 ; 128 9c: 80 83 st Z, r24 MCUCR |= (1 << JTD); 9e: 80 81 ld r24, Z a0: 80 68 ori r24, 0x80 ; 128 a2: 80 83 st Z, r24 a4: ff cf rjmp .-2 ; 0xa4 <main+0x10> With O0 (optimization off) you get a code which is way off from the 4 cycle limit: MCUCR |= (1 << JTD); 90: a5 e5 ldi r26, 0x55 ; 85 92: b0 e0 ldi r27, 0x00 ; 0 94: e5 e5 ldi r30, 0x55 ; 85 96: f0 e0 ldi r31, 0x00 ; 0 98: 80 81 ld r24, Z 9a: 80 68 ori r24, 0x80 ; 128 9c: 8c 93 st X, r24 MCUCR |= (1 << JTD); 9e: a5 e5 ldi r26, 0x55 ; 85 a0: b0 e0 ldi r27, 0x00 ; 0 a2: e5 e5 ldi r30, 0x55 ; 85 a4: f0 e0 ldi r31, 0x00 ; 0 a6: 80 81 ld r24, Z a8: 80 68 ori r24, 0x80 ; 128 aa: 8c 93 st X, r24 ac: ff cf rjmp .-2 ; 0xac <main+0x24> WRITE A better approach is to just use a write operation that will work fine with any optimization level (Os,O1,O2,O3) but not when you disable optimization (O0) Using Os, O3, O2 MCUCR = (1 << JTD); 88: 80 e8 ldi r24, 0x80 ; 128 8a: 85 bf out 0x35, r24 ; 53 MCUCR = (1 << JTD); 8c: 85 bf out 0x35, r24 ; 53 Using O1 MCUCR = (1 << JTD); 94: e5 e5 ldi r30, 0x55 ; 85 96: f0 e0 ldi r31, 0x00 ; 0 98: 80 e8 ldi r24, 0x80 ; 128 9a: 80 83 st Z, r24 MCUCR = (1 << JTD); 9c: 80 83 st Z, r24 Using O0 MCUCR = (1 << JTD); 9c: e5 e5 ldi r30, 0x55 ; 85 9e: f0 e0 ldi r31, 0x00 ; 0 a0: 80 e8 ldi r24, 0x80 ; 128 a2: 80 83 st Z, r24 MCUCR = (1 << JTD); a4: e5 e5 ldi r30, 0x55 ; 85 a6: f0 e0 ldi r31, 0x00 ; 0 a8: 80 e8 ldi r24, 0x80 ; 128 aa: 80 83 st Z, r24
H: Preemptive Interrupts and "Context Switching" In RTOS, when a Higher Priority task becomes Ready to Run, it stops or preempts currently running (Lower Priority) task and start executing itself. Before switching tasks, RTOS saves required data related to lower priority task (Context Switching) Coming to my question, Like tasks, Interrupts also have priorities. When a Lower priority interrupt is executing and a Higher priority interrupt comes, What happens? Does it stores all data on Stack etc. just like RTOS? What will happen to my variables used in ISR? (Note that, this scenario is possible in a Non-RTOS based application too!) AI: This is basically entirely platform and compiler dependent. Some MCUs/CPUs have hardware for saving some or part of the stack, some do not. Additionally, Stack saving/loading is compiler-determined on some platforms. At least on atmel's xmega MCUs, context saving is up to the code, rather then the hardware. You can therefore write naked ISRs that could muck with the previous context without too much trouble. Basically, there is no general rule aside from "read the docs of the CPU in question".
H: Where have the 8 bit sound chips gone? I know it's 2014 and you can get an MP3 player and 40 bazillion terabytes on a microscopic chip. But I want to build a 6502 based retro computer and, in a perfect world, I would order up about 200 SID chips. Anyway, are there any mass produced audio chips these days that closely resemble the remarkable chiptunes of the 80's? I've ordered four AY-3-8912's off eBay but I'd like to find something similar but still in production. Oh, gutting vintage computers is out of the question. I restore them. Not gut them. ;-) EDIT I wanted to post a followup to those who are curious. Finding old vintage audio chips on eBay isn't too difficult. But, obviously, not for any kind of mass production. Anyway, I have found an alternative using the Propeller chip from Parallax. Using that microcontroller, you can emulate with high accuracy the SID, AY-3-8910 and SN76489 chips. Each emulated chip resides in one cog (from 8). SIDcog v1.3 SNEcog v0.6 AYcog v0.8 AI: Where have the 8 bit sound chips gone? No longer in production due to lack of demand. in a perfect world, I would order up about 200 SID chips. Too late are there any mass produced audio chips these days that closely resemble the remarkable chiptunes of the 80's? There's the things used in musical greetings cards and things like this - but thats resemble in the way an iPod resembles a Walkman. It fills a vaguely similar niche but uses very different technology. There's also SwinSID SwinSID is a hardware replacement for legendary SID sound chip
H: A question on how the transistor works Now I am not getting how the second equation is made. Because how can you measure VBC? Because then it will be like measuring the potential difference between two split wires... Something like this... So is that possible? AI: You can measure the voltage between any two points. For example, I could measure \$V_{kitchensink,tongue}\$ like this: place positive lead of voltmeter on kitchen sink place negative lead of voltmeter on tongue read measurement from voltmeter While this is probably not a meaningful measurement, it is defined anyway, because my tongue exists at some electric potential, and my kitchen sink exists at some other electric potential, and the difference between them is the "voltage", which is more accurately called the electric potential difference.
H: Changing I2C address I need to connect two Si114x light sensors to one I2C bus. I don't have them physically yet. Every sensor has the same I2C address, so connecting them with the default settings would mean a conflict. However, the datasheet (http://www.silabs.com/Support%20Documents/TechnicalDocs/Si114x.pdf) mentions a BUSADDR command which modifies the address, and the default value of the modified register is 0x00 (not 0x5A which is given as a slave address, that's a bit weird). My question is: does the sensor keep the address in a non-volatile memory? The datasheet doesn't say it explicitly. Can I just connect one sensor first as the only sensor to the bus, reprogram its address and then add the second sensor? Is it some kind of pattern in I2C devices? If not, the address modification command wouldn't make sense to me. AI: On page 54, the datasheet states: I2C Address[7:0] Specifies a new I2C Address for the device to respond to. The new address takes effect when a BUSADDR command is received. That pretty much means, that you first set this RAM value, then call the BUSADDR command. Anyway, I think your only shot is to separate one of the sensors somehow. This could mean a transistor for holding the SCL line high while you program the other sensor's address. After the initialization, you can keep this transistor conducting. simulate this circuit – Schematic created using CircuitLab ... I hope I didn't mess up the MOSFET's orientation ... Of course, this requires a separate signal. And I don't think you can do without it.
H: Possible uses of a MELF resistor? I have been doing some net-surfing on Farnell's website and stumbled upon a section called MELF Surface Mount Resistors According to Wikipedia, this package family has a rather funnily sounding de-abbreviation Most End up Lying on the Floor, since they are extremely easy to lose. This may be due to the fact that they are cylindrical... I myself have lost quite a few of such diodes. Wiki says, that there are three basic sizes. MELF, MiniMELF, MicroMelf - the two latter are in the power-rating range of 0603/0805 resistors. The 1W MELF package is obviously useful for dissipation reasons. So my question is, why on Earth would anybody design a board containing small MELF components, since they can easily be replaced with more modern flat parts? I cannot see a single advantage. Please prove me wrong. AI: The cylindrical construction of MELF devices provides an optimal power rating and pulse load capability related to the mounting space. Continuous development has led to improved long-term stability and moisture resistance, and allows high-temperature operation to + 175 °C. This paper explores why this resistor series has become so successful, and why there is often no alternative to it today in professional applications. Vishay
H: How should I use rotary switches and resistor networks to uniquely relate each possible combination of switch settings to an analog voltage? I'm designing a switched-mode power supply. I need to give my users the ability to set a voltage setpoint, with a range of approximately 200-800V, and at least 4V of resolution. This needs to be a hardware solution that feeds into my microcontroller. Cheap and simple and hard for the user to screw up are the goals. My predecessors have used potentiometers, which make it impossible to know what you've actually set without running the system. I don't have a display to work with, just a couple blinky lights. Not really the most effective way to identify a voltage like this. I'm thinking of using rotary switches. Three rotary switches, and an appropriate combination of resistors, should let me translate the setting of the switches to an analog voltage. In my ideal world, 000 translates to no voltage, 999 translates to 3.3V, and every setting in between scales linearly. Alternately, I could use twelve digital inputs to read the same information, but I'll need an I/O expander for that. I'm sure I'm not the first person to consider something like this. Is there a canonical way of doing this? If I go the analog route, how many resistors am I going to need? How many different values? Or is there an obviously better way to address this problem? AI: If you wire all three switches to give a single analog output, you require 0.1% resolution. Since common precision resistors are 1%, and ADCs typically have a couple of counts of uncertaintly, I don't think this technique is practical. However, if you wire each switch independently to an ADC input, with resistors selected to give evenly spaced voltages, it would be much easier to get reliable readings, and would even work with 5% resistors. You could use three ADC inputs, or a single ADC with analog switches to read the input switches one at a time.
H: Creating a specific volt/current "test load" Working on a complex power supply, but to test its limits I would like to create a set of test loads of specific voltage/current. There are several devices for creating a set load, but they seem to start in the $300+ level. I've found a circuit for creating a "dynamic load": http://www.ko4bb.com/Test_Equipment/DynamicLoad ...but both would only act as a single load at-a-time. Question 1: If have a specific Voltage/Amp load in mind, can I just use a power resistor AS that load for testing purposes? I would like to create a set of 5V/2.1A loads. Using Ohm's Law, that would work out to a: 2.38095Ω 10.5W resistor. Am I understanding that correctly? I'm not finding a resistor with those specific stats, but I found: 2.5Ω 10W 1% resistor, which would work out to a 5V 2A load 2.4Ω 10W 5% resistor, which would work out to a 5V 2.08333A load The second gets me closest to my "target", but when I look at these two different resistors, it seems that the first is a lot "beefier" (heat sink case, etc.), but I lack enough experience to understand which would be best for my purposes. Instinct is telling me that if I'm using a resistor as a load, and I want to do any extended length of testing (several hours at least) that heat dissipation will be something I need to plan for? Question 2: Can I place a cheaper ceramic resistor against a heatsink to create a test load for several hours, or would the military spec resistor be a better option for my purpose? AI: Your calculations are correct, you would need a 2.38Ω resistor that can handle 10.5W of power. Both resistors you found, however, only have a 10W rating. With the 2.5Ω at 5V, you would be producing exactly 10W; I don't recommend operating a power resistor at its maximum rating for any duration of time. Components likely exceed their tolerance to some degree, but there's always a margin of error, so you should avoid operating things at the max rating unless you have good reason to do so. In the case of the 2.4Ω resistor, you would actually be running it at 10.4W (\$2.08A * 5V\$), which exceeds its rating. Definitely don't do that. Going back to the desired load: 5V at 2.1A, 10.5W. There aren't precisely any 2.38Ω power resistors, but if you double it you get 4.76Ω and 4.7 is a common value among resistors. If you put two 10W 4.7Ω resistors in parallel, you'll get 2.35Ω total resistance, and have 20W total power handling capability. Note that they are 5% tolerance, so actual resistance will vary. Edit, per comments: Note that power rating on resistors is the max amount of power that they can dissipate. How much power they need to dissipate depends on how much current they draw. Remember, current (measured in Amperes) is drawn (and determined by) the load, not the power supply*. For two equal value resistors in parallel, resistance is halved but power handling is additive. So two 10W, 4.7Ω resistors in parallel have a resistance of 2.35Ω but a total power handling capability of 20W.
H: magnetics for ethernet PIC18f I need to add ethernet connectivity to a PIC18f66j60. The datasheets tells about magnetics. But I know only very little about that. Do you know any surface-mount magnetics suitable for this use ? I look for external magnetics. MagJacks are not an option. Thanks EDIT : I've found a lot of parts such as H1102 or H2019, but they feature a kind of coil beetwen the two output pins. Will that work ? AI: I have used the H2019 in the past. Here is a snippet of a schematic of it connected to a PIC and a RJ45 jack:
H: Trouble simulating Colpitts in Multisim I've been trying to get a Colpitts oscillator to work with multisim, following this schematic, which I found in a book (I just copied it): Yet, it does not work, all I get is a 0 voltage signal from the oscilloscope. The same circuit, simulated in LTSpice, worked fine: So, does anyone with experience in multisim know how to get this simulation to work? A similar oscillator in the "examples -> miscellaneus circuits -> claposcillator" works great, adn the book where I found it also simulated it in Multisim and according to it, simulation works fine as well (book is Electronic devices eighth edition, by Floyd, page 84X) Here are some of the things I've tried: Add a AC voltage source with low voltage to simulate noise Change the values of the capacitors to the ones in the LTSpice figure Try different transistors and components AI: It's not the same circuit on the emitter. You've got a 1k pot in series with a 1k resistor and the pot wiper connects to a grounding capacitor. You've also got a 10pF cap where it is 100nF in LTSpice. I'm not saying any of these matter but you can't possibly make comparisons with these glaring disparities. EDIT Following comments from the OP, the problem I think arises from the new "intended" operating frequency of the circuit (he uses a 10pF cap on the multisim circuit to set the resonant frequency whilst the LTSpice circuit has 100nF). Added to this is the lack of emitter capacitor - the multisim circuit shows it connected via the wiper of a pot set midway and this will drastically reduce the gain and prevent or delay oscillation. Remember that the collector has to generate enough signal to drive the 10nF capacitor (C3) and at a much higher frequency this 10nF (via C5, 1uF) will probably look like a short circuit - the gain of the transistor has to be greater than 1 for it to begin oscillation and with no directly connected emitter capacitor and a 10nF effectively connected to the collector I think the gain will be less than unity. I'm not totally familiar with this type of Colpitts oscillator but it seems to me that the LTSpice circuit should oscillate at about 41kHz whereas the MS circuit should operate at about 4.1MHz - this isn't going to happen with a 10pF - its reactance at 4.1MHz will be nearly 4 kohms and this will get "battered" by R1 and R2 in the imedance versus resistance race. Do the sensible thing and start with the same circuit. On the LT circuit, the 100nF will have an impedance of about 40 ohms at 41kHz and therefore not be hardly affected by R1 and R2.
H: Reversing car battery's polarities I had to charge my car battery two days ago. I used another car's battery to do so. I accidentally reversed polarities (+ with -) and vice verse. There were very strong sparks. I was trying to understand the reason behind it mathematically, but I couldn't find any reason behind this behavior online. AI: If you short out one battery you get sparks because of the high discharge current actually melts metal which flies-off from where the short is made/enacted. If you wire two batteries in series and short the combined series battery out you'll get sparks, maybe even bigger ones. Now, think about what you did - you put two batteries in series and then created a short. I know you think you put two batteries in parallel but draw out the circuit and you'll recognize that wiring one one wrong way round (in parallel) is like shorting two in series out. If you wired two batteries in series but they were "opposing" (+ to + and - to -) you'd just get a small current flow as they equalized in voltage - this is called putting them in parallel BUT you can also see that they are in series with a short added.
H: Why are there only four passive elements? I've read that there are four types of passive elements: resistances, capacitors, inductors and memristors. The memristor was predicted 30 years before it was produced. But why couldn't you invent other type of passive element? Is there a proof? The definition I'm using of passive elements is something with no gain, no control and linear. AI: There are four physical quantities of interest for electronics: voltage, flux, charge, and current. If you have four things and want to pick two, order not mattering, there are 4C2 = 6 ways to do that. Two of the physical quantities are defined in terms of the other two. (Current is change in charge over time. Voltage is change in flux over time.) That leaves four possible relationships: resistance, inductance, capacitance, and memristance. If you want another fundamental component, you need another physical quantity to relate to these four. And while there are many physical quantities one might measure, none seem so tightly coupled as these. I'd suppose this is because electricity and magnetism are two aspects of the same force. I'd further suppose that since electromagnetism is now understood to be part of the electroweak force, one might be able to posit some relationships between the weak nuclear interaction and our four elements of voltage, current, charge, and flux. I haven't the first clue how this would be physically manifested, especially given the relative weakness of the weak nuclear force at anything short of intranuclear distances. Perhaps in the presence of strong magnetic or electrical fields affecting the rates of radioactive decay? Or in precipitating or preventing nuclear fusion? I'd yet further suppose (I'm on a roll) that the field strengths required would be phenomenal, which is why they're not practical for everyday engineering. But that's a lot of supposition. I am a mere engineer, and unqualified to speculate on such things.
H: Voltage regulator middle pin not soldered to the board Today I noticed that my Arduino board only has two of the pins of the voltage regulator hooked up. I thought I understood how it worked, but I must be missing something. Why isn't the middle pin hooked up to anything? Was it always like this or did I break it? The board seems to work just fine. AI: The soldered tab on the regulator chip usually connects to the middle pin and you can bet half a years wage on IT being connected to the circuit: -
H: Wiring multi node devices with i2c I wanted to confirm that my approach is correct for wiring multiple devices together communicating over I2C when each node is utilizing DC\DC converters. Should I be including a ground connection over the I2C cable (#1) or would that cause a ground loop with the main 20 foot GND connection. AI: Since your power supplies are not isolated (and the micros thus share a common ground), an additional ground wire should not be necessary as long as the common ground is beefy enough, and is kept out of the vicinity of strong EM fields (don't run it next to 110V or 220V 50/60Hz). Minor differences between the grounds at the micro side shouldn't cause problems with logic level detection. If you want to be sure that nothing couples onto the communication lines, use a shielded cable, but only connect the shield to ground on one side. This will avoid any ground loops. Better immunity from grounding issues can be obtained using a differential communications scheme or isolation transformers, but the likelihood is that they won't be needed in this case.
H: Does all bluetooth modules support RFCOMM? I am about to order a Bluetooth module and I wonder if RFCOMM is such a basic feature that it is always (or close to always) supported in Bluetooth modules? Let's say for Bluetooth 2.0+. Previously this has never been a problem, and it have always been there, but this might be good to know. AI: It depends on the module. There are absolutely no guarantees, because the modules contain their own embedded microcontroller and firmware which provides services. You can get modules which have enough of the stack in their onboard processor that they do take care of RFCOMM and present as a serial port. There are other modules (which are more flexible) and require the micro to talk something like BCSP and take care of the higher level functions such as L2CAP and RFCOMM. You need to carefully look at the datasheet for the specific module you are looking at buying, and be especially careful because most of these chips are all identical except for the software running on them.
H: What is the maximum current a human body can bear? Which causes death of human when a certain amount of current passes through him? And what is the maximum current a human can bear? AI: 10mA through the heart can be enough to kill a person, regardless of voltage. Normally, your skin has very high resistance. But if electrical current manages to get to the heart by any means, low voltage can be fatal since your internals have a lot lower resistance than your skin.
H: Why is a Transistor called a Transistor? Okay now I know how a transistor works, but how can it transfer resistance? I am not getting it because all I know about Transistors is that "A Transistor is used to control the flow of current in a Secondary circuit using a Primary circuit." But how does it transfer resistance? AI: John Pierce named it, according to a PBS documentary in 2000. He worked with Shockley at Bell Labs. Before Shockley sandwiched three semiconductor layers together, the only kind of transistor was the point-contact...uh, not "point contact transistor"! That word wasn't invented yet. "Point contact solid state amplifier"? But Shockley's invention became "transistor" for "transfer"+"resistor", but what sense, you ask, does that make? Current flowing between emitter and collector is a "transfer" of charge. It is not a good conductor - it is a resistor. Also, vacuum tubes were commonly characterized by "trans-conductance" as a measure of gain: output current divided by grid voltage. Transistors were supposed to be opposite of tubes in many ways - more reliable, use far less power, rugged not delicate, etc. The opposite of conductance is resistance. There's no particular logic in characterizing the gain of a transistor by some output voltage over some input current, but for naming a sexy new gadget who cares. Today, and for the last few decades, bipolar transistor amplifier capability has been characterized by beta which is a pure number, current over current, and JFETs are characterized by, um... transconductance. (Also called "transfer admittance")
H: How does electricity represent sound? I understand that AC electricity can travel through wires to represent sound. But, to be honest, I can't find a good explanation of it. Here are my questions: How exactly is this setup? Does voltage represent decibels or W/m2? Does the frequency of the current have a 1:1 ratio with the frequency of the sound waves (1Hz = 1Hz)? I assume that there are probably different standards. (line level and speaker level, for example). AI: In the case of audio, energy must be translated from electric current to pressure waves (sound waves) by some sort of transducer (a speaker). Speakers produce sound by physically pushing air out of the cone, and thus producing the required pressure waves. An electric current is passed through the speaker coil to produce a magnetic field which either pushes the cone outwards or pulls it inwards. Thus the instantaneous magnetic field (or speaker cone position) is directly related to the instantaneous value of the current, thus the frequency of the outputted sound will be the same as the frequency of the current in the coil. To answer a couple of your questions directly, the voltage across the speaker terminals will affect the current, but decibels (dB) are a measure of gain on a logarithmic scale, e.g. 20 dB is an increase of 100 times. However, there is also the dBm which measures power compared to 1mW, so a 3 dBm increase is equivalent to doubling the power. Lastly, "line level" just refers to a set voltage range for the audio signal (more about line level here).
H: How does a capacitive receiver work for a fox and hound set? I have been scouring the internet trying to find this answer, I've found hints and ideas, but nothing concrete, like an actual theory of operation. I'm making a fox and hound wire tracer for my final project in ECE 202. The signal generation isn't hard, I get that concept, but I'm having trouble figuring out the theory behind the "hound," that picks up the signal from the wire. I had always thought they used inductance to pick up the signal from the wire, and found one such design here. I may go with that, but I still want to know how the more common (and likely less bulky) capacitve probes work. I found these three schematics, all of which seem to be a variance on the same principle. I see a capacitor connected to a high impedance before going into the amplifiers. The fancier ones appear to have some sort of bandpass filtering circuit as well, but I know what to research there. I just don't understand the principle which is allowing these to pick up the signal. Is it just an antenna? If so, what is the purpose of the capacitor? I vaguely recall something about electrically lengthening an antenna with inductors and shortening with capacitors, but that doesn't seem like what's going on here. AI: The 2nd design is an inductive coupled example using an AM radio. The other two pick up an alternating electric field just like your body picks up AC alternating electric fields as discovered when you touch the input of a speaker amplifier and you get a low hum sound through your speaker accompanied by higher frequencies if you are in the vicinity of other circuits such as switch mode power supplies. For a simple AC power example, the electric field lines exit a power conductor tangentially and "connect" or "end" at anything that represents an "earth". Normally these field lines are quite short because the neutral wire in AC power wiring represents "earth". However, you can make a higher frequency oscillator that puts a signal onto a plate/wire and the capacitive connection that the person holding the transmitter makes with ground will cause electric fields to emanate. The receiver, likewise has a plate/probe/wire and can intercept these fields. It has an amplifier to boost the small signal it picks up and this is heard thru the speaker. Both transmitter and receiver rely on a person or large object making a capacitive ground connection unless the equipment is powered from AC and earthed already. That's my take on it anyway.
H: PIC:how can we get 1 ms interrupt using 16bit timer? I am using PIC24FJ256GB106 controller.I am setting configuration bit for internal frequency to FNOSC_FRCPLL. I have confusion to this configuration bits that Am i getting 8MHZ or 16MHZ or 32MHZ ? if I want timer(16bit) interrupt at every 1 ms then which frequency i have to use ? FOSC or FCY? When i am setting FNOSC_FRCPLL configuration bit then what is FOSC and FCY? AI: FNOSC_FRPLL means your ultimate clock will be the output of the PLL module. Summarizing from the PIC24F family reference manual: 6.8.3 FRC Oscillator with PLL Mode (FRCPLL) The output of the FRC postscaler block may also be combined with the 4x PLL to produce a nominal system clock of either 16 MHz or 32 MHz. Although somewhat less precise in frequency than using the Primary Oscillator with a crystal or resonator, it still allows high-speed operation of the device without the use of external oscillator components. The FRCPLL mode is selected whenever the COSC bits are ‘001’. In addition, this mode only functions when the direct or divide-by-2 FRC postscaler options are selected (RCDIV2:RCDIV0 = 000 or 001).
H: Difference between Voltage source and Current source? So what's the difference between a Voltage source and a Current source? Aren't they the same? Because after all they are related with the formula \$V = IR\$. So it means that If we produce a voltage, there should be a current and vice-versa. So really what's the difference? AI: Voltage and current sources are not related by \$V=IR\$. This applies to resistances. However, you can connect a resistor to a voltage and current source, and then see what happens to voltage across the resistor and current through it. A voltage source will maintain a constant V, regardless of the load connected to it. A current source will maintain a constant I, regardless of the load. Consider what happens as R changes in these two cases: simulate this circuit – Schematic created using CircuitLab For the case on the left, consider the resistance \$R\$, and the voltage across it \$V_R\$, and the current through it, \$I_R\$: R Vr Ir 0Ω 1V ∞A 1Ω 1V 1A 2Ω 1V 0.5A 3Ω 1V 0.33A 4Ω 1V 0.25A ∞Ω 1V 0A Now consider the case on the right: R Vr Ir 0Ω 0V 1A 1Ω 1V 1A 2Ω 2V 1A 3Ω 3V 1A 4Ω 4V 1A ∞Ω ∞V 1A In all cases, \$V_R = I_R R\$. On the left, \$V_R = 1V\$ (by Kirchhoff's voltage law), so \$I_R\$ is whatever it needs to be to satisfy Ohm's law. On the right, \$I_R = 1A\$ (by Kirchhoff's current law), so \$V_R\$ is whatever it needs to be to satisfy Ohm's law. Also notice that 0Ω is equivalent to a short circuit, and ∞Ω is equivalent to an open circuit. In some cases this results in infinite voltage or infinite current, which is an indication that these things can't physically happen. For example, if you actually short out a real voltage source, like a battery, the wire has actually some small resistance. A lot of current flows, but not an infinite current. If you like, you can think of a voltage source as something that moves current, but adjusts the amount such that a constant voltage is maintained. You can think of a current source as something that adjusts the voltage across itself so that a constant current is moved. Realize of course that you are endowing the power of thought to inanimate objects, which isn't really true. Really all that's happening is that a current or voltage source introduces one constraint to a system of equations that must be solved. You should also think about what happens when the thing connected is not a resistor. For example, what if it's a diode, like an LED? The voltage source still attempts to maintain a constant voltage, and the current source attempts to maintain a common current, but no longer is the equation being solved \$V=IR\$. That describes the behavior of resistances, but now the equation will be something else, describing whatever it is you have connected.
H: How to write VHDL program to send command to PS2 device I'm using Quartus II 13.0sp1, DE1 Board for testing, and Cyclone II FPGA EP2C20F484C7N. I need to write program in VHDL that sends command to device. I have already created entity and architecture which I successfully used to receive keys from keyboard. Now I need entity that send command to mouse, since mouse expects me to send it commands to start streaming mode. My biggest problem is that I don't know how to DECLARE and USE ps2_clk and ps2_dat pins to send command to mouse and to receive data from mouse (using same pins to both-way communication). Just after I send 11 bits to mouse, I need to receive one bit using same pin (ps2_dat), and after that receiver ACK byte from mouse using that same pin. Also before I send command I need to pulldown clock line low, for period of 100 microseconds, and after that I need to release clock line so that mouse can generate clock. I hava no idea how to implements this. Or maybe I misunderstood protocol? AI: The PS2 clock and Data lines are implemented as open-drain with pullup resistors. Thus you treat it in a similar way to i2c. So, in your entity, you could do: Port ( .... io_ps2_dat : inout std_logic; io_ps2_clk : inout std_logic; .... ); Bear in mind that for open drain you must make the pin '0' or 'Z'. Not '1'! Never drive a '1' on an open drain bus as you may fry the mouse. If you put a 'Z' on, the pin will read one, pulled to high by the resistor. io_ps2_dat <= '0'; .... io_ps2_dat <= 'Z'; Does this get you started? Edit: I'll add a bit more about comms in host-to-device communications. The PS/2 mouse always generates the clock signal. If the host wants to send, it must go to "Request-to-send" state: Pulling Clock low for at least 100 microseconds (inhibit comms). You can do this by simply putting '0' on the io_ps2_clk line. Because it's open drain this is perfectly safe and the mouse will notice. Enter Request-to-send mode by pulling Data low, then release Clock. When the mouse detects this state, it will begin generating a clock signals and reads in 8 data bits and one stop bit when the clock is high. This you (the host) can change the Data line only when the Clock line is low. After the stop bit is received, the mouse will acknowledge the received byte by bringing the Data line low and generating one last clock pulse. (ACK# - it's very I2Cish).
H: Adder hardware logic simulate this circuit – Schematic created using CircuitLab If this circuit is a part of a 4 bit full adder, where A1,B1 are adder inputs and C1 is carry in from previous bit, does C2 give the correct output for the carry out bit? According to my calculations C2 doesnot, although S1 generates the correct value of the sum. Please, I need a cross-check. AI: This circuit is more complicated than necessary, but it looks like C2 does give the correct output. The simplified expression for C2 is: $$ C_2 = \overline{\overline{(A_1+B_1)}+(\overline{C_1} \cdot \overline{A_1B_1})}\\ =(A_1+B_1)\overline{(\overline{C_1}\cdot\overline{A_1B_1})}\\ =(A_1+B_1)(C_1+A_1B_1)\\ =C_1A_1+C_1B_1+A_1A_1B_1+A_1B_1B_1\\ = C_1A_1 + C_1B_1 + A_1B_1 $$
H: Use for trackless / bare stripboard? I've seen a few stripboards laying around that have no copper tracks. After looking online I can see that you can indeed buy these but I can't seem to find why or how to use them. How can you use it if there's no tracks to solder too? AI: It's often called perfboard (perforated board). You poke the leads of through-hole components through the holes, bend them to provide mechanical security then solder those leads to each other or to wires. Example from here Embroidery for engineers.
H: Simple Circuit with a Op Amp We are supposed to find \$i_o\$. Looking at the 25-V voltage source and the \$5k\Omega\$ resistor, the current is \$i_x=\frac{25}{5\times10^{-3}}=5mA\$ because the voltage across both inputs of the op-amp are equal (ideal) and zero because the positive terminal is connected to the ground. Using node votlage equations at node \$V_1\$ and \$V_0\$, $$\frac{0-v_1}{50\times10^{3}} +\frac{0-v_1}{10\times10^{3}} = \frac{v_1-v_0}{40\times10^{3}}$$ Knowing \$i_x\$ allows us to determine \$V_1\$ which is \$50\times10^{3} \times 5\times10^{-3}=250V\$ Is it \$-250\$V? Solving for \$v_0\$ I got \$-550V\$. Using KCL at node \$v_0\$, \$i_0=i_1+i_2=23/600 A\$ But, for some reason, the answer is wrong. Am I missing something? Did I do something wrong somewhere? AI: V1 is -250V, so then V0 is -1450V. I0 is 30mA through the 40k, plus 48.3mA through the 30k.
H: Transistor voltage rating? Lets say i have a mosfet where the drain->source voltage is 100 but the gate->source voltage is 5. Do i need a transistor rated for 100v or 5v since at that gate voltage only 5v would pass through? Also what happens to the other 95 volts in this scenario? Will they contribute to heating the transistor? Also why does this red box keep whining about quality standards? It would help if it said anything other than "no". EDIT: schematic AI: You need a transistor rated >> 100V (consider Vds when Vgs=0) Across the 10k resistor Voltage doesn't heat, Volts x Current does. So the heating is Vdson . Ids SE likes Qs to be more than perfunctory?
H: Unexpected rectifier waveform I've built a simple half-wave rectifier using the following components. \$10\$k\$\Omega\$ resistor 1N914 diode 1 kHz sinusoidal source I'm measuring the voltage across the resistor with an oscilloscope. This is the wave I get with the source set to a magnitude of 1.5 V: \ Bust as soon as I increase the magnitude of the source above 3.0V, this starts to happen. \ Can anyone explain what is happening here? Is this expected behaviour, or have I made a mistake? AI: This has happened to me once and I struggled with it only to find that what I thought was a 1N4148 glass diode (like a 1N914) was in fact a 3.3V zener diode - try reverse biasing it like a zener to see if it draws current and acts like a voltage regulator. Even if you assumed 10pF cross capacitance this would be an impedance of nearly 16 Mohm at 1kHz and not enough to do what the screen shots suggest. It has to be a broken diode or the wrong diode.
H: Why does this first-order RC filter with an op-amp display resonance? I built this circuit and simulated it in CircuitLab and was trying to make an active low pass filter. However, it shows a frequency response like a resonant low pass filter and I can't figure out why. Here's the schematic: And the frequency response: The gain of the frequencies below the resonant frequency is set by the ratio of R2/R1 (x10 with these values), as expected for an inverting op-amp circuit. But I can't figure out why there is the resonant peak at 800 Hz for this first-order circuit, or how to calculate the resonant frequency. And the response of a few different cap values: And the response of different values of R1: Changing the value of R1 has no effect on the resonant frequency, only on the gain of the circuit. I don't understand why this circuit behaves this way. Can anyone explain it to me? I came up with this equation for the value of \$V_{out}\$: $$V_{out} = -( \frac{A \times R2}{R1 + R2 + R1R2Cs - A \times R1} ) V_{in} $$ Does this equation look right? It makes sense to me that when \$(R1 + R2 + R1R2Cs) << A \times R1 ,\$ the result is approximately equal to R2 / R1. But I have no idea where the peak at 800 Hz comes from. AI: I think, if you assume that the internals of the op-amp contain, in effect, a first order low pass filter, you will have created for yourself what is known as a multiple feedback low-pass filter. I used a great simulation tool from Mister Okawa here to produce this: - If you look closely at the circuit in the picture above and imagine that R2 and C2 are inside the op-amp, your circuit becomes the same. There is some hand-waving here because I'm taking a stab in the dark about what R2 and C2 actually are and "massaging" them numerically to fit close to producing a peak near 800 Hz. C2 being 5pF is in the right order for the "conventional" stabilizing stage inside an old-fashioned op-amp like the TL081 and I guess R2 would be in the vicinity of a few kohm. Anyway I'm convinced this is what is happening!!!
H: What are the dangers of a DIY fuse in a multimeter? For the past few years I have been running my Fluke 79III without a fuse in its F44.100A 1kV fuse holder. This has meant that I've been unable to use the 40mA circuit. When I blew the old fuse, I discovered that it had been previously 'repaired' with another fuse soldered to the original Buss DMM-44/100 fuse. Then I went to look for replacement fuses and was aghast to find them selling for £10 each, so I wasn't surprised that the previous owner had 'repaired' the fuse rather than replacing it. What I now wonder is what the consequences of once more 'repairing' this fuse might be. I don't play with three phase, and I'm unlikely to play with more than about 260VAC, so could I safely use a 250VAC, 500mA fast acting fuse in its place? Watch Big Clives Things you should know about fuses. (including a 15kV one) video if Spehro Pefhany's answer hasn't already convinced you not to try this. AI: It's the same with disabling or bypassing any safety device, I believe you could be completely safe, but what if someone else picks it up and uses it? The danger is of arc flash, of course. Perhaps if you could mark it (and cover the model/Cat/IEC markings that would lead one to believe that it's safe to use on 600VAC? "Do not use on mains". Not sure if that is legally necessary or sufficient in the UK, but it might reduce the possibility of injury. Here's what's left of a multimeter that was involved in an accident that killed two people. Evaluation of the meter circuit showed that it used a small glass 8AG fuse rated 0.5A at 250V for circuit protection on some functions. According to Underwriters Laboratories, the interrupting capacity of this style of fuse is only 35A at 250V. It has no specified interrupting rating above 250V. An estimate of the fault current through the meter shows that it could have been from several hundred to as much as 1,000A at 277V The whole story is here. Note that the circuit was not even an industrial circuit, and "only" 277VAC phase-to-ground, but 480V phase-to-phase. The available fault current was not small. I once tested some 5A/250VAC rated ordinary 5x20mm fuses on a light industrial 240V circuit (50A circuit). Almost every time they arced from end cap to end cap, and the glass tube literally exploded. Molten metal was found to have solidified in a layer on the glass shards, so there was a cloud of it after the tube ruptured. A plastic housing would have contained the shards, but anyone foolish enough to be closely observing without a face shield or safety glasses could have been injured or blinded. Interrupting (current) capacity is an important factor, and it's not marked on fuses generally. Wow, there's a huge price range on that fuse- I see everything from $5 to $36.
H: Basic PIC circuit is not working I have just begun in the world of microcontrollers, and the first microcontroller. I chose to work with was the PIC from Microchip. The PIC I am using is the PIC16F877A. I am using MPLAB IDE and HI-TECH C. I am trying to make an extremely simple program that turns on an LED. This is the code I am using: #include<htc.h> #define _XTAL_FREQ 8000000 __CONFIG(UNPROTECT & PWRTDIS & WDTDIS & HS & LVPDIS); int main() { TRISB0 = 0; RB0 = 1; while(1); } When I hook up the PIC to my circuit the LED does not turn on. Here is my circuit diagram and a picture of my circuit: A few other notes about my circuit: I am using a 9 volt battery hooked up to a 7805 regulator for the power supply. I have measured the voltage coming from pin RB0 with a multimeter and it measures 0.0 V. If there is no problem with my circuit I could have programmed the chip wrong. My capacitors hooked up with my crystal are 22 pf, not 22 µf as in the schematic. I have put 100 µf capacitors between pins 11 and 12 and between 31 and 32. AI: As it's impossible to put code in comments, I'll put my suggestion for code that sets the Config bits correctly here. The issue is I don't have this compiler so I cannot be certain of the names (LVPDIS as opposed to, say, LVP_OFF in assembly) but if I'm wrong, someone could comment(?) #include <htc.h> #define _XTAL_FREQ 8000000 __CONFIG(UNPROTECT & PWRTDIS & WDTDIS & HS & LVPDIS); int main() { TRISB0 = 0; RB0 = 1; while(1); }
H: Permanently dimming an incandescent light bulb I have purchased a nice light bulb with long visible wires/resistors and plugged it in, on the ceiling. It burns too bright without a dimmer and does not look as intended (also the lifespan decreases). I would like to permanently dim it. However the light switch does not have enough space inside it for a full dimmer, though I can fit something smaller. I was thinking of connecting a big resistor serially to the bulb. Is that a good idea? I was thinking around 2 KOhm, as I figured that is the typical lightbulb resistance and therefore it would halve current. What is the difference with the 0.1W and the 50W ones? Can either take the 220V we have over here? Would it overheat closed inside the switch hole? Am I talking nonsense and should I go back to reading my uni books again? AI: I am going to assume it's an incandescent bulb of the "artistic" type with interesting filament structure. If it's an LED or CFL bulb, the below comments do not apply. It's possible to connect a silicon diode in series with the bulb to permanently dim it. The behavior is not linear because the light bulb proportionally sucks more juice (technically speaking) when the tungsten filament is not running at full temperature. There's no way to adjust the brightness, so it's either acceptable to you or not. The diode part number would be different depending on the bulb wattage, but a 1N4007 should work for anything up to 100W or so, and a 1N5407 for about any bulb you'd be likely to use. Be prepared to occasionally replace the diode after the bulb blows- the symptom would probably be the new bulb operating at full brightness. There's less chance of that happening with the 1N5407. They're less than 50 cents each. If you have a bunch of them, you could install them in random orientation (which end of the diode goes to which side of the power) to be nice to the power company. Note: I have no opinion on whether this is acceptable to fire, insurance or other codes and regulations in whatever 240V country you're in. Electronically it will work.
H: Low profile i2c level shifting solution I have a system that involves two boards and i2c communication between them. One of the boards uses 2.8V for i/o (including i2c) and the other 3.3. The 3.3V board is always the master and the 2.8V is always the slave. It will never be the case that the 2.8V part initiates a transaction. There are two board to board connectors between the boards. The relevant signals passed are +3.3V, sda (either 3.3V or 2.8V), and scl (either 3.3V or 2.8V). The 2.8V board uses an LDO to generate it's 2.8V locally from the 3.3V. The obvious solution is two fets and 4 pull-ups, but I'm very space constrained. I have room for this on the 3.3V board, but not the 2.8V board (even when using 0402 resistors and a small array package for the two fets). The 3.3V board doesn't have any 2.8V (see above) and I cannot add anymore board to board connectors. As a result I need to do something else. I thought about doing the "ugly" thing and putting the fets/pull-ups on the 3.3 board and generating the 2.8V with either a biased zener from the 3.3 or dropping the 3.3 over a shotkey. That's not super elegant, but would probably work OK (I don't want to add another LDO to the 3.3V board). Any other suggestions? Sort of feel like I'm scratching my ear with my toe instead of my finger, but the design is pretty constrained. AI: How about pulling the I2C lines up to 2.8v instead of 3.3v? The high state threshold level for the 3.3v device is obviously much lower than 2.8v (normally 0.7 * Vcc which would be 2.3v for 3.3v supply) so it should work fine.
H: Can a composite video line doubler be made using simple hardware components? (composite -> progressive scan) I have a lot of old analog video equipment and my trusty Apple IIe Color Monitor is finally dying. Since CRT's aren't produced anymore, and because I just am interested in how it is done, I obtained a decent plasma monitor (I can't get enough of those deep black tones). I want to know if an analog signal can be deinterlaced without resorting to a FPGA or similar overkill. Can something to get rid of the interlacing effect on non-CRT's be made with components like 74-series IC's and proc amps (and maybe a AVR microcontroller), or do I need to go out and get some specialized chip from some specialized producer? All I want for output is progressive-scan composite video (although a better signal would be acceptable, I would prefer composite). The most complex digital video generation hardware I have ever worked with was that of a Commodore 64 (converted it to PAL by swapping IC's with a european one, and replaced a few caps). My other experience was just adding a analog filter to a NES system. So digital isn't really my thing. I hate to think this is a dumb question, and hopefully, even if there's no answer, I am not the only one who wants this. AI: Interlaced scan composite video signal isn't easily convertable to similar progressive-scan signal. You need to store the whole frame into some kind of memory and resend it at different speed using progressive scan. The simpliest way you will need a DAC-ADC pair with Fq about 6.5 MHz, an SRAM or ADRAM unit capable of running at 13 MHz clock and holding two frames, and the logic to control both input and output address. This way you will be able to store two interlaced half-frames and resend them back as progressively-scanned frames. Everything said above applies to monochrome images as I don't know how any color-coding system works with progressive scan. The image produced is likely to have visible interlacing artifacts, especially if there are horizontally moving objects in the image. It's a quite difficult task to remove them, but if you really want to reduce them, the better option is to have a PC with a analog video capture card and a program that processes and displays the image captured.
H: How to make a PowerSwitch Tail I have an arduino board, and I would to turn a different, completely isolated circuit, on and off. Actually, I will be running 230V to another device, and then control whether it is on or off, with the arduino. http://www.powerswitchtail.com/Pages/default.aspx I have been looking a bit at these, and it looks interesting. The problem is, shipping to Europe means they become quite expensive. So how can I make one myself? Do I need to build some kind of relay? What components can actually handle sending 230V through it, but be controlled from arduino's 5V? AI: It looks like they used to sell a kit. There is a schematic near the bottom. A relay of some sort is your best bet. Just be sure it can handle the current and voltage requirements. Also, be mindful of how much current the relay coil will need to operate (unless you use a solid state relay). You may need a transistor in between the Arduino and relay to amplify more current. As always, be extremely careful when dealing with high voltages and current. Do no undertake this project until you have done thorough research of what safety precautions you need to take.
H: Solving an Op-amp circuit The image of the circuit is shown below and it required to find \$V_0\$, My first attempt at solving this problem is by changing the current source into a voltage source with 1-V and 2k\$\Omega\$ resistance. The fact that the inverting and non-inverting terminals aren't grounded make this problem look difficult.To the point which, I don't know how to proceed with this question or where to start. I would appreciate any help. Following some thought and another schematic from a hint suggested by Alfred, I produced a schematic representing our work. And my solution for the problem is below, Using node equation at nodes A and B we have, $$\frac{V_A-V_B}{1k}=-0.5 \text{mA}$$ $$\frac{V_B-(2+V_A)}{1k}=-0.5-x$$ where x is the current that is sent in the output of the op-amp. Using KCL, at the bottom node near the current source we see that the same current that goes through the op-amp also goes through the \$2\text{k}\Omega\$ resistor. Hence, we have, $$\frac{-V_A}{2k}=x$$ Replacing this in the second equation, $$\frac{V_B-(2+V_A)}{1k}=-0.5+\frac{V_A}{2k}$$ And and solving the equations yields \$V_A=-2 \text{-V}\$ and \$V_B=-1.5 \text{-V}\$ AI: I don't know how to proceed with this question or where to start. If there is (net) negative feedback, then you proceed by setting the voltage across the op-amp input terminals equal to zero: $$v_+ = v_-$$ Note that with zero volts across the input terminals, the 2k resistor in parallel with the current source is irrelevant; there is zero volts across it so there is zero current through it. You may remove it from the circuit without changing the solution. This should get you started. @AlfredCentauri I still don't see the bottom loop, do you mean the loop v+ connected to VB then connected to the voltage source and then the resistor and finally VA. Is that considered a loop even with the op-amp? And when I do I still don't get your equation. simulate this circuit – Schematic created using CircuitLab This is the bottom-most loop and KVL clock-wise 'round the loop starting with the voltage across the 1k resistor is: $$i_1 \cdot 1k\Omega -2V + V_B - V_A = 0 $$ rearranging yields $$V_B = V_A - i_1 \cdot 1k\Omega + 2V$$ If the presence of the voltage source above is puzzling, recall that the output of the ideal op-amp is an ideal (controlled) voltage voltage source referenced to ground which I've shown explicitly here.
H: RS485 + Power over twisted pairs, still need isolation? I need to communicate with a piece of hardware on an elevator car. I have a few twisted copper pairs available, but it's not CAT5, so Ethernet is out. Instead I'd like to use RS485. I've been reading and ground level difference can really mess up 485, I'm also passing power along with the RS485. ( So 6 conductors: A,B,X,Y,5V and GND ). Since the unit in the elevator will draw power from the copper pairs is ground level difference still an issue? Do I need to go full out on the isolated 485 or is that overkill? note1: These cables can be as long as twice the height of a building ~100-200FT note2: Communication speed is not critical, it can go slow. note3: LDO takes 5V to board 3.3v so we have some room for voltage drop on wire. AI: If you can guaranteed the grounds are going to be close (within +/-7V peak) under all possible conditions, then no isolation is required. Personally, I would go for isolation without question. What happens when lightning strikes nearby? I foresee a bunch of RS-485 transceivers getting replaced and an unhappy customer.
H: Is there any disadvantage to changing trace width in the middle of a trace? Say I have a trace running across a board. It's 50 mils the majority of its length, but in one short place it narrows to 25 mils to make it through a tight area. As best I can tell, this will be preferable to a 25 mil trace the same length, and only slightly inferior to a 50 mil trace without the few percent of its length narrowed to 25 mils. Is there any disadvantage to the narrowing? Odd high-frequency effects? EMI? Obviously traces have many possible uses, including delivering power, carrying signals of different frequencies, grounding... so under what circumstances will this matter? AI: Yes, but these disadvantages may be negligible. Disadvantage 1: High frequency signals encounter a discontinuity. I would start worrying at a few hundred megahertz because the change in trace width changes the characteristic impedance (not just dc resistance) of that line. The discontinuity changes scattering parameters, creates harmonics, reflections, and other headache-inducing problems. Disadvantage 2: Voltage drop (and increased power dissipation) due to higher trace resistance. If the decreased-width percent of the trace is less than 10%, I wouldn't worry. All of these effects can be calculated for your potential design, however. Here's an online tool that helps estimate trace resistance Here's a downloadable tool that has a lot of built-in equations
H: Highly linear amplifier for tiny voltages I have a tiny voltage which ranges between 0V to 0.05V (bandwidth of this signal is <100kHz) that I need to amplify to 0V to 3.3V. If I would like my final voltage to be distorted only upto 0.5%, what is the best circuit to accomplish this? P.S. Yes, I have considered using an Op-amp, however, as far as I know, opamps are very non-linear in the lower and upper end output voltage (the output voltage starts to saturate?). Edit 1: I only have access to 0V and 3.3V. AI: Murata have a range of power supply convertors that are intended for this application: - The one I've highlighted will take a supply of 3.3 volts and produce output voltages of +/-5V. The outputs are isolated too. The one immediately above is the same but produces +/-3.3 volt outputs. All are rated at 1W. There are plenty of this type of converter around. Cost in Farnell for the one highlighted is just over £5. So this overcomes the op-amp clipping problem. Regards the actual op-amp, you need an amplification of 66 and a signal that is up to 100kHz. This implies you are looking for an op-amp with a GBW product of 6.6MHz BUT to keep distortion down to a decent limit you should look for something with a GBW of at least ten times this figure. I'd consider using the LT6236 from Linear technology. It's got a GBW of around 200MHz and very low noise figures. It's also got rail-to-rail output swing capability and an input offset of 0.5mV max. Supply current is only 3.5mA so it's pretty suitable for the OP I would say providing DC accuracy at the output is acceptable as being up to +/-33mV. As with any op-amp of this type look to keep input driving source impedances low to minimize effects of bias currents AND make sure the power supply pins are properly decoupled.
H: ADC analog pin connection That is my circuit: Input: 400V DC U2_1: LTC1285 (ADC) http://www.farnell.com/datasheets/1575635.pdf U2_2: IL261 (digital isolator) http://www.nve.com/Downloads/il260-1.pdf The circuit behavior is: 1: resistive partitor with high precision resistor to decrease the input voltage. 2: zener diode protect from eventually overvoltage. Now the question: In point 3 is useful to use a low pass filter for clean the DC on ADC input from eventually high frequency noise? If yes, how can I connect it for a proper functioning? Is the first time I use an ADC.. thanks in advance! AI: The ADC parts you are using are recommended for 3V operation not 5V (which I am presuming what you are using, given the 5.1 volt protection zener and attenuation ratio). LT say "For 5V specified devices, see LTC1286 and LTC1298". Using a zener at 3V is going to be a bit sloppy (due to zener ineffectiveness) so I'd recommend a schottky diode clamp OR choose R2 to be a bit bigger so it can safely attenuate to a voltage within the input range of the ADC. A low pass filter is probably a good idea - how quickly is the 400V input changing? How fast are you sampling? What are your expectations of performance?
H: Power switch with slow control signal I am trying to switch on and off a circuit that draws about 0.8 amp at 12 V. The obvious choice is to set a MOSFET. The problem is that the control signal (the one that goes on the gate of the MOSFET) is changing very slowly (1 volt per hour). So when this slow signal reaches MOSFET threshold voltage it is not instantly turned off or on, it is operating in bad non saturated mod for some time. How do I make a switch that turn on and off instantly? I tried to use a relay that is controlled by MOSFET with zener diode as voltage sense. That will not work because when relay is switched off the current stops and power supply increases the voltage a little (because no load), and sense circuit thinks that voltage is ok again and turns relay back on. So relay open and closes like crazy near that threshold region! AI: You want to threshold detect a slowly varying signal (1 V/hour). This should be done with something that has high gain around the threshold point, and a little hysteresis. The high gain makes the result full high or full low on either side of the threshold, and the hysteresis prevents chatter due to the inevitable noise on the signal when it is close to the threshold. It also provides a positive snap action. For any finite gain, there would still otherwise be a soft area right around the threshold. The conceptually simplest way to achieve this is with a comparator. For example: R3 and R4 form a voltage divider to make 1/2 the supply, which in this case comes out to 2.5 V. C1 filters out small ripples on the supply to make a nice and clean 1/2 supply signal into the negative input of the opamp. The input signal is compared to this 2.5 V threshold. When above, the output goes high, and when below the output goes low. However, if that was all, there would still be problems when the input signal was very close to the threshold. R2 provides a little positive feedback, which causes the hystersis described above. When the output goes high, a little bit of that is added to the input that the opamp sees. This effectively lowers the threshold for the input to be interpreted as low. When the output is high, R2 and R1 form a voltage divider, the output of which must be 2.5 V for the opamp output to flip again. To cause that to happen IN must be 25 mV below the 2.5 V threshold. When OUT is low, the same thing happens in reverse. IN must 25 mV above the threshold to flip the state of the opamp again. This causes a 50 mV hysteresis band around the threshold. The hysteresis band should be sized to be a bit larger than the peak to peak noise on IN. For purely digital signal levels, you can use a logic gate with Schmitt trigger input. These work like the circuit described above, but the hysteresis is built into the gate. The downside is that the hystersis band is usually quite wide and the threshold somewhat unpredictable. This is because these are intended for logic signals, not for accurately threshold detecting analog signals. Even if you use a Schmitt trigger gate, it's good to understand the theory as illustrated by the circuit above.
H: How to ensure serial transmission and reception of required data without any garbage values in the 8051? I'm trying to continuously transmit the character 'L' from the microcontroller 8051 to the PC at a baud rate of 9600. The frequency of the 8051 is 16 MHz, and I accordingly loaded the BRL register with "0XFC" for baud rate generation. However, I can see a stream of garbage values on the hyper terminal; I even tried changing the auto reload values from 0xFB to 0xFF to no avail. Is there any way for me to generate the exact Baud Rate in the microcontroller or a way for me to fix this problem? Edit: Also, even if I transmit just a single alphabet from the PC to the controller, and the code is written in a way for the controller to echo everything sent from the PC sometimes the character the controller sends in response is different from what I'd sent. My code is as follows: #include "reg_c51.h" char uart_data='L'; void main (void) { SCON = 0x40; BDRCON &=0xE0; BDRCON |=0x08; BRL=0xFC; IEN0 = 0xF0; BDRCON |=0x10; while(1) { SBUF = uart_data; while(TI==0); TI=0; } } AI: That's actually a subtle "gotcha" in asynchronous serial communications — if there are never any gaps in the data that are at least as long as a character time, it's possible for the receiver to get out of sync with respect to the byte boundaries, and there's no way to recover. Any '1' followed by a '0' could be construed as being a stop bit/start bit pair. One possible fix would be to send a byte of all-zeros (or all-ones) every now and then. If the receiver is out of sync, this will force it to resynchronize on the next start bit.
H: How can I program Mega2560 with Atmel Studio 6.2 I have got the SainSmart Mega2560. The problem is now: how can I program it with Atmel Studio 6.2? I can find no way to upload code, because the controller is not in listed and with ISP I can not do it, because STK600 is needed which I don't have! Is there another way to program the Mega2560 with Atmel Studio 6.2? AI: Why not use the Ardiuno IDE? Unless you know what you are doing, its much easier to preserve the bootloader this way. I expect the support is based from that viewpoint also.
H: Small Signal BJT Model I want to know why there is a minus sign in the output voltage. AI: From the model viewpoint, the voltage-controlled current source is pointing in the direction that an increase in input voltage leads to a decrease in output voltage. From a practical point of view, more voltage on the base means more collector current, which decreases the output (collector) voltage in an NPN common-emitter configuration. If your output was taken across the load resistor (from Vcc to collector) rather than from the collector to ground, then the sign would be positive.
H: Circuit to keep two LEDs on when buttons are released I am trying for the first time to build something on my own. I am pretty n00b when it comes to electronic so, please, bear with me. I'm trying to build a "simple" schematic that goes like this: there are two buttons (SW1 and SW2) normally open, and 2 LEDs (D2 and D3) associated to each button. When a button is closed, the relative LED turns on, but when button is released, the relative LED shall continue to stay on. One button shall not influence the other LED. In addition, there is a third button Reset button which is used to turn off both the LEDs: while it's pressed, the Reset button will turn off the LEDs. To do this (apparently) simple circuit, I am using some gates: a NOT gate which inverts the reset button: when button is not pressed, the gate shall be high and enter two AND gates. two AND gates which take the reset as one input. When reset is pressed (+Vcc), the NOT gate should go low, making the AND gates to go low in output. The other input of the AND gates is the output of two OR gates (one-to-one). the OR gates (OR1, OR2) use a feedback mechanism to keep high the signal once it goes high. Each OR has SW1 (SW2) and the output of the AND gates (AND1, AND2) as input. When reset is pressed and no button is pressed, the OR goes low, but if one button is pressed and no reset is pressed, then the output is high, which goes in the AND port, which shall output high and thus keeping the OR gates high. I realized on a breadboard the circuit below simulate this circuit – Schematic created using CircuitLab Sorry, in the image some resistors are wrong: R5 = R3 = R1 = 5.6k Ohm R6 = R7 = 10k Ohm I used 74LS04 for the NOT gate, 74LS08 B1 for the AND gates and 74LS32 for the OR gates. Being LS, I connected all the unused input to ground, while every other input shall be connected, because I tried to use pull-down resistors on the inputs. Now, this is the first time I try something this complex: I know this is conceptually simple, but I just don't have the tools and knowledge to deal with the hardware fabrication. In fact, this circuit is not working as I was expecting: even if the reset button is not pressed (or even if it is pressed), the NOT gate will always produce an output voltage of 0.75, which is (I think) low. In fact, the SW1 and SW2 buttons will just turn on the LEDs when they are closed. If I remove the link that goes from the NOT gate to the AND gates, leaving only the D1 LED as output, the NOT gate works as expected. As additional input: the chips are connected properly to Vcc and GND (+5V and 0), and I am using, as a power source, a stabilized power supply (that is actually a recycled computer PSU). Well, that's all for now... Can someone give me an advice? I can't really understand what's happening (and why). AI: The concept looks sound. The main thing I see is that your 5.6K resistor is way too high to guarantee a low level for a 'LS04. The 100 ohm resistors you used elsewhere are okay (but they'll get warm if the switch is held). Suggest you use ~150 ohms for the pull down resistors and maybe 4.7K for the LED resistors. It would be better to use a spare inverter for each of the LEDs (so the output is low for LED 'on') and connect the LED + resistor between Vcc and the output. That's because you're loading the outputs with the LED and TTL can't source current that well. Then you can use 470 ohms or even less for the LEDs and they'll be much brighter.
H: What are buffer and latches in microprocessor? I would like a description that clarifies the concepts of what buffers and latches are and the difference between them. I'm asking for buffers and latches in respect to the 8086 microprocessor. AI: A buffer allows a signal to drive more inputs than it would by itself, or provides input protection / amplification. For the 8086, it's used in the output sense, allowing internal signals to be made robust to drive external devices. A latch is a circuit to accept and store one or more bits, with a 1-to-1 input / output ratio. That is, it's not RAM. It differs from a register in that the storage takes place while a control input is at a particular level (0 or 1), while a register stores the input data upon receipt of an edge (rising or falling). Latches are used with 8086s to store addresses and data, and are used instead of registers because they maximize setup times. That is, if data or addresses change internally while the latch enable is active, the data passes through immediately, while with a register it would not be available until after the appropriate clock transition had occurred. The early microprocessors used every trick they could to increase their usable speed, and this is one of them.
H: LED driver circuit help needed Please help me figure out which inductor to use from this datasheet. Sorry - it's in Chinese as this is an Asian sourced IC and not sold in the US. (Use google translate if necessary - but, the meaning is clear enough from the digrams and tables. ) The formula for the inductor, given on page 3 is as shown below: I'd like to use a single energy efficient LED like this (I'm open to other white LED suggestions) I'm using 2 alkaline AAA batteries. Question 1 Based on the formula given above, should Vin be 2V fully discharged point of 2 x AAA Alkaline cells? or 3V (= 2 x new Alkaline AAAs cells) to avoid over current? Question 2: to calculate P for LED, I use 5mA at 2.9V = 145 mW - which is normal conditions for LED (page 2 from LED datasheet) - good assumption? I came up with 580nH - is this correct? AI: Yes. Your application of the formula is correct. I can provide part numbers for better LEDs than that. "Soon" ... (just stumbled out of bed to complete a report) At about 15 mW a 'good' modern LED will give >= 150 l/W or about 2.25 lumen. That's enough to illuminate 1+ sheet of A3 paper to good readable level with colour well discerned. If illuminating a small enclosed space it should be more than you need. The formula (from above) is $$ P = {V_{in}^2 \over L \cdot 10^-6} $$ or $$ L = {V_{in}^2 \over P \cdot 10^{-6}} $$ \$L\$ in henries, or remove \$10^{-6}\$ and use \$L\$ in μH. With this sort of IC the brightness varies approximately with the square of the input voltage so you get a power ratio of 9:4 for voltage changing from 3V to 2V. A 2:1 difference is hardly noticeable to the eye if you look at one light at a time. Look at two side by side and you can distinguish down to the 20% - 50% difference range. "Wall wash" with two LEDs side by side and you can typically see differences down to 10%. LED: Look at Cree ML-E to start. There are much better now. More on that soonish.
H: What makes DSSS a more robust transmission technique compared to FHSS? In many textbooks it is stated that DSSS is more robust than FHSS. Especially in terms of interference and delay spread? What is the exact reason. Lets say we multiply a given bit 1 with a larger bit sequence. How does this make the communication more immune against delay spread & interference? AI: I think that claim, taken at face value [sound byte'd], is somewhat dubious. Such a claim depends on the application. I also disagree that one inherently more robust in terms of interference immunity. If you are operating in a fixed channel using DSSS and you have a loud interference source in the same channel (could be fixed frequency - but higher power than you) you will loose a higher % of your packets than if you were using a FHSS system that utilized the entire band. But if you are using an FHSS system in an area where a lot of your neighbors are also using FHSS and have the same general set of hop channels then you would be in trouble. I've run into both of these situations. The first was using 900MHz ISM DSSS radios in an area where a local internet provider was using louder licensed (somehow) radios in the same channel as me (they were also using DSSS) - that channel was relatively saturated/highly utilized. The latter case was when using a FHSS radio that only had a small set of channels that it actually hopped to - so it didn't utilize the entire band. If there were other broadcasters in the same part of the band it was in it would loose a higher percentage of packets. In particular - I was jamming myself (or rather some installations of the product I was supporting were installed close together and were jamming each-other). A poor implementation of either can lead to jamming / excessive packet loss. Also, there is no reason why you can't use a combination of the two together to more uniformly utilize the spectrum. Essentially, utilize DSSS at each FH channel. There are some obvious decisions you should make when designing a system. For example, if you want to operate in the 2.4GHz ISM band you should pick channels between the WIFI channels if you know your device may operate in an area with multiple wifi networks (e.g. avoid picking something right in the middle of channels 1, 6, and 11 - pick frequencies between channels 2-5, 7-10, 12-14). This article actually says that DSSS systems do WORSE with multipath / delay spread in large areas. But in enclosed small areas they do alright. "We shall also conclude that for long distances, point-to-multipoint topologies in reflective environments such as cellular deployments in a city, DSSS has no chance to survive, leaving FHSS the absolute winner, based on its famous multipath resistance." http://sorin-schwartz.com/white_papers/fhvsds.pdf
H: Resistors in series current question According to Wikipedia, the current of resistors in series will be Vin/R1+R2. Now I could be over thinking this but is that the current that you'll get out or is that just used for determining the power of resistors or both? http://en.wikipedia.org/wiki/Voltage_divider AI: You are measuring the current through the circuit. By Ohm's Law you know the current through a resistor is proportional to the applied voltage. But what happens when you don't know the voltage across the terminals of the device (i.e. what's the voltage at the middle node of the voltage divider?). You can figure that out simply enough if you know the current through the network. Simply combine the resistor into a single component and apply the same rules as if it were a single resistor. $$i = \frac{V}{R_3}$$ Where $$R_3 = R_1 + R_2$$
H: What are these pulses? To continue of this question... I figured out the main problem and now I have an odd problem. at first, let me to put the codes. "Main.c": /* Includes ------------------------------------------------------------------*/ #include "stm32f0xx_hal.h" /* Private variables ---------------------------------------------------------*/ SPI_HandleTypeDef hspi1; /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_SPI1_Init(void); int main(void) { uint8_t aTxBuffer[] = "Rohalamin"; /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* System interrupt init*/ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_SPI1_Init(); /* USER CODE BEGIN 2 */ HAL_GPIO_WritePin( GPIOA , GPIO_PIN_4 , GPIO_PIN_SET ); /* USER CODE END 2 */ /* USER CODE BEGIN 3 */ /* Infinite loop */ while (1) { HAL_GPIO_WritePin( GPIOA , GPIO_PIN_4 , GPIO_PIN_RESET ); HAL_SPI_Transmit_IT( &hspi1 , (uint8_t*)aTxBuffer , 10 ); HAL_GPIO_WritePin( GPIOA , GPIO_PIN_4 , GPIO_PIN_SET ); } /* USER CODE END 3 */ } /** System Clock Configuration */ void SystemClock_Config(void) { RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6; RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1; HAL_RCC_OscConfig(&RCC_OscInitStruct); RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0); __SYSCFG_CLK_ENABLE(); } /* SPI1 init function */ void MX_SPI1_Init(void) { HAL_SPI_MspInit(&hspi1); hspi1.Instance = SPI1; hspi1.Init.Mode = SPI_MODE_MASTER; hspi1.Init.Direction = SPI_DIRECTION_2LINES; hspi1.Init.DataSize = SPI_DATASIZE_8BIT; hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; hspi1.Init.NSS = SPI_NSS_SOFT; hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256; hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi1.Init.TIMode = SPI_TIMODE_DISABLED; hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; HAL_SPI_Init(&hspi1); } /** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); /*Configure GPIO pin : PA0 */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : PA4 */ GPIO_InitStruct.Pin = GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI0_1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(EXTI0_1_IRQn); } "stm32f0xx_it.c": /* Includes ------------------------------------------------------------------*/ #include "stm32f0xx_hal.h" #include "stm32f0xx.h" #include "stm32f0xx_it.h" /* External variables --------------------------------------------------------*/ extern SPI_HandleTypeDef hspi1; uint8_t aTxBuffer[] = "R"; /******************************************************************************/ /* Cortex-M4 Processor Interruption and Exception Handlers */ /******************************************************************************/ /** * @brief This function handles System tick timer. */ void SysTick_Handler(void) { HAL_IncTick(); HAL_SYSTICK_IRQHandler(); } /** * @brief This function handles SPI1 global interrupt. */ void SPI1_IRQHandler(void) { HAL_NVIC_ClearPendingIRQ(SPI1_IRQn); HAL_SPI_IRQHandler(&hspi1); } /** * @brief This function handles EXTI Line 0 and Line 1 interrupts. */ void EXTI0_1_IRQHandler(void) { HAL_NVIC_ClearPendingIRQ(EXTI0_1_IRQn); HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); HAL_SPI_Transmit_IT( &hspi1 , (uint8_t*)aTxBuffer , 2 ); } "stm32f0xx_hal_msp.c": /* Includes ------------------------------------------------------------------*/ #include "stm32f0xx_hal.h" /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { GPIO_InitTypeDef GPIO_InitStruct; if(hspi->Instance==SPI1) { /* Peripheral clock enable */ __SPI1_CLK_ENABLE(); /**SPI1 GPIO Configuration PA4 ------> SPI1_NSS PA5 ------> SPI1_SCK PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI */ GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF0_SPI1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(SPI1_IRQn); } } void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { if(hspi->Instance==SPI1) { /* Peripheral clock disable */ __SPI1_CLK_DISABLE(); /**SPI1 GPIO Configuration PA4 ------> SPI1_NSS PA5 ------> SPI1_SCK PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI */ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); /* Peripheral interrupt Deinit*/ HAL_NVIC_DisableIRQ(SPI1_IRQn); } } and look at my saleae result: I seperated each 8bit. if you consider those 10 bytes are "Rohalamin"+0 but there are two problem. 1- Why cannot the saleae identify the "Rohalamin"+0? 2- There are so much pulses on the Enable line. Why? What are they? are they noise? AI: There are a few things in your code that I'm concerned about. First of all, you are using external interrupts for SPI, while transmitting manually. It requires an external interrupt source to trigger the interrupt (a button for example). In any case, external interrupt lines should never be left unconnected. I would suggest disabling interrupts for now, and enabling them later if needed. Second - you've redefined aTxBuffer[] in your main routine that was previously defined in stm32f0xx_it.c Third - you are controlling nSS pin in software. At the beginning of the transmission the pin should be pulled LOW. You've done that correctly. However, pulling the nSS pin HIGH in software will not work the way you've done it. You have to set an interrupt on the RXNE flag and pull nSS HIGH inside the interrupt. This way nSS will be HIGH as soon as SPI transmission ends. Here is an example code with Standard Library (note that you might have to adjust it for your microcontroller): // Enable interrupts on RXNE SPI_I2S_ITConfig(SPI1,SPI_IT_RXNE,ENABLE); ... // SPI1 interrupt handler void SPI1_IRQHandler(void) { if (SPI_GetITStatus(SPI1,SPI_IT_RXNE)) { uint16_t temp = SPI_ReceiveData(SPI1); // Read SPI data and clear RXNE GPIOA->BSRRL = GPIO_Pin_4; // Set nSS pin (PA4) HIGH } } And finally - it would be helpful to have a schematic of what you're working with.
H: Has anyone programmed ATmega8A using USBasp? I have failed to program ATmega8A using USBasp. I am sure that the wiring is ok. I have programmed an ATtiny13A several times with the same USBasp. However, no luck with the ATmega8A. This is the error avrdude shows- avrdude.exe: error: programm enable: target doesn't answer. 1 avrdude.exe: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. I tested without the microcontroller connected and found the same error. Which means I have broken connection. I don’t think so. Is there any possible reason avrdude shows this error without broken connection? AI: Your setup might just be flawed. I have programmed not specifically the ATmega8, but I have done an ATmega16 which is the same process. I note the article on my website which has been used by many. At one point in the article I list a command: -c usbasp -p atmega16 -B12 -U flash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i You will change this to -c usbasp -p atmega8 -B12 -U flash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i
H: 9V battery and resistor are connected in series - the voltage across the resistor is < 9V. Why? I am taking my first steps into learning about electronics as a hobbyist and I am struggling to understand something about resistance. I have read about Ohm's law and it seems fairly straightforward so I set up a simple circuit on http://123d.circuits.io. This circuit consists of a 9V battery and a single resistor (10 Ohms) with its leads connect directly to the 9V battery. simulate this circuit – Schematic created using CircuitLab When I place the probes of their simulated voltmeter across the leads of the resistor, it reads 7.83V. I can't make any permutation of Ohm's law produce that result. What would be the expected voltage across the resistor? Based on other posts on this site, I would expect the voltage to be 9V. I don't know how that simulator (123D) calculates its values or how it simulates the circuit. I am sure that I am missing something fundamental but so far I haven't figured out what. Is the 123D circuit simulator right? Should there be only 7.83V across that resistor? I set up a similar circuit (using CircuitLab) and it seemed to show that the voltage would be 9V. So I am confused. Is this just an inaccuracy of the 123D's simulator? Can someone help me to clear the fog? AI: They are simulating a (more or less) real 9V battery. They've modeled the battery as an ideal voltage source of 9V with a series resistance of ~1.5 ohms. simulate this circuit – Schematic created using CircuitLab If you work this out, the current is 9V/(11.5 ohms) = 0.783A, so the voltage across the 10 ohm resistor must be 7.83V.
H: Headphone cable as antenna How can headphone cables act as Antennas for built-in radios in smartphones ? Is it possible because of different frequency channels or what is the theory/mathematics behind this? On a side note, what would be a hardware implementation for this application? AI: If you think about it, any antenna picks up virtually anything from a few kHz to over a GHz - all these competing signals arrive on the input stages of a receiver but the receiver does what it does best - it focusses on the frequency band it is interested in and largely rejects everything else. Clearly a big signal just outside what it focusses on can have an effect and these are known phenomena to radio guys. Using a headphone audio wire is no different - the audio is never really anything like close to the frequency band of interest for the radio so it barely breaks a sweat rejecting it even though it might be a few volts peak-to-peak whilst the real signal received might be a few micro volts. A single-order 1 MHz high pass filter will provide 120 dB rejection to a 1Hz signal. A 2nd order 1 MHz high pass filter will provide 120 dB of rejection to a 1000 Hz signal. A third order will reject 10 KHz at 120 dB and so on and so on. The filter in a radio is probably equivalent to a 6th order at least.
H: Where can I find a transistor similar to a 2n 3904? I have what I believe is a 2N 3904 638 transistor. It measures 50MΩ at around 70°F. How can I find a data sheet on this? How would I go about finding a similar / replacement thermistor? PS: I did try Google Searching for those numbers but didn't come up with anything definitive, so this is partially about learning what the right way to identify / look up components is. Also, if I need to graph the resistance over a temperature range I can do that as well. AI: It's an NPN transistor- a very common one. You can find the data sheet easily by searching. They're around a dime each in small quantities from any distributor. They've tied the base and collector together so it's a diode-connected transistor. Such a diode-connected transistor follows the ideal diode equation more closely than a real diode at lower currents. In the simplest implementation you put a current (say 100uA~1mA) through the transistor and it has a forward voltage of around 600mV that changes at about -2mV/°C. However the forward voltage and the tempco vary from unit to unit. By using two or three different currents you can cancel out the unit variations and also the resistance of wires going to the sensor by using a bit of math and choosing the currents carefully. It's possible to get interchangeability of sensors in the +/-1°C range typically without calibration or selection. This exact method is used to monitor CPU die temperature in a PC- the diode is part of the CPU chip. If you want to test if it is functional, many multimeters have a diode test function that should show a number such as something between 500 and 600 in one direction, and overrange (open) in the other direction. If it reads something like that, it's almost surely functional.
H: 12 V LED strips in series with a 24 V power supply? I am purchasing 50x - 1 meter / 12 V / 72 LED / Rigid SMD 5730 strips directly from China. I don't know the LED manufacturer, nor the resistor being used. (Yes, this is a gamble.) The strip is one that could be cut at every 3rd LED. So, it seems that every 3 LEDs is wired in series, and there are 24 groups of 3 wired in parallel. Each strip is specified at 12 V/18 W. I would like to take 2 strips, and wire them in series with a 24 V 18 W power supply. (By series, I do not mean chaining them in parallel and calling it series like the billion articles polluting my google searches) My question is, can I wire two 12 V strips in series using a 24 V power supply? It seems like I can, but am worried I am overlooking something that I don't even know to ask, or I do not have enough information without the LED spec sheet. AI: Well, yes and no. On the one hand, connecting 2 in series ought to work. On the other hand, you will need 24 volts at 36 watts. Since each string takes 12 volts at 18 watts, its current must be 1.5 amps. Connecting them in series will still take 1.5 amps, but the total power will be 1.5 x 24, or 36.
H: Why do some power plugs have holes in them? I've just learned that electrical chargers with pins with holes in them are illegal in Australia. Here's what I'm talking about (ignore the one second from the left): What's the purpose of these holes? AI: Retention mechanism: Some sockets have a spring loaded ball like structure (or variant) that engages this hole as a "detent" holding the plug in place.
H: Battery Ampere-hour rating vs Battery Amps (not an experienced user) I have almost no experience whatsoever with the technicals of electronics so this is probably a very easy question for someone who does. Do you know if a battery with a 200Ah rating can put out 200A for one hour or are there limitations? According to this website's third paragraph (Battery Ratings - Chapter 11 - Batteries And Power Systems), you can. For example, an average automotive battery might have a capacity of about 70 amp-hours, specified at a current of 3.5 amps. This means that the amount of time this battery could continuously supply a current of 3.5 amps to a load would be 20 hours (70 amp-hours / 3.5 amps). But let’s suppose that a lower-resistance load were connected to that battery, drawing 70 amps continuously. Our amp-hour equation tells us that the battery should hold out for exactly 1 hour (70 amp-hours / 70 amps), but this might not be true in real life. With higher currents, the battery will dissipate more heat across its internal resistance, which has the effect of altering the chemical reactions taking place within. Chances are, the battery would fully discharge some time before the calculated time of 1 hour under this greater load. But wouldn't that mean you could hook up a 200Ah battery and ask it to put out 12000A for one minute or 720000A for a second? That seems very unrealistic, lol. I'm trying to find the proper kind of off grid battery that can power a microwave through a 3000 watt power inverter. The microwave needs 1800 watts and the battery needs to be 12 volts so that would mean I need about 150 amps, I'm wondering if a battery with a 200Ah rating could do it? AI: Your hunch that batteries have a current limitation is correct. In general, it's hard to tell the current rating [A] from capacity [A·h]. You have to look it up in the datasheet. A lot depends on the design of the battery. For example: coin cells with 500mAh capacity may have only 3mA max current. Another (opposite) example: automotive starter battery with 40Ah capacity may have 500A max current. Lead-acid batteries are interesting in this respect, because there are two distinct types. Starter lead-acid batteries are designed specifically to deliver high peak current for a short period of time. Deep discharge, however, dramatically shortens the life of a starter battery. So, it's not suited for routine operation at high depths of discharge. Your typical starter battery in the automobile works at very shallow depth of discharge. Deep cycle lead-acid batteries are designed (as name suggests) to discharge further. But they can not provide as much instantaneous current. Here's an example datasheet for a deep cycle battery. Have a look at the nominal capacity on p.1. Notice that capacity depends on discharge current (i.e. the rate of discharge). - Depth of Discharge Starter Battery Deep-cycle Battery 100% 12–15 cycles 150–200 cycles 50% 100–120 cycles 400–500 cycles 30% 130–150 cycles 1,000 and more cycles (Source.) p.s. If you want to read-up, here's an excellent web site on batteries - Battery University.
H: I stuck a 450 V 10 µF capacitor in a 110 AC wall outlet and it exploded... why? When I put it in the outlet it "popped" with some oily gray smoke. Honestly I thought that the voltage rating on the capacitor meant you could feed at least that much voltage through it, but clearly I'm missing something fundamental. I am glad I tried this with a rubber gripped wrench. AI: The voltage rating on an electrolytic capacitor is for DC, not AC. The impedance of a 10 uF capacitor at 60 Hz is 265 ohms so it would draw about 0.45 amps. The combination of too much voltage and too much current will result in destroying the capacitor. In most applications of such capacitors, they follow the output of an AC to DC rectifier so they see an AC ripple voltage on top of a relatively high DC voltage. The ripple voltage will cause current to flow through the capacitor but it will be much less than what you subjected your capacitor to because the ripple voltage is only a fraction of the full AC input voltage. Most electrolytic capacitors have a maximum ripple current rating to prevent overheating. The voltage rating gives the maximum of DC + AC ripple that the capacitor can withstand. In general this should be derated by at least 25% to protect the capacitor and increase reliability.
H: How to measure the resistance of digital potentiometer AD5241 in circuit when power on I have designed a transimpedance amplifier including a digital potentiometer AD5241. The circuit is showed below. I want to test the AD5241 to make sure it works as designed. simulate this circuit – Schematic created using CircuitLab My question is how can I measure the resistance of AD5241 when power on. As AD5241 has been connected to other components, it can not be tested independently. Should I use a multimeter to measure the resistance between the two terminal of AD5241 directly? But I have learned that when the circuit is power on, the measurement value would be incorrect. Or any other methods? (one condition is that the output of PD may be unknown) Thank you! AI: Since the - input of the opamp will be at GND, (zero volts) no matter what, the opamp's output voltage will change in order to force enough current through the AD5241 to keep the - input at zero volts, no matter what the diode's doing. So, if the AD5241 is sitting at, say, 1 megohm and everything is stable, then if you shunt the AD5241 with 1 megohm, the output of the opamp will drop to half of what it was before it was shunted since that's the voltage that's needed to pump the same current as before through half the resistance. Then, in order to divine the resistance when you don't know what it is, measure the voltage from the output of the opamp to GND (NOT to the summing junction) and then shunt the AD5241 with resistance until the opamp's output voltage falls to half of what is was originally. Then disconnect the shunt, measure its [the shunt's] resistance, and VOILA! that'll be the AD5241's resistance. Of course you'll need to be careful not to change the illumination of the diode or disturb it in any way...
H: USB Interrupt and Isochronous transfer bandwidth concept I read in the USB spec and other USB materials on the web that interrupt transfer mechanisms (for devices like mice/keyboard) are guaranteed a 'bounded latency'. Whereas the isochronous transfers (media device - camera/speakers) are guaranteed USB bandwidth and bounded latency as well. If I have a high-speed device (480Mbps), then what does the 'bounded latency' and 'guaranteed bandwidth' mean? I understand that for media devices, a guarantee of the USB speed should be there in order not to drop any audio/video frames/packets. But what does bounded latency offer over here that gauranteed bandwidth cannot? AI: In USB, guaranteed bandwidth also implies bounded latency, but not the other way around. USB is organized into 1 ms time slices. For interrupt transfer, the host is guaranteed to send a OUT packet to the device each slice. Maybe it can be configured for once every N slices, I don't remember. Interrupt packets are short, so you don't get to transfer much data, but you know the host will come around and ask periodically. For isochronous, a fixed part of each 1 ms time slice is allocated to the device. Not only will the host send the OUT packet each slice, but you can configure it to contain a specific amount of payload, or the IN reply packet to have a specific payload. Obviously this allocates some of the fixed bandwidth to a particular device, so all devices can't have this with arbitrarily large data. Since the available resource is finite, the host can refuse your device altogether. This is one of the drawbacks of insisting on a fixed bandwidth. There are also rules about how much of each 1 ms slice the host can allocate to interrupt and isochonous tranfers. I think something like 20% must be left unallocated, which means the host will poll bulk transfer devices during this time. There can be any number of bulk devices, so there is no guarantee how often the host will get around to polling any one device. In most cases, the interrupt and isochronous transfers don't add up to much, so in practise most of the time is left over for bulk devices. Usually the host will poll all bulk devices in a loop during any left over unallocated time. If you're the only device on the bus, then bulk transfer will give you access to most of the bandwidth, whereas interrupt and isochronous still get the small dedicated bandwidth they are configured for. Unless you really need some minimum bandwidth or latency, just use bulk transfers.
H: Where to look for logic level of a circuit in the datasheet? Whenever I pick a chip for my project, I run through the same chore: finding out if its logic levels match what I work with. Is it 5V? 3.3V? 1.3V? Or one of these that sources whatever level I apply to VCC and reads anything from 0.6V to 36V and more just fine? I'm fairly sure that information is supposed to be in the datasheet but only rarely I manage to find it somewhere in clear view. Common search for "Logic" turns up only irrelevant entries; search for Voltage brings hundreds of various ratings, levels, tolerances etc. I usually end up looking up a circuit involving given chip. What are the usual entries/clues/symbols to look for in a datasheet to find the logic levels of given circuit? AI: There are usually 4 values you need to find: \$V_{IL}\$ and \$V_{IH}\$ These are the input logic levels. They are often listed as a proportion of the supply voltage, such as \$V_{IH} = 0.6 V_{DD}\$, which is 0.6 times the supply voltage (so for 5V that would be 3V). The low voltage must be below \$V_{IL}\$ and the high above \$V_{IH}\$. \$V_{OL}\$ and \$V_{OH}\$ These are the output voltage levels. They are listed as maximum and minimum values respectively. Again, they may be listed as a proportion of the supply voltage.
H: Differential ADC where input goes below ground rail? I've been reading up on differential ADCs but haven't quite wrapped my head around them. I'm a hobbyist with no real training, you see. I'm wondering, is it possible to use a differential ADC with +5/0 supply and an input signal where the negative input is below 0V? I'm wondering if I just have to keep the signal difference within 5V (like +/-2.5V) or if the signal must be between the supply rails of the ADC? AI: First, that question should be clearly answered in the datasheet for the device. The absolute maximum section will tell you what voltage range the inputs can tolerate without damage to the part, and the operational spec will tell you what input voltage range it can sense. Second, it is very unlikely that the A/D can sense voltages outside its power supply range. Again though, read the datasheet for the definative answer. Most likely you will need to put a resistor divider in front of your A/D. That attenuates signals, so the signal level into the resistor divider can be larger than the native signal range the A/D can convert. Note that the second resistor of the divider (the one your input signal is not attached to) doesn't have to go to ground. In your case, you may want to connect it to the positive supply, or some other fixed voltage source.
H: How to make LED lamp (220V 50Hz input) circuit by using 1 watt LEDs? I think to make LED lamp circuit by using 1 watt LEDs (300mA and 3.6V). How to make circuit. But I can not use transformer.Because size and cost of transformer is high). Input single phase, 220V,50Hz AC supply. Please help me. AI: Here's a circuit that uses a high voltage buck type regulator: - WARNING!!! - THE OUTPUTS OF THIS CIRCUIT ARE EFFECTIVELY AT AC MAINS VOLTAGE AND MAY KILL YOU IF TOUCHED. Its output voltage is 36V at 330mA but I reckon adjustment of the R8/R9 ratio should lower the voltage. Here is the digikey reference design page. You may not be able to get down to a low enough voltage to drive one 3.6V LED but a few in series would work. Here's another idea: - Here's the page it came from. And here's another circuit: - WARNING!!! - THE OUTPUTS OF THIS CIRCUIT ARE EFFECTIVELY AT AC MAINS VOLTAGE AND MAY KILL YOU IF TOUCHED. This should give you a few ideas OR just go and buy one for $5 ============================== ADDED I'm tacking this on the end of Andy's answer as the question was open when I started this answer and had been closed by the time I finished answering it - ie it had been closed while I was in the process of answering. If I was able I'd post this as a separate answer: Here is a design that may meet your requirement. It uses a high frequency transformer which you can have wound at local labour rates. With proper supervision this could be done by relatively unskilled people as long as they can follow instructions. Also, for your suggested order size you can probably get a local company to do this at an acceptable cost. Full description here: IGBT powers ultra low-cost offline wall adapter This has output voltage feedback but it could be converted to LED string current feedback with ease. Note use of IGBT as main switch. The MBT3945 is a bipolar thyristor acting as a voltage triggered clamp on the gate. Read the circuit description to see how it works. The same function could be achieved with two low cost bipolar transistors. The circuit is less complex than it may at first appear. 5 capacitors, 6 diodes, 6 resistors, 1 optocoupler, 1 zener, 1 ... Their circuit is 110 VAC powered. If you are in Kerala then you probably want 230 VAC operation. It will work at 230 VAC with more care. This IGBT STGPL6NC60D will probably be suitable. iT costs about $US0.50 from Digikey in the quantity you mention. Data sheet here It is a fast device - liable to be very adequate for your task. If this circuit is too complex for you then you are liable to have problems with any "good" circuit. What you are trying to do is a non trivial task and inherently dangerous. Taking too many shortcuts will kill your users.
H: Does a "Buck Step Down Voltage Regulator" provide constant output voltage regardless of input voltage? I've got a small solar cell panel rated at 20V on a good sunny day. I need to regulate this down to 13.8V to charge a lead battery. Can I use a "Buck Step Down Voltage Regulator" for this? I'm uncertain about whether the regulator will provide 13.8V regardless of input voltage, or if it just provides an output voltage relative to the input voltage. Specifically, I'm looking at an LM2596 regulator. AI: A quick look at your part on Ebay and the chip datasheet (thanks, @whatsisname) suggests that it has a regulated adjustable output. So yes, if you set it for 13.5V it will hold to that voltage. Provided that you don't violate the input requirements. A buck converter can only ever put out a lower voltage than the input; so you have to make sure the input voltage never falls below ~14V in order to guarantee the 13.5V output. You say your solar panel is rated at 20V on a "good day". What panel output do you get on a "bad day"? If it falls below ~14V you'll probably have problems charging your battery.
H: Burning rectifier capacitor 220V input I have built the following circuit for 1 watt power LED lamp. The capacitor C4 (220uf 50v) was heating after a few seconds then it burnt. What is wrong with the circuit? I can remove C4 but reducing brightness. AI: Arshid - Your circuit will work as shown, but there are some problems. First - why did the cap blow up? My best guess is that you installed it backwards. Look closely at C4 on the schematic. See the + sign? You need to pay attention to it. Your cap should have a polarity indicator, either a + or -. I've simulated the circuit, and it should work. The maximum voltage across C4 is about 25 volts. The zener will dissipate about .75 watts, so be sure to use a 1-watt diode. R3 NEEDS to be a 5-watt resistor. If you had not turned off the circuit after the cap blew, and you are using something like a 1/4 watt resistor, you would have seen R3 start smoking. C5, for what it's worth, can be a 10-volt cap. Note that it filters the output of a 4.7 volt zener. The current through the LED is about 100 mA. Now for some suggestions. The first, and most important, is that you buy a cheap multimeter. Without it you will have no idea what's actually going on in your circuit. Second, and very nearly as important - Never use a circuit that is powered directly from mains. It only takes a seconds carelessness making a measurement to cause you great bodily harm. Third, (and this follows directly from the second) - get a transformer. And you don't need a big, expensive transformer. For what you are doing, 12 volts at one amp will do just fine. Your circuit can be replaced by simulate this circuit – Schematic created using CircuitLab But note that the LM317 needs to have a heat sink. The current set resistor R1 can be a 1/4 watt. The 470 uF cap will need to have the + end at the top, - end tied to ground.
H: Draw a finite state machine for a welding machine I am trying to draw a fsm for a welding machine. So far I have the following table, which I think is right.. The system has three normal states: stopped, started, and welding. It will only transition from stopped to started when the power button is pressed, and from started to welding when the weld button is pressed, then from weld to stopped when the power button is pressed again. The system only has a single output: a signal called fail, which is set to a 1 if there is an incorrect sequence of button presses. Adding a failed state makes the system easy to implement as a Moore machine. The state transition table would look something like: Following that description can anyone help me with the design please? It has been a long time since I did something very similar. AI: Here you are the correct FSM you asking for!
H: How to hook up a load cell to an Instrumentation amplifier correctly I am trying to get load cells connected to an instrumentation amplifier. The load-cells I have are extremely similar to the ones here https://www.sparkfun.com/products/10245. They have 3 wires coming out of them. A red, white as well as black one. Now according to the schematic here which is for a single load cell , when used with a ad620, it should be hooked up like this Google Image. So my first couple of question are as follows: -What do the red, black and white wires stand for and how do we identify the purpose of each wire -I need to use 4 load cells instead of one. With 3 wires coming out of each load cell , I end up with a lot of wires. In what fashion should they be connected to achieve the Wheat Stone bridge? -The wires are connected the metal with some white glue. Does this glue play a major role? Is it some special kind of glue or can I use any kind which is available? I looked at this schematic which is an explanation about how load cells work(http://www.allaboutcircuits.com/vol_1/chpt_9/7.html) but I am still unable to figure out how to exactly make the connection. Could someone please help me out? AI: What you have is probably two strain-gauges in each package forming a half-bridge. The wire colours could mean anything so what you have to do is take a multimeter and measure the resistance. You should be able to figure out what you measure from this: - simulate this circuit – Schematic created using CircuitLab Between two of the three wires you should read a resistance that is twice as high as the resistance between the 3rd wire and either of the original wires. The wire in the middle (above circuit) is the input to your amplifier and the wires at the top and bottom is where you apply your excitation voltage or current. As a start, two of the three-wire load-cells can be excited together and the individual outputs fed to an instrumentation amplifier but, there's one more thing; whatever colour are the excitation wires, make sure they are applied oppositely on one of the load-cells - this ensures that one output rises with load whilst the other one falls. If you don't do this you will not measure a signal. That gets you two load-cells into one instrumentation amplifier and to get 4 load-cells either parallel them up or use another instro amp.