# DIY Simple Build

(Caetano Chappuis) #1

Hello everyone,

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.

best wishes,
Caetano

Links:

(Patrick José Pereira) #2

Hi Caetano,

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.

(Willian Galvani) #3

Hi Caetano,

Since you are just starting, start from the basics, but I have some nice steps if you wish to go further.

1. 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

2. 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

3. 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

4. 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.

5. 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.

(Willian Galvani) #4

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.

(Caetano Chappuis) #5

Thank you very much for your suggestions. I will keep this page updated how far I come with that project

(Caetano Chappuis) #6

Thank you very much for the great answer, you really helped me a lot. I will keep this page updated how I come with my project.