Bike Speedometer Exploits Magnetic Sensor

Sensors Insights by Aznan Firmansyah

This article focuses on creating an accurate bike speedometer using a GreenPAK and a magnetic sensor. Two methods are used to approach this application: the first uses the frequency detect blocks of the SLG46536V, the second method centers on a RPM counter design. The nominal resolution of this application is 1 m/s but can be changed depending upon the number of magnets used on the wheel.

 

Introduction

When measuring and displaying the speed of a bicycle wheel using a magnetic sensor, the system should be able to interpret measurement in meters per second. To realize this system, we will attach a sensor device on the bicycle. Our GreenPAK design will then perform logical operations to update the output periodically or simultaneously to interpret measurement results using 4 binary digits. This application is designed to be precise up to 1 m/s.

The input of the system is a digital signal from a magnetic switch. The magnetic switch is used because, though both magnetic and optical sensors are known to be used in tachometers, magnetic switches are favorable for applications that have ambient light. This is critical for a solution that can be easily-affixed to a bicycle. In this application, every full rotation of the wheel represents 2m traveled (roughly the circumference of the wheel). For this application note we will try two designs, both of which have their pros and cons. The first design utilizes the frequency detector of the SLG46536 to determine the rotational speed of the bike. The second uses the typical RPM method of incrementing the number of pulses (full rotations) over a given period.

The key advantages to using a Dialog GreenPAK are it is smaller, lower cost, simpler, and easier to develop than most other solutions. Furthermore, the sensor design for the bike speedometer can be modified into more intensive projects, such as the internal speedometer for an electric bike or moped. A microcontroller could be used as well, but the size and power consumption of the microcontroller can make it less appealing to a customer.

The system can be tested by inspecting the digital output signal. For this application we use between four to six LEDs for visual representation of the data. Each LED represents a single bit of a binary sequence. The application has been tested by comparing the digital output of the sensor to various radial speeds of a wheel. To show this solution is appealing for the biking industry we can evaluate dimension, development capability, and other parameters of comparison.

 

First Design: Frequency Detector

In terms of components, the SLG46536 is one of the meatier GreenPAK ICs; it has a large amount of counter/delay/frequency detector blocks. The frequency detector of the counter blocks acts like a frequency filter and can be configured by set counter data. From the counter data a signal will be generated that will determine if the incoming pulses occur frequently than the given period. For this IC there are two types of frequency detectors, namely 8-bit and 16-bit. Accordingly, to generate more precise measurements, more bits are better than fewer. For this application we use both. 

If the input of this block has a higher frequency than the configured frequency, the frequency block will output a digital high.  Two 16-bit CNT blocks, utilized as a frequency detector, are shown below:

Fig. 1: Frequency Detector Configuration for Speed 1 m/s (Left Side) and 2 m/s (Right Side).
Fig. 1: Frequency Detector Configuration for Speed 1 m/s (Left Side) and 2 m/s (Right Side).

The application’s wheel circumference is 2.06 m. Consequently, when the wheel of the bike rotates at least one time in 2.060s the horizontal speed of the bike is more than 1 m/s. Because of that, we set counter data to 803 with clock source OSC0 CLK/64. By these calculations the period of the block will be 2.05824s, since this is the closest configurable value to 2.060s.

Similarly, we wish to configure the second frequency detector to detect speeds of more than 2 m/s. The wheel of the bike should rotate at least one time in 1.030s. We thereby set the counter data to 401 with clock source OSC0 CLK/64, to make period of block 1.02912s. This methodology will be implemented for the other speeds, i.e. 3 to 7 m/s, for a single IC in this application. The output of each frequency detector will be described in Table 1.

 

Table 1

If we want to measure more than 7 m/s, we can extend it by adding another IC. If another IC is added the maximum speed will be up to 14 m/s. This speed is fast enough for a bike.

Fig. 2: GreenPAK Design for First Method with Measurement Range 0 to 7 m/s.
Fig. 2: GreenPAK Design for First Method with Measurement Range 0 to 7 m/s.

Every increase of speed by 1 m/s uses one counter block for detection. So, for this design we only can measure up to 7 m/s with a resolution of 1m/s. However, this design can be extended by adding more ICs. The digital circuit on this design converts bit from Table 1 to a 3-bit binary sequence, which are output on B2:B0.

Table2

 

Table 3

B. Extended Version of Speedometer with Speed Range from 0 to 14 m/s

From the previous design, we know that the maximum speed is only up to 7 m/s. So, by adding one more IC we will scale up the maximum speed up to 14 m/s. Below is a GreenPAK design and configuration that has been implemented with the SLG46536V.

Fig. 3: GreenPAK Design for Extended of First Method with Measurement Range 8 to 14 m/s.
Fig. 3: GreenPAK Design for Extended of First Method with Measurement Range 8 to 14 m/s. 

Overall, the design for the extended IC is like the main IC. However, the output of the main IC will also be an input of the extended IC. The overall system using two ICs for this application is shown by the diagram below.

Fig. 4: System Diagram for Using Frequency Detector with Double IC.
Fig. 4: System Diagram for Using Frequency Detector with Double IC.

 

Second Design: RPM Counter

The second design is a very different method of reading speed than the first. In this design we are using a full-adder digital circuit. Every cycle of the wheel will increment the counter by one. The counter will reset after a given period. For this design we use 2.06s as the period; this also becomes the refresh-rate of the measured result. So, if there is only one cycle in 2.06s, it means the bike’s speed is only 1 m/s. If there are 2 cycles in 2.06s, it means the bike’s speed is 2 m/s, and so on.

Fig. 5: GreenPAK Design Using RPM Counter.
Fig. 5: GreenPAK Design Using RPM Counter.

In this design, the maximum speed can be measured up to 63 m/s (6-bit output). There are many options to optimize this method based on our need. For example, it’s possible to improve the measurement accuracy to 1 km/h; the output will update for every 2.06 x 3.6 = 7.42 s. Since this refresh rate would be unusable for many applications, another choice would be to improve the accuracy up to 2 km/h and update the output every 3.71 s.

So, the measurement result will be multiplication of 2 km/h such as, 2, 4, 6, 8, 10 and so on. In this fashion the design also may be implemented in 3 km/h of accuracy and will update the output every 2,472 ms. The system diagram of this method is illustrated in figure 6.

Fig. 6: System Diagram for RPM Counter Method.
Fig. 6: System Diagram for RPM Counter Method.

The simplest method to improve accuracy would be to have more than one magnet on the wheel; this would ensure multiple pulses of per rotation and would give better resolution in RPM.

 

Results

Now we have two alternative designs for comparison:

Table 5

 

In most circumstances the second design is likely a better application. So, for the next capture, we will focus on the second design, namely using the RPM counter.

Fig. 7: Simulate Circuit Design Using Dialog Development Board.
Fig. 7: Simulate Circuit Design Using Dialog Development Board.

 

Fig. 8: Prototype Circuit Using LED for 5-bit Output.
Fig. 8: Prototype Circuit Using LED for 5-bit Output.
 

 

Fig. 9: Magnet and Magnetic Switch Attached to Bicycle.
Fig. 9: Magnet and Magnetic Switch Attached to Bicycle.

We used the back wheel of the bicycle to test our speedometer designs. So, below are the measurement results for each wheel speed. There are 5 LEDs. The Most Significant Bit is interpreted by the LED on the left side.

Fig. 10: LED Output.
Fig. 10: LED Output.

Figure 10 shows the results for the first 4 bits (up to 7 m/s), where we can see that the design was able to output the binary value of the bike’s velocity.

One alternative solution to using the GreenPAK would be to use a small microcontroller, such as an Attiny85. However, using a MCU has its own disadvantages – such as knowing how to program it, which programming environment to use, as well as increased cost and size.

 

Table 6

 

Conclusion

In this application note we outlined how to create a simple bike speedometer with a Dialog GreenPAK SLG46536V. We were able to measure the rotational speed of the bicycle wheel with a magnetic sensor. We demonstrated two approaches to solving this problem – a frequency method and an RPM method. The RPM counter could also be used for other applications such as anemometers, tachometers, etc.

 

About the author

Aznan Firmansyah graduated from Bandung Institute of Technology at the School of Electrical Engineering and Informatics in 2016. Presently he's working as electrical engineer on Bhimasena Research and Development. His sphere of interest has included robotics, electronics design, image processing, and programming language.