Robin2:
Maybe we have different images in our respective heads about the way the system described by the OP actually works.
My problem is that I cannot see how it is possible to say "a little more up" if {A} you don't know the angle of the planes and {B} you have almost no control over the quantity of movement.
...R
Wait, didnt I mention the linear potentiometer can retrieve the angle of the planes? Now Im still reading on nested PIDs to plan somehing. I think adxl345 is a good option, so the 3 sensors would be the accelerometer, the sonar and the linear pot to tell the angle of planes. I was sill hoping we could get away with only 2 sensors thoug: sonar and potentiometer. But with only hose 2 pid loops, there is nothing monitoring the x axis acceleration, wich is a critical variable influencing the z position of the submersible, so this will not work, am i correct?
JCSB:
Wait, didnt I mention the linear potentiometer can retrieve the angle of the planes?
I don't recall seeing that anywhere.
If it is true then that alters the picture in a big way - I presume it means you can drive the planes to any pre-determined angle that you wish? Is that correct?
Is the sub ballasted so that it's always upright? Then you could skip the measurement of deck angle and just assume that it's always close enough to upright. But if the dive planes can steer it past 45-degrees nose-up or -down, then measurement would be advisable.
If it is true then that alters the picture in a big way - I presume it means you can drive the planes to any pre-determined angle that you wish? Is that correct?
...R
*I'm so sorry I forgot this big detail, probably because I was working on a debugging version of this project when I started this post..
So you can drive the planes to a said angle, but indirectly, because the linear actuator doesn't know at all what the angle is, it just moves until it reaches its limit if we don't tell it to stop (takes around 1.5 sec to go from completely closed to completely open, here is the documentation by the way Newton Gripper). We add the linear potentiometer to follow the planes movements and feedback their angle to the microcontroller.
MorganS:
Is the sub ballasted so that it's always upright? Then you could skip the measurement of deck angle and just assume that it's always close enough to upright. But if the dive planes can steer it past 45-degrees nose-up or -down, then measurement would be advisable.
It should be pretty stable, because we will have an horizontal caudal fin for stability, and the device will be towed with a rope attached around its head. But I was wondering, since the boat will be towing it at variable speeds, the x axis speed (following the boat at its speed) will be variable, and it will directly influence the speed at which diving planes convert this horizontal speed into vertical speed.. Is this horizontal speed therefore important to monitor? When the boat is moving fast, steeper angles will mean much faster going up or down in the water column? If you think this is not such an issue, I might have a reasonable control with a 2 parts nested PID, with the sonar monitoring the distance from seabed, and then the linear potentiometer, telling me what is the angle of the planes at that precise moment?
It says:
"First off, when the speed gets higher than the setpoint, the error gets negative, right? When then multiplied by the proportional constant, the output variable also is negative, but the PWM duty cycle is only 0-100% (or 0-255).
No, often when you control a motor the PID output is a signed value, positive for forward, negative for
backwards - then you can do full control by position or speed, forwards or backwards or stationary."
What does he mean by often? (referring to the PID output is often a signed value, giving ctrl for forward and backward values).. I believe this isn't the case for Arduino library, right? the output values range from 0 to 255? So, in my case, I'm struggling to get my output to be able to send negative values, because the code I have shared at the beginning of this post is completely wrong, comparing the output to the last cycle's output in a non functional way.. Are negative and positive range of values doable with the PID Arduino library?
I found I could not make sense of the Arduino PID library so I just took the three core formulas for calculating P. I and D and wrote my own code specific to my project.
The concept is very simple but, IMHO, things get very confusing because the PID library is written to be a "black box" that should work in every situation.