So I am pretty new to programming, and I thought I would step into this world since I think it is pretty interesting.
I do have the Arduino UNO, the Bar30 High-Resolution with the I2C Level Converter and the T100 Thruster with the basic ESC speed controller.
My goal is to make something simple like:
If it reached let’s say 2 meters, the thrusters would start spinning so that it stays at that position / or goes up a few centimetres and will switch off until it reached the 2 Meters and so on.
To be honest, I do not know where to start, and it would be great if could have a little help throughout this project.
You’ll need a attitude sensor (IMU, acc, gyr, mac, etc…) to estimate roll/pitch/yaw to be able to do some stabilization.
Also, it’s necessary to take a look in some basic attitude control algorithms or logic (PID, Fuzzy, H - infinity, etc…) and filters (Loss-pass filter, FIR, IIR, Kalman or EKF).
Probably @williangalvani can give his two cents about this.
I would recommend to do some kind of simulation (if possible) to learn this kind of stuff before putting everything together.
Since you are just starting, start from the basics, but I have some nice steps if you wish to go further.
Make an on-off controller: if depth is lower then X cm under what you want, send a PWM to to up. if it is higher, send a PWM to go down. in the middle, don’t do anything
Make a Proportional controller: Write a loop measuring the distance from your target height, and output a PWM proportional to that difference (kc*error) play with the gain and see what you get
Make a Proportional-Integral controller: In the loop you had before, start integrating (basically summing) the error over time, and add another term proportional to that, play with the gains again and see what you get. with a PI controller you should be able to track your target correctly
Add a derivative term: Here things start to get interesting. Add another term for the derivative of the error and add a new gain for that ( kc*error + ki*sum_error + kd*delta_error). With this you should be able to speed up the response and better resist to disturbances.
Now you can start looking at sensor fusion, try to make a simple filter to get a better depth reading from accelerometer and pressure, for example.
For the electronics and programming part, first make sure both systems work isolated.
First try to run the motor using the Arduino. I suggest you use this example to make it work. avoid running the thruster on air, as it is water-cooled!
Then get the pressure sensor working.
When you know both works, you can write the control code using both.