Wednesday 31 May 2017

monostable - 555 timer, one shot trigger


I'm trying to create a circuit that will pass a 12V pulse on the rising edge of a push button (it can be triggered by the entire input pulse but rising edge preffered). I've had some experience with microcontrollers but I'm very new to ICs. I believe I can use a monostable multivibrator, constructed with a 555 timer.


Datasheet: http://www.ti.com/lit/ds/symlink/ne555.pdf


The below circuit is taken almost directly from the datasheet (pg. 10) with the addition of the trigger configuration. My understanding of the graph in figure 10 of pg. 10 is that the pulse is generated on a "low" input at the trigger, would my configuration below create this low input when the button is pressed (pull up resistor, I believe)?


schematic


simulate this circuit – Schematic created using CircuitLab


The output pulse length is found approx by: \$T=1.1{\times}R_1{\times}C_x\$



I'm having trouble wrapping my head around what the threshold and control inputs do and so in the above equation I'm unsure which capacitor value to use, \$C_1\$ or \$C_2\$?


When triggered, is the output pulse equal to the input source \$V_1\$ or another value?


Not 100% on choosing a value for \$V_2\$, graph would indicate using a value of \$\frac{V_1}{2}\$ works?


Sorry, I know this is a lot of questions, thank you for any and all help.



Answer



C1 is the capacitor that is used along with R1 to set the pulse length using the formula you gave. So you can substitute R1 for R, and C1 for C in the formula.


The CONTROL lead is used to adjust the interior comparator levels, in this case it is not used. The capacitor C2 just provides some noise immunity to prevent false triggering. It is typically 10 nF to 100 nF.


The output will be equal to V1 when triggered, and ground otherwise.


Instead of using a separate V2 voltage, you can just tie R2 to V1. The TRIGGER voltage just needs to be above V1/3 when not active, but there is no reason it can't be equal to V1. A good value of R2 is 10K.


You should also put a 100 nF capacitor between the Vcc pin and ground.



Here is a simplified view of interior circuit of the 555:


enter image description here


Note the three 5K resistors on the left that create a voltage divider; that's where the name 555 comes from. The resistors set up a voltage of 2/3 V on the - input to the upper comparator C\$_{A}\$, and 1/3 V on the + input of the lower comparator C\$_{B}\$.


When the TRIGGER falls below 1/3 V, the lower comparator C\$_{B}\$ outputs a high and sets the flipflop, and the OUTPUT goes high. The external capacitor C1 also starts to charge. When the external RC network made up of R1 and C1 reaches 2/3 V, the upper comparator C\$_{A}\$ goes high, and resets the flip-flop, and the OUTPUT goes back to 0.


Potential problem: Looking at the interior circuit of the 555, if the TRIGGER input is held low for longer than pulse length, it will keep the lower comparator C\$_{B}\$ high and the OUTPUT will remain high.


You can get around this problem using a differentiating input:


enter image description here


It generates a short negative going pulse regardless of how long you hold the switch down.


batteries - How to measure battery voltage


I am building a battery powered device. Almost all of my logic is running at 3.3v, although I do have a 5v supply for a few hobby servos.


I want to measure the battery voltage, but I can't do so directly with the ADC on my controller because the battery voltage (depending on the cell count of the lithium polymer battery that the user connects to the device) can vary between 6 and 36 volts. (My 5V and 3.3V supplies are fine with this input variation already.) The ADC can't measure anything above its supply voltage.



Obviously I need some sort of amplifier with a fractional gain, about 1/12 or so. Should I just use a simple voltage divider? How do I decide what values to use? Maximizing sleep-mode battery life is a concern, so that votes for using large values. What constrains how large those values can be? (The input impedance of the ADC, right?)


Am I better off using some sort of opamp amplifier circuit for some reason?


What's the usual solution here?



Answer



There is no one "usual" solution. Some are:



  1. Use a high side switch. Use a fairly low impedance voltage divider, but only turn it on for a short time around each battery reading. Since it's on for only a very small part of the total time, the average current draw will be low. This is usually done with a P channel FET so as not to add a offset voltage.

  2. Use as high a impedance divider as your A/D can tolerate. A/Ds are specified for some maximum source voltage impedance for two reasons, to charge up the sample and hold cap within the specified acquisition time, and so that leakage current causes a small enough offset to ignore. Too high impedance for the first reason can be overcome by a longer sampling time, which some A/Ds allow you to control. However, there is nothing you can do about the leakage. 100 nA will cause 100 mV error with 1 MΩ source impedance, for example.

  3. Use a high impedance divider followed by a buffer amp. You still have to consider leakage, but good opamp input leakage is usually a lot less than microcontroller pin leakage.



Tuesday 30 May 2017

pcb design - PCB tracing - Ground plane and Power plane?


Is it generally a bad idea, in simple or moderately heavy circuits, having two layers, to have a power plane in the top and a ground plane on the bottom?


The tracing would become much easier, there wont be virtually any noise, better heat dissipation and aesthetically the circuit would be layed out neatly.


Also, is there any handy guide to refer, when to use a thicker trace for different values of current?


Thanks.




microcontroller - Using Arduino to program at89s51


I want to program at89s52, and on the internet there are many tutorials on how it is usually done, but almost all of them use the RS232 output from the computer, which I don't have.


The only resource that actually implements it in another manner that I found is the usbasp page. This is something I would by default do, but I would like input from users who have experience programming the 8051 first.


1) Is it possible to implement device programming with an arduino? If so, is it feasible? I'm not entirely familiar with how exactly the SPI programming works, but it is something I am interest in learning. The idea is that I look at the datasheet, find out exactly what needs to be done, and use an SPI library for the arduino.


2) If 1) is too impractical and/or unreliable, should I go ahead and proceed with the USBasp project? I've read somewhere that on newer version of windows, this process is unreliable. So, what are your experiences with USBasp, to those who have done something similar in the past?


3) Any other suggestions or recommendations to upload a program onto the chip?



Answer



The AT89S51 is an 8051 architecture microcontroller, not an AVR architecture microcontroller like the Arduino and (as normally expected by) it's ecosystem of programmers.



However



  • The AT89S51 supports serial programming using an SPI interface (MISO,MOSI,SCK,Reset)

  • People claim to have used avrdude (and progasp172) to program an AT89S51 (ref)


If I am right, any Arduino running the ArduinoISP sketch should be usable, in conjunction with avrdude, to program an AT89S51.


Probably not very many people have tried this.


There are numerous inexpensive ISP programmers that are known to avrdude or which emulate a programmer known to avrdude. For example, I've used both an Arduino and a bus-pirate to program a bare ATtiny85 on a breadboard. An unrelated but useful description here


That leaves you with the job of generating a binary file for your target microcontroller.


fpga - Using signal in different modules vhdl


I am trying to connect a microcontroller(cortex m3) and a fpga(actel a3p060). I am able to read/write successfully with 16 bit databus. My modules in vhdl is structured as follows:



  1. Top module(interface with controller)

  2. sub module where I am having a frequency divider.


The idea is to generate different frequencies fed by the controller to the fpga. In the main module, I'm passing a signal called as the Load_Divider which will be checked in the frequency divider module as follows:


process(Load_Division)
if(Load_Division='1')
Data_Buffer<=DataBus;

Load_Divider <='0';
end if;
end process;

if(Counter = X"0000") then
Counter <= Data_Buffer; //reloading counter

And in the main module :


case Address is
"00100"=>Load_Divider <='1'; // generating load signal when proper address is found


But what happens is my Load_Divider is not going '0' when driven from the sub module.


Is it not possible to drive a signal from two modules?



Answer



It is possible to drive a signal from two modules.


However, it is not straightforward; the two modules have to cooperate - if one drives '1' and the other '0' at the same time, you have created a short circuit across the power supply, and you can potentially damage the device. In simulation, thankfully, the results are less dramatic!


Two ways to do so; and the reason not to use either of them inside an FPGA.


The first way is the traditional "wired AND" where there is a weak '1' permanently connected to the signal. Traditionally this was a resistor connected to +5V; in VHDL you might say Load_Divider <='H'; in the toplevel design. H and L are weak versions of '1' and '0'.


Now every driver can either pull it low, or turn off


if condition then 

Load_Divider <='0';
else
Load_Divider <='Z';
end if;

('Z' means the high-Z or high impedance state, i.e. turn off the driver).


If ALL the modules drive Z, the output is 'H' (equal to '1').


The second way is called a tri-state bus. Here either module may drive 0, 1 or Z onto the bus. However, you the designer MUST make sure that when one module is driving '0' or '1', ALL the other modules are driving 'Z', to prevent the short circuit and damage mentioned above. That requires the cooperation of all the modules in some way:


if my_turn then 
Load_Divider <= my_signal; -- 0 or 1

else
Load_Divider <='Z';
end if;

Either of these techniques are valid ways to communicate between separate FPGAs and other chips (memories, CPUs) on your board. But inside an FPGA there are no tri-state signals (only on its I/O pins) so if you use either technique above, the synthesis tools translate it into an equivalent signal without the tri-states.


For example the first technique (wired-AND) might translate to


Load_Divider_1 <= '0';   -- module 1
Load_Divider_2 <= '1'; -- module 2
Load_Divider <= Load_Divider_1 and Load_Divider_2;


where you can see that each signal has only one driver. So why not write that in the first place?


rs232 - Driving relay with PC serial port fails after few hours


Ive been trying to use this schematic: this schematic to drive relay (from this answer).


(Components are as specified in schematics, with D2 being 1N4007)


Vcc is 12V from PC standard Molex connector, DTR is from RS-232 DB9 serial port from same PC, and GNDs from both Molex and DB9 ports are connected.


I've completed bottom half of schematics (ending with T1), and wrote a simple software which does DTR ON for 2 seconds, then OFF for 2 seconds, then repeats. I've tested it (by connecting voltmeter between Vcc and output from T1) and it worked for at least an half an hour by happily alternating between 0 V and 12 V (open terminal voltage) exactly as I needed.


I left it doing this ON/OFF switching, and went to work on upper half for few hours. However, when I come back, the lower part of schematics was dead - it's open terminal voltage between T1 collector and Vcc now alternated between 12V and 10V, and if I connected some load (upper half of circuit, which seems to work OK if I connect it to power supply directly) it dropped to constant about 3.5V


I'll tear it down in few days to examine/rebuild, but in the meantime, can someone:



  1. spot would could be wrong with this, and


  2. suggest what can be changed to make it more robust (it is going to be installed in fairly inaccessible place)?


UPDATE At the time it was detected not working correctly, T1 or rest of electronics did not seem hot (about room temperature, maybe little higher -- of course it might have been dead already by then)


UPDATE 2 Another thing, when measuring DTR to GND on PC serial port via voltmeter, it seems voltages are -12V for OFF and +12V for ON (instead of 0V and 12V which I'd assume - however it seems valid configuration). Could that have impacted the circuit (and how to protect from it) ?


UPDATE 3 The forensics shows that the transistor T1 died (the E-C measures as 12k resistor), the rest of components are OK. Does that help find the problem? I also note that BC517 has VEBO of 10V - could that have caused the problem (the collector was open at the time T1 died)?



Answer



Never found out why the T1 in original schematics died. In the end, I've rebuilt the lower part a little different: here


It seems to be working (both with, and without the upper half) so far with no ill effects. Hopefully it will continue to work...


power supply - USB data transfer without charge


This is a total hardware noob question, but I really need an answer to this one:



I have 2 devices, A & B that are both self-powered. I would like to disable the +5VDC cord inside USB port, but still send data between devices through Data+ & Data- cables. Can this be done?




gate driving - Bootstrap circuit for high-side MOSFET driver


I am very familiar with the operation of bootstrap drivers on MOSFET driver ICs for switching an N-channel high-side MOSFET. The basic operation is covered exhaustively on this site and others.


What I don't understand is the high-side driver circuitry itself. Since a good driver pushes and pulls large amounts of current, it makes sense that another pair of transistors exist within the IC to drive the VH pin high or low. Several datasheets I've looked at seem to indicate they use a P-channel/N-channel pair (or PNP/NPN). Taking away the construct of the IC chip, I imagine the circuit looks something like this:


schematic


simulate this circuit – Schematic created using CircuitLab


It seems that we've just introduced a recursion problem. Assuming the node marked as "floating" can be any arbitrarily high voltage, how are M3 and M4 driven that doesn't need yet another driver to drive the driver (and so on and on)? This is also assuming the high-side driver is ultimately controlled by a logic-level signal of some kind.



In other words, given an arbitrarily high floating voltage, how is the push-pull drive of M3 and M4 activated by a logic-level signal that originates from off the chip?


Point of clarification: The specific question I'm asking has only to do with activating the high-side push-pull bootstrap drive with a logic-level signal. When the high-side voltage is relatively low, I recognize this is trivial. But as soon as the voltages exceed typical Vds and Vgs ratings on transistors, this becomes harder to do. I would expect some kind of isolation circuitry to be involved. Exactly what that circuitry looks like is my question.


I recognize that if M4 is a P-channel FET (or PNP), another bootstrap circuit is not necessary. But I'm having trouble conceiving of a circuit that will generate the proper Vgs's for both M4 and M3 as the external transistors are switched back and forth.


Here are screen captures from two different datasheets that show a similar circuit to what I drew above. Neither go into any detail about the "black-box" driver circuitry.


From the MIC4102YM:
enter image description here


And the FAN7380:
enter image description here



Answer



schematic



simulate this circuit – Schematic created using CircuitLab


Note 1: The input voltages are only \$V_{cc}\$ and \$V_\text{High Voltage}\$. You don't apply anything at the \$V_{BS}\$ node. It is only for representation.
Note 2: Notice that there are two different type of grounds. Those grounds must not be directly connected to each other.


You must drive the MOSFET between its gate and source terminals. Since the source terminal voltage of a high side MOSFET will be floating, you need a separate voltage supply (VBS: \$V_\text{Boot Strap}\$) for the gate drive circuit.


In the schematic below, VCC is the voltage source of the rest of the circuit. When the MOSFET is off, ground of the boot strap circuit is connected to the circuit ground, thus C1 and C2 charge up to the level of Vcc. When the input signal arrives to turn the MOSFET on, ground of the gate drive circuit rises up to the drain voltage of the MOSFET. The D1 diode will block this high voltage, so the C1 and C2 will supply the driving circuit during the on-time. Once the MOSFET is off again, C1 and C2 replenish their lost charges from VCC.


Design criteria:



  • RB must be chosen as low as possible that will not damage D1.

  • Capacity of C2 must be chosen enough to supply the driving circuit during the longest on-time.

  • Reverse voltage rating of D1 must be above \$V_\text{High Voltage} - V_\text{CC}\$.



The input signal must be isolated from the boot-strap circuit. Some possible isolaters are:


Optocoupler


enter image description here


Optocoupler is the most basic method for isolation. They are very cheap compared to other methods. The cheap ones have propagation delay times down to 3\$\mu\$s. The ones with less than 1\$\mu\$s propagation delay are as expensive as isolated gate drivers though.


Pulse Transformer


enter image description here


Pulse transformer is a spacial type of transformer for transferring rectangular pulses. They have less number of turns in order to avoid parasitic capacitance and inductance and larger cores for compensating loss of inductance due to reduced number of turns. They are much faster than optocouplers. Delay times are less than 100ns in general. The image above is for illustration only. In practice, the current they can provide is not enough for driving a MOSFET fast; so they need additional circuitry in practice.


Isolated Gate Driver


enter image description here



Isolated gate driving is a relatively new technology. All the complexity of gate driving is encapsulated in one single chip. They are as fast as pulse transformers, yet they can provide a few amperes of peak gate current. Some products also contain on-chip isolated DC-DC converters, so they don't even need boot-strapping. However, all these super features come with a cost.


circuit analysis - LTSpice: How to use .meas command to find the fundamental frequency of non-sinusoidal signal?


I want to find fundamental frequency of a periodic signal (non-sinusoidal) in certain time window using the .meas command in LTSpice.


I was using the following code to calculate frequency (in kHz).


.meas tran T1 find time when V(OUT)=0 rise 1000 .meas tran T2 find time when V(OUT)=0 rise 1100 .meas tran Frequency param 100/(1000*(T2-T1))


This works fine for certain cases, but when I do the parametric sweep, it gives inaccurate readings because of two issues:


Here, I assume at 1000th cycle, signal reaches its measurement window (say from time=4ms) but sometimes it doesn't. Therefor, I want to specify the absolute time for the measurement. from 4ms in this case, I have added a sample voltage waveform as below (with parametric sweep)


enter image description here



The zoomed waveform from 4ms is


enter image description here


My questions is


Is it possible to specify the starting time for the above code so that it will count cycles from the specified time? ( I tried to use trig-trag and from-to commands but failed)



Answer



It looks like you know your final simulation time, and the waveforms are about settled at the end of it, so, considering what I see in your picture, you can consider 4.4ms a mark from which you can measure, like this:


.meas t1 find time when v(out)=0 cross=1 td=4.4m
.meas t2 find time when v(out)=0 cross=3 td=4.4m
.meas T param t2-t1




Looking more closely (the grey-ish waveform), it looks like you have skewed sines in there, which will account for harmonics, so you can't really rely on this measurement for detecting the fundamental, only its apparent period. Just thought I should add this.


Monday 29 May 2017

ground - Anti-static mat connected to earth directly or 1E6 ohm resistor?


Should an anti-static mat be connected to earth directly or with 1E6 ohm resistance in between?


2 layer mat. Upper side: dissipative (10E7 ~ 10E10 ohm/m²). Bottom: conductive.



To be a little more precise: connection to earth will be thru a CGP (common ground point) which is at earth potential. So, 1E6 ohm resistance or not, between mat and CGP?




In response to Lorenzo Donati: so, the workstation environment explained in Op Amp Applications Handbook, chapter 7, page 95, looks like this:


enter image description here


Why not the following setup? Note the wrist strap grounding, which i edited from the original image.


enter image description here


Now, instead of 2E6 ohm resistance to earth, there is 1E6 ohm between the wrist strap and earth. Is this enough?


Page 96: "Again, a 1E6 ohm, from the wrist strap to ground, is required for safety".




power - How to increase the rated output voltage/current by connecting multiple op amps?


Is there a way to increase the power output from connecting multiple op amps?


My guess is that connecting the op amps' output in parallel will increase the rated current, and connecting power supplies with a common ground on the op amps to increase the voltage. For example, +15 V to first op amp, then -15 V to second op amp; the saturation of the parallel connected op amps should be 30V?


I'm using THS3202 and looking for driving a \$50\Omega\$ load at around 50 W


I have seen the datasheet and all the rated/maximum. How can I connect multiple op amps to increase the resulting output wattage?




Answer



In order to increase the power output using multiple op amps, you should use the maximum rated supply voltage (to maximize output voltage) and put the op amps in parallel to increase the output current. For example, the OPA454 datasheet shows how to do this on page 17:


enter image description here


In this schematic, \$A_1\$ is the master amplifier which provides the gain, and \$A_2\$ is the slave (which is just a unity gain buffer intended to double the output current capability of the overall circuit). Note that both amplifiers are configured with the same supply voltage -- in the case of the OPA454, this is a maximum of \$\pm 50\$V.1


However, this will only double the output power of the amplifier since it only allows you to double the output current (with no change in the supply voltage). Op amps can't supply 50W so this isn't enough for you. If you really want to increase the power output, use a power amplifier stage. The same OPA454 datasheet shows how to do this as well:


enter image description here


The op amp is driving a push-pull amplifier consisting of external power transistors. Note that the feedback loop is connected not to the op amp's output but to the push-pull amplifier's output (which is the overall circuit's output). This circuit has a much higher output current, which is provided by the power transistors rather than the op amp itself.




1 There are a number of potential challenges that must be considered with this parallel connection (stability, slew rate, choosing the current sharing resistor \$R_S\$, etc.). Apex Microtechnology's AN26 application note has a good explanation of these challenges.


microcontroller - Double polarity pulse with one single power source and virtual spdt switch


I have a problem in the design or my circuit. I need send data at a maxixum bitrate of 12000 bits /second. The high value should be +12v and the low value should be -12v providing at least 35mA of current. I initialy thought that I could easily get thoses values with the max232 chip. But when I did some tests, I could only get -7.25v, far from the -12v I need. The rest of the time, no data should be sent through the wire, so the current should be stopped logically. I made a diagram of the concept of my circuit so it's easier to understand : enter image description here I will use a 12v battery if need be, but I'd rather find a way to use a 9v battery. I would use a 5v regulator to get the 5v required for my microcontroller and then with my microcontroller I would send data. That data would then be converted to (+12/-12v high/low). The S6 Switch is used to stop the current when I do not wish to transmit data.


I've thought of a way of accomplishing all of that, but I have technical difficulties to achieve a logical spdt switch and on the whole I wonder wether it would work and if there wouldn't be a better design that mine. Here's a diagram of my first draft : enter image description here So I use an inverter schema with the IC MC34063 that will provide me with a -12v with 100mA. Then for the +12v I directly use the power source. I'm sure it's a good idea. Then I would use an electronic equivalent of a spdt switch (S1) connected to both the +12v and -12v driven by one or two pins of the microcontroller (preferably one). That should give me nice squared -12/-12v signals (not sure about that too) and then I would have electronic switch (S2) to open or stop the signal whenever needed.


So to sum up, my questions are :


1) Will my design work, what would be problematic ?


2) Is there a better design, maybe more efficient and with less components that mine.


3) How do I achieve the electronic equivalent of the spdt switch (S1) ? I've already opened a thread for S2 that was solved (see Electronic switch with negative and positive voltage)


4) With my design, will I get a nice squared -12v/+12v usable signal that will supply me with the 35mA I need ?



5) Can I work with a 9v battery instead of 12v battery ?


6) Can I use less microcontroller pins ? Ideally 1, but 2 would be okay as well.


Thank you for your help and inputs.



Answer



The other solution is very nice, but, as you mentioned you could actually put your transmitter device in a H-bridge configuration, we can make all this a lot simpler. First, no need to have a -12V supply, then. Second, there are ICs we can use. Yes sir. And I claim I have the solution with one single chip.


The trick is to use a simple MOSFET driver to directly drive the transmitter device. We need to drive it at both ends, so current can eventually flow both ways. So we need a dual MOSFET driver. We'll be using one that has an interesting configuration for what we need: the MCP14E8. It is interesting because it has an output non-inverted and another inverted, and it has enable pins. That's all we need:


enter image description here


Oh my god, it's beautiful.


This chip accepts 3.3/5V logic levels even when supplied with 12V. It can provide as much current as you may need (specified for 2A peak - continuous is not specified, however, because it is not really the purpose of these chips, but it certainly is more than what you require).


Other possibility, with FAN3223



enter image description here


For the supply part, if you use a 12V battery, there is nothing more to do. If you want to use a 9V battery, the charge pump trick with a spare MCU pin can be applied. Here is a charge pump that outputs 12V from 9V, and that can deliver 1W power at about 85% efficiency:


enter image description here


Circuit pastebin: http://pastebin.com/a3Mr7bq6 (note: blue text labels on input/outputs are wrong, should be "9V input" and "12V output")


The is exactly the same principle as in the other answer, except I chose to use mosfets here (this gives higher transient currents when state changes, but overall, the consumption is lower), and the charge pump outputs 3/2*VBAT instead of -VBAT. The trick here is to charge two capacitors in series through 9V, then we "split them" to get two times 4.5V, that we put in parallel and add to the battery voltage. Overall, we get about 12V (due to the diode drops).


This whole charge pump thing may seem a strange solution compared to using a cheap boost converter. But actually, if you use a small P-channel/N-channel pair in a single package (like DMG6602) and triple schottky diodes in single packages (like BAT54TW), it makes a compact solution with 3 tiny chips, 4 caps and 4 resistors only. And super cheap in volumes.


DRO scales 4-pin connector identification


I've purchased some scales for use with a mini milling machine and the open source DRO-550 digital readout platform. They are essentially equivalent to permamenet mount digital vernier calipers so that the X/Y/Z position of the milling table can be tracked and displayed. The end product is shown below with the included LCD readout:


DRO scales


Many scales use a standard mini USB connector even though the protocol is more SPI-like, however these use a 4-pin connector that I'd like help identifying. In the first photo the top scale of the ruler is 1/64" so it appears pin spacing is either 1/32" or 0.8mm, which I've also confirmed by measurement to reduce parallax.


DRO connector 1


The following photo taken on a different angle shows there are two rows of pins although they are physically connected so it is a 4-pin connector. The overall outer dimensions of the protrusion that pushes into the socket is around 0.2" / 5.2mm wide by 0.12" / 3mm high, so a little smaller than a mini USB.


enter image description here


I'd prefer not to cut the cables and re-terminate so wondered if this is a standard connector type that anyone can identify?




Answer



I managed to identify the connector after exhaustive searching of various suppliers through all 0.8mm pitch connectors. It is a member of the Hirose MQ172X Series with the 4-pin SMT receptacle being a Hirose part number MQ172X-4PA. After locating the part number it is widely available from Element 14, Digikey, Mouser etc.


Rather than make a custom PCB for a one-off I've ordered a couple of DFN-8 to DIP-12 SMT adapters from Proto Advantage (part number IPC0065) that I'll cut in half to mount the connectors to.


Sunday 28 May 2017

flyback converter issue


enter image description hereenter image description here


When loading flyback converter with heavy load, waveforms are as expected. But with light load, waveforms are not as expected. What can be the reason ? Duty cycle is less than 50% so no slope compensation issue.


(Attached one is waveform of drain to source of MOSFET)




pcb - What is this squiggly trace for?


macro shot of a PCB with a squiggly trace on it


It's on pin 14, which is the master clock input (MCLK) of a WM8761: Low cost stereo DAC. I'm guessing it's meant to act as a small inductor? But why would you want that on a clock input?



Answer



It's a serpentine track. They are often used where equal track lengths are required with high-speed designs. In this case it is probably used to implement a very short delay.


pic - PIC16: How do I modify the configuration words?


As I understand, the configuration words are different to the standard 8 bit registers. They are 14 bit wide, and they can only be accessed in "programming mode".


From reading the datasheet I do not understand how to enter programming mode and then modify the configuration word. Can I modify the programming word from my C code (e.g. within the main function), or should I somehow instruct my programmer (PICKIT 3) to do some magic before the main function is reached?



Answer




I do not quite understand how I'm meant to enter programming mode and then modify the configuration word? Can I modify the programming word in my C code (e.g. within the main function)?



The configuration words are mapped in program/instruction memory. They are mapped at an address location which is not accessible during normal device operation (it can be accessed only during programming mode). These configuration bits specify some of the modes of the device, and are programmed by a device programmer, or by using the In-Circuit Serial Programming (ICSP) feature of the midrange devices. So you should set these configuration bits in your code, but outside of any functions, using a compiler specific #pragma or macro.


From the XC8 User Guide:




The configuration bits for baseline and mid-range devices can be set with the __CONFIG macro which was supported in HI-TECH C, for example:


#include 
__CONFIG(WDTDIS & HS & UNPROTECT);

To use this macro, ensure you include in your source file. For devices that have more than one configuration word, each subsequent invocation of __CONFIG() will modify the next configuration word in sequence. Typically this might look like:


#include 
__CONFIG(WDTDIS & XT & UNPROTECT); // Program config. word 1
__CONFIG(FCMEN);

The easiest way to set your device's configuration bits is through MPLAB X. Instructions taken from here:




  1. From the main menu select Window ▶ PIC Memory Views ▶ Configuration Bits

  2. In the configuration bits window, click on any value in the Option column and it will turn into a combo box that will allow you to select the value you desire.

  3. Click on the Generate Source Code to Output button

  4. The IDE will automatically generate the code necessary to initialize all the configuration bits to the settings you specified in the window. This code may now be copied and pasted into one of your source files, or you may save it to its own file and add it to your project. To save the file, right click anywhere in the output window and select Save As from the popup menu.




Further reading:



transistors - Minimal Hall effect sensor circuit to keep something off after certain RPM achieved


I have a somewhat limited understanding of electronics and circuits. I'm trying to build a circuit that will keep a transistor in an off state after a given threshold of RPM is achieved using a A3144E Hall effect sensor.


For example, anything let's say that is below 500 RPM, I would like the transistor to be in an on state, and anything above 500 RPM, the transistor should be in an off state.


How could this be achieved using minimal and common parts without the use of a microcontroller, etc.?



Answer



You can do this with an LM2917 (or 2907) and a few support components. Have a look at page 9 of the PDF. The transistor state is inverted from your requirements, but that's easy to fix with another transistor.


schematic



simulate this circuit – Schematic created using CircuitLab


Without actually building and testing it myself, and given that it's 20 years since the only time I've used an LM2917, I'm not going to promise you that this circuit will work - but based on the datasheet it should. It should cover from about 220rpm to 900rpm; changing the upper and lower revs is just a matter of changing the resistors.


The rpm is set by C1 and (R1+R2). R2 is adjustable, allowing you to set a resistance of between 33K and 133K.


The relationship between frequency, resistance and capacitance is: F = 1 / 2RC


F is rpm / 60, so:



  • rpm / 60 = 1 / 2RC

  • rpm = 30 / RC

  • Using a 1uF capacitor (as I did in the schematic):

  • rpm = 30,000,000 / R



So for a 33K resistor, rpm = 909 and for a 133K resistor, rpm = 226. Smaller resistor values give higher rpm's.


The normal behaviour is that the (internal) transistor switches on when the frequency is above the set point. Q2 (and R5) flip that behaviour - Q2 switches off when the frequency is above the setpoint.


batteries - Possible to power STM32 Nucleo boards with USB battery pack?


I have a wireless-transmitter module connected to a Nucleo board. The sensor draws power (~200 mA) from the Nucleo board's 3.3V out pin.


Case A (successful): When I connect/power the Nucleo board with a standard USB (5V) cable connection to my PC, then:



  • the transmitter module successfully transmits (I successfully receive packets on remote unit)



Case B (unsusccessful): But when I connect/power the Nucleo board with a USB cable to a Battery pack (one of those phone backup-battery packs with 5V output @ 1A), then:




  • I get 1.1 V for the multimeter reading on the 3.3V out pin of the Nucleo board




  • the transmitter module isn't transmitting (I'm not receiving packets on remote unit)




  • the Nucleo board's LD1 (LED) just continuously blinks at 1 Hz





-


Question: Is there some physical re-configuration I have to do to allow the Nucleo to be USB-powered by a 5V-Usb-out battery pack, and to successfully draw power (about 250 mA in my case) from the board's 3.3V out pin?


Here is the schematic of the Nucleo board including its power circuitry: http://ds.arm.com/media/resources/db/platform/st/nucleo_f401re/MB1136.pdf



Answer



A few options from simple to complex:




  1. JP1 is the usb power limit bypass jumper. When OFF, the ST/Link part of the board attempts to enumerate with high power request. If it successfully enumerates with the requested power, it enables the USB power Mosfet. When ON, it signals the ST/Link that External Power is being used, and should enable the power mosfet anyway. Simply putting this jumper on should do the trick.





  2. Cut a usb cable, and wire the V+ to the either the E5V pin (Make sure JP5 is set on pins 2-3, for external power.), or the 5V pin, depending on if you want the ST/Link side of the board to be on as well or not. If you don't need the Programmer and Debugging while on a usb battery pack, use the 5V pin. Otherwise it's a waste of power, as small as it may be. (Additionally, remove the JP5 jumper just to make sure)




  3. Solder the SB1 (USB Power Management Bypass). This is a normally open jumper trace. When soldered, it physically bypasses the USB Power Management mosfet, connecting USB 5V directly to the target board and 3.3V regulator.




Saturday 27 May 2017

Three 12v computer fans, how much voltage on my power supply do i need?



i have 3 12v computer fans and i'm not sure to use 36v ac power supply. i've only done a couple of projects before and this is my first one without complete guidance. Three 12v computer fans, how much voltage output does my ac adapter need?




control system - Gain of proportional Controller with distubance $sin(10t)$


The diagram below represents the position of ocean oil platform system which use the proportional controller with gain \$k\$. The output \$x(s)\$ is the platform deflection regards the position desired. Consider the platform initial position \$0\$ and it subjects of waves forces the sea, which effect could be represented for disturbance \$d(s)\$.


enter image description here


a) Determine the transfer function \$x(s)/d(s)\$ in terms of \$k\$ and \$G(s)\$.



b) Consider the Bode diagram below with respect of \$G(s)\$. Suppose that it apply a disturbance as unit step function (\$u(s) = 1/s\$). What the amplitude of deflection, in steady state, of platform in respect the position desired in function of gain \$k\$?


enter image description here


c) Consider now that the disturbance would be the sine signal on time domain given by expression \$d(t) = \sin(10t)\$. Determine the value of the gain from proportional controller \$(k)\$ for, in steady state, amplitude of deflection of platform in respect the position desired been equal to \$0.1\$



I really think that I've solved correctly the letter a) and b) but i have theory doubts about the letter c)



a) \$x(s) = -x(s)\cdot k \cdot G(s) + d(s)\Rightarrow \frac{x(s)}{d(s)}+\frac{x(s)\cdot k \cdot G(s)}{d(s)} = 1\$


\$\boxed{\frac{x(s)}{d(s)} = \frac{1}{1+k \cdot G(s)}}\$


b) We need to value \$x(t\rightarrow\infty)\$? but \$e(t\rightarrow\infty) = \underbrace{\text{input}(t\rightarrow\infty)}_{=0} - x(t\rightarrow\infty)\$


\$e(t\rightarrow\infty) = -x(t\rightarrow\infty)\$



\$E(s) = R(s) - x(s) = -x(s) = -d(s)\cdot\frac{1}{1+k \cdot G(s)} = -\frac{1}{s}.\frac{1}{1+k \cdot G(s)}\$


\$e(t\rightarrow\infty) =\lim_{s\to 0}s \cdot E(s) = \lim_{s\to 0}s\cdot-\frac{1}{s} \cdot \frac{1}{1+k \cdot G(s)} = -\frac{1}{1+k\cdot G(0)}\$


\$G(0)|_{db} = 6.25\$


\$ \boxed{x(t\to \infty) = \frac{1}{1+k \cdot 10^{\frac{6.25}{20}}}}\$


I stuck the letter c)


Consider \$\mathscr{L}(sin(10t)) = \frac{10}{s^2+10^2}\$


\$e(t\rightarrow\infty) = -x(t\rightarrow\infty)\$ (same idea that letter b)


\$E(s) = R(s) - x(s) = -x(s)\Rightarrow e(\to \infty) = \lim_{s\to 0}s.-d(s).\frac{1}{1+k\cdot G(s)} = \lim_{s\to 0}s\cdot-\frac{10}{s^2+10^2}.\frac{1}{1+k.G(s)} = 0\$


Seems something I've missed this part.


Can someone give me any hint?




Answer



I don't know if I am understanding your question correctly—the wording is a bit confusing.


You know that your output to disturbance ratio is defined by the transfer function:


$$\dfrac{x(s)}{d(s)}=\dfrac{1}{1+kG(s)} $$


Just like you found it.


Question 'C' appears (better wording would help) to ask to find the gain \$k\$ so that the magnitude (amplitude) of the ratio of the output, \$x(s)\$, to the disturbance, \$d(s)\$, is \$\bigg|\dfrac{x(s)}{d(s)}\bigg|_{s=j\omega}=0.1\$. That would mean that:


$$\bigg|\dfrac{x(j\omega)}{d(j\omega)}\bigg|=\bigg|\dfrac{1}{1+kG(j\omega)}\bigg|=0.1\tag 1 $$


So you don't actually need to find the Laplace transform of the disturbance because the only unknown now, is \$k\$—you can find \$G(j\omega)\$ from the bode plot and the frequency of interest is \$\omega=10\$.


Remember that the Bode plot gives the steady state response of a system to sinusoidal inputs, that is why you make \$s=j\omega\$ and in this case, you are getting an input sine wave. So by looking at the bode plot, you know what your output sine wave, after steady state has been reached, looks like. At \$\omega=10\$, the output wave will have a corresponding amplitude determined by the magnitude response of \$\frac{x(j\omega)}{d(j\omega)}\$.


From the bode plot, you can find the missing piece before you can find \$k\$, and that is \$G(s)\$ evaluated at \$s=j\omega\$.



$$ G(j\omega)=\dfrac{2.05}{\big(\frac{j\omega}{10}+1\big)^2}$$


With that (after plugging in the expression for \$G(j\omega)\$ in (1)), you can solve for \$k\$ in the expression at \$\omega=10\$:


$$\bigg|\dfrac{1}{1+kG(j\omega)}\bigg|=0.1 $$


And \$k\approx 9.68\$ (double check this).


I hope this answers your question.


Smallest Magnetic Relay and how to choose the Ampere rating



I am building an automation system, where I don't have much space, so I require really small relays, 3.3 or 5 VDC controllable relays.



I need to connect it to say a lamp, or a fan, equipment's that draw less than ampere and work at 230 VAC. The 5 V 10 A relays are really big, and I need some advice on choosing the smallest relay and want to know the minimum ampere rating they should have.


Please share your ideas, thanks.



Answer



SSRs are usually rated for more current than you need (I gather you need \$\le 1\:\textrm{A}\$) and their packaging is often designed with a heat sink in mind. So they are usually not small devices -- perhaps rather larger than the size of an equivalent-purpose mechanical relay. They also tend to drop up to \$2\:\textrm{V}\$ across their leads, so in use you might see dissipation of \$\le 2\:\textrm{W}\$. Which probably means that you actually don't need a heat sink, of course. But they tend to build them with that in mind, anyway. So they usually aren't small.


It's possible to make an SSR using a pair of SCRs and tiny 8-pin ICs like the MOC3023 or MOC3063. But even if you source some smallish parts quite capable of the modest dissipation you need, doing all that just complicates matters and you'd also need to work out the packaging and safety details, too. So I think that's off the table here.


That said, you can find SSRs in your current rating. They will look something like these:


enter image description here enter image description here


But I'm not sure why you can't find a small relay. Here's one:


enter image description here


This can be found for sale at Digikey: Potter & Brumfield Through-Hole Relay SPST-NO. The contacts are rated for \$250\:V_{AC}\$ at \$2\:\textrm{A}\$, which seems to meet what you say you need. They are also small, at \$10\: \textrm{mm}\times 6\: \textrm{mm}\times 5.65\: \textrm{mm}\$. And not terribly expensive, either.



(I haven't checked if that relay is UL approved. You need to check that out, if it matters to you.)


The idea of a reed relay is also possible. Here's what one of those would look like:


enter image description here


This can also be found for sale at Digikey: Cynergy 3 S2-05EU. The contacts are rated for \$300\:V_{AC}\$ at \$1\:\textrm{A}\$, which also seems to meet what you say you need. They are also small but larger than the above telecom unit, now at \$7.62\: \textrm{mm}\$ diameter and \$22.86\: \textrm{mm}\$ length -- about 3 times the volume as the earlier device. They are more expensive, too. But in this case, designated as UL approved.


arduino - I burnt a pin. Now, what do I do?


I accidently shorted pins 10 and 11 with 10 set to output HIGH and 11 set to input. The pin 11 is not working. How do I figure out what component I burned?


Can the problem be fixed?



Answer



Assumption: As the specific Arduino model has not been specified, using the Arduino Uno to illustrate this answer. The rationale applies identically to the other Arduinos, for their respective pin-outs and microcontroller operating voltages.


Please refer to this pin-out diagram for the Arduino Uno: (source)




Arduino Uno pin-out






  • As can be seen, Pin 10 and 11 are both standard GPIO pins.

  • Any GPIO can not output a voltage higher than the microcontroller's supply voltage (VCC), in the Arduino. For the Uno VCC is 5 Volts.

  • Any GPIO pin can withstand input voltage up to VCC and a slight bit higher (5.5 Volts is tolerated as standard)

  • Also, when any Arduino GPIO is set to input, it is in a high impedance state, thus making it impossible to pass enough current into it for the voltages involved, for any damage to occur.

  • Thus, shorting pins 10 and 11 can not cause any damage to either pin, in the circumstances reported in the question.


Now let us examine the alternative possibilities:



  • If the Uno is powered from the DC barrel jack instead of 5 volts from the USB connection or other regulated power supply, the Vin pin outputs 1 diode drop lower than this input voltage: This would be around 8.3 Volts if the supply is a 9 Volt battery attached to the barrel jack.


  • Shorting this VIN pin to any of the analog or digital pins of the Arduino (other than specific pins which are protected by resistors) is very likely to destroy either the internal ESD diode / protection circuitry for that pin within the microcontroller, or destroy the microcontroller itself. This could be the cause of the problem.

  • Another hypothesis is that Pin 11 was exposed to some other source of high voltage, beyond the board's Vcc. This could be due to back-EMF from a motor, or from the high voltage (can be 10+ volts) generated by a piezoelectric bender (piezo speaker) if it is knocked against something. This could cause damage to ESD diodes / protection circuitry as noted above

  • Next, electrostatic discharge from static electricity can damage any given GPIO pin even while the device is not powered up. Did you happen to comb your hair and then touch the Arduino board at some point, for example? The problem will only show up later, when attempting to use that pin on the board, so causality is often difficult to pin-point.

  • Finally, if two pins are both set to output, one set high and the other low, and these are shorted, the "High" pin sees a short to ground through the "Low" pin. This source to sink contention can cause the microcontroller to heat up, and though the AVR microcontrollers typically have output protection on GPIOs, this may cause one or the other of the pins to stop functioning - though the entire microcontroller failing is more likely in this case.




Having said all that, if for whatever reason Pin 11 no longer performs input or output, the MCU's corresponding internal protection circuitry is irrevocably damaged. There is no way to repair this. This has been covered well in the answer by Manishearth.


Consider yourself fortunate that the entire microcontroller did not get destroyed, and re-code your applications to not use Pin 11 any more.


Personal tip: I've blocked the VIN sockets on my Arduino boards a long time ago by sticking some stripped insulation into them, to avoid ever accidentally exposing any jumper wire to that voltage. If I ever actually need to use VIN some day, I'll spend a delightful hour struggling to extract that bit of insulation stuck in there.


Friday 26 May 2017

opto isolator - Protect PC817 Optocoupler Anode from High Voltage


Voltage at IN3 will vary from 10V to 28V, How can I protect the optocoupler from getting damaged due to high voltage.


What is the maximum voltage and Minimum voltage should be given at anode (Pin 1) to sense LOW properly on GPIO.



Is there any external pull up needed at Pin 4 connected to GPIO of MCU.?


EDIT :


I am doing few calculations based on the comments, let me know if they are right


First of all the Optocoupler forward voltage is 1.2V and the maximum forward current for LED is 60mA.


The value for resistor R13 should be 

We will take LED current as 10mA

R = (Vin - Vf)/I


R = (12-1.2)/0.01

R = 1080 ohm ~ 1K resistance

If Voltage is increased upto 28V,

I = (28-1.2)/1000
= 26mA

This is well below the maximum LED current i.e 60mA. So there should be no issue with the high voltage and the 1K resistor is fine.



Now coming to collector load resistor value which is not mentioned in the image,


in data sheet the Vce saturation voltage is 0.1~0.2V

if Load Resistor is 10K
Ic = (Vcc-Vce)/R
= (5-0.1)/10000
= 0.49 mA

This value is also well below the maximum collector current which is 50mA.


So I think based on above calculation, Input resistor of 1K will work fine and collector Load resistor has to be added of value 10K.



Comments?


enter image description here




microcontroller - P CHANNEL MOSFET gate directly GPIO


I'm currently using this circuit to control my load from MCU logic HIGH


It works great, after self reflexion why just not do like this ?


What is the difference from the first circuit ? It's safe for my MCU ? I use NDP6020P is a Vgs(th) max -1V my VCC is 3.7V.


I know in the last circuit when MCU is LOW my load is "ON" instead the first circuit "LOW" = "OFF"


Regards




What are class E amplifier RF choke guidelines?



I am designing a novel circuit that I beleive has not been constructed yet! No -- I'm just using an exotic switching device for a class E amplifier.


My operating frequency is close to the 160 ham band (my target is between 1 and 2 megahertz).


I have seen multiple designs for bands closer to 80 meters (a few megahertz) that use a 47 uH RF choke on the drain of a mosfet. I will be winding this inductor myself so I would like to optimize this value and determine its effect on the output matching circuit.


I have an LCR meter and I am operating this amplifier at a bandwidth not exceeding 10kHz.


Have a schematic (I see this is for 160m and has a larger inductor):


160m schematic


Do I have to know my load impedance before selecting the RF choke or is that load independent? (as a side note I am using Cree SiC power mosfets because I have a source...)



Answer



I already implemented this topology in the past.


I had the chance to collaborate directly with the inventor of the technology, Nathan O. Sokal, but fortunately you don't need to because references are available.



The most useful document about this class E topology to design and tune our amplifier was the following paper: Class-E RF Power Amplifiers. It contains all the design equations required.


arduino - Smart charging circuit for NiMH battery pack


I want to build a solar powered charger for a niMh battery pack to run a microcontroller. What are the fundamentals of building a smart circuit that will not overcharge the battery and will also allow current to be pulled directly from the panel



Answer



In most cases with a small panel and a NimH battery the peak charge rate is below 1C and the supply varies with insolation (sunshine level). In addition, if the battery is near the panel the battery temperature varies with insolation. All these factors make most usual NimH charge termination algorithms and methods inapplicable.





  • Negative delta V detection is problematic at best when you charge V is variable.




  • Delta temperature rate rise is utterly swamped if the cell is sun exposed and




  • Absolute cell temperature is not a good measure of endpoint for the same reason.




In such cases a very reasonable charging strategy is to terminate charge at 1.45V per cell.



This can be adjusted for temperature. In my designs I also add charge current sensing and adjust the threshold down if the cell is still accepting large charge currents when almost charged. This helps compensate for a degree of variability between cells. Cells of different models and different manufacturers are usually reasonably consistent with the 1.45 / cell setting but some are fully charged at as little as 1.35V/cell.


If the cell output is wanted for other purposes when not needed for charging then charge control can use a series regulator or on/off series switch. If the battery is the only load then a shunt regulator to dissipate excess power can be
a good choice for smaller panels. Note that if the panel is taken "off charge" its voltage will drop and hysteresis will be needed to prevent endless on off charge cycling.


pcb design - DIY PCB Manufacture: Photoresist or Toner Transfer?


So here's what happening: I have my board layout ready to go on eagle, and am looking for a good way to produce this board at home, of a quantity of about 2 or 3, so not large scale at all. All the components are through-hole and the layout is single sided. For those curious the layout looks like this (the lines are from the a bad render as I just took a screenshot of it from paint):


enter image description here


Looking at DIY PCB manufacture all round the world wide web I have arrived at two most effective methods (from what I know): 1. Using a pre-made photoresist board to etch traces and 2. directly transferring ink from photo paper on to the copper (both using Ferric Chloride to route traces).


Since I have zero experience with this could someone please share some knowledge as to: for my application (low scale DIY PCB manufacture), which method would be the better choice and proved to be the most effective?


And for those with some experience in making your own PCB's at home, any advice or tips to share about this with a completely inexperienced guy like me? Any layout re-design required?


Really appreciate it.



Answer



Photoresist



Photoresist will give you the best results, and once you have the knowhow, it's easy and fast to make further PCBs. But it's a complex way for DIY:


As UV light source, the sun or an ordinary light bulb might work somehow, but a source specialized for UV and exposure is definitely better. (For DIY: get an old, thick (!) scanner and a face tanner and build your own exposure unit - This is identical to small and cheap semi-professional units, but can cost up to 90% less)


You need to produce a mask where black areas are as light-tight as possible, while other areas are as transparent as possible. The higher the contrast, the better.
To my experience, laser printer can produce a quite dark black on standard paper, but when the paper is more transparent, the black becomes lighter, too. There are sprays to be applied to a printout promising to increase the density (darkness), but this doesn't work for all toners. And there are other sprays making the paper more transparent, like oil does.


Next, you need to develop and etch your exposed PCBs.


In general, you need some test series to find out if your mask and UV light source are suitable, and what's the best exposure and developing time. This costs some PCBs or at least cans of photoresist and lots of time.


Long story short: This method is very expensive and time consuming when doing it just once.


Toner transfer


Also for this method, you need several trials, but as you get a good "preview" on the PCB before etching, you can just remove the toner with some solvents and try again. However, be prepared to produce more PCBs than you need, because pieces of the toner may separate from the PCB during etching.


Beneath the right technique of ironing (time, pressure), the paper is the most critical part. More glossy papers like those from magazines will not suck up the toner and leave more on the surface (better for the transfer), but the toner may also form a thinner film on them (not so good). And glossy papers don't soak as easily in water, so it's harder to peel them off without damaging the mask on the PCB. Some papers may contain some wax, oil or similar substances, which may also be transferred to the PCB. Clean the PCB gently with some dish liquid after transfer. (And also: clean it before the transfer with some good solvents like benzine or acetone.)



As edges are usually not that sharp and precise when using toner transfer, this method is not very suitable for PCBs with SMD components. You need a large clearance (space between tracks) and high track widths. The bigger, the better. But if you're making PCBs very rarely and don't need too much precision, toner transfer is a good alternative.


For your board, I would increase the width by a factor of 2 or more. You can still use thinner tracks where needed, just inspect them more carefully after the transfer. Also, you are using thermals (slits around holes in the copper plane, making soldering easy). For toner transfer, I would not use them, as they are too small to come out nicely on the PCB.


A paint pen (which applies thick pain, not just ink) is fine to correct errors or to fill large areas. (It seems many printers use less toner for filled areas than for lines). A needle and / or a scalpel can be used to scratch away an excess of paint.


voltage - How to step down from 4.5V to 3.3V?


I'm trying to step down my source voltage of 4.5V to a 3.3V suitable for the MPR121. The chip has at the best settings a typical current of 393μA. The 3.3V has to be quite accurate as to not damage the keypad. When researching, I've come across two possible solutions that could achieve what I want to do:




  • Voltage Divider
    In this case, can the output be stable and accurate enough to be able to step down and voltage and if so, what value resistors would I use?





  • Voltage Regulator
    This is then another IC just to step down the voltage (footprint wise), any suggestions on which regulator I would use (linear, switching)?





Answer



Since the voltage drop ratio is relatively low and the output current requirements also low, use a linear regulator. 3.3 V is a common voltage, so there are many fixed linear regulators available at that voltage.


These things have only three pins and are very simple to use. The pins are the input voltage, ground, and the output voltage. You will also need a 1 µF or so ceramic cap between input and ground, and between output and ground.


You are dropping (4.5 V) - (3.3 V) = 1.2 V. You have to be careful to choose a regulator that can work with that headroom. These are often called LDOs (Low DropOut).


The efficiency from the voltage drop will be 73%, plus a little more loss for the quiescient current. At only 400 µA output, the overall wasted power will be very small.


Also take a look at the quiescient current spec. For some linear regulators, that would add significantly to your 400 µA figure. Others work with only a few µA.



Take a look at the MCP1700 series, but there are many many others that would be fine too.


Some older LDOs are not "0 ESR output cap stable". Simply stay away from them. They were designed before the era of small and cheap ceramic capacitors that could do a few µF.


The MCP1700 series I mentioned is 0 ESR output stable, requires a maximum of 350 mV headroom, has only 4 µA quiescient current, and can deliver up to 250 mA. These are my "jellybean" LDOs, meaning that's what I use unless there is a good reason not to. I don't see one in this case.


Why a high voltage AC always present in SMPS AC to DC power adapters


I'hv seen every 2 pin SMPS AC to DC adapters shows a little high voltage respective to the ground on the out put, on both + and GND wires(or more if more wires present).


This voltage is high enough to light small neon bulbs or a line tester, but very low current, barely could be felt. This voltage vanishes if I connect the output to ground somehow, e.g. touch it while standing on floor bare foot.


As the size of the adapter increases, the AC voltage and current increases. When laptop adapters are powered from a ungrounded AC outlet, they gives reasonable shock from the 19V DC(or whatever else) output.


Perhaps this is the reason why many 3 pronged laptop adapter carries a warning CONNECT ONLY TO GROUNDED OUTLET Connecting to a grounded outlet magically vanishes the high voltage.


I am aware about the EMI filtering capacitor connected between high voltage and low voltage ground, I tried to solve this by removing them, but this trick is not working.



  1. Why and how this mysterious AC voltage is created ?


  2. Is it harmful to sensitive electronics components ?

  3. Is there any way to solve this without grounding the DC output side ?



Answer




  1. The internal transformer used to step down (and isolate) the power voltage has capacitance between primary and secondary - this can be around 10pF to 1nF depending on construction and size and is enough to produce several to several hundred micro-amps of current.

  2. It can be harmful to sensitive electronics - the open circuit AC voltage normally produced on an un-grounded wall-wart might be AC voltage divided by two so this means 60V AC for an 120V AC power supply.

  3. Grounding is the only method I can think of but, remember that the amount of current that can be supplied is not harmful enough to cause you any damage providing you are sensible and don't push the wires into your eyeballs or connect through your body to ground via your torso.


Can I use SPI for asynchronous serial output?


I need a second serial async output channel on the MSP430G2553 and would like to use the SPI USCI to do this.


Is the USCI SPI baud rate stable enough to do this at 300 baud, 2400 baud or 9600 baud? I am currently using the 8 MHz clock.


Is there any other option that can save me from bit-banging?


My current thinking for 300 bd Tx is as follows:



  1. set prescaler to 26666 LSB first

  2. load byte into Txbuf

  3. load 0x7F into Txbuf to generate stop and start bits

  4. repeat 2-3


  5. send final stop bits 0xFF


It might also be possible to send ten bits of data on other members of the MSP430 family that contains a SPI.


Thanks for your responses.



Answer



Using SPI to output more than eight bits is possible, as long as you can ensure that TXBUF is always filled.


Your scheme of using 0x7F every second byte becomes unreliable if a delay happens; it might be a better idea to distribute the actual data over two bytes:


1110xxxx xxxx1111
iiisdddd ddddSiii


(i = idle, s = start bit, S = stop bit, d = data)


Then you only have to keep these two bytes together and can allow a pause after them.



  1. Wait for TXBUF empty (TXIFG);

  2. disable interrupts;

  3. write 1st byte to TXBUF;

  4. wait for TXBUF empty;

  5. write 2nd byte to TXBUF;

  6. enable interrupts.



However, check that the SPI module of your MCU actually outputs 1 (the most recent value) when it's idle. It might output the first bit of the last byte instead; in that case, you need to send 0xFF afterwards (or the next valid two-byte combination).


Receiving with SPI might be more dangerous. Any interupt latency will affect the at which you sample the data bits, so you will have a delay that, in practice, is uncontrollable.




Alternatively, you can use a timer output to emulate a UART. Use continuous mode, program a CCR for the time of the next signal edge, and with set or reset output mode as needed. In the interrupt handler, program the following edge (add the bit length to the CCR, and switch set/reset mode, if needed). This is similar to bit-banging, but guarantees the timing as long as you can handle the interrupt for each bit fast enough.


Similarly, you can use a timer for receiving: program a CCR in capture mode on the falling edge. When you get an interrupt, you get the exact time of the edge in the CCR register, and you can then reprogram the CCR for compare mode, triggering in the middle of the respective next bit; in the interrupt handler, the SCCI bit shows the value of the timer input when it was triggered.


Thursday 25 May 2017

c - Why using a pointer interfacing LCD HD44780


I'm trying to interface with an LCD display (HD44780). I came across a tutorial on the internet to send characters and strings to the display. Everything went well and it works fine but I have no idea why a pointer is used. I'm not quite familiar with pointer in C. I know that thay can hold addresses of variables etc.


Can someone explain me why it is used to send data to the LCD and what it exactly does in the code below?


#define lcdE    0x04
#define lcdRW 0x02
#define lcdRS 0x01

#define lcdport PORTC //port where LCD is connected
#define lcdDIR DDRC

void lcd_init(void); //initialize
void cmd_to_lcd(unsigned char cmd); //send command to LCD display
void char_to_lcd(unsigned char character); //send character to LCD display
void set_cursor_to_1st_line(void); //set cursor at the beginning of the first line
void set_cursor_to_2nd_line(void); //set cursos at the beginning of the second line
void clear_display(void); //clear display and return to home position
void string_to_lcd(unsigned char *ptr); //send a string to LCD display


void cmd_to_lcd(unsigned char cmd)
{
unsigned char temp = 0;
temp = cmd; //store cmd in temp
cmd &= 0xF0; // clear lower nibble
lcdport &= ~(lcdRS|lcdRW); //pull RS and RW low
lcdport |= lcdE; //pull E high
lcdport = cmd | lcdE; //output cmd and hold E high
_delay_us(10);

lcdport &= ~(lcdE); //pull E low
_delay_us(10);
cmd = ((temp << 4) & 0xF0); //shift command 4 left and clear lower nibble (send lower nibble of cmd)
lcdport |= lcdE; //pull E high
lcdport = cmd | lcdE; //output cmd and hold E high
_delay_us(10);
lcdport &= ~(lcdE); //pull E low
_delay_us(50);
}


void lcd_init(void)
{
lcdDIR = 0xFF; //port C as output
_delay_ms(30); //wait for lcd internal init
cmd_to_lcd(0x28); //4-bits, 2 lines, 5x8 dots
_delay_us(10);
cmd_to_lcd(0x0C); //turn on display, cursor, cursor blink
_delay_us(10);
cmd_to_lcd(0x06); //increment AC on operation and move set cursor move to right
_delay_us(10);

cmd_to_lcd(0x01); //clear screen and move to home position
_delay_ms(2);
}

void char_to_lcd(unsigned char character)
{
unsigned char temp = 0;
temp = character;
character &= 0xF0;
lcdport |= lcdRS; //RS = 1: data register

lcdport &= ~(lcdRW); //RW = 0: write operation
lcdport |= lcdE;
lcdport = character | (lcdRS | lcdE);
_delay_us(10);
lcdport &= ~(lcdE);
character = ((temp << 4) & 0xF0);
lcdport |= lcdE;
lcdport = character | (lcdRS | lcdE);
_delay_us(10);
lcdport &= ~(lcdE);

_delay_us(50);
}

void string_to_lcd(unsigned char *ptr)
{
while(*ptr)
{
char_to_lcd(*ptr);
ptr++;
}

}

Answer



C language does not have a native string format, so instead, strings are implemented as character arrays. The string_to_lcd function receives a pointer to the memory location where the first character of the string is.


By conventions in C strings are terminated with a null character (0x00).


Edit


The while statement first checks if it reached the end of the string (current character is different from null), if it is, the character is printed and the pointer is incremented in order to point to the next character. The cycle stops when the null character is reached.


camera - Where can I find a fast (1KHz) LCD plate?



I'm not looking for a graphic or text LCD display here, just essentially a single, large pixel, capable of going from dark-light-dark in under 1ms. The faster, the better.


The idea is to create a secondary shutter for a still camera, increasing the flash sync speed of the camera. Here's a video of a similar idea, but on a CMOS video camera. Seems like they're using a pane from a pair of 3d shutter glasses, which operate at video speeds (60 or 120 hz, not fast enough.)


Something like the panel in an auto-darkening welding helmet would be along the lines of what I need, providing they can also transition from dark-light at high speeds.


What are these called? What can I search for (LCD panel obviously doesn't help)? Where might I be able to find one? (Aside from hacking apart a welding helmet.)



Answer



What you're looking for sounds like an LCD shutter, specifically a Pi Cell LCD Shutter. The more modern welding helmets use the TN LCD Shutters which have the same slower speeds as 3D shutter glasses. From what I've read the Pi Cell LCD Shutters can have a switching speed of up to 1000Hz.


Liquid Crystal Technologies claim they'll send you a free 1"x1" or 4"x1.5" TN LCD shutter or a 1"x1.5" pi cell shutter. The pi cell shutter will be the faster one. I've never needed an LCD shutter, so I can't verify anything any company claims about theirs, but free is certainly worth a try if you can get them to send you one.


pcb design - How do I look at all the footprints in a KiCAD library?


In the KiCAD PCBnew layout editor, is there some way to see what a footprint looks like before I place it? Or am I forced to select a footprint that has a plausible-sounding (ASCII text) name, place it, and then afterwards delete it and start over ... until I find the right one?


How do I look at all the footprints in a footprint library without laboriously selecting one, placing it, going "That's not what I wanted", through the whole list?


I would be happy with any one of



  • a quick way generate .pdf of all the footprints in the library

  • a quick way to generate a "dummy PCB" with every footprint in the library


  • somehow show each footprints one by one, with at most a single arrow-key to get to the next one (like the KiCAD EESchema schematic editor, when I place a schematic symbol I can see what it looks like before I place it.)




Wednesday 24 May 2017

touchscreen - How and What do pullup resistors do?


I am a high school student, with a basic understanding of physics.I am trying to learn how a resistive touchscreen works.


I found this link from Texas Instrument to be the best source. But the information there is still to general.


F1


On page 2, it explains how a touscreen detects a touch before determining the coordinates. A positive voltage is applied at Y+. Current will therefore flow from Y+, the point of high voltage, to Y-, the point of low voltage.


I am not sure:




  • Where the pullup resistor is in the picture.

  • Why they have to have significantly higher resistance than the total resistance of the touchscreen.

  • (referring to the previous bullet) What is meant by the "total resistance of the touchscreen". Which part of the circuit shown is the touchscreen.

  • What do "high" and "low" mean in the picture.

  • (See paragraph below)What is pin.& What is a "pin-change interrupt".


Here is the exact paragraph that explains this: enter image description here




What do the pins mean on this rotary encoder?


I'm trying to repair a speaker of mine (old AudioEngine A5). The encoder that controls the volume is not working properly and turning the volume up REALLY loud sometimes when you touch it.


I had some encoders lying around so thought I would try and replace it, but the newer encoder has one more pin and the names on it are very different.


Any idea what these pins mean, or alternatively where I could source the same encoder?


These are the pins on the broken encoder:


broken encoder


These are the pins on the new encoder:


new encoder


Also, I've tried googling for the part number but nothing turns up. Am I looking at some different type of encoder maybe?



Here's a pic of the part numbers for the broken encoder:


broken encoder part numbers




led - Problem with 555 timer and 4017 counter


schematic


simulate this circuit – Schematic created using CircuitLab


I'm attempting to make a circuit that flashes each LED sequentially. So far my 555 timer works just fine and gives me a pulse about 3x/second for the clock on the CD4017. However the LED's flash in random orders.



For the split second that the timer supplies voltage to the 4017, a random LED is lit up. For the split second that it stops supplying voltage all the LEDs dimly flash on.


Note that for the sake of simplicity, I only included 5 LED's in the schematic. There's ten LEDs for the 10 outputs of the CD4017.


Any idea what's going wrong here? I'm a first year student of E.E. so I'm still learning a lot. Thanks!


EDIT: This is essentially what I'm trying to create: 555-4017 LED Sequencer



Answer



Do you have the datasheet for your specific 4017? It is quite possible that you need more current than the 4017 can handle.


For example, the datasheet for a Texas Instruments CD4017BE shows (graphs on page 3) that with a drain-to-source voltage of 10V, each output pin can sink no more than ~15mA:


CD4017BE typical current sink characteristics graph


As @Tony mentions in his answer, if the LEDs have a typical forward voltage of 2 to 2.2 volts, then the 100Ω current limiting resistors you are using drop approximately 7 volts. Using Ohm's law, I = E / R, the current each output pin would need to sink is around 70mA.


Try a higher resistor value to lower the current significantly, say 10mA. The LEDs won't be as bright, but it might be within your 4017's current sinking ability and at least allow you to determine if things are working correctly.



You can figure out the resistor value to use by rearranging Ohm's law:


$$R = \frac{E}{I} = \frac{7}{0.02} = 350\Omega$$


If that works, and you want to make them brighter, you'll need to either find a 4017 that has greater current ratings on the output pins or add some transistors.


Edit:


Note that the circuit you linked has a "1K2" resistor connecting the LEDs to ground (negative). That's equivalent to 1.2kΩ which works out to slightly less than 6mA per LED.


Edit 2:


Per @Curd's comment, I am also including the source current diagram from the datasheet.


CD4017BE typical current source characteristics graph


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

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