Bug Trap v2

A new year, a new module, a new bug trap :). The original bug trap was made from recycled solenoids, the new bug trap is designed from scratch, with a focus on reliability and maintainability. The scenario is that the University is overrun with cockroaches and the students are required to design an automatic bug trap. The new hardware platform is shown in figure 1, having three main components :

  1. Net: a "high" powered servo motor connected to a square net via a connecting arm. When energised the servo pushes the net down into the closed position, trapping the cockroach, otherwise it lifts the net up into the open position.
  2. Base: this section contains two infra-red illuminated LED sensor modules i.e. front and rear sensor, that detect when a cockroach is in the trap. Signals interfaced to a FPGA board via a GPIO expander module.
  3. Control panel: user console containing a RED status LED, a toggle switch and a RED push switch.

Figure 1 : Bug trap

These sensors (LED sensor modules and switches) and actuators (servo and LED) are interfaced to the FPGA using an PCF8574 I2C GPIO expander (Link), shown in figure 2. This was partly due to a need to reduce the size and thickness of the connecting cable, but mainly due to the the limited IO lines on the FPGA board used. Note, to reduce construction time this hardware is based on bought in Arduino modules.


Figure 2 : GPIO expander

The pin-outs are:

The acrylic base template and the 3D printed elements were designed in openScad, shown in figures 3 and 4. Note, the 3D printed base is used to mount / hold in place the various modules i.e. recessed inserts owing to lack of mounting holes. The model files can be downloaded here: (Link).

Figure 3 : Base

Figure 4 : 3D models

To reduce the amount of wiring needed to connect the various sensors and actuators to the GPIO expander i made a small patch board as shown in figures 5 and 6. Plug J2 connects to the I2C expander, J5 connects to the servo. Plug J1 and J2 connect to switches, JP6 to front panel LED. Plug J3 and J1 connect to the infra-red sensor modules.

Figure 5 : interface circuit


Figure 6 : Interface PCB

The aim of the practical based on this hardware is to demonstrate the operation of basic logic gates, their functions and how these can be combined to implement different functions i.e. the fundamental building blocks of a computer. In the previous bug trap labs this hardware was constructed using TTL gates (Link). With the changes of curriculum we no longer teach electronics, therefore, i shifted logic gate teaching into an FPGA. Students can design and implement logic circuits as schematics, these are then synthesised and uploaded into the FPGA for testing. The top level schematic shown in figure 7, that controls this hardware is made up of three components:

  1. Bug_Trap_Controller : a combinatorial logic circuit developed in the practical, processing the input sensor data to control output actuators:
  2. Virtual_Wires : the seven signals controlling the bug trap (listed above) are not directly connected to the FPGA board as individual wires, rather signals are transferred between the FPGA board and the bug trap hardware using a serial Inter IC Communications (I2C) Bus, significantly reducing the number of wires in the white connecting cable. Note, the reason for this abstraction was due to limited IO lines, this is not visible to the bug trap controller. In addition to implementing this communications link this component also updates the seven segment LED display with the status of these signals.
  3. Clock_Divider : the FPGA board has an on board oscillator producing a 10MHz clock. This is divided down to a slower frequency to produce a 1Hz clock on the CLK_OUT pin. This signal will be used later to control the servo motor's position.

Figure 7 : top level schematic

To communicate data to and from the hardware a PicoBlaze system has been constructed and is integrated into the design using the virtual_wires component. This system provides the four inputs (pio_F_o) to the bug_trap_controller schematics and sends its two output (pio_F_i) signals to the hardware across the I2C bus shown in figure 8. The internals of the PicoBlaze system is shown in figure 9. This is used as a "black-box" component in the practical i.e. students only need to implement in the logic control in the bug_trap_controller schematic.

Figure 8 : I2C data packet

Figure 9 : PicoBlaze system

The first bug_trap_controller uses only the red push button as shown in figure 10, directly controlling the servo and LED. A short video is available here: (Link).

Figure 10 : Manual mode only

The second bug_trap_controller uses only the infra-red sensors as shown in figure 11, a short video is available here: (Link).

Figure 11 : Automatic mode only

The third bug trap combines the auto and manual modes, as shown in figure 12.

Figure 12 : Bug trap control rules

To combine the automatic and manual control rules the toggle switch is used to select between the two rule sets i.e. a MODE switch, the selected mode is indicated by the LED:

These control rules can be "rephrased" as shown in figure 13, or as the truth table shown in figure 14.

Figure 13 : Updated control rules

Figure 14 : Truth tables

These rules can be implemented using the logic circuit shown in figure 15.

Figure 15 : Control logic

A short video of the trap implementing the manual and automatic modes is available here: (Link)(Link).

Figure 16 : Testing, manual mode (top), triggered (bottom)

The fourth bug_trap_controller implements a manual and automatic mode, but also uses the infra-red sensors to detect the size of the bug. In automatic mode if the bug is small and only triggers one sensor the trap is triggered lowering the net, holding the bug. However, if the bug is larger, or tries to push through the trap and triggers both sensor the trap enters persuade mode, repeatedly hitting the bug, a short video is available here: (Link).

Figure 17 : Auto, Manual and Persuade mode

Creative Commons Licence

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

Contact email: mike@simplecpudesign.com

Back