Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters Learning Objectives: At the end of this topic you will be able to; explain, and illustrate, how a D-type flip-flop can be set up to produce a divide-by-two function; complete timing diagrams for a 1-bit counter; show how two D-type flip-flops can be connected together to form a 2-bit binary up counter; complete timing diagrams for a 2-bit counter; realise that counters are available in a number of formats e.g. up/down, binary/BCD/decade; design and analyse simple systems that use a counter and combinational logic to produce a sequence of events; make a counter reset at a given value. 1 GCSE Electronics. Unit E2 : Applications of Electronics 2.2.2 Binary Counters Often we need to count events, such as the number of boxes moving along a conveyor belt or the number of cars entering a car park. We can use electronic counters to perform the counting. We have already looked at the D-Type flip-flop being used: for data transfer as a latch In this section we will examine how the D-Type can be used to make a counting system. First, we adapt it to produce a divide-by-two function. We show later that this is an important part of electronic counting. Configuring the D-Type flip-flop to produce a divide-by-two function Q D Clock Input Output CK Q Notice that the only connection is the link between Q and D. A pulse generator is connected to the clock input. 2 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters Initially, Q and Clock are at logic 0, and Q , and D at logic 1. The timing diagram follows: Clock 1 2 3 4 Q Q D Remember: changes occur only on the rising edge of the clock pulse, and then the value of D is copied to Q. 3 GCSE Electronics. Unit E2 : Applications of Electronics At the first rising edge (1), input D is at logic 1, since it is connected to Q . This changes the Q output to logic 1, and so Q (and hence D) change to logic 0. Clock 1 2 3 4 Q Q D The outputs remain like this until the next rising edge of the clock (2). 4 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters The D input is now at logic 0, which is copied to the output Q. This causes Q (and D) to change to logic 1 as shown below. Clock 1 2 3 4 Q Q D You should now start to see a pattern emerging in the diagram! 5 GCSE Electronics. Unit E2 : Applications of Electronics At the next rising edge (3), the logic 1 present on the D input which is copied to the output Q, and so Q (and D) change to Logic 0 as shown below. Clock 1 Q Q D 6 2 3 4 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters At the next rising edge (4), there is now a logic 0 present on the D input. This is copied to the output Q, and Q (and D) change to logic 1 as shown below. Clock 1 2 3 4 Q Q D This pattern would continue in the same way for further clock cycles. Notice that the output from Q has exactly half the frequency of the clock pulse, so this circuit could also be used as a simple frequency divider - the divide-by-two function. The divide-by-two action forms the basic building block of a binary counter. Another name for this circuit is a 1-bit counter. 7 GCSE Electronics. Unit E2 : Applications of Electronics A 2-bit binary up counter Two 1-bit counters can be joined together as shown below to form a 2-bit binary up counter: Output B Output A DA Clock Input QA DB QB CK CK QA QB Notice that the clock input of the second counter is connected to the Q output of the first. The timing diagram for this system is shown opposite. 8 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters Initially QA and QB are at logic 0, Clock In = logic 0, Q A = DA = logic 1, Q B = DB = 1. Clock In 1 2 3 4 DA QA QA DB QB QB 9 GCSE Electronics. Unit E2 : Applications of Electronics At the first rising edge of Clock In (1) – DA = logic 1 and so QA becomes logic 1, and so Q A becomes 0. No change to QB, as the clock input to flip-flop B has gone from logic 1 to logic 0, a falling edge Clock In 1 DA QA QA DB QB QB 10 2 3 4 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters At the second rising edge of Clock In (2) – QA becomes logic 0, since DA was logic 0. Q A is the opposite of QA and so becomes logic 1, QB becomes logic 1 as the clock input to flip-flop B has gone from logic 0 to logic 1, a rising-edge, which copies DB to QB. Clock In 1 2 3 4 DA QA QA DB QB QB 11 GCSE Electronics. Unit E2 : Applications of Electronics At the third rising edge of Clock In (3) – QA becomes logic 1, since DA was logic 1, Q A becomes 0, QB remains logic 1 as the clock input to flip-flop B went through a fallingedge. Clock In 1 DA QA QA DB QB QB 12 2 3 4 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters At the fourth rising edge of Clock In (4) – QA becomes logic 0, since DA was logic 0, Q A becomes 1, QB copies DB and changes to logic 0 as the clock input to flip-flop B has gone from logic 0 to logic 1, a rising-edge. Clock In 1 2 3 4 5 6 DA QA QA DB QB QB 13 GCSE Electronics. Unit E2 : Applications of Electronics At the fifth rising edge of Clock In (5) – QA becomes logic 1, since DA = logic 1, Q A becomes 0, QB remains at logic 0 as the clock input to flip-flop B has gone from logic 1 to logic 0, a falling-edge. Clock In 1 DA QA QA DB QB QB 14 2 3 4 5 6 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters At the sixth rising edge of Clock In (6) – QA becomes logic 0, since DA = logic 0, Q A becomes 1, QB changes to logic 1 as the clock input to flip-flop B has gone from logic 0 to logic 1, a rising-edge. Clock In 1 2 3 4 5 6 DA QA QA DB QB QB 15 GCSE Electronics. Unit E2 : Applications of Electronics For further clock pulses, it is simply a case of repeating the patterns as follows. Clock In 1 2 3 4 5 6 DA QA QA DB QB QB Looking at the values of QB and QA after each clock pulse shows us that we are counting up in binary: Binary 01 count 16 10 11 00 01 10 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters In the example we have just looked at, there were a lot of graphs drawn but there was really no need to draw them all. Look at the final graphs. Notice: i. The Dx input graphs are identical to Q x graphs so one of them could be ii. removed. QB changes on the falling edge of QA (which is the rising edge of Q A ) iii. The output at QB is half the frequency of QA, or a quarter of the frequency of the clock, so the counter is a very good frequency divider. Clock In 1 2 3 4 5 6 QA QB We have made a 2-bit counter, with A as the least significant bit, because it changes the most frequently, and B the most significant bit. 17 GCSE Electronics. Unit E2 : Applications of Electronics Activity 1 : To investigate a 1-bit counter 1a. Set up the circuit shown below. 1b. Ask for a circuit check. If approved, switch on the power supply. In this activity we use a push switch to simulate clock operation. The switch is outputs logic level 0 until pressed. 1c. If the Q indicator is on, then press the clock push switch to switch it off . Use the switch to generate the sequence shown in the table. Fill in the Q output level in each case. ‘P’ indicates a press and ‘R’ a release of the pulse button. Clock Level 18 Q (Output Level) 0 P 1 R 0 P 1 R 0 P 1 R 0 P 1 R Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters 1d. Assume that you provide the clock pulses, shown below. Fill in the corresponding Q output levels. 1 Clock 0 Time 1 Q 0 Time 1e. Your graph should show that the Q output changes its state with every rising edge of the clock pulse. The Q output only changes to logic 1 on the odd numbered (decimal) clock pulse. The circuit is effectively dividing by 2. This forms the basis of a binary counter. Activity 2: 2a. Modify your circuit to the one shown below. The switch is now connected to the reset input of the D-Type. Switch on the simulation. The clock indicator LED and the output indicator LED should be flashing. 19 GCSE Electronics. Unit E2 : Applications of Electronics 2b. When the push switch is pressed, the output of the D-Type will go to logic 0 and the output LED will be off. 2c. When the clock LED is off release the switch and count 10 clock pulses while a partner counts the number of times the Q output indicator comes on during this interval. Record the value in following table. Repeat for the other values given. Number of clock pulses. 10 20 30 40 Number of output pulses (Q) Comment on your result. ...................................................................................................................................... ...................................................................................................................................... ...................................................................................................................................... ...................................................................................................................................... ...................................................................................................................................... 20 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters Activity 3: To investigate a 2-bit up counter 3a. We will now use the Q output from the first flip-flop to act as a clock input for the second flip-flop on a 4013 D-Type. 3b. Set up the circuit as shown below. 3c. Ask for a circuit check. If approved, start the simulator. You should now have a binary counter that counts up to 11 (binary) then resets to zero. 3d. Pressing the push switch at any time during the counting sequence will reset both D-Type flip-flops and stop the count taking place. 21 GCSE Electronics. Unit E2 : Applications of Electronics Activity 4: To investigate a 2-bit down counter 4a. In activity 3 you made a 2-bit up counter. You are now asked to make a down counter. Complete the following table by filling in the values for the Q outputs. 4b. Q2 Q1 0 0 1 1 0 1 0 1 Q2 Q1 Filling in the table should give you a clue as to how to set up a 2-bit down counter. Complete the following diagram to show a down counter. 4c. 22 Show your diagram to your teacher. If approved, set it up and try it out. Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters 4d. Did you have to make any modifications to your design. If so, what were they? ...................................................................................................................................... ...................................................................................................................................... ...................................................................................................................................... If you made modifications draw the correct version of your circuit in the space below. 23 GCSE Electronics. Unit E2 : Applications of Electronics Homework Questions 1 1. A D-type flip-flop can be used to make up a counter. The following block diagram shows the basic outline required to build a two bit binary up counter from two D-Type flip flops. However three connections are missing. a) Complete the diagram by adding the missing connections. D1 Q1 D2 Q2 Clk Clk Q1 b) Q2 [3] Complete the following timing diagram for a 2 bit counter. Assume the flip-flops are rising edge triggered. Clk Q1 Q1 Q2 [3] 24 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters c) Draw a diagram to show how you could use 3 D-Type flip-flops to make a 3 bit binary down counter. [4] 25 GCSE Electronics. Unit E2 : Applications of Electronics Counter ICs In the previous section we made a simple 1-bit counter and extended it to 2bits, and then 3-bits. In principle we could keep adding D-type flip-flops to extend the counter to 5, 6, 7 or 8 bits. In practice, this requires a lot of connections, which take up a lot of space in a circuit. Instead, these counters are available as single chip devices called counter ICs. A 2 bit counter is probably easier to build from D-type flip-flops. For 3 bits or more, counter ICs will be more suitable, as fewer connections will need to be made. The circuit symbol for a 4-bit counter IC is as follows: D C CK B A Cout R Notice: i. the single clock input. ii. the outputs A, B, C, D, with A the least significant bit. iii. the Cout terminal which provides a clock pulse to a second counter should more bits be needed. iv. the reset terminal which is active low, i.e. a logic 0 causes the counter to reset. (Alternatively if the reset terminal is labelled R then it is active high, i.e. a logic 1 is needed to cause the counter to reset) 26 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters The output of a 4 bit binary counter is shown below. Input Event No: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 D 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 Binary Output C B A 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 0 0 0 The binary digit in the ‘A’ column is referred to as the least significant bit (LSB), it is the one that changes the most often. The binary digit in the ‘D’ column is referred to as the most significant bit (MSB), it is the one that changes the least often. 27 GCSE Electronics. Unit E2 : Applications of Electronics Types of Counter The number of bits (binary digits) in the counter determines the highest number it can count up to before resetting. A 4-bit counter can count from 0 -15 in binary whereas an 8-bit counter can count from 0 to 255 in binary. Different varieties of counter are available: - up, down, up/down, rising edge triggered, falling edge triggered, binary coded decimal (BCD), decade counters etc. BCD and Decade counters are covered in our next topic. The list provided here should help you when choosing one for your practical work. Sometimes we need a counter that counts only up to five or six for example. In this case we need to apply an external reset to the IC. Ask yourself; what is the biggest number that we want to be displayed before the reset takes place? Let’s have a look at an example to illustrate this. What is the biggest number that can be displayed on the following system ? a f Decoder / Driver b g c e d D C B A Cout R 28 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters The inputs to the NAND gate, come from counter outputs B and C. The output of the NAND gate goes to logic 0, and resets the counter, only when both outputs go to logic 1. The first time this happens is when the count reaches 0110 in binary (i.e. decimal 6), is the first occasion when the B and C outputs are high at the same time. The output of the NAND gate changes to logic 0, approximately 5 nanoseconds later (that’s about 5 thousand millionth’s of a second!), the counter resets, outputting ‘0000’, all in the space of a few nanoseconds. The effect this has on the display is that it does not have time to show the number 6 before it is reset to zero. The sequence shown on the display will be, 0, 1, 2, 3, 4, 5, 0, 1, 2 etc. The following example shows a similar system, but using a counter with an active high reset. What is the largest number displayed in this case? a f Decoder / Driver b g c e d D C B A Cout R The correct answer is decimal 8. The counter resets when outputs A and D are on, this corresponds to a counter output of binary 1001, which is 9 in decimal, so the last number displayed will be one less than this, i.e. 8. 29 GCSE Electronics. Unit E2 : Applications of Electronics Note: With a counter that resets on an active high (logic 1) signal, no logic gate is needed when you want it to count up to 3 and reset on 4 or count up to 7 and reset on 8. The reset can be taken directly from the C, or D output respectively as shown below. a f Decoder / Driver b g c e d D C B A Cout R This arrangement causes the counter to count in the following sequence: 0000, 0001, 0010, 0011, 0000, 0001, etc Beware: If the counter resets with an active low (Logic 0) signal and you want to count up to 3 or 7 then a NOT gate will be needed between the C and D output and the R input. For the rest of this section we will concentrate on the up counter described earlier, based on the CMOS 4516 Binary counter. 30 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters Activity 5: To investigate a 4-bit binary counter IC (4516) 5a. Set up the following circuit. 5b. Start the simulation and operate the switch ‘SW1’ several times. You should observe that the led’s light up in different patterns each time the switch is pressed. 5c. Keep pressing the switch ‘SW1’ until all the LED’s are off. 31 GCSE Electronics. Unit E2 : Applications of Electronics 5d. Complete the table below by copying down the state of the LED’s each time the push switch ‘SW1’ and then released. No. of Presses 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 5e. 32 State of LEDs 0000 0001 Modify your circuit so that the switch input to the clock is replaced with a pulse generator set at 1Hz as shown below. Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters 5f. Observe the counter, counting up to 1111 (binary) then resetting to zero before repeating the count. 5g. Now make a further modification to bring the RESET function into operation, as shown below. 5h. Investigate what happens when ‘SW1’ is pressed and released when the counter is running and the LEDs are coming on. Comment: .................................................................................................................... ........................................................................................................................................ 5i. Investigate what happens when ‘SW1’ is pressed and held on when the counter is running and the LEDs are coming on. Comment: .................................................................................................................... ........................................................................................................................................ 33 GCSE Electronics. Unit E2 : Applications of Electronics Resetting the counter automatically You should have observed that when ‘SW1’ is pressed the counter resets and starts counting again. The counter will not respond when the reset pin is at logic 1. Once the reset pin is returned to logic 0, counting continues. In the next activity, we make use of this feature to change the maximum count of the counter. Activity 6 : Resetting a binary counter 6a. Set up the following circuit. 6b. Run the simulation and watch the LEDs carefully. What is the count sequence now? ................................................................................................................................... ................................................................................................................................... ................................................................................................................................... 6c. 34 Logic gates can be used in various combinations to reset the counter on any number to suit the application involved. Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters Combining Counters and Logic Circuits One of the most common uses for counters is to automate certain electronic systems that have a continuously repeating pattern, e.g. traffic lights. In this final section of this topic we use a combinational logic circuit linked to a clock and counter to produce these fully automatic systems. An Automatic Traffic Light Display: The traffic light sequence is as follows. To design the system we proceed in the following way. STEP 1: We decide how many output displays we require. In this case it is three (RED, AMBER, GREEN) STEP 2: We decide how many inputs the logic system requires. There are four different settings of outputs. To provide these, we need 2 inputs. 35 GCSE Electronics. Unit E2 : Applications of Electronics STEP 3: We now form a truth table for the logic system. The inputs come from the two least significant bits of a binary counter, B and A. The traffic light sequence is given in the table: Inputs B A 0 0 0 1 1 0 1 1 Red 1 1 0 0 Outputs Amber 0 1 0 1 Green 0 0 1 0 Commentary Red Only Red and Amber Green Only Amber Only Our system is shown in the following diagram: Red Amber Green Logic Circuit A B When B = 0 and A = 0, the RED only is to be on (row 1). When B = 0 and A = 1, the RED AND AMBER are on (row 2). When B = 1 and A = 0, the GREEN only is to be on (row 3). When B = 1 and A = 1, the AMBER only is to be on (row 4). 36 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters STEP 4: We now look at the logic functions needed for each output. i) The RED output is the inverse of the B input, and therefore RED B B ii) RED The AMBER column is the same as the A input. AMBER A iii) The GREEN is only on when A is NOT 1 (i.e. 0) AND B = 1. This could be written down in Boolean notation as follows. GREEN A . B The logic circuit for the green would be made up as follows. A GREEN B STEP 5: We now know which logic gates are needed to produce the outputs. We can draw the full logic system. RED AMBER A GREEN B 37 GCSE Electronics. Unit E2 : Applications of Electronics STEP 6: Adding a counter and clock to the logic system gives the full circuit diagram: Notice that we only need the 2 least significant bits of the 4-bit counter. 38 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters Designing Simple Sequential Logic Systems Activity 7: Traffic light system Now consider the same sequence starting with the GREEN. It follows the sequence given below: 7a. How many output displays are required ? ...................... 7b. How many different output patterns are required ? ......................... How many inputs are required to cover this number of combinations? ..... 7c. Complete the following truth table. Inputs B 0 0 1 1 7d. i) A 0 1 0 1 Red Outputs Amber Green Green Only Amber Only Red Only Red and Amber Study the RED column. Is it the same, or the inverse, of an input? Complete the Boolean expression for the RED. RED = ................................................................ 39 GCSE Electronics. Unit E2 : Applications of Electronics ii) Study the AMBER column and complete its Boolean expression. AMBER = ................................................ iii) Study the GREEN column and then complete its Boolean expression. GREEN = ................................................ 7e. Draw a diagram for the logic system using AND, OR and NOT gates. 7f. Add a counter to your system so that it will automatically step through all four states continuously. Complete the circuit diagram of your solution in the space below: 40 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters 7g. Check your circuit then set it up and try it out. Describe any modification you had to make. ............................................. ................................................................................................................................ ................................................................................................................................ Activity 8: Disco Lights Design a system to produce the following sequence of lights. 8a. How many outputs are required ? ....................... 8b. How many different output patterns are required ? ...................... How many inputs are required to generate this number of combinations? …………… 41 GCSE Electronics. Unit E2 : Applications of Electronics 8c. Complete the following truth table. Inputs B A 0 0 0 1 1 0 1 1 8d. i) X Outputs Y Z No Lights on Study the X Output column and complete the Boolean expression for the X Output. X = ....................................................... ii) Study the Y Output column and complete its Boolean expression. Y = ....................................................... iii) Study the Z Output column and then complete its Boolean expression. Z = ....................................................... 8e. 42 Draw a diagram for the logic system using AND, OR and NOT gates. Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters 8f. Add a counter to your system so that it will automatically steps through all four states continuously. Complete circuit diagram of your solution in the space below 8g Check your circuit then set it up and try it out. Describe any modification you had to make. ............................................. ................................................................................................................................ ................................................................................................................................ ................................................................................................................................ ................................................................................................................................ 43 GCSE Electronics. Unit E2 : Applications of Electronics Homework Questions 2 1. The diagram below shows a circuit which makes three LED’s glow in a sequence. The clock feeds one pulse every second into the 2-bit binary counter. The counter outputs (A and B) are fed into logic gates. These control three LEDs. (a) Complete columns A and B of the following truth table to show how the output state of the binary counter changes. A is the least significant bit. Pulse No 0 1 2 3 4 (b) 44 B A R Y G Complete columns R, Y and G of the truth table to show how the state of the LEDs change in response to the binary sequence. Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters (c) Study the R, Y and G outputs carefully and see if you can produce a circuit diagram for the required output using a less complex logic sub-system than the original one. 45 GCSE Electronics. Unit E2 : Applications of Electronics Solutions to Homework Questions Homework Questions 1 1. a) b) Clk Q1 Q1 Q2 c) Clock In 46 D1 Q1 D2 Q2 D3 Q3 Clk Q1 Clk Q2 Clk Q3 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters Solutions to Homework Questions 2 1. (b) Pulse No 0 1 2 3 4 B 0 0 1 1 0 A 0 1 0 1 0 R 0 0 0 1 0 Y 0 0 1 1 0 G 0 1 1 1 0 (c) 47 GCSE Electronics. Unit E2 : Applications of Electronics Examination Style Questions 1. (a) The following diagram shows the symbol for a D-type flip-flop. The flip-flop is rising edge triggered. The D-input state is transferred to the Q output when the clock rises from the logic level 0 to 1. Complete the following diagram by showing the Q output state. [3] (b) A D-type flip-flop can also be set up as a 1-bit counter. On the following diagram of a D-type flip-flop: (i) (ii) (iii) 48 Draw in the connection(s) needed to make it into a 1-bit counter; [1] label with the word ‘INPUT’ the connection where the input pulses enter the flipflop; [1] label with the word ‘OUTPUT’ the connection where the output pulses leave the flip-flop. [1] Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters 2. A binary counter can be built from a series of D-type flip-flops, or can be obtained as a dedicated counter IC. (a) The diagram shows a pulse generator and a rising-edge triggered D-type flip-flop. Draw on the diagram the two connections required to convert the D-type into a 1-bit counter, connected to the pulse generator. [2] (b) The next diagram shows a counter IC, with its reset controlled by an AND gate. Complete the table to show the sequence of outputs produced, including the effect of the AND gate. Pulse Number 0 C 0 Outputs B 0 A 0 1 2 3 4 5 6 7 [3] 49 GCSE Electronics. Unit E2 : Applications of Electronics 3. An illuminated advertisement has three sections X, Y and Z which light up in a predetermined sequence. A block diagram of the control system is shown below. A logic system is required that will produce the following sequence. (a) Complete the following truth table for the logic system. You may assume a particular section of the advertisement sign is lit up when the corresponding output is high. Inputs B A 0 0 0 1 1 0 1 1 X Outputs Y Z [3] 50 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters (b) Study the X output. It is the inverse of one of the inputs. Write down an expression to describe this output. X = .............................................................................. [1] (c) Study the Y output. There is one type of gate that will produce this. What type of gate is it? X = .............................................................................. [1] (d) What type of gate will provide the required output for Z? ..................................................................................... [1] (e) You have a selection of NOT, AND, OR, NAND and NOR gates available. Draw a labelled diagram in the space below showing how the logic system can be made up by choosing from the gates available. [4] 51 GCSE Electronics. Unit E2 : Applications of Electronics 4. A binary counter is used to control a set of motorised valves in a water pumping station. The block diagram for the system is shown below. A valve opens when it receives a logic 1 signal, and closes when it receives a logic 0 signal. (a) Here is a partly completed truth table to show when the valves open and close. Pulse number Counter outputs Valves Open or Closed C B A 1 2 3 Start 0 0 0 Closed Open Closed 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 Use the outputs of the counter and the logic gates to decide when each valve opens and closes. Complete the table by stating whether valves 1, 2 and 3 are open or closed at each stage of the sequence. [3] (b) What happens to the counter outputs when pulse number 4 is processed by the counter? [1] ................................................................................................................................................. ................................................................................................................................................. 52 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters 5. (a) A student is asked to build a miniature set of traffic lights for a model village. Here is the block diagram for the control system. Pulse generator Logic system Counter Traffic lights The circuit diagram for the counter is shown below. To the redlight To the yellow light To the green light Pulses from pulse generator C B A R The table shows the possible output states for the counter. Pulse number 0 1 2 3 4 5 6 7 (i) Counter outputs C B A 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 Traffic lights Red light Yellow light Green light The counter resets when the reset input R receives a logic 1 signal. Which pulse number will cause the counter to reset? .................... [1] (ii) Use the counter outputs to decide what signals are sent to the traffic lights. Complete the first four rows of the table to show whether logic 0 or logic 1 signals are sent to the red, yellow and green lights. [4] 53 GCSE Electronics. Unit E2 : Applications of Electronics 6. A cyclist wants to count how many laps she completes. There is a pressure pad on the track. This acts as a sensor which outputs a pulse as each wheel goes over it. (a) Why is a divide-by-two circuit needed between the pressure pad and the lap counter? ……………………………………………………………………………………………….. (b) ……………………………………………………………………………………………….. [1] A D-type flip-flop is used to make the divide-by-two circuit. Modify the diagram of the D-type flip-flop to make it perform the divide-by-two action. You must show: how the pressure pad is connected to the D-type flip-flop; how the output of the D-type is connected; any other connection(s) needed. [3] 54 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters (c) The first graph shows the output of the pressure pad send directly into the divide-by-two circuit. Use the axes provided to draw the signals at Q and Q outputs. The Q output is initially at logic 0. The D-type flip-flop is rising edge-triggered. [4] 7. A 4-bit binary counter shown below. The counter must reset when counter output reaches twelve. The counter is reset by taking the reset pin to logic 0. Complete the diagram below to show how this can be done. Bit A of the counter is the least significant bit. [3] 55 GCSE Electronics. Unit E2 : Applications of Electronics 8. The D-type flip-flop can be used for data transfer, under the control of the clock. The D-type flip-flop is rising-edge-triggered. The signal shown in the first graph is sent into the D input. The second graph shows the pulses sent into the clock input. Use the axes provided to draw the signals at the Q and Q outputs. The Q output is initially at logic 1. [3] 56 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters (b) A binary counter can be built from a series of D-type flip-flops, or can be obtained as a dedicated counter IC. (i) The following diagram shows a pulse generator and two rising-edge triggered Dtype flip-flops. Draw on the diagram the connections required to make a 2-bit up-counter, connected to the pulse generator. [3] (ii) The graph shows clock pulses applied to the 2-bit up-counter. Use the axes provided to draw the signals which would appear at the outputs of the two flip flops. Initially the QA output and QB output are both at logic 0. [3] 57 GCSE Electronics. Unit E2 : Applications of Electronics 9. A D-type flip-flop can be used as a 1-bit counter. (a) Draw on the diagram the two connections required to convert the D-type into a 1-bit counter, connected to the pulse generator. [1] (b) The D-type flip-flop is rising-edge triggered. (i) Label a rising-edge on the pulse generator output graph below. [1] (ii) The Q output is initially at logic 1. Complete the graph to show the signal at the Q output. [2] (iii) Draw the graph to show the signal at the Q output. [1] (c) The system is also known as a divide-by-two circuit. The pulse generator has a frequency of 10 Hz. (i) What is the frequency of the signal at the Q output? ................................ (ii) What is the frequency of the signal at the Q output? ................................ [2] 58 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters 10. The diagram shows a 3-bit counter receiving pulses from a pulse generator. Output C is the most significant bit (msb). Complete the table to show the counter outputs, C, B and A, when the 2nd and 3rd pulses are counted. C Outputs B A 0 0 0 0 1 0 0 1 Pulse Number 2 3 [2] 59 GCSE Electronics. Unit E2 : Applications of Electronics 11. (a) Complete the following diagram to show how the two D-type flip-flops (Bi-stables) can be connected together to form a 2-bit binary counter. (b) Complete the following timing diagrams for the outputs QA and QB. The D-types are rising-edge triggered. [2] [4] 60 Topic 2.2 – Sequential Systems. 2.2.2 – Binary Counters 12. The following diagram shows a pulse generator and a rising-edge triggered D-type flip-flop. (a) Draw on the diagram the two connections required to convert the D-type into a one-bit counter, connected to the pulse generator. (b) The following graphs show the pulse generator output, and four possible signals. [2] Which graph shows the correct output from Q? ............................... [1] 61 GCSE Electronics. Unit E2 : Applications of Electronics Self Evaluation Review Learning Objectives My personal review of these objectives: explain, and illustrate, how a D-type flip-flop can be set up to produce a divide-by-two function; complete timing diagrams for a 1-bit counter; show how two D-type flip-flops can be connected together to form a 2-bit binary up counter; complete timing diagrams for a 2bit counter; realise that counters are available in a number of formats e.g. up/down, binary/BCD/decade; design and analyse simple systems that use a counter and combinational logic to produce a sequence of events; make a counter reset at a given value. Targets: 1. ……………………………………………………………………………………………………………… ……………………………………………………………………………………………………………… 2. ……………………………………………………………………………………………………………… ……………………………………………………………………………………………………………… 62