Wednesday, 6 November 2013

Pull-up and Pull-down Resistors

Pull-up and Pull-down

It's a boring subject to some, but resistors are important for the correct operation of electronic circuits. According to Wikipedia pull-up (and pull-down) resistors are used to ensure that inputs are at expected levels when external devices are disconnected. Pull-up resistors are connected to +ve voltage to drive the line high and pull-down resistors are connected to ground to drive it low. Without a pull-up or pull down resistor the output could be set to an undesired state or jump between 0 and 1. When the input is connected to another component it can still be driven to the desired state, overriding the default pull-up or pull-down state.

Floating Inputs

The Raspberry Pi GPIO pins are all initialized as inputs when power is applied even though later on the boot code and drivers will change the pin functions and whether they are inputs or outputs. One of the issues with my first prototype board was that the floppy drive motor would spin up when power was turned on to the system. After some investigation I realized that this resulted from a floating input because the boot state connected the GPIO input to the 74LS06 input with no other source to set the inputs low or high. The solution is to add pull-up or pull-down resistors to set the desired power-on state.

I'd like to thank my brother, Noel, for this diagram showing suggested values for pull-up and pull-down resistors based on the data sheet for the 76LS06 IC, I could not have designed the interface electronics without his advice. Based on his suggestions I will be using 2.2k resistors for pull-down and 10k resistors for pull-up (to 3.3v).

The motor, drive select and step signals must be pulled to ground to prevent them becoming active on power up. Other signals such as step direction and side select can be pulled in either direction, but pulling them high with 10k resistors consumes less power and is the preferred solution. The write gate signal is connected to GPIO 2 (SDA) which already has a 1.8K pull-up resistor on the Pi circuit board so it can be left as-is.

Open Collector Pull-Up

Pull up resistors are also used for connecting the GPIO inputs to the output of open collector devices such as the 74LS06 device I am using. In this case the pull up resistors are connected to 3.3v, not 5v to ensure that the Raspberry Pi GPIO pins are not driven higher than 3.3v, which could damage them. In this configuration a lower value resistor improves the switching speed of the signal. This is important when reading floppy disk data at high clock rates (4-8 MHz) but less important for long duration signals such as the index pulse. Again, based on advice from my brother I have chosen 330 ohm for the floppy disk data and 10k for other signals. The track zero signal is connected to GPIO pin 3 (SCL) which already has a 1.8K pull up resistor on the Pi circuit board. I could also have used the internal GPIO pull-up resistors but they are not connected at power on.