E72(a) Mini-Project

Solar Seeker

The laboratory this time involves more design than any of the previous labs, and introduces some new concepts and devices. Accordingly, you will be given more than one week to complete the project. There is a lot of work to do, so don’t put it off. Expect to spend some time outside of the normal lab time working on it.

The goal of this mini-project is to design a simple device that tracks a light source. This could be used to keep a solar panel (or telescope) aligned with the sun. It is done by using two photocells that are facing in different directions. The cells are connected to a motor, and you will be designing a circuit that reads the output of the photocells and turns the motor in the direction of the brightest light. When the two photocells register the same amount of light, it is pointing directly at the light source.

Your strategy for controlling the motor is called proportional control -- you will send a current to the motor that is proportional to the difference between the outputs of the two photocells. That way, when the light falls predominantly on one photocell (i.e., there is a long distance to turn), you apply a lot of power to the motor. As the signals from the photocells equalize, the power to the motor diminishes, until it stops entirely.[1]*

The rest of this lab handout is devoted to discussing the new devices that you will be using, and giving you some hints on how to proceed. However, the design will be entirely your own.

New devices and concepts:

The CdS photocell

To measure light you will be using a photocell made of a semiconductor called Cadmium Sulfide, or CdS. The CdS is laid out in a long line that zigzags across the surface of the detector. As light hits the CdS it knocks charge carriers loose, and the increased number of carriers decreases the resistance of the device. The schematic for the device is shown.

On your motor, there are two of these devices attached in the circuit shown below. The two 560resistors (labeled R) are included to limit current so that the photocells can’t be easily damaged. The connections at the left and right are connected to two voltages (Probably either +5 and ground, or +10 and -10).[2]† If connected to +5 and ground, the voltage at the middle terminal is 2.5 volts when the same amount of light falls on both photocells (the resistances of the photo-cells are the same), and will increase and decrease as more or less light falls on one photocell instead of the other. If you use +10 volts, then the voltage will be zero when the same light falls on both cells.

The MOSFET

In this lab you will be using MOSFETs (Metal Oxide Semiconductor Field Effect Transistors) to drive the motor. MOSFETs are often preferable to bipolar (NPN or PNP) transistors when driving large amounts of current because the inputs are voltage controlled, and require little input current. A good model for the input of a MOSFET is simply a capacitor -- the only current needed is whatever is required to charge and discharge the capacitance.

Just as with bipolar transistors, there are two flavors of MOSFETs, n-channel and p-channel. A diagram of the two types of transistor is shown.

There are several things to notice about these devices. The most important is that there are three terminals: the gate (the input), the source (source of charge carriers) and the drain (drains charge carriers). In the n-channel device the current generally flows from drain to source when the gate voltage is sufficiently greater than the source voltage. For the p-channel device, the current flows from source to drain when the gate voltage is sufficiently lower than the source voltage. There is a diode between the source and drain on both devices, which is important when switching inductive loads (because you can’t stop current flow rapidly without a large change in voltage -- the diode prevents this large, and potentially damaging, voltage). We won’t worry about it, and if you hook up your circuit properly you won’t really notice it is there. Subsequent circuit drawings won’t include the diode. The devices are called HexFets because the gate is laid out in a hexagonal pattern on the silicon.

For the devices that we will be using the resistance between the drain and source is much less than 1 ohm when the gate voltage is at least 2 to 4 volts above the source voltage for the n-channel device, and the gate voltage is at least 2 to 4 volts below the source voltage for the p-channel device. The n-channel device has the part number IRFZ20 and the p-channel device has the part number IRF9Z10. The pinouts for the two devices is identical and is shown at right.[3]*

The transistors are static sensitive. When handling them always ground yourself first (either on the oscilloscope ground, or on the metal case surrounding the outlet box.

The H-Bridge

To control the motor you will be using a circuit configuration called an H-bridge (it physically looks like the letter H). To get current to flow from left to right through the motor you set P2 low (to turn on the associated transistor) and you set N2 high (to turn on that transistor). You must make sure that N1 is low and P1 is high. To make current flow in the opposite direction (and make the motor turn in the opposite direction) make P1 low, N1 high, P2 high and N2 low. The potential for disaster arises because if you drive P2 low and N1 high simultaneously you have a direct connection between 12 volts and ground, and something will go (hopefully the fuse on your board). Before you apply power to your circuit, check your connections very carefully (and then re-check them).

You will need to design the logic that takes the PWM output and drives the four transistor inputs.

Open-collector TTL Logic

The discussion above assumed that you had a circuit that output 12 volts for a high and 0 volts for low. Unfortunately standard TTL uses logic levels of about 3.5 volts and 0 volts. You could simply put the output of each gate through a comparator (as in the flash A/D lab), but the wiring gets messy. Another option is to use what is called open-collector TTL. With these devices, the output is simply the collector of a transistor. A low output is still zero volts, but for a high output the transistor is in cutoff so the output is effectively an open circuit. If you connect a resistor between the collector and 12 volts, the high output would be 12 volts. To get standard logic levels use 5 volts instead of 12 volts (the chip can take up to 30 volts). The resistor should be in the neighborhood of 1k.[4]† An open-collector invertor is the 7406. A buffer is the 7407.

Pulse width modulation

So far, you have seen how to use transistors to drive a motor that is either fully on or fully off. But for this exercise you are to control the motor with a signal that is proportional to another, analog, signal. To do this you will use a technique called pulse width modulation, or PWM. This technique is useful because transistors can be used either fully on (voltage is close to zero, so power is close to zero) or fully off (current is zero, so power is zero). This switching is done rapidly compared to the characteristic times of the system. Continuously variable control is achieved by varying the ratio of the time the transistor is on, to that when it is off. A light dimmer works this way. Your eye cannot sense rapid changes in light levels so when the light is turned on and off rapidly, your eye doesn’t sense it. The greater the proportion of time that the light is on, the brighter it appears.

Most PWMs start with a triangular wave (it can be symmetric, but need not be).

The triangular wave is compared to an analog input (two different inputs are shown). As long as the analog input is greater than the triangle wave the digital output is high. Since input B is greater than analog input A, then digital output B is higher for a greater fraction of time than digital output A. A block diagram of the PWM is shown.

A block diagram:

To help solidify your thinking here is a block diagram. I will supply you with the CdS sensors and the motor. You build everything else.

Some hints:

  • Come to lab with a full schematic and make alterations as you go. If you just show up and start hooking things together, this could take a long(er) time. I want a copy of this schematic included in your lab report.
  • The schmitt trigger oscillator generated a nearly triangular wave if you look at the voltage across the capacitor. This voltage was centered around ground. If you need it oscillating around another voltage you can use some kind of summing circuit or a diode clamp circuit, or I can help you come up with another circuit.
  • Think hard about whether you want 5 volts and ground or +10 volts driving your CdS sensor circuit.
  • You can use the same signal to drive the input N1 and P2 if you make sure that it is only +12 or 0 volts. If it takes on some intermediate values both transistors will be on at once, creating a low resistance path between 12 volts and ground.
  • If you elect to control N1 and P2 with the same line, the motor will be stopped at a 50% duty cycle (current will go one way through the motor for half the time, and the other way the other half).
  • If you elect to control N1 and P2 with the same line, set the pulse width modulator frequency to about 1 kHz. Much slower and you get jerky motion. Much higher and the transistors start to heat up form the currents during the transition when both N1 and P2, and N2 and P1 are on.
  • Another way to drive the H-bridge is to determine the direction and speed you want to go and have the current go just one way through the motor, not back and forth. This method saves power.
  • Build each section individually and test it independently if you can. Don’t go on until you are sure it is working and you understand how it is working. Don’t try to get the whole thing working at the same time.
  • While you are checking the individual sections (in fact up to the very end), take off the photo-cells from the motor so you don’t have to worry about the wires wrapping around the motor shaft. Put the screws back in the metal plate on the motor shaft so they don’t get lost.
  • Double and triple check your wiring to the H-bridge. The transistors are somewhat expensive, and we have a limited supply.
  • The transistors are static sensitive. When handling them always ground yourself first (either on the oscilloscope ground, or on the metal case surrounding the outlet box).
  • Feel free to bounce your ideas and questions off of me.

Apparatus:

You should find in the lab:

  • A small breadboard to put your MOSFETs on. We are using these little breadboards in case something gets hot. That way we won’t destroy one of the large boards. The transistors will fit in the breadboard if you gently force them into the holes.
  • A 12 volt, 1 amp supply to drive your H-Bridge. This plugs into the small breadboard, and has a fuse in line with it.
  • A Motor with two photocells mounted and a 5 position terminal strip. Two of the connections drive the motor and the other three connect to the photocell circuit. The red wire from the photocell circuit represents the connection in the middle, between the two photocells.
  • The transistors are static sensitive. When handling them always ground yourself first (either on the oscilloscope ground, or on the metal case surrounding the outlet box).

For your lab notebooks.

Include a copy of your original schematic. I will look for this when grading your lab notebooks.

Include a well written, but concise, description of how your circuit works, describe the design decisions that you made, and include any design equations.

Describe how you verified that the circuit worked properly.

Include a copy of your final schematic and note how it was different than your original.

I want to see your circuit working before you dismantle it.

[1]* Note: There will be some error because the motor will stop with some finite current through it (i.e., the signal from the two photo-cells will not be exactly equal). This problem can be meliorated somewhat by increasing the gain (the constant of proportionality between the difference in photo-cell outputs and the current driving the motor), though increasing it too much can cause other problems.

[2]† Don't make the voltage difference across the circuit more than 20 volts (to keep from damaging any components). You can power any op-amps and comparators in your circuit from +10 volts.

[3]* Note that the drain is attached to the metal tab. Make sure that these don’t short-circuit accidentally when you build your circuit.

[4]† It can’t be too low or excessive currents are needed to drive the output low, it can’t be too high or it takes a long time for the output voltage to change from low to high (due to the charging of parasitic capacitances).