USB CONTROLLED WEB SITE HIT COUNTER ATMEL ATTINY25 WITH DELPHI

Web site counts the number of inputs to the circuit .. Circuit attiny25 an interesting and MAX7219 section based on the indicators used for the 7-segment display 8 hunting and Delphi source code are… Electronics Projects, USB Controlled Web Site Hit Counter Atmel Attiny25 with Delphi “avr project, microcontroller projects, “

usb physical hit counter

Web site counts the number of inputs to the circuit .. Circuit attiny25 an interesting and MAX7219 section based on the indicators used for the 7-segment display 8 hunting and Delphi source code are six examples of how electronics applications with Delphi can

USB PHYSICAL HIT COUNTER BASED ON AVR ATTINY25

This is an USB Physical Hit Counter.This version requires one MCU to communicate between PC and 7-segments display driver.I decided using AVR and this is my first AVR project.The purpose of this project still same as previous version.Therefore,it used to count and display the total page hits on any website instead of using only general scripts such as PHP,Java,CGI etc.The host software no USB driver programming required. Hardware and software on Display side

USB PHYSICAL HIT COUNTER BASED ON AVR

USE RS232 INTERFACING

The display I have used come from version 2 which it is MAX7219 and 7-segment x 8. MAX7219 requires only 3 I/O from MCU. ATtiny25 is the heart of this project.The firmware for this project written in AVR-GCC.This firmware modified from EasyLogger example which developed by Christian Starkjohann from Objective Development.Also,Christian Starkjohann developed an excellent USB firmware called AVR-USB which is a firmware-only implementation of a USB 1.1 compliant low-speed device for Atmel’s AVR microcontrollers.With this AVR-USB driver, it is easy to implement USB interface on AVR microcontroller project without dedicated USB hardware or no requires any USB to RS232 devices such as FT232. From the circuit above this circuit requires at least 300mA,9-12V DC or AC external power supply for MAX7219 to avoid overloading on USB bus.The regulator(IC1) needs an appropriate heat sink.The IC3 use bus-powered.

I use MAX7219 in decode-mode to reduce program memory space(2k for ATtiny25) because of this mode no program memory space to keep 7-segment font required. Here is the code inside the function usbFunctionSetup in firmware which is the importance code to receive command from PC.

    USB_PUBLIC uchar usbFunctionSetup(uchar data[8])  
    {  
    static uchar replyBuf[2];  
    uchar Dlen;  
    usbMsgPtr = replyBuf;  
    switch (data[1]) {  
    case 0: // data format => data[3]:data[2]:data[5]:data[4]  
    MAX7219_DisplayChar(1,data[3] >> 4 & 0×0F); // display digit 0  
    MAX7219_DisplayChar(2,data[3] & 0×0F); // display digit 1  
    MAX7219_DisplayChar(3,data[2] >> 4 & 0×0F); // display digit 2  
    MAX7219_DisplayChar(4,data[2] & 0×0F); // display digit 3  
    MAX7219_DisplayChar(5,data[5] >> 4 & 0×0F); // display digit 4  
    MAX7219_DisplayChar(6,data[5] & 0×0F); // display digit 5  
    MAX7219_DisplayChar(7,data[4] >> 4 & 0×0F); // display digit 6  
    MAX7219_DisplayChar(8,data[4] & 0×0F); // display digit 7  
    Dlen = 0;  
    break;  
    case 1:  
    MAX7219_Clear();  
    Dlen=0;  
    break;  
    case 2:  
    MAX7219_Init();  
    Dlen=0;  
    break;  
    default:  
    Dlen=0;  
    break;  
    }  
    return Dlen;  
    }

HOST SOFTWARE

I have written the host software in Delphi 6 and Indy 10 component installed on my PC as previous version.But this version requires a spacial library called “LibUSB-Win32” which is a port of the USB library libusb to the Windows operating systems (Win98SE, WinME, Win2k, WinXP). The library allows user space applications to access any USB device on Windows in a generic way without writing any line of kernel driver code. Also,this host software requires CoolTrayIcon and TextTrayIcon component for delphi.This component allow this host software minimize to the system tray as show in the picture below.My host software is just example and there are no some features such as no checking internet connection or not,no checking text file(hits.txt) exists or not.But,you can be modified or write your new software. As before,the host sofware will read text file(hits.txt) from web server every 10 seconds or more(timer1 interval) then send data to display circuit via USB.

This Delphi component can be downloaded from the link below or search on google for “Delphi CoolTrayIcon”. Web server script On the my web server,I create a text file to keep the hits number(e.g.hits.txt) with set file permission to chmod 755 or 777 then place the PHP script below on any page that you need to count the page hits,sidebar.php in my case.The hits.txt will be fetched by host software.

 <?php  
    $hitfile = $_SERVER[’DOCUMENT_ROOT’].”/counter/hits.txt”;  
    $hits = @file_get_contents($hitfile);  
    file_put_contents($hitfile,$hits+1,LOCK_EX);  
    echo ($hits+1); // comment this line if do not want to display  
    ?>

The host software tested on Windows XP only.Please don’t ask me about MAX7219 PCB,I have designed about two years ago and I cann’t find the orginal PCB file.I use AVR ISP programmer and PonyProg to experiment this project.

Source: https://320volt.com/en/attiny25-delphi-ile-usb-kontrollu-sayici-hit-counter/ USB Hit Counter project Attiny25 and Delphi source code schematic files alternative link: usb-controlled-web-site-hit-counter-atmel-attiny25-with-delphi.rar alternative link2link3


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top