VHDL Motor Speed Control : Motor Speed Driver & Measurement
by billychen102 in Circuits > Computers
1122 Views, 2 Favorites, 0 Comments
VHDL Motor Speed Control : Motor Speed Driver & Measurement
NOTE: This page is one part of a larger build. Please ensure you start HERE, so you understand where the following fits in within the larger project.
In order to run the two motors on the robot, we need a program that able to translate the command from the control unit into the shape of Pulse Width Modulation ( PWM ) to determine how fast the robot is and the direction pulse so we are able to run the robot. Not only that, to control the direction of the robot. On the other hand, we need to measure the movement of the robot. That is why the measurement of the system is necessary for the smoothness of the robot's run. In this Instructable, we will show you and explain the parts needed for the whole system of Motor Driver and Measurement.
Our system consists of :
Motor Driver :
- Speed PWM Generator
Speed Measurement :
- Encoder
- Counter
- Shift Register
- Subtractor
- Seven Segment
SPEED PWM GENERATOR
As its name suggests, pulse width modulation speed control works by driving the motor with a series of “ON-OFF” pulses and varying the duty cycle, the fraction of time that the output voltage is “ON” compared to when it is “OFF”, of the pulses while keeping the frequency constant.
The power applied to the motor can be controlled by varying the width of these applied pulses and thereby varying the average DC voltage applied to the terminals of the motor. By changing or modulating the timing of these pulses the speed of the motor can be controlled, ie, the longer the pulse is “ON”, the faster the motor will rotate, and likewise, the shorter the pulse is “ON” the slower the motor will rotate. In other words, the wider the pulse width, the more average voltage applied to the motor terminals, the stronger the magnetic flux inside the armature windings, and the faster the motor will rotate and this is shown below. Other than that, from this generator, we can control the direction as well. The input of the direction will be the high and low signals. For instance, if we set the signal of the direction to the high position, it will turn the motor in CCW condition, otherwise, it would become CW.
To find out more about this, you can click here >> HERE
SPEED MEASUREMENT
Starting from here, we will work on measuring the speed and giving feedback on the speed and direction of the motor. Speed measurement will be divided into 6 steps and each of them will be required in different files and has different functions.
ENCODER
In this part, we made an encoder that is used for speed control feedback in DC motors where an armature or rotor with wound wires rotates inside a magnetic field created by a stator. The DC motor encoder provides a mechanism to measure the speed of the rotor and provide closed-loop feedback to the drive for precise speed control. This is achieved by making markings on the face of the motor that is in line with the rotating axis and this marking is then converted to code so that we can see the rotation of the motor and the direction of the rotating motor.
To find out more about this, you can click here >> HERE
COUNTER
In this part of the code, it has the function to count up or count down the value of binary that is sent passing through this part. We make it this way because we want to make a counting timing device that will activate according to the limit of count that is determined from the user input. The upper limit of the count is user programmable and the counter’s increment value can be user-defined. The signal is then sent to the Shift Register. In the code that we have to build, we use an internal signal for the value of the count named count_in, we also have count_up and count_dwn to increase or increase the value of the counting by 1 so we can make the counter count up or count down depending on the circumstance that we need it. We also made a reset setting to reset the value of the count_in just in case we need to reset the system.
To find out more about this, you can click here >> HERE
SHIFT REGISTER
In this part of Speed measurement, we will be discussing the Shift register and its function. This sequential device loads the data present on its inputs and then move or “shifts” it to its output once every clock cycle, hence the name Shift Register.
A shift register basically consists of several single bit “D-Type Data Latches”, one for each data bit, either a logic “0” or a “1”, connected together in a serial type daisy-chain arrangement so that the output from one data latch becomes the input of the next latch and so on. Data bits may be fed in or out of a shift register serially, that is one after the other from either the left or the right direction, or all together at the same time in a parallel configuration.
in this 8 Bit shift register, we're gonna use the SIPO (serial-in parallel-out)type of shift register.
To find out more about this, you can click here >> HERE
SUBSTRACTOR
We need a subtractor in this code to determine the feedback of the motor so it could be sent and processed by error management code. The subtractor can be adjusted according to the amount of the shift registers needed to shift the state value. Therefore, the right feedback calculation can be done.
To find out more about this, you can click here >>HERE
SEVEN SEGMENT
In this part, we are using a seven-segment which is an output display device that provides a way to display information in the form of hex numbers which is an alternative to a more complex dot matrix display. It is used to display the result of the subtractor. So, we have the visualization of the feedback measurement.
To find out more about this, you can click here >> HERE
Conclusion
In conclusion, the purpose of the motor driver is to drive the motor by giving the H bridge PWM signal with a certain duty cycle and high-low signal to control the direction of the motor. As for the speed measurement, its purpose is to measure the feedback speed and direction given by the motor and send it to the error management
code to be later processed.
Some of the code was inspired from the references below :
PWM Generator :
https://www.fpga4student.com/2017/06/pwm-generator...
Shift Register :
https://www.electronics-tutorials.ws/sequential/se...
Counter :
https://www.engineersgarage.com/vhdl-tutorial-19-d...
7 Segment :
https://www.fpga4student.com/2017/09/vhdl-code-for...
Encoder :
https://motion-drives.com/what-does-an-rotary-enco...
Below is the file contains a more detailed version of the system