Mar05
Physical hit counter for website
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.

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.

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.


Download project here
Include Delphi 6 example,circuit,php script
Download ComPort 3.1 here
Open source Delphi component
New version coming soon.Have fun
Physical Hit Counter based on AVR ATtiny25
USB interface version
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.
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.
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.
Download project here
Include Delphi 6 example,circuit,php script
Download ComPort 3.1 here
Open source Delphi component
New version coming soon.Have fun
Physical Hit Counter based on AVR ATtiny25
USB interface version
















Daniel on 05 Mar 2008 at 7:10 am #
Hi thereVery cool. Love this sort of lo-hi-tech gadgetry…
If I had the abilities to replicate it I would, but i haven’t so instead I’ll leave you with an idea: Use a live webcam feed of the counter, as an actual hitcounter on your website…
You’ve probably thought of this already, but there it is…
Cool regards
Daniel
Odin84gk on 05 Mar 2008 at 8:27 am #
Very nice. I like how you didn’t need to decode the serial information.I was looking at your schematic, and I would recommend adding a current limiting resistor (10 Kohm) between C1 and RTS (before or after diode, does not matter).
When you start your machine, the cap will be asking for an “infinite” amount of current (minus the resistance in the diode, cap, cable, ect). Since it is a 100uF cap, its going to ask for a lot of current (relatively speaking). A 10K resistor guarantees that you will never ask for more than 15mW (12V^2/10,000ohm) in power.
Thanks again for the great idea for a simple interface.
Derek Tombrello on 05 Mar 2008 at 8:45 am #
I don’t suppose any one could write a program for this that would run on Linux? I can handle the hardware side, but software is not my thing anymore…Awesome project - BTW!
Nathan on 05 Mar 2008 at 9:04 am #
I like the idea that I just made your counter click. Makes me want to keep refreshing the page (i am not really going to, I just want to) and imagine your counter clicking away. I suppose now that you have the Make link, it’s will be going non stop for a while!Plasma2002 on 05 Mar 2008 at 12:48 pm #
hehehehe… tell me… did you take the picture of it on 42 hits on purpose? If so, your definitely one hoopy frood who really knows where his towel isBob on 05 Mar 2008 at 9:23 pm #
Hi DanielI can’t do that now because of my upload bandwidth limited to 10KB/s.
Thanks for your comment.
Hi Odin84gk
Thanks for your comment.
Hi Derek Tombrello
Check out this website for linux and rs232 http://www.ontrak.net/linux.htm
Hi Nathan
Thanks for your comment.
Hi Plasma2002
You may doubt why I take the picture on 42 hits.Because 42 is the number of counter while I test my prototype.Why not I take the picture at 000000? Because this counter take about 18 hours to count from 000042 => 000000.
Thanks for your comment.