Inductive Loop Detector works by detecting an inductance change in wire loop (coil) that is buried in road. It does that by measuring the frequency of the internal oscillator which powers the mentioned coil. When a metallic object moves over the coil it changes its inductance and that in turn changes the oscillator frequency which is measured by the microcontroller. It is used for vehicle access control at door and barrier controls, for monitoring the occupancy and for vehicle counting in parking garages, for traffic light installations and traffic controllers, for direction and speed detection of vehicle traffic (if dual channel version is used), in car-wash plants, etc.
Two versions of this device were made: v2.0 and v2.1. Version v2.0 had TPS5405 SMPS buck converter IC but that turned out to be a bad choice because of it's low maximum input voltage and dynamic switching frequency change (special feature of TPS5405) which interfered with our loop oscillator in some cases. Therefore, here is a better version v2.1 that uses LM2596 IC.
Signal filtering: Adjustable in 4 steps (LOW, MED-LOW, MED-HI, HI)
Coil/loop inductance: 20 uH – 1000 uH
Frequency range: 40 kHz – 140 kHz
Frequency adjustment: 4 steps (LOW, MED-LOW, MED-HI, HI)
Sensitivity: 0.001\% - 0.5\% digital in 8 configurable steps
Detection speed: <10 ms (with LOW filtering stage and loop frequency of 40 kHz)
Startup time: ~8 sec
Power supply: 7-40 V DC / 5-28 V AC
Current consumption: ~0.035 A
Protection: Galvanic isolation + gas discharge tube for lightning protection
Pinout of electronics (note: this is actually for version 2.0 but pinout is the same for this version 2.1)
Hardware Main component of this device is Colpitts oscillator which consists of just one transistor and few passive components. Frequency of oscillation is determined by number of coil windings - inductance and capacitors in oscillator circuit - capacitance, which can be changed with DIP switches. Wire loop (coil) is isolated from sensor electronics with 1:1 ratio isolation transformer. Transformer that I used in this project is from an old ADSL modem but rewound to 1:1 ratio. Transformer is not really critical, but RM5 core is your best choice. Note: You can build this oscillator without a transformer too! Common frequency range used for these detectors is from 30 kHz to 150 kHz.
Oscillator is connected to PIC16F877A microcontroller's RA4/T0CKI input via NPN transistor. Microcontroller is measuring the frequency of oscillations and determines whether the detection has occurred or not. There is a LED bargraph display that is used to show and set current detection sensitivity level and it also displays current level of detection as metalic objects approach the coil.
MCU PIC16F877A (entire schematics can be downloaded by clicking on the red download button bellow)
Electronics are powered by LM2596 SMPS step-down (buck) converter IC. It has a maximum input voltage of 40V DC which is perfect in case our electronics are powered from alternating ~24V because after rectifying we end up with 34V DC. LM2596 can provide 2A of current which is actually an overkill for this sensor, but I went for it since it is extra cheap and easy to order from eBay.
Voltage regulator LM2596
Firmware As this project is all about measuring the frequency (30-150 kHz) we need to choose the best method of measurement for this application. We can choose from two methods of measurement: frequency measuring (direct method) by using "gate time" or period measurement where we count pulses and work with that value.
The only suitable method for this application is actually the "period measurement". Impulses from oscillator are connected to RA4/T0CKI input pin of microcontroller, and on every overflow of TIMER0 counter I simply read the value of counter TIMER1. TIMER1 is configured as a free counter and its value is incremented with every internal clock pulse (Fosc/4). TIMER0 is configured and prescaled so that during normal operation of sensor electronics TIMER1 must never overflow over it's maximum value (65535). Value of TIMER1 is manually cleared to zero on every TIMER0 counter overflow, so it starts counting from 0 every time.
After powering up the device, oscillator starts to oscillate and microcontroller performs a startup measurement which is reported on yellow LED by blinking in 10kHz steps. Initial setup of TIMER0 is: prescaler=1:2, reloader=0. Reloader is a preset initial value which is loaded into TIMER0 after each overflow in order to speed it up. Prescaler tells us that the value of TIMER0 will increase by 1 on each 2 pulses that arrive from the oscillator. This means that overflow of TIMER0 will occur after 512 pulses which in turn means that by using MCU Fosc=12 (actually 12/4 MHz) and at loop oscillator frequency of 30 kHz TIMER0 will always overflow when value of TIMER1 increases to 51200. If we calculate the resolution at these values we can see that it is 0.58 Hz which is excellent. Under these same conditions but at loop oscillator frequency of 140 kHz value that TIMER1 value would be 10971 and resolution would be 12.76 Hz which is pretty bad.
It would be best if we could somehow fix value of TIMER1 counter to around 53000 at any given loop oscillator frequency. This can actually be done by prescaling the TIMER0 and preloading it with some initial values. This means that after microcontroller starts and performs initial measurement, it can figure out the best values for TIMER0 prescaller and reloader so that TIMER1 gets around 53000 where it will have best resolution and in turn have best sensitivity. Value for TIMER1 has been chosen to 53000 because during normal operation no metallic object can increase it that much so that it causes an overflow. In case it does overflow, the microcontroller will re-adjust TIMER0 prescaler and reloader values so it gets back to around 53000.
By using this method we ensure that device has the best sensitivity at any loop oscillator frequency.
After the initial calibration is finished, sensor remembers current value of TIMER1 and uses it as baseline value to compare with any following measurement. If frequency change that crosses selected threshold is detected, the sensor goes into "detect" state. Later when frequency changes back to the baseline value the sensor goes back to "idle" state.
During normal operation sensor constantly re-adjusts the baseline frequency value because it tends to drift with temperature changes of electronics and the wire loop itself.
DIP Switches There are 10 DIP switches to configure the operation of sensor electronics. When the switch is in left-hand position it means that it is turned "off", right-hand position means that switch is turned "on". Sensor should be reset after making any DIP switch changes!
Signal Filtering (B)
Signal Filtering (A)
Presence Selection (B)
Presence Selection (A)
ASB (on, off)
Relay Pulse Duration (on = 500 ms, off = 100 ms)
Relay Pulse Type (on = on loop leave, off = on loop enter)
Relay Type (on = presence, off = pulse)
Frequency Selection (B)
Frequency Selection (A)
Signal Filtering There are 2 DIP switches for selecting 4 filtering stages: DIP 1 i DIP 2. Filtering stages are described in detail in PDF user manual.
Presence Selection If this option (DIP 3 and DIP 4) is selected to infinity, the "detect" state will remain as long as there is a vehicle above the loop. One possible problem of using this option is that in "detect" state sensor electronics do not track and compensate for frequency drift. In extreme situations this can either cause false detect when vehicle finally leaves the loop (in this case device must be reset manually), or somewhat slower response time of further detections until device completes positive frequency drift compensation.
ASB - automatic sensitivity booster DIP 5 - This option increases sensor sensitivity to maximum upon detection. This is usually used to detect trucks and vehicles with trailers if sensor is not already configured to maximum sensitivity. If sensor is already configured to maximum sensitivity, this option is ignored.
Relay Pulse Duration DIP 6 - This option selects the duration of relay pulse in case Relay Pulse Mode is selected. When the DIP switch is at "on" position the pulse lasts ~ 500 ms, if the switch is at "off" position the pulse lasts ~ 100 ms.
Relay Pulse Type DIP 7 - In case Relay Pulse Mode is selected; this option defines whether the pulse will occur when vehicle approaches the loop or leaves the loop. When DIP switch is at “on” position then the pulse will occur when vehicle leaves the loop, otherwise the pulse occurs when vehicle arrives on the loop.
Relay Mode DIP 8 - This option selects Relay Mode. If the switch is at "off" position then relay will be activated for as long as there is a detection. Otherwise relay will just send out the pulse which is defined by DIP 6 and DIP 7.
Frequency Selection Frequency of loop oscillator is primarily defined by the wire loop geometry and the number of windings. In order to slightly change the frequency of the loop oscillator there are two DIP switches DIP 0 and DIP 9. Loop oscillator frequency is displayed on yellow status LED after the device is reset. LED will blink in steps of 10 kHz. Example: if LED blinks 7 times it means that the frequency of loop is from 70 kHz to 79 kHz. Sensor should be reset after making any frequency adjustments!
PC Configurator All working parameters of the sensor can be fine-tuned by using supplied PC application.
PC configuration UART (TTL!) port
Explanation of parameters
Sensitivity - "Osjetljivost" When metallic object approaches the loop it changes its inductance which in turn changes the oscillator frequency. Oscillator frequency is internally represented by number that has range of 1 to 255. Smaller metallic objects (for example bicycles) make smaller changes to this number while larger objects (such as cars) make bigger changes. Sensitivity has two thresholds: detection threshold which represents the number that the object must change inside the MCU in order to declare detection, and un-detection threshold which represents the number that is required in order for it to remain in "detect" state. Un-detection threshold is always smaller than the detection threshold and is usually 1/2 or 1/3 of the detection threshold.
Programmed values for each sensitivity level remain in sensor's internal EEPROM memory and can be selected with the Sensitivity Button while device is operating.
Signal Filtering - "Filtriranje" Filtering is very important part of sensors internal operation. There are 4 filtering levels that can be selected and fine-tuned using this PC configurator app. Parameters that define filtering levels are:
Mean value (average) calculation defines how many consequent measurements of loop frequency oscillator are required in order to produce one clean measurement. This option directly influences the speed of detection: larger number = slower detection speed but higher stability; lower number = faster detection but smaller stability.
Detection filter defines how many successive detections are required in order to declare a real detection. This option prevents false detections (glitches).
Speed of positive drift compensation is an important filtering parameter which defines the rate at which the sensor will adjust baseline frequency to the new frequency that changes in the opposite direction of change that occurs when metallic object approach the loop. This parameter defines the time required to re-calibrate the baseline value when metallic object moves away from the loop. Value entered here is multiplied by 17 and expressed in milliseconds.
Speed of negative drift compensation is the most important filtering parameter which defines the rate at which the sensor will adjust baseline frequency to the new frequency that changes in the same direction of change that occurs when metallic object approach the loop. Lower number for this parameter means that the sensor will faster compensate for the frequency drift but it also means that vehicles must arrive over the loop faster than the sensor compensates for that change. Value entered here is multiplied by 17 and expressed in milliseconds.
Note: Number used for negative drift compensation can also be used for positive drift compensation. Parameter used for positive drift compensation should be equal to or smaller than the number used for negative drift compensation.
There are 4 levels of filtering that can be programmed into the sensor and later selected by the appropriate DIP switches.
PPC (permanent presence canceller) - Presence Selection Values for Presence Selection can also be fine-tuned. Detailed instructions about this can be found in PDF user manual.
Note: All files required to build this device (schematics and PIC firmware) are available by clicking on the red download button bellow.
Video of sensor in use (this is video of version v2.0)
Testing on the desk
Photos of sensor (note: this is PCB version v2.0)
Device in idle state showing current sensitivity level (maximum)
Device in "detect" state
Bottom PCB side where MCU is located
Close-up of top PCB side
Gas discharge tubes and 1:1 isolation transformer
Soldering top side
DIY stencil from a fizzy drink can
Close-up of bottom PCB side with MCU and 12.000 MHz crystal
Hello, when you supply the voltage to that circuit R3(2) - put +5V there, it should start to
oscillate and you should see a square wave at the scope where you connected channel A. If it is
not working, try replacing Q1 with NPN transistor (such as BC847B), and changing L1 and C2, C3
capacitors. Also you can remove two zener diodes from the simulation. You can also try
increasing the supply voltage to 9 and 12V to see if it will start to oscillate. IP: n/a
im trying to simulate the circuit but its not working.would you please check out the screen
shot and let me know what is going on?
https://drive.google.com/open?id=0B-6R9_947YUaaWFrN3ZySnlnVkU IP: n/a
Kico119: I use PICKit3 to program my detector. I solder everything on the PCB and then I
connect PICKits: GND, RB7, RB6 and RST pins to the PCB pins (test points) that you can see on
the PCB. That is how I program the PIC. IP: n/a
Hi, neon lamps are not necessary. You can replace both transistors with any other NPN kind. Try
it, it should work just fine! Maybe you will need to adjust R8 (470ohm) in oscillator, maybe
increase it to 1k in that case, but try and see. IP: n/a
Hi. I want to Make a prototype and dont want to use pcb.
I have 2 questions
1.is there any non smd alternatives for BSS123 and BC847 that i can use in this circuit?
2. There are 2 Neon things before the transformer, what are they, and are they necessary? IP: 126.96.36.199