Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Control System] motor control #37

Open
philipesclamado opened this issue Jan 31, 2023 · 0 comments
Open

[Control System] motor control #37

philipesclamado opened this issue Jan 31, 2023 · 0 comments
Assignees

Comments

@philipesclamado
Copy link
Member

philipesclamado commented Jan 31, 2023

Desired speed and direction

  1. Define the predetermined path: Define the predetermined path for the boat to follow. This can be done by specifying a series of waypoints.
  2. Determine the boat's position relative to the predetermined path: Calculate the boat's position relative to the predetermined path using GPS data. This can be done by calculating the distance between the boat's current position and the nearest point on the predetermined path.
  3. Calculate the desired direction: Calculate the desired direction for the boat to follow based on the boat's position relative to the predetermined path. For example, if the boat is to the left of the predetermined path, it should steer right to return to the path.
  4. Calculate the desired speed: Calculate the desired speed for the boat to follow based on the boat's position relative to the predetermined path. For example, if the boat is far off the path, it may need to increase speed to reach the path quickly, while if it is close to the path, it can reduce speed to maintain accuracy.
  5. Adjust the motor output: Adjust the motor output based on the desired speed and direction calculated in steps 4 and 5. You can use a closed feedback loop with a motor controller and other sensors, such as a compass or gyroscope, to adjust the motor output as needed.

Actual speed and direction

  1. Calculate the distance travelled: Calculate the distance travelled between two GPS readings using the Haversine formula. The Haversine formula calculates the distance between two points on the surface of a sphere (in this case, the Earth) given their latitudes and longitudes. You can find implementations of the Haversine formula in various programming languages online.
  2. Calculate the time elapsed: Calculate the time elapsed between two GPS readings. This can be done by subtracting the time of the first GPS reading from the time of the second GPS reading.
  3. Calculate the speed: Divide the distance travelled by the time elapsed to calculate the speed of the boat. This will give you the boat's speed in units such as meters per second or miles per hour.
  4. Calculate the direction: Calculate the change in position between two GPS readings to determine the boat's direction. You can use the difference between the latitudes and longitudes of the two GPS readings to calculate the change in position. Then, you can use trigonometry to calculate the direction of the boat relative to the true north. For example, you can use the arctangent function to calculate the angle between the boat's position and true north.

Closed feedback loop

  1. Calculate the desired speed and direction: Determine the desired speed and direction based on the boat's course and any navigational commands. This can be done manually or by using a navigation algorithm.
  2. Calculate the actual speed and direction: Use the GPS data to calculate the actual speed and direction of the boat. You can use the distance travelled and time elapsed between GPS readings to calculate the speed and the change in position between GPS readings to calculate the direction.
  3. Compare the desired speed and direction with the actual speed and direction: Calculate the difference between the desired speed and direction and the actual speed and direction.
  4. Determine the motor output: Use the difference between the desired and actual speed and direction to determine the motor output. You can use a proportional-integral-derivative (PID) controller to control the motor output.
  5. Send the motor output to the motor controller: Use the microcontroller to send the motor output to the motor controller. The motor controller will adjust the motor speed and direction based on the feedback from the GPS data, and the process will repeat in a closed loop.
  6. Tune the PID controller: Tune the PID controller's parameters to ensure stable and accurate control of the motor output. This can be done by adjusting the proportional, integral, and derivative gain values until the boat responds as desired.
@philipesclamado philipesclamado changed the title [Control System] PID tuning [Control System] motor control Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants