Part 2 : Error Calculation
by sanjayanicholas668 in Circuits > Robots
201 Views, 2 Favorites, 0 Comments
Part 2 : Error Calculation
NOTE :This instructable is one part of a larger build. Please ensure you start at HDL Motor Speed Control, so you understand where the following fits in within the larger project.
The function of this block is to calculate error by doing substraction between the goal and the feedback of each motor. The result is action. Action is a 9 signed bit that will be transform to unsigned bit so the PWM (Pulse Wave Modulation) can read the bit number.
Signal Input & Output
Input
- L_GOAL
- R_GOAL
- L_FEEDBACK
- R_FEEDBACK
Output
- L_action
- R_action
Internal signal
- L_temp_action
- R_temp_action
Block Diagram
These are block diagram for error calculation.
- The square block function as a substractor between A and F
- The second Square ( limit ) function as a comparator
- The trapezoid block function as a multiplexor (MUX)
How It Works
This module calculate error for each motor. This module works by substracting 9 signed bit from goal and 9 signed bit from feedback. The result of the substraction is the action. Since we substract 9 bit with 9 bit so there is a chance of overflow in the action. Overflow is condition when the result show an extra bit that don’t fit in the used bits. Overflow can be solve here by maximize or minimize the error depending on the result. Because the bit is 9 signed bit so the range of the result is +255 to –256. The output that we want to is range from +255 to –255. We don’t use –256 because the signed bit can’t be translated to PWM.
Here's the link for VHDL code : Error.vhd