Machanical counter
This is a physical hit counter.It used to count page-hits on the website instead of using software only.The counter will be connected to rs232 port through a few of electronic components that performs as a counter driver and power supply circuit.The counter that I used is a mechanical counter or electromagnetic counter model SC-212 which I get from an old coin-op game machine as show in the photo.As the counter’s nameplate specified, this counter requires 12VDC power supply, this means that it requires a 12V pulse to increase the counter by 1.Also,the in the nameplate show the maximum speed is 15 CPS, but I not use beyond this speed in my project.
This physical hit counter consists of three parts:
1. PHP hit counter script run on web server.Place this script into webpages(e.g. sidebar.php for wordpress template or in a specific page as you need).This script will count the number of times a page is called and store this number into a simple text file(e.g. hits.txt).The code below is the PHP hit counter script. To use the script above you need to create a folder “counter” and chmod to 0755 or 0777 then create a text file “hits.txt” in the counter folder and chmod to 0644 or 0777 too.


2. PC software run on my computer.This software performs two functions. The first is to fetch text file(i.e. hits.txt) on my web server every 10 seconds or more.I used Delphi 6 with ComPort 3.1 component installed.In Delphi,it is easy to read a text file from web server by using Indy component as show in the code below. The second is to send a break signal over RS232 serial line to the counter driver circuit by using ComPort3.1 component .To increase the counter by 1 just sending a break signal as show in the code below. Delphi design time Delphi run time
3. Hardware interface between computer and counter driver circuit.As I mentioned above,the counter interface to computer via RS232 but not directly connected.The circuit below is a simple on/off switch.
Physical hit counter

The TX pin to be used to turn on/off NPN transistor T1(general purpose switching transistor) by sending a break signal on and off from Delphi.When set break on the TX pin is become to Space-state or “0″ or +3….+25v or “on state” in Delphi.When set break off the TX pin is become to Mark-state or “1″ or -3….-25v or “off state” in Delphi.This voltage is shown in the electrical specifications of the serial port is contained in the EIA (Electronics Industry Association) RS232C standard.In the practice,it depends on many factors.On my desktop computer voltage at “0″ is 10.6V and at “1″ is -10.5V.Although,the counter requires 12VDC as I say but on my prototype it works fine.The RTS or pin 7 on DB-9 connector perform a power supply function.When it is set to “0″ or “on state” in Delphi the voltage at this pin is +10.6V (on my desktop computer). I have to try to make a real time video to show on this page but not works,due to my upload bandwidth limited about 10KB/s.Here are some photos and video of my prototype.
Prototype Prototype
physical hit counter specification

Download project here
Include Delphi 6 example,circuit,php script
Download ComPort 3.1 here
Open source Delphi component
New version coming soon.
See latest version
Via USB interface and display the hits number on 7-segment which is driven by MAX7219 from MAXIM and control with AVR microcontroller. Have fun :)


Engineering Tech books
Electronic kits