PCBs (Part 1)

Part 1, 2, 3, 4

PCB design pitfalls… A quick glance on the net brought me to various interesting web sites:

“4 Circuit Board Design Mistakes to Avoid”
“PCB Design – The Top 5 Mistakes”
“6 PCB Design Mistakes to avoid designing printed circuit boards”
“7 Fatal Mistakes to Avoid on Your PCB Design”
“Top 9 mistakes that PCB engineers need avoid in PCB design”
“Top 10 PCB Routing Tips for Beginners”
“11 Myths About PCB Layout”

4, 5, 6, 7, 9, 10, 11 ? Is there really a limit to the number of PCB design pitfalls ? Probably not. From the very early times when I was using an ink pen to draw the tracks on plain copper before immersion in iron perchloride up to now, I had my glorious and my inglorious times which were more or less related to the success in making nice clean flawless PCBs.

So, based on my experiences, here is a list of reminders that I am sharing with you.

  • Footprints: Always get the components that you will solder on a PCB, check there dimensions, check your footprint libraries. Once routed, print the PCB copper layers and check the footprints. Personally, I am using my very own footprint libraries in order to avoid mastikes.
  • Not Plated Holes (NPTH): Unless your design is really screw-less, always provision holes for mounting your PCB on stands, posts or what so ever.
  • (Wire) Routing : If the copper layers look nice, the routing is probably fine. Spaghetti designs are almost always synonymous of trouble. Simplify and shorten routes. Check tracks width and maximize then when dealing with power supplies. Avoid routing tracks between pins.
  • Thermal relief: choose proper copper widths. Ban vias, plated holes, wide tracks located next to SMD pins. Avoid multiples tracks connect to a single pin.
  • Ground planes: Always ! However ground planes may have an impact on some components: use keep out areas if necessary. All tracks carrying weak signals must be buried.
  • Thermal vias: Although your prototype works great on the bench, the PCB may be used in harsh conditions and some components may insufficiently dissipate heat. Create thermal vias beneath power components and have sweet dreams.
  • Cuts: Did you check the overall dimensions of your PCB ? Check it again this way: print the PCB on plain paper, glue this page on cardboard, cut along the edges and try to adjust this mock PCB to its destination. Plain easy, plain beneficial.
  • Test points: Always ! Add test points to power supplies, critical signal points (inputs, outputs, driving pins, etc.). Whenever possible, group the test points in order to facilitate the work of the troubleshooter.
  • Silk prints: Always ! They are so usefull for identifying component references and orientations, test points, etc. Be strict while placing text, apply your own rules, e.g. on top or on the right. Always reference your PCB with a project name or code and above all with its revision name or code.
  • Wires: If you can, always tidy wires on one side. Don’t you ever connect wires here and there in the middle of nowhere. That’s rude.
  • Connectors: Less critical than wires however tidy connectors on the PCB edges, leave room around connectors so that clumsy fingers may be able to plug them.
  • Components: Use homogeneous component sizes. Try to orient polarized components in the same direction.
  • LEDs: So useful. LEDs are inexpensive and light indicators may save you a lot of time in the context of testing proof of concept prototypes. Feel free to get rid of the LEDs once all early tests pass.
  • Print geber files and analyze them individually. I am personally using a different software for designing PCB and for checking gerber files.
  • Check list: Build your own QC check list. Be strict, and whatever happens, even if your are in a hurry, use it: ultimately the time spent here will save you a great deal of time then ! If possible, ask someone else to counter check your works.
  • Backup: Once the gerber files is sent to the supplier, compress all related files and archive them (including libraries). Bringing corrections to the original files will drive you nuts. Create a “findings” file and a new version holding corrections.
  • Antennas: Think the PCB as a 3D environment ! Well, I think that if you are dealing with antennas you already know about the previous points of attention.

And now my very last advice: always leave one night in between your last final review and the upload of your gerber files to your favorite PCB maker. Most brains work hard during night, synthesizing thoughts and works so that, quite often in the morning, you may have an sparkling idea and get back in a hurry to one of those reminders that I tried to enumerate for you.


Next post on same subject

Current generators (Part 1)

Part 1

Here starts a new series of post dedicated to current generators. As usual, the idea is to describe working experimental prototypes that feature few components and quite good performances.

Current generators can be found in various applications such as battery chargers (advanced ones, aka multiple stages or intelligent battery chargers), LED drivers and all sorts of industrial applications such as 4-20 mA current loops.

Let’s start from the simplest up to more refined designs. Tweaking the LM317 voltage regulator is probably the simplest design. It requires only one very common chip and one adjustable resistor along with a couple of capacitors if high stability is required (optional components marked with a *).

Simplicity has a price, and in this case, the circuit suffers from few drawbacks: current adjustment is not linear versus the potentiometer cursor position as I = (1.25 / R), consequently it is tricky to adjust. However, thanks to additional fixed resistors, the adjustment range may be constrained and ease the fine tuning of current .

Next is a plot of the output from a current regulator where the feed back resistor is made of an adjustable one (150 Ohm) in parallel with a fixed one (1500 Ohm) to which is added an other resistor in serial (120 Ohm). This configuration results in an almost linear output ranging from 5 to 10 mA.

A better idea would consist in designing a more elaborate – although still simple circuit. The next one features an operational amplifier, a specialized chip used for measuring the voltage across a shunt resistor plus a few extra passive components. An INA193 chip (U2) is inserted in the feed back loop of the op-amp so that the voltage setting from the potentiometer (P1) is compared directly to the output voltage of the INA193 which is itself directly proportional to the current flowing through the shunt resistor (R shunt). The operational amplifier (U1) shall comply to the following characteristics: single supply power supply voltage, rail to rail input and output and output current compatible with the required output current of the circuit. I personally choose the MCP6001/2/4 which delivers up to 23 mA  and which I used a lot in recent designs.

Building the circuit is very easy as shown from the next picture

Next is an illustration of a simple spread-sheet (Open-Office format) that I built (as in many other designs) to play around with values. You may download it from >here<. I use color conventions for highlighting values of interest: orange for input values, gray for clones and yellow for output values.

It is possible to achieve higher output currents thanks to an additional transistor as show in the next schematic. This time, the current drawn is only limited by the transistor specifications: in the present case, the 2n3904 can drive up to 200 mA. However, care shall be taken with power dissipation, as this plastic package dissipates only 1.5 W.


I you lack the INA193 chip, you may build a differential amplifier of your own. Next is a suggested schematics for such current regulator.

It features a differential amplifier built around U2 which gain is determined by the R1/R2 and R3/R4 ratio (assuming R1=R3 and R2=R4). In this way the differential amplifier outputs a voltage which is equal to: G * the voltage drop across R shunt, where G is the gain. In order to achieve the proper amplification, resistors shall be from the precision class, 1% or better. R5 is a voltage limiter thus limiting the current output. Next is an illustration of the components set up on a breadboard.




Particle sensors (Part 1)

Part 1
I am amazed by the massive improvements of sensors along the last 10 years. Not so long ago, some sensors would fit in a shoe box and require 24 VDC, not to talk about the interfaces, weight, etc. These improvements are mainly due to the incorporation of advanced sensors in smart phones: camera, accelerometers, gyroscope, light sensors, gps, touch sensors, etc. Theses sensors come tiny, 3V, ULP, featuring digital interfaces and they come cheap too. Too bad for the pressure sensors, most industrial accelerometers: as there is no application yet for smart phone, the are still big, greedy, analog and expensive !

However, most sensor manufacturers try their best to offer new types of sensors. Some of them feature some well known components. The power of theses sensors lies in the embedded intelligence, the DSP inside which perform awesome calculations at high speeds. Among these sensors, I was intrigued by the particle sensor from Honeywell, namely the HPMA115S0-XXX, HPM Series Particle Sensor. I got one sample from Honeywell and gave this literally black box a try. The datasheet contains a very limited set of information, enough to make it run but probably insufficient for designing an industrial product.

The principle of operation is rather simple. A fan located on one exit of a S shaped channel creates a gentle air stream which carries particles. A light beam is directed across the air stream path while a photo-diode collects the photons. The signal of this photo-diode is computed locally my a MCU (FPGA ?) and outputs a serial signal on a UART port. This is how it looks really

Important: As the sensor features a fan, it requires a 5 VDC supply (<80 mA peak). However the UART port manages 3 V signals. Although the serial port is 5V tolerant, my advise is to use a bidirectional level translator such as this one:

Some code is available from Github, but, sorry, I did not like it. So I decided to rewrite it from scratch. Firstly, I decided to get rid of the continuous reading mode as it outputs large frames of mostly empty data. I understand that they made room for data that will be issued along with future development of the product. So far, I will skip this option. The code mainly consists in a command sender and a response reader. Both types of command are made flexible in order to match with commands requiring arguments or not as well as responses holding data or acknowledgment bytes. Next is the main command sender function. Use it for commands which require an argument.

Send command with argument
void sendCommand(uint8_t cmdType, uint8_t *vData, uint8_t dataSize)
	uint8_t vBytes[8];
	const uint8_t dataOffset = 3;
	/* Header in first place */
	vBytes[0] = 0x68; 
	/* Length in second place, equals (data size + 1) */
	vBytes[1] = (dataSize + 1);
	/* Command type in third place */
	vBytes[2] = cmdType;
	/* Data if any */
	for (uint8_t i = 0; i < dataSize; i++)
		vBytes[dataOffset + i] = vData[i];
	/* Compute and record checksum */
	vBytes[dataOffset + dataSize] = checkSum(vBytes, (dataSize + 3));
	/* Send array of bytes */
	for (uint8_t i = 0; i < (dataSize + 4); i++)

Each byte is buffered in order to compute the check sum according to their respective values. Next is the overloaded function that you will use for (most) commands which do not require an argument:

Send command without argument
void sendCommand(uint8_t cmdType)
	uint8_t *mock;
	sendCommand(cmdType, mock, 0);

Plain easy. Reading responses is a little bit more tricky as shown below

Read response from device 
bool readResponse(data_t *data)
	/* Set default response */
	bool res = false;
	/* Receiving buffer */
	uint8_t vBuffer[8];
	uint8_t ptr = 0; 
	/* Set default length to its maximum (data_size + 1) */
	uint8_t length = 5;
	uint8_t cmdType = 0;
	/* States */
	bool eofd = false;
	bool sofd = false;
	/* Read incoming bytes */
	if (mySerial.available())
		while (mySerial.available())
			/* Read and convert character */
			uint8_t readByte = (uint8_t)mySerial.read();
			if (!sofd)
				switch (readByte)
					case 0x40:
						/* Data header */
						sofd = true;
					case 0x96:
						/* Negative acknowledgment */
						sofd = true;
						eofd = true;
						res = false;
					case 0xA5:
						/* Positive acknowledgment */
						sofd = true;
						eofd = true;
						res = true;
			if (sofd && !eofd)
				/* Record byte */
				vBuffer[ptr] = readByte; 	
				if (ptr == 1)
				/* Length in second place */
					length = readByte;	
				else if (ptr == 2)
				/* Command type in third place */
					cmdType = readByte;
				else if (ptr == (length + 2))
				/* End of frame */
					eofd = true;							
					/* Check sum */
					if (vBuffer[length + 2] == checkSum(vBuffer, (length + 2)))
						/* Compute data */
						switch (cmdType)
							case cmdReadParticleMeasuringResults:
								data->pm_2_5 = ((uint16_t)vBuffer[3] << 8) | vBuffer[4];
								data->pm_10 = ((uint16_t)vBuffer[5] << 8) | vBuffer[6];	
								res = true;
							case cmdReadCustomerAdjustmentCoefficient:
								data->custAdjCoeff = ((uint16_t)vBuffer[3] << 8) | vBuffer[4];
								res = true;
				/* Increment pointer */
				ptr += 1; 
	/* Return result */

The function is built so that it will return a true state if every thing went right and vice versa. As the acknowledgment bytes are doubled, I simplified the code and check only the first incoming acknowledgment bytes (0xA5 = positive, 0x96 = negative). 0x40 is the first place announces data. All received bytes from a response containing data are buffered, once again for checking their sum. And here is the checksum function:

Compute the check sum from an array of bytes
the specified "bytes" number of bytes is used 
uint8_t checkSum(uint8_t *vData, uint8_t bytes)
	/* Sum bytes */
	uint16_t sum = 0;
	for (uint8_t i = 0; i < bytes; i++)
		sum += vData[i];
	/* Compute the check sum */
	uint8_t check = uint8_t((0x10000 - sum) & 0xFF);
	/* Return checksum */




Metal detector (Part 1)

Dear cousin, I lost my keys in the middle of the meadows, would you please make a metal detector for me ? Urgent !

This is really how this project started ! More or less, as I have in mind the design of an Earth’s Field Nuclear Magnetic Resonance spectrometer which features magnetic fields sensors on which I already spent some time.

I started this metal detector project with a quick look at published projects on the web. Most, not to say all, projects feature a magnetic field sensor. The principle of operation consists in observing the changes in the magnetic permeability of the volume located on both sides apart a coil. There are multiple ways to implement this principle. One consists in emitting a magnetic pulse and measuring the strength of the echoed signal. The other consists in measuring the changes in frequency of a resonating tank. Both have their advantages and drawbacks. After few attempts, I decided to go for the second option which is far simpler in terms of mecatronics and electronics.

As mentioned above, the heart of the device is a resonating tank made of a coil and two capacitors. This configuration is known as the Collpits oscillator, named after its inventor Edwin H. Colpitts. The resonating frequency depends on the C1, C2 and L1 values, f = 1 / 2 . Pi . sqrt(L1. (C1 . C2) / (C1 + C2)).

Bipolar junction transistors, FET transistors or integrated op-amplifiers must be used to softly bias the oscillator and maintain a perpetual oscillation. I will use very popular small signal transistors such as the NPN 2N3904 or the 2N2222. For the passive components, I choose the following values: C1 = C2 = 10 nF and L1 = 600 µH, which results in a theoretical 92 kHz oscillating frequency. The reason for these choices lies in the capability of Arduino interrupts to cope with high frequencies. Staying close to 100 kHz was the objective and it proved to be alright. Various configurations exist and are described below:

First configuration:

C3 = 100 nF, R1 = R2 = 5 k, R3 = 1 k

Second configuration:

R1 = 100 k, R2 = 1 k, C3 = 10 nF

Third configuration:

C3 = 100 nF, R1 = R2 = 5 k, R3 = 1 k

Fourth configuration:

C3 = 1 nF, R1 = 470 k

Fith configuration:

C3 = 1 nF, C4 = 100 nF, R1 = R2 = 5 k, R3 = R4 = 1 k

As mentioned before, C1, C2 and L1 were chosen so that the resonating frequency is compatible with the sensing performances of the micro-controller. The use of lower frequencies will result in lower frequency shifts when a metallic object is present near the coil thus reducing the overall performances of the detector. I chose the first configuration which features a clean sine signal swinging from almost 0 V to almost 5 V.

The code is very straight forward in its basic version. Advanced users will add refinement for fine tuning the signal and taking into account frequency drifts caused by temperature mainly. It consists in sampling the number to cycles per second. The frequency stays idle at about 96 KHz and rises up to about 97 kHz when a metallic part enters the magnetic field.

volatile uint32_t pulse_counter; 
void setup(void) 
	/* Initialize the serial port */
	/* Configure sensing pin (Digital pin 2)*/
	pinMode(2, INPUT); 
	attachInterrupt(0, count_pulse, RISING); 
void loop(void) 
	/* Reset counter */
	pulse_counter = 0; 
	/* enable interrupts */
	/* disable interrupts */
	/* Plot data */
	Serial.print(millis() / 1000.0, 1); 
 /* Called when interrupted */
void count_pulse(void) 
	pulse_counter += 1; 


Time to use the metal detector… Well, it is not very sensitive however, it will do the job for finding keys fallen in the the grass.

Hello cousin ? No more worries, the keys were in my pocket ! Thanks anyway !

Well the followers of arduinoos will benefit from this quick and dirty project. Advanced users may decide to improve the design, starting from a the thermal stabilization of the oscillator as it is sensitive to temperature changes and drifts.






Switch Mode Power Supplies (Part 3)

Part 1, 2, 3

Current sensing. This part is probably the most critical and most uneasy. It is critical because current sensing will protect both the power supply and the driven load from excessive currents and thus excessive amounts of energy dissipated in both the source and the receiver. There are multiple designs available for current sensing. I found interesting to review some of them.

Let’s start with the most unusual, although popular in the early 80’s electronics: the coil sensor. The output current flows through a coil which surrounds a reed switch.

BTW, this coil is from an HP5840 A25 board. If you ever worked on this product, and survived the risky business of troubleshooting this board, please send me an email 😉

If the current rises, so does the magnetic flux. If the current exceeds a certain level, the magnetic flux is high enough to close the reed switch. This switch is connected to the power supply driver and triggers an – almost – immediate stop. The major advantage of this design lies in its ability to withstand heavy currents which have almost no effect on the voltage drop across it. and consequently this circuit dissipates very little energy.

The most popular sensing device is the shunt resistor. According to the Ohm law, the more the current flowing through a resistor the more the voltage drop across the resistor. All we have to do is to insert a resistor within the receiver loop and measure the voltage drop across this resistor. There are mainly two type of designs: the resistor is attached to the low side of the circuit and the resistor is attached to the high side of the circuit. In the early days of electronics, both following designs were very popular: both feature a transistor which base emitter junction is biased by the voltage drop across the shunt resistor.

Shunt resistor on the low side:

As soon as the voltage across R2 exceeds 0.6 V, T1 is turned fully on and switches the feedback line to the regulator to ground. R1 acts as a current limiter.

Shunt resistor on the high side:

As soon as the voltage across R2 exceeds 0.6 V, T1 is turned fully on and switches the feedback line to the regulator to Vout. R1 acts as a current limiter to the base of T1.

Along with the popularization of ICs, Op. Amps replaced the transistors allowing lower resistor values (and thus lower power dissipation) as well as more accurate control.

Shunt resistor on the low side

In this case we use an op. amp. configured as a non inverting and amplifying stage. This is a simple design which suffers from multiple draw backs: the load has no connection to ground, voltage regulation is made uneasy and the input will pickup all the ground disturbances.

Shunt resistor on the high side

In this case we use a differential amplifier. Although this design looks nice and easy, it requires very particular attention. Using resistors featuring standard tolerances will generate errors and the op. amp. must cope with relatively large common-mode signals. In addition, none of the load terminals is attached to ground making shorts to ground detection impossible.

In both cases, the op. amps must feature a rail to rail outputs.

Chips makers designed specific, small, low cost ICs containing the amplifying stages and their ancillaries. In this way the design of the current sensing stage is easy with a low foot print and a tidy design. In some cases an appropriate design of the copper layer will be substituted to the shunt resistor. Next is an example among many, featuring the TI INA193 IC which is available in sot_23_5 packages and various gains (x20, x50 and x100)

Some other designs get rid of the resistor and will directly measure the current flowing through the circuit. These chips feature a hall sensor which is orthogonal to the current flow. The major advantage of this design is the very low voltage drop across the sensing element; consequently, they are very well suited for high current sensing, low foot print and little heat dissipation. In addition they offer an excellent galvanic isolation and they are very suited for measuring current flows in both directions. Check this component which is also available on modules for fast prototyping : Allegro ACS723

Direct Digital Synthesizer (DDS) (Part 9)

Part 12345678, 9

Let’s go a few steps further in the direction of a fully featured arbitrary wave generator ! The early posts describe how to generate clean waves at various frequencies. In this post, I will explain how to offset the signal and how to attenuate it.

Setting negative offsets requires… negative voltage ! Which Arduino  platforms do not provide. However, thanks to simple and cheap components, this problem will not bother us long. I will use an ICL7660 (or its numerous equivalents) to produce a negative voltage symmetric in value to its supply voltage. If your are looking for constrained voltages, supplying the chip (and consequently the whole circuit) with +5 V will be fair enough as long as your signal will roughly stay within the -4 to +4 Volts. If you need a wider range, you may just use Vin and feed your arduino platform with an appropriate DC voltage source (12 V in my case). The ICL7660 requires one booster capacitor and a filtering capacitor (100 µF or more in this case).

The principle of operation is illustrated in the next picture (figures relate to the +5V version):

First stage is the DDS that you now know well. Next is the offset suppressor at the end of which the signal will range from -1.5 V to +1.5 V (as I use 3.3 V as a reference voltage). Next is the low pass filter that has already been described followed by a simple potentiometer which acts as an attenuator. The attenuated signal enters a differential amplifier which inverting input is wired to an other potentiometer which delivers a signal ranging from -Vcc to +Vcc which correspond to the possible range of offsets to be subtracted from the wave signal.

Next picture illustrates the whole circuit driven by a generic Arduino UNO 3 platform.

Words of advise: Using a negative voltage is probably unfamiliar to many Arduino enthusiasts lacking experience in analog electronics. Care shall be taken while wiring the circuit on a bread board. Care shall be taken with polarized capacitor which do not like at all being improperly biased !

Best performances shall be achieved with components featuring tights tolerances. Resistors will be 1% in the worst case, 0.1% is strongly suggested. The basic LM324 may be replaced by any compatible quad operational amplifier: check the supply voltages ! (e.g. The TS924 will not work !).

The gain of the amplifying stage is set by R9 and R10: G= 1+(R10/R9). Set the gain according to VCC+ and VCC-. R9 and R10 shall be in the range of x10 kOhm. e.g. Select R9 = R10 = 10 kOhm in order to achieve a x2 gain.

Next picture illustrates the prototype that I assembled for early testing. The wiring may look a little bit messy: it is not. Wires should be kept short in  order to prevent noise pickup. Both the Arduino platform and the breadboard sit in a fit for purpose 3D printed shell.

Next picture illustrates the signal as read out of the DAC (@2 kHz) and as read at the output of the circuit, using a negative offset (notice the different scales).

This other picture illustrates what goes on when the offset is set too low !

Enjoy !


Switch Mode Power Supplies (Part 2)

Part 1, 2, 3

Next picture illustrates the principle of operation of my proposal for an arduino controlled Switch-Mode Power Supply (SMPS):

Instead of using an integrated chip, we will use arduino as a controller. The basic configuration requires an output line to drive the switch and two analog inputs for reading the voltage from the current sensor and the output voltage sensor. Both the voltage and current sensor are represented as functions as they require some attention.

The heart of the system is the driver of the switch. As explained before, the amount of energy flowing through the SMPS depends on the on/off ratio of a periodic signal. This all about PWM (Pulse Width Modulator). And timers from the micro-controllers can do the job nicely for us. As we will leave timer0 in peace because it cares about millis() and micros() functions, we will use timer1 which is very handy for the job. Firstly we will set timer1 prescaler to 1 in order to achieve the fastest PWM:

TCCR1B |= _timerPrescaler;

_timerPrescaler is a user defined constant from the application, defined as

const uint8_t _timerPrescaler = 1; 	/* 1 to 7, 0 = timer off, typ. 1 */

Timer1 features a programmable resolution allowing 256, 512 or 1024 steps per cycles. Once again, we will go for the fastest PWM and go for 256 steps.

/* Set fast PWM mode 5, 6 or 7, depends on timer Bits which can take the values 8, 9 or 10 (bits) */
TCCR1A |= ((_timerBits - 7) << WGM10);

As a result of these choices, the final PWM cycle time shall be : 16.000.000 / 1 / 256 = 62.500 Hz.

Adjusting the cyclic ratio (so as to say the on/off ratio) is done by adjusting the upper count trigger level of timer 1 in the OCR1B register. The updates are performed just before timer1 starts counting; the synchronization is performed thanks to the setting of a variable which can be read or write from any function from the application:

	/* Set synchronization variable */
	_syncState = 0x01;

Next lines of code illustrate the way synchronization is performed when a synchronization is required:

/* Set timer upper count */
_syncState = 0x00;
while (!_syncState);
OCR1B = dutyCycle;

This happens in the regulation control functions as well as in the analog to digital conversions. In this way, measurements are always performed in the same way at the same time.

Lets talk a little bit about the switch. The component of choice for achieving this task is a MOSFET transistor. Among their most interesting properties is the resistance between the drain and the gate of the transistor which is very low (< 1 Ohm) when the transistor is On. From the previous post, we know that the lower the voltage across the transistor the least the power dissipation.

In this case, I decided to go for a P-Channel MOSFET. Although they drive less current – compared to N-Channel MOSFET, but still largely enough for us – they are simpler to drive when used on the high side of the power supply. However driving a MOSFET transistor still requires some attention. There are roughly three ways of designing this part of the circuit: the quick and dirty way, the simple and yet efficient way and the lazy way.

The quick and dirty consists in the following circuit.

The gate of the MOSFET is driven to a low state by a general purpose transistor. When the transistor is not conducting, the gate is driven to a high state via a resistor. This configuration is simplistic but it has multiple drawbacks. Such a configuration is slow and the on and off states are achieved after “long” transition times during which power will be dissipated. Also, the source/gate voltage must be kept within limits (typically 10 to 12 V, check the MOSFET specifications) otherwise you will kill the transistor. So, lets get rid of this option which is good enough for driving LEDs or relays at low speeds.

The lazy way consists in using an integrated circuit which will do the driving job for us. You may even use N-Channel MOSFET transistors as some of these circuits generate their own bootstrap  voltage (see below) so that the gate can be bias at higher voltages than Vin.

The alternative is the use of a fit for purpose driver:

The driver consists in a totem pole made of two complementary transistors which common emitters (low impedance side) drive the gate of the MOSFET. This is a simple and efficient solution which keeps switching delays low. The resistors shall be chosen according to Vin and to the MOSFET specifications.

I cannot conclude this post without mentioning the use of N-Channel MOSFET transistors. These designs require a proper biasing of  the MOSFET gate, at the higher voltage that the voltage at their drain. Next circuits are dealing with the use of a bootstrap which elevates the driving voltage at the gate of N-Channel MOSFET.

Here is a custom design which uses few additional discrete components

This is in few words the way it works. When PWM in is high, T2 is fully on, T1 is fully off and the test point B is at almost 0 V so that the lower end of C1 is at 0 V and its upper end at Vin, consequently charged through D1. When PWM in is low, T2 is fully off,  T1 is fully on so that the lower end of C1 is at almost Vin. As a voltage of almost Vin is present at C1 ends, the upper end of C1 (test point A) is now at almost 2x Vin thus biasing properly T1 gate. This is the principle of the charge pump applied to biasing the N-Channel MOSFET gates without additional power supply.  It works fine as long as a residual off and off state exists in order to keep the charging process alive. This may create some problems when the over voltage current or over-current protections are triggered. Also T1 driver is not optimal so that I did not adopt this solution in my later developments.

You may prefer to use a specialized IC that contains a voltage elevator. Next picture illustrates the wiring of one among the most popular chips (IR2110):

If you stick to my original design, you will not use the MOSFET on the low side and keep using the free wheel diode. However, better performances will be achieved using the low side MOSFET. Last trick: if you are lacking a free wheel diode and have a spare N-channel MOSFET, use its protection diode (across drain and source) a free wheel diode, that will do the job perfectly.

Next post on same subject

Memories from my first trips in Silicon Valley

As I was tidying my electronic components, I found an untouched plastic bag containing an DC that I bought a loooooooong time ago in San Jose.

At this time, some friendly colleagues from SID (HP Scientific Instruments Division located in California Avenue) drove me to some great places around Palo Alto, including some electronic shops such as Fry’s and JDP Mocrodevices (They knew that electronics was one of my hobbies). Although I was leaving next to Paris and having access to electronic shops, I was amazed by the huge variety of components available, and above all, this was the first time I could buy components just like in a supermarket. I brought back a bag of them, including this TI DAC0800 analog to digital converter that I did not use finally. Surprisingly, they are still available at a slightly lower price that in the 80’s and not taking into consideration the changes in the value of money.

Switch Mode Power Supplies (Part 1)

Part 1, 2, 3

This is the begining of a series of posts dedicated to an original subject that I had in mind for sometimes now. After few attemps, I decided to share my early design which might drive us up to building a versatile lead-acid battery charger.

The aim of these posts is not to rewrite or reword the numerous publications related to switching power supplies. It is an attempt to show and explain how to build a pretty simple and yet powerful Switch Mode Power Supply (SMPS).

Let’s start with some fundamentals and explain the principles of regulated power supplies. There are multiples ways of getting a source of DC voltages: batteries, solar panels, alternators and dynamos, AC-DC converters, etc. However, most of these sources fail to deliver a constant DC voltage: batteries are getting slowly discharged, alternators and dynamos may have unstable driving speeds and deliver fluctuating voltages, AC-DC converters vary according to AC drifts and power consumption. If one really need a constant DC voltage, he will have to insert a voltage regulator in between the source of DC voltage and the load.

There are mainly two different ways of controlling the power supply output: you may use an analog regulator or a switched regulator.

An analog regulator (e.g. 78xx series regulators) is comparable to a tap with a feed back. If the flow at the exit of the tap is higher than expected the  tap is slightly closed, down to the expected value. And vice versa (I am over-simplifying, but that’s the idea). This type of regulator is very simple, cheap and comes most of the time integrated and built in one component (true for medium to low power regulators). However, these regulators suffer from a major drawback: power dissipation ! The reason is that the energy which is not used by the load has to be dissipated. This is the reason why most regulators of this kind feature large thermal dissipators to which are attached the regulators or transistors (high power). Let’s check that through an example:

On the left hand side is a source of DC voltage (~15V). On the right is the load to be fed by regulated voltage. This is a resistive load of 500 Ohm across which flows a current of 1/100 A, as the resistor is biased by the 5 V from the 7805 regulator. This same current flows through the 7805 regulator. As the voltage drop across the regulator is 10 V, the dissipated power is easy to compute.

From this example, we can draw some recommendations: avoid large voltage differences between the input and the output of the regulator, constrain the current used by the load and use appropriate heat dissipators. The good news however is that most modern regulators feature over-current and over-temperature protections which will protect the component located on the load side.

Switched regulators solve the heat dissipation problem to the cost of few external components and “intelligent” controllers. Back to the hydraulic comparison, on one side we have a reservoir of energy fitted with an on/off valve, a damper and a flow sensor. The idea is to switch the valve on and off  in order to drain just the required energy from the reservoir. As the on/off cycles create fast pressure changes a damper is fitted between the valve and the exit of the device. Based on this design, it is easy to understand that the longer the on time, the more the power flowing through the regulator. The flow sensor measures the amount of energy leaving the device and applies the feed back to the valve controller.

This is how it translates in electronic terms. This design is known as a buck converter: other component arrangements can be used for generating an output voltage which is higher than the voltage at the input (This is the booster design). Some are capable of generating a constant voltage whatever the input voltage: e.g. many portable devices feature buck-boost converts so that two 1.5 V battery can feed electronics requiring 3.0 V. Buck-Boost converters will deliver a constant 3 V from the fully charged state of the batteries (~3.3 V) down to their fully discharged state (~1.6 V). Many publications cover the principles of SMPS, among which this one or this one. The main benefit from the switched power supplies lies in the very low power dissipation across the switching element .

Further readings:

Next post on same subject

3D Prints: pen holder

Are you looking for an original present for (next) Christmas ? Here it is ! I made a couple of them for relatives and they loved it, so that I am 100% sure about my advertisement for this 3D printed product !

However, printing the parts might be really challenging because of the heterogeneity of the main part profile. Your printer must be well calibrated and cleaned.


Otherwise, you may, after a couple of hours (actually almost 8 hours), get very disappointed with incomplete prints, broken pieces,  unequal density of  filament prints, etc. Like in this unsuccessful attempt

In other words, this print will not only please people around you, it will challenge your printer performances! Ready for this challenge ? Here are the STL files (cube and optional bottom plate which prevents the pens from falling when moving the pen holder).

Enjoy and keep me posted with your own results.

Back to the main topic