Part 2 : Error Calculation

by sanjayanicholas668 in Circuits > Robots

187 Views, 1 Favorites, 0 Comments

Part 2 : Error Calculation

F6JIFCRKQ2CEPLP.png

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

Capture.JPG

Input

  1. L_GOAL
  2. R_GOAL
  3. L_FEEDBACK
  4. R_FEEDBACK

Output

  1. L_action
  2. R_action

Internal signal

  1. L_temp_action
  2. R_temp_action

Block Diagram

Error.png

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

BLOCK DIAGRAM.jpeg

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