Attiny44 speed sensor circuit

25,172

Attiny44 speed sensor
Attiny44 speed sensor

The final project involves cycling rollers that require a method to sense the rotational speed of one of the rollers. Speed sensors on bicycles typically function by detecting a magnet attached to a spoke on one of the wheels using a Hall Effect sensor or a reed switch. A similar principle will be used to determine the rotational speed of the rollers by placing a magnet on one of the rollers and counting the number of rotations over a known period. An initial step is to confirm the functionality of the Hall sensor by illuminating an LED as the magnet passes. This feature will be integrated into the final design to indicate operational speed sensing and facilitate development with the Attiny44 microcontroller. The first design step involved selecting a current-limiting resistor for the LED. With a maximum allowable current of 40mA and a required voltage drop of 1.8V across the LED, a minimum resistor value of 80 ohms was determined. A misunderstanding led to the initial choice of a 10K resistor, as a current of approximately 10mA is necessary for the LED to illuminate. According to Ohm's law, a resistor value around 320 ohms was calculated, leading to the selection of a 500-ohm resistor. The Allegro A130x series of Hall sensors in the FabLab inventory were reviewed and deemed suitable for the application. The output signal from the sensor is centered on Vcc/2, swinging up to Vcc and down to ground, depending on the polarity of the passing magnet. Consequently, an Analog to Digital Converter (ADC) on the Attiny44 is required to read the input signal, necessitating a bit on Port A for the input. After reviewing the data sheets for both the Hall sensor and the Attiny44, it was confirmed that no additional external circuitry was required to connect the two devices. Familiarity with Eagle was gained through tutorials on Sparkfun, leading to the creation of the circuit schematic. The auto-routing feature was utilized for the board trace layout, eliminating the need for jumpers by using a combination of Port A pins. The PCB was cut using the Modella, and components were mounted on the board. The resonator posed a challenge during mounting due to uncertainty about solder flow beneath it, resulting in the lifting of a copper track from overheating, although it did not require repair. The resonator is mechanically secured with three contacts. After verifying the board, programming was conducted using the FabISP. Limited programming experience prompted the use of the Arduino compiler for ease. The initial test programmed the controller to blink the LED every second. The subsequent step involved confirming that the controller was reading the Hall Effect sensor by monitoring the ADC output in a serial data stream sent to a computer. This was successful, yielding a stream of readings averaging 512, corresponding to Vcc/2 as anticipated, with changes occurring when a magnet was brought near the sensor.

The project employs a Hall Effect sensor to detect the rotational speed of a roller in a cycling roller setup. The Hall Effect sensor operates by producing a voltage output that varies based on the magnetic field detected from the magnet attached to the roller. The sensor's output is centered around half the supply voltage (Vcc/2), which necessitates the use of an ADC on the Attiny44 microcontroller to interpret the variations in the voltage signal as the magnet passes by. The selected 500-ohm current-limiting resistor ensures that the LED illuminates adequately, providing a visual indication of the sensor's operational status.

The integration of the Hall Effect sensor and the microcontroller is straightforward, as no additional circuitry is required beyond the basic connections. The programming of the Attiny44 is facilitated through the Arduino IDE, which simplifies the coding process for testing the sensor's functionality. The initial LED blinking test serves as a preliminary verification of the microcontroller's operation, while subsequent tests with the Hall Effect sensor confirm the system's ability to detect magnetic field changes and translate those into meaningful speed measurements.

For the physical assembly, attention must be paid to the mounting of components, especially the resonator, to ensure proper soldering and electrical connectivity. The use of the Modella for PCB fabrication allows for precise layouts, and the auto-routing feature aids in efficient trace design. Overall, this project highlights the practical application of Hall Effect sensors in speed detection for cycling rollers, combining electronic design, programming, and mechanical assembly into a cohesive final product.My final project, cycling rollers, requires a method of sensing the rotational speed of one of the rollers. Typically speed sensors on cycles work by detecting the passing of a magnet attached to a spoke on one of the wheels using a Hall Effect sensor or a reed switch.

I intend to use a similar principle to determine the road  speed of the rolle rs by placing a magnet on one of the rollers and counting the number of rotations in a known time. As an initial step towards this, I want to establish that I can use a Hall sensor in this way by having it illuminate an LED as it passes. This feature will be incorporated in the final design to allow a user to determine the speed sensing is operational and will allow me to start developing with the Attiny44.

The first step in the design was to select the current limiting resistor for the LED. Once I understood that the maximum allowable current was 40mA and that a voltage drop of 1. 8V was needed across the LED a minimum 80R resistor was needed. I mistakenly believed that a 10K resistor could be used as I did not initially understand that a current of order of 10mA is needed for the LED to illuminate. Ohms law indicates a resistor around 320R, hence the selection of 500R. I reviewed the data sheet for the Allegro A130x series of Hall sensors in the FabLab inventory and determined they were suitable for my need.

One feature of their operation was the output signal was centred on Vcc/2 swinging up to Vcc and down to Gnd depending on the polarity of the magnet passing the sensor. This meant that I needed to use an Analogue to Digital Convertor on the Attiny44 to read the input signal which in turn determined that a bit on Port A would be required for the input signal.

I reviewed the data sheets for the Hall sensor and the Attiny44 and determined no further external circuitry was needed to connect the two devices. Having become familiar with Eagle following the tutorials on Sparkfun, I drew the schematic for my circuit.

Once I had inputted that, I used the auto-routing feature to layout the board traces. I found that I could eliminate the need for any jumpers by utilising a combination of Port A pins which I finally selected. I cut the PCB using the Modella and mounted the components on the board. I found the resonator particularly difficult to mount as I could not be sure solder had flowed underneath it.

I managed to lift a copper track through overheating the board whilst doing this, although it was not broken and did not need repairing. Mechanically it is held in place as the resonator has 3 contacts holding it in position. Once the board was checked I programmed it using the FabISP. My programming experience is limited so I elected to use the Arduino compiler to ease this process. As a test, I first programmed the controller to blink the LED on and off every second. The next step was to establish the controller was reading the Hall Effect sensor by reading the ADC output in a serial data stream sent to my computer.

This was successful and showed a stream of readings averaging 512 corresponding to Vcc/2 as expected, changing when a magnet was passed near the sensor. 🔗 External reference