📜 ⬆️ ⬇️

Musical box and rotary encoder on FPGA board

Introduction


We have been working on our program to create the coolest (at least, the loudest) case.

It’s a bit like the FPGA’s buzzer. Finally, we will provide a link to a github repository where a reader can access the source code. You can make something similar.
So, let's start!

Hardware and Software



image






A brief story


A long time ago, it was decided to get closer to a hardware. Computer architecture course on FPGA boards. After some discussions, we chose to implement a system with a rotary encoder. It’s not really a problem. However, it turned out that FPGA's PS / 2 port is dead.
')
Eventually, it is melody that is played when the button is pressed.

Musical box


We can distinguish one note from another. Hence, it is possible to make it.

They are pretty easy to implement.

It is a signal that changes between high and low. It is a wavelength of light. I / O, I / O, I / O, I / O, I & O;

image

This picture was taken from here .

Cyclone IV has a clock generator with frequency 50 MHz. Using the definition of a square wave, it’s hard to derive the following formula:

x = (50 * 10 ^ 6) / (2 * n )

It is a number of ways to complete the process.

To make a buzzer generate waves with frequency n Hz we implemented a clock divider.
You can read here .

Another but :
It is not possible to play notes with low frequencies. So, we used the F # of the 4th octave to the C # of the 5th octave.

It is a flowchart of the musical box.

image

Rotary encoder


How does the rotary encoder work?

It has been made with a pair of conductor plates and two analogue sensors.

For example, it can be used to make it. So, at that moment we can know whether we are turning the encoder clockwise or counterclockwise. The sensor is the following: Every time when the sensor goes. If at that moment B is asserted, the encoder was turned clockwise, otherwise, counterclockwise. The word rotation

image

(the picture was stolen from howtomechatronics.com )

The rotary encoder

image

Also, we want to display the 8-segment display. This is a formula that we use is:

angle = ( number of rotations mod 20) * 18

Materials


The code of our project is here .

Here are the videos of the rotary encoder.

Authors : Amina Miftahova, Kamil Kamaliev, Lev Svalov.

Source: https://habr.com/ru/post/431612/


All Articles