Skip to the content
2 layers140 × 90 mmMetaldetector, the printed circuit board in 3D

Hardware and Software for a custom build metaldetector + pressure sensing shield

Size
140 × 90 mm
Copper layers
2
Thickness
1.6 mm
Parts
149
Nets
101
Pads
482
Tracks, vias
1,473, 123
Pours
1
Routed
Yes
KiCad
KiCad 4
Created
30 Dec 2018
Updated
4 Jan 2019

Overview

Metaldetector is an open-source printed circuit board by sharst, from the sharst/metaldetector-shield repository on GitHub, published under the LGPL-3.0 licence. It is a 2-layer board of 140 × 90 mm with 149 parts on 101 nets, routed with 1,473 tracks and 123 vias.

It is built around the MCP2551-I/P, ICL7660N and LM2596S-5.0, with the LF356N, MCP3008-I/P and 74HC4052 among its other parts. Its parts include 50 resistors, 27 connectors, 26 diodes, 16 ICs and 13 capacitors. It belongs with the AVR (ATmega, ATtiny) boards of this library.

Main components

8

README

README.md

metaldetector-shield

Hardware and Software for a custom built metaldetector + pressure sensing shield. This shield was used in a robotics project for contactless navigation (see https://www.youtube.com/watch?v=rSrG_VnvrPk). The hardware and software were jointly developed by Simon Harst and Stefan Brüwer.

It features:

  • connection of up to 8 coils which emit and receive electromagnetical impulses
  • connection of up to 8 pressure sensors to detect air pulses
  • 24V connection with on-board conversion to 5V for the microcontroller
  • on-board CAN-Controller to connect the board to a CAN-bus
  • chaining possibility to connect two or more boards together for infinite extension
  • a ROS example to use it in your robotics application: www.github.com/sharst/metaldetector-ros

What you can do with it:

  • Contactlessly detect metal objects in the vicinity (distance depends on the coil and object used)
  • build a rig of 8, 16 or more coils by chaining several boards together
  • detect changes in air pressure (in our case upon collision inside an inflateable bumper)
  • send all the information on a CAN or serial bus

The board and all accompanying software is fully open source, so you can get involved, too!

Hardware setup

How does this work?

The heart of this shield is an arduino microcontroller, which rapidly triggers 8 rigs of transistors connected to coils. From the impulse of current, the coils generate an electromagnetical impulse. In case there is metal in front of the coil, it will reflect part of the impulse which in turn can be sensed by the coil. The weaker echo of the impulse is again converted to current in the coil, which is measured by an ADC on the board. If you want to see a typical response as measured by the ADC, check out the coil response gif below (--> Configuration files). The board sums up the response. This sum can be used to infer whether a metal object is present and how far away it is.

In addition, the shield can measure impact in terms of air pressure. To do that it constantly measures a rolling average of up to 8 air pressure sensors independently. In case it measures a spike of air pressure above a threshold, it emits a custom message.

The metaldetector shield

This is what needs to be done to get one board running (no chaining):

  • Solder at least one sensing coil to the COIL_GND and COIL_0 inputs (for more information, check out --> "A note on the coils"
  • (Optionally) connect one BMP180-pressure sensor to one of the pressure inputs
  • Connect the arduino on the board to your PC and flash the current firmware
  • Set jumper J1 to set the board to MASTER mode
  • Set jumper J2 to disable chaining
  • In case you do not have a coil/capacitor installed at the 24V input, set jumper J3 to bridge the coil connector
  • Connect 24V to one of the 24V ports
  • The values of the coils are being output on the serial port now (115200baud)

To enable chaining

Chaining allows you to connect two boards together. The impulses of the coils will influence one another. Therefore you should not operate two coils close together if you want accurate results. The metaldetector board already takes care that up to 8 coils are fired independently in a row and do not influence each other. If you need more than 8 coils, you can use chaining. Chaining uses an additional signal line between two boards, and the boards will take care to always fire their coils alternatingly.

  • Remove jumper J2 to enable chaining
  • Set jumper J1 on one board to make it the chaining MASTER. Remove the jumper on all other boards to make them slaves
  • You can directly chain the 24V power source as well by connecting the secondary 24V-port to the next board
  • Connect to signal wires between the boards. The first one should go from output (>) on board 1 to input (<) on board 2. The second one goes from input (<) on board 1 to output (>) on board 2.
  • If you want to connect more than two boards together, connect them in a circle, always taking care that the output goes to the input of the next board, and the input is connected to the output of the previous board.
  • If you are using the CAN bus, make sure that the boards are using unique CAN addresses (set them in metaldetector-shield.ino --> TX_CAN_ID and RX_CAN_ID)

How to produce the boards

  • We always ordered our boards at PCB-Pool (in Germany). They accept the kicad-files given in the hardware folder directly as input.
  • You can order the entire BOM on farnell, including the wire for the coils. Check out the BOM in the hardware folder.

A word on the coils

The coils are key when it comes to which objects can be detected. Here's a few notes:

  • The larger the coil diameter, the less focused the impulse will be. In general you get a weaker response with larger coils, but also you cover less area
  • We tested both with round and rectangular coils, both worked great.
  • The more impedance, the less current flow you will get at the fixed 24V, which means less stronger impulses and responses. But it also means less power consumption.
  • The more windings the coil has, the stronger the impulse. But also you will naturally get higher impedance with more windings.
  • you will have to experiment to find the best tradeoff for your application. In our case it was a coil from 0.4mm wire with 150 windings equalling to ~11 Ohm.

A note on the pressure sensors

  • We ordered the BMP180 sensors on ebay. Note that there are several versions. The boards we used are 1cm x 1.2cm in size. We hand-crimped the cables to connect them via the JST-plugs.
  • If you want to use pressure sensors in an outdoor environment, water resistance is key. We used two cable glands connected together to create an air- and water-tight case. We connected an air tube from the one side which guided the air impulse from the bumper cushion into the case (blue arrow). On the other end we connected the air pressure sensor (red arrow). See image here..
  • For extra water resistance, it is possible to put the pressure sensor into a ballon before inserting it into the cable gland. See image here.

Software setup

We've tried to make the software setup as easy as possible for you. Therefore, all the software needed is bundled in this repository, either directly or by submodules.

To get the arduino running

text
# Go anywhere where you want to check out this repo
cd ~
git clone https://github.com/sharst/metaldetector-shield
cd metaldetector-shield
# Get all the contained submodules
git submodule init 
git submodule update
# The repository contains an arduino folder. This is basically an arduino sketchbook setup and ready to go. First backup your current one:
mv ~/sketchbook ~/sketchbook_bckp
# Now link the one from the repository with a symbolic link. This means you can still use and manage the repository in the original location, but arduino will find your files.
ln -s ~/metaldetector-shield/arduino ~/sketchbook
  • Open the arduino IDE (tested with v 1.6.9)
  • Select Tools --> Board --> Arduino Nano
  • Tools --> Programmer --> AVR ISP
  • File --> Open --> ~/sketchbook/arduino/metaldetector_shield.ino
  • Upload
  • Open Serial Console, set it to 115200 baud, watch the output.

Overview of the software

./arduino: Contains all the software relevant to the arduino (i.e. the firmware and all libraries) ./PythonLivePlotting: A library to do dynamical plots and updates of figures

Configuration files

board_v23.h : Contains mostly pin settings (hardwired on the board, don't change them!). You can also set some identifiers on where pressure and heartbeat signals get send on the CAN-BUS, and the identifier to switch coils.
metaldetector-shield.ino: The main sketch for upload. Contains some interesting settings:

  • TX_CAN_ID: The CAN ID used for writing messages on the bus. If you are using several boards on the same bus, make sure this is unique for each board.
  • RX_CAN_ID: The ID that this board listens on for messages on the bus. You can dynamically switch some functionalities on the board by sending messages. Make sure this ID is unique for this board.
  • DEBUG: Whether or not to output information on the serial bus.
  • COMM_TIMEOUT: How many ms to wait for a signal from the slave board in chaining mode
  • DEBUG_RAW_ADC_COIL: Only works when DEBUG==true. This will output the raw measurements of the given coil as sampled by the ADC. Run python plot_raw_coil.py to visualize these values. This is a sample output where we approach a metal object to the coil: Raw output of ADC values
  • DEBUG_RAW_PRESSURE: Only works when DEBUG==true. This will output the raw measurements of the given pressure sensor. Run python plot_raw_pressure.py to visualize these values. This is a sample output where we register several bumper hits on the given pressure sensor. In red are detected collisions. Raw output of pressure values
Typical operation mode

Check out the loop-function in the main sketch. A loop consists of the following steps:

  • If coils are enabled, trigger each coil once and read out the results
  • we want to average over several measurements. coil.data_ready() goes to True as soon as we have collected this amount of measurements
  • In case some coil data is ready we will output it on the serial bus as a four-byte message, which will be in the format [40 (COIL_REGISTER set in board_v23.h), [0-7] (coil_index), highbyte(value), lowbyte(value)]
  • The communication state is toggled so the next board can start measuring
  • We now sample the pressure sensors. If one of them transitions a threshold value, we encode this information bitwise. For instance, if pressure sensors 2 and 4 have surpassed the threshold value since the last call, get_bumper_transitions will output 0b00010100 (the second and fourth bit are True).
  • We now send out the string "BUMPER" on the serial bus. On the CAN-bus we will send the bitcoded value, this time in the format [25 (PRESSURE_REGISTER set in board_v23.h), 0, highbyte(bitcode), lowbyte(bitcode)].
  • We send out a heartbeat message on the CAN bus. This message contains the information on which ports some pressure sensors are connected and whether the metal sensing functionality is currently switched on. Which ports are currently connected to pressure sensors is again encoded bitwise, i.e. 0b10001001 means that there are sensors connected on the first, fourth and eigth connector on the board. A heartbeat message has the format [30 (HEARTBEAT_REGISTER set in board_v23.h), bitwise encoding of connected sensors, (1 or 0 whether coils are enabled)]
Getting the CAN bus running
  • In order to interface with a CAN bus from a computer, you typically need a CAN to USB converter. We had some eccellent results with the USBtin. It is open source, has a superb interface, a loving maintainer and can be ordered readily assembled.
  • In order to connect it, just connect the HIGH, LOW and GND (marked as "T" on the USBtin) lines between the two boards.
  • If you want to connect more metaldetector boards, there are two CAN connectors on each one: One coming in, one going out.
  • In addition, you need one termination resistor somewhere on the bus, typically on the last element of the bus chain. If this last element is a metaldetector board, you can simply set jumper J4 to enable the termination resistor.
  • Connect the USBTin to your computer, open the interface and set it to 500kbps and see the messages from the board coming in.
  • There is also a ROS driver available which directly interfaces the metaldetector-board to ROS messages www.github.com/sharst/metaldetector-ros

Summary: Information flow from the metaldetector-shield

Information flow from the metaldetector-shield

Parts

149
QtyValueFootprintReferences
101kResistors_SMD:R_1206_HandSolderingR13, R17, R21, R25, R29, R33, R37, R41, R48, R51
910kResistors_SMD:R_1206_HandSolderingR1, R2, R3, R9, R43, R44, R45, R46, R47
9220Resistors_SMD:R_1206_HandSolderingR14, R18, R22, R26, R30, R34, R38, R42, R49
9CONN_1Own_Components:solderpad_singleP1, P11, P12, P13, P14, P15, P16, P17, P21
9SCHOTTKY 1A 20VOwn_Components:DO-214AC_HandsolderingD1, D6, D9, D12, D15, D18, D21, D24, D27
81k/1WResistors_SMD:R_2512_HandSolderingR12, R16, R20, R24, R28, R32, R36, R40
82k PLANARResistors_SMD:R_2512_HandSolderingR11, R15, R19, R23, R27, R31, R35, R39
8CNY17F-4X OPTOOwn_Components:SMDIP-6U7, U8, U9, U10, U11, U12, U13, U14
8MOS_POwn_Components:TO-252-3Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8
8TVS-DIODE 400VOwn_Components:DO-214AC_HandsolderingD4, D7, D10, D13, D16, D19, D22, D25
8TVS-DIODE 5VOwn_Components:DO-214AC_HandsolderingD5, D8, D11, D14, D17, D20, D23, D26
4CONN_1Own_Components:boreP22, P23, P24, P26
3100Resistors_SMD:R_1206_HandSolderingR4, R7, R8
347uFCapacitors_SMD:c_elec_6.3x5.3C1, C11, C12
3JUMPERSocket_Strips:Socket_Strip_Straight_1x02JP1, JP3, JP4
2100nFCapacitors_SMD:C_1206_HandSolderingC5, C6
2100uF ELKOCapacitors_SMD:c_elec_6.3x5.3C8, C9
227pFCapacitors_SMD:C_1206_HandSolderingC3, C4
274HC4052Housings_SOIC:SOIC-16_3.9x9.9mm_Pitch1.27mmIC1, IC4
2HEF4051Housings_SOIC:SOIC-16_3.9x9.9mm_Pitch1.27mmU3, U4
116MHzOwn_Components:HC49SM-Crystal16MHzC2
11n5824Diodes_SMD:DO-214AB_HandsolderingD3
1220uF / 25VCapacitors_SMD:c_elec_8x10.5C10
12N7002Own_Components:SOT-23_Handsoldering-MOS-NQ9
1350Resistors_SMD:R_1206_HandSolderingR10
1560Resistors_SMD:R_1206_HandSolderingR5
1560kResistors_SMD:R_1206_HandSolderingR6
1680uF / 50VOwn_Components:CAP_D12_5_H13_5_SMDC7
168uHOwn_Components:Ind_68uHL1
1Arduino_Nano_Headerw_conn:arduino_nano_headerJ1
1BAT_CONN1schraubklemmen:mkds_1,5-2P18
1BAT_CONN2schraubklemmen:mkds_1,5-2P19
1BMP1w_conn_jst:b4b-ph-klP2
1BMP2w_conn_jst:b4b-ph-klP4
1BMP3w_conn_jst:b4b-ph-klP7
1BMP4w_conn_jst:b4b-ph-klP9
1BMP5w_conn_jst:b4b-ph-klP3
1BMP6w_conn_jst:b4b-ph-klP6
1BMP7w_conn_jst:b4b-ph-klP8
1BMP8w_conn_jst:b4b-ph-klP10
1CAN_CONN1w_conn_jst:b4b-ph-klJ2
1CAN_CONN2w_conn_jst:b4b-ph-klP25
1CAPAPOLCapacitors_ThroughHole:C_Radial_D18_L36_P7.5C13
1ICL7660Housings_SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mmU1
1INDUCTOROwn_Components:BOURNS-2124-V-RCL2
1LF356NHousings_SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mmAMP1
1LM2596Own_Components:TO-263-5U2
1MASTERMODE_JUMPSocket_Strips:Socket_Strip_Straight_1x02JP2
1MCP2515Housings_SOIC:SOIC-18_7.5x11.6mm_Pitch1.27mmIC2
1MCP2551Housings_SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mmIC3
1MCP3008Housings_SOIC:SOIC-16_3.9x9.9mm_Pitch1.27mmMCP1
1PING_CONNschraubklemmen:mkds_1,5-2P5

Similar boards

  • 2 layers60 × 110 mmCore PCB, the printed circuit board in 3D

    Core PCB

    brunolalb/AlarmClockRestoMod

    ESP32 Software for an Alarm Clock Resto Mod

    70 parts
  • 2 layers105.4 × 67.6 mmCarpc, the printed circuit board in 3D

    Carpc

    festlv/carpc

    RaspberryPi based CarPC build, to replace stock Volvo navigation system

    51 parts55
  • 2 layers68.7 × 53.5 mmSensor interface 1.1.0, the printed circuit board in 3D

    Sensor interface 1.1.0

    WATonomous/interfacing-mono

    repo for all firmware, ROS nodes, messages, and schematics to live

    61 parts1
  • 2 layers97 × 58 mmCANTest, the printed circuit board in 3D

    CANTest

    ElBabar/CANTest

    A board designed to test CAN connectivity between 2 arduino nanos

    33 parts
  • 2 layers100 × 51 mmTXDemo, the printed circuit board in 3D

    TXDemo

    ElBabar/TXDemo

    Demo board for CAN and XBee communication

    43 parts
  • 2 layers70 × 55 mmXBee node, the printed circuit board in 3D

    XBee node

    ElBabar/XBee_node

    Node for CANbus and XBee commuincation

    23 parts
  • 2 layers31.8 × 54.6 mmRpi can, the printed circuit board in 3D

    Rpi can

    jnod/rpi_can

    12 parts
  • 2 layersControlBoard, the printed circuit board in 3D

    ControlBoard

    knoerk/MicroGasExchange

    Software, Circuits and PCB for microcontroller based gas exchange system

    106 partsGPL-3.0

Questions

How big is the Metaldetector PCB?

It measures 140 × 90 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Metaldetector use?

149 parts, built around the MCP2551-I/P, ICL7660N, LM2596S-5.0 and LF356N. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Metaldetector KiCad files?

From the sharst/metaldetector-shield repository on GitHub, at the commit this page was made from: the board is hardware/metaldetector.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the Metaldetector design in my own project?

Its repository publishes it under the LGPL-3.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).