- Published: Thursday, 05 July 2012
- Written by Jon Chandler
- Hits: 5646
Pull-Up Resistors I was assembling my sous vide board and I started to wonder about the number of pullup resistors as I was counting them out. The board has a total of ten pullup resistors. At what point does the current drain of the pullup resistors become significant?
The basic circuit is shown below. The following pullups are on the board:
- /MCLR (10k)
- I2C SDA and SCL lines (2 resistors, 4.7k)
- Switches ( 2 x 10k)
- Option Jumpers (3 x 10k)
- SSR (10k)
- One-Wire (4.7k)
Just how much current is being drawn by these resistors? First, let's look at the typical arrangement of a switch. The switch is connected between a port pin and ground, and a pullup resistor is connected between the port pin and +5 volts. When the switch is open (not pressed), the post pin is pulled up to 5 volts by the resistor. When the switch is closed (pressed), the port pin is connected to ground as is the pullup resistor. Using Ohm's law,
That's not so bad, but considering all of the pullup resistors on the board, several milliamps could be wasted, which might be significant in a battery powered application. But notice that this current only flows when the switch is closed and the resistor is shorted to ground. If the switch is open, the only current draw is the leakage current of the port pin. For a PIC18F2520, this is listed as 200 nA for most port pins, and 1 µA for /MCLR. The pullup resistor for an open switch draws virtually nothing - this is the typical case for a push-button switch.
Next, let's look at my option jumpers. For the sous vide system, there may be several options: the type of sensor (one-wire or thermocouple), the allowable temperature range (for a water bath, the temperature can't go above 100°C (212°F) but the turkey fryer I'm using can be used with oil, which can go to a much higher temperature but I may want to limit temperature, and a third option is whether the temperature is displayed in Celsius or Fahrenheit. My solder jumpers may be more familiar as DIP switches. These can be considered as fixed switches with the same current draw as above. If the jumpers are shorted, the current draw of each is 0.5 mA. If they're not jumper, like an open switch, the current draw is virtually nothing.
My solid-state relay (SSR) is connected between +5 volts and a port pin. When the port pin is high, the SSR has no voltage across it and it's not switched on. When the port pin is low, there is 5 volts across the SSR and it's switched on. The pullup resistor isn't strictly necessary but it ensures a known off-condition if the port pin is not configured as an output. Like the switch, if the port pin is high, the current draw is virtually nothing. When the port pin is low and the SSR is on, the current draw is 0.5 mA. In the case of the sous vide controller, the SSR is off most of the time (on about 1 second out of 20 depending on the bath temperature).
The pullup resistors for I2C and One-Wire serve a slightly different function. The I2C and One-Wire data lines idle high, pulled up by the pullup resistor. The master and slave devices communicate by pulling the data lines low using an open collector type arrangement. This allows the master or any of the slaves to drive the data line. A typical I2C communication sequence is shown here. One of the lines is a clock signal with approximately a 50% duty cycle. The data line is high or low to transmit a 1 or 0 data bit for each clock cycle. Note that the clock signal is active only during a communication sequence.
Typically, 4.7k pullup resistors are used for I2C and One-Wire although a range of values can be used. When the lines are pulled low, the current draw is
This only occurs during data transmission. The clock has a 50% duty cycle and the average duty cycle of the data line is about 50% so the total current drain about 1.1 mA during data transmission.
Considering the 10 pullup resistors on my sous vide board, the worst case load with all three option jumpers shorted is less than 5 mA. This isn't important for my line-powered application - the LCD back light draws 200 mA for comparison. How could this be reduced for a battery-powered application? One approach is to increase the value of the pullup resistors. An area where a large savings can be achieved is with those pullup resistors for the option jumpers. These are checked at program initialization and otherwise ignored. The pullup resistors could be fed from a port pin which is only active when those jumpers are being checked. A quick and easy fix for the biggest current draw.