Summary of Coil Winding machine counter with Atmega8 and Reed relay
This article details the design of a digital counter for coil winding machines using an Atmega8 microcontroller. It describes two hardware variants: one with a 3.3V Nokia 5110 LCD and another with a 5V HD44780 character LCD. The system utilizes a reed relay to generate pulses and a polarity connector to determine motor direction, allowing the counter to increment or decrement. A reset button initializes the count, while an ISP connector facilitates programming via USBAsp.
Parts used in Coil Winding Machine Counter:
- Atmega8 microcontroller
- Nokia 5110 LCD (Variant 1) or HD44780 Character LCD (Variant 2)
- L7833 3.3V regulator
- Reed relay
- Momentary reset switch
- USBAsp AVR programmer
- External 8MHz crystal
- Transistor for pulse handling
- Voltage dividers (R3-R4 and R5-R6)
- Coil winding machine motor
Connectors
Everything has been mounted on a test board, including the headers for: ISP programmer (USBAsp), the 5110 Nokia LCD, the power supply (5V in, fed to the 3.3V regulator), the Reed relay connector, the reset button connector and another 2 pins connector, used to read the polarity of coil winding machine’s motor, so we know we either increment or decrement the counter.
Connectors
There are a few connectors:
J1: is for the power supply. The circuit takes 5V, that get into the L7833 for 3.3V output used by the atmega8 uC and the LCD.
J2: is the LCD connector, going to the Nokia 5110LCD.
J3: goes to the reed relay. This is the place we generate pulses for the microcontroller to count.
J4: is the polarity connector. It must be connected in parallel on the coil winding machine’s motor. It was designed for a 12V motor (but this can be changed by adjusting the voltage dividers formed by R3-R4 and R5-R6, so they take in the motor voltage, and output not more than 5V). If the motor is connected in normal polarity, we will read PD0 high, if the motor is in inverse polarity, we’ll have PD1 high. This info is used in the code to either increment or decrement the counter.
J5: is just a simple momentary switch. When pressed, will reset the counter to zero.
ISP connector: is a 10 pin connector used with the USBAsp AVR programmer.
Fuse Bits
External 8MHz crystal. The settings are:
avrdude -p atmega8 -c usbasp -U lfuse:w:0xff:m -U hfuse:w:0xc9:m
Variant 1 : Atmega8 + Nokia 5110 LCD + 3V power supply
I am using an Atmega8-8PU (configured for 8MHz with external crystal), a Nokia 5110 lcd, and a transistor to handle the pulses from a reed relay. A 3.3V regulator provides the voltage for the entire circuit.
Variant 2 : Atmega8 + 2×16 HD44780 Character LCD + 5V power supply
Some of my readers asked for a custom variant, that uses a 2×16 HD44780 LCD (or a 1×16 smaller variant). These displays require a 5V voltage supply, so here is variant 2 of the digital counter, modified to support these requirements. See the images below.
Variant 2 images
For more detail: Coil Winding machine counter with Atmega8 and Reed relay
-
How does the circuit handle different LCD voltage requirements?
Variant 1 uses a 3.3V regulator for the Nokia 5110 LCD, while Variant 2 is modified to support 5V supplies for HD44780 displays. -
Can the polarity connector work with motors other than 12V?
Yes, the voltage dividers formed by R3-R4 and R5-R6 can be adjusted to accept different motor voltages as long as the output does not exceed 5V. -
What determines whether the counter increments or decrements?
The code reads PD0 high for normal polarity and PD1 high for inverse polarity from the motor connection to decide the counting action. -
How is the microcontroller configured for operation?
The Atmega8 is configured for 8MHz operation using an external crystal with specific fuse bit settings applied via avrdude. -
What component generates the pulses for counting?
A reed relay connected to J3 generates pulses that are handled by a transistor for the microcontroller to count. -
How is the counter reset to zero?
Pressing the momentary switch connected at J5 resets the counter to zero. -
Which tool is used to program the microcontroller?
A 10-pin ISP connector allows the use of a USBAsp AVR programmer to upload code to the device.


