The Association of Model Submariners.

Would you like to react to this message? Create an account in a few clicks or log in to continue.

* THE FORUM FOR ALL THOSE INTERESTED IN BUILDING AND OPERATING MODEL SUBMARINES *


Cheap Arduino Auto leveler  14212712

Just a reminder that this Forum will close for posts next November (2025) . It will continue to be available as a reference on the Wayback Machine https://web.archive.org/

Cheap Arduino Auto leveler  14212712

For a guide to past events see the "Shows and Events" section.
B i
::::

S

P~~~

$$$

Who is online?

In total there are 21 users online :: 0 Registered, 0 Hidden and 21 Guests :: 1 Bot

None


Most users ever online was 180 on Tue Nov 05, 2019 6:03 am

Latest topics

» Futaba -868/915mhz equipment
Cheap Arduino Auto leveler  EmptyTue Oct 29, 2024 4:46 pm by tsenecal

» RC Drift Gyro for pitch control
Cheap Arduino Auto leveler  EmptySun Oct 20, 2024 2:04 pm by geofrancis

» WW2 mini sub build
Cheap Arduino Auto leveler  EmptyThu Oct 17, 2024 2:34 pm by geofrancis

» sonar data link
Cheap Arduino Auto leveler  EmptyMon Oct 14, 2024 4:31 pm by geofrancis

» Robbe Seawolf V2
Cheap Arduino Auto leveler  EmptySat Oct 12, 2024 3:52 pm by geofrancis

» ExpressLRS - 868/915 Mhz equipment
Cheap Arduino Auto leveler  EmptyFri Oct 11, 2024 8:58 pm by Marylandradiosailor

» Flight controllers as sub levelers
Cheap Arduino Auto leveler  EmptyFri Oct 11, 2024 8:14 pm by geofrancis

» 868/915 Mhz as a viable frequency for submarines.
Cheap Arduino Auto leveler  EmptyThu Oct 10, 2024 3:21 am by tsenecal

» Microgyro pitch controller corrosion
Cheap Arduino Auto leveler  EmptyWed Oct 02, 2024 11:32 am by geofrancis

Statistics

Our users have posted a total of 12534 messages in 1992 subjects

We have 1021 registered users

The newest registered user is Mike Echo

3 posters

    Cheap Arduino Auto leveler

    avatar
    geofrancis


    Posts : 323
    Join date : 2021-09-24

    Cheap Arduino Auto leveler  Empty Cheap Arduino Auto leveler

    Post  geofrancis Thu May 11, 2023 2:38 pm

    I just found this video on youtube showing a very cheap arduino based sub leveler based on Atmega328 and a MPU6050 IMU looks interesting, I havent tested it myself.




    Code:
     
    #include Wire.h
    #include MPU6050_light.h
    #include Servo.h
    #include ServoInput.h

    //Define Variables we'll be connecting to
    double Setpoint, Input, Output, Gain1, Gain2;

    ServoInputPin-3- TR;                //angled brackets here
    //Signal diveplane from receiver to PWM pin 2
    ServoInputPin-2- Switch(800, 1800);  //angled brackets here
    //switch signal from receiver  PWM pin 3 cal for 3Pos switch Transmitter channel 5 (mc-10)

    const int NumPositions = 3;

    Servo servoTR;                    
     //creates a Servo with the name „servoTR“ =Tiefenruder

    MPU6050 mpu(Wire);

    void setup()
    {
        Serial.begin(9600);
        Serial.flush();
        Wire.begin();
        mpu.begin();
        //Serial.println(F("Calculating gyro offset, do not move MPU6050"));
        //delay(1000);
        mpu.calcGyroOffsets();
        Serial.println("Done.");


        //Input = mpu.getAngleX();
        Setpoint = 100;     //0-Referenz of gyro, approx. in degrees servo arm (0...180)
        Gain1 = 5;          
        Gain2 = 7;          

        servoTR.attach(8); // Servo  signal wire (yellow)  connected to pin 8
    }

    void loop()
    {
        mpu.update();

        float rudder = TR.getAngle();                
    // get angle of servo (0 - 180) TR input from receiver
     
        int position = Switch.map(1, NumPositions);  // get Switch pos 1-3
      
      
        if (position ==1)
     {
        servoTR.write(Setpoint - mpu.getAngleX() * Gain1);  
      }
        else if (position==2)
       {
        servoTR.write(Setpoint - mpu.getAngleX() * Gain2);
       }
      
        else
      {
        Output = rudder;          // schleift Senderinput durch zu TR Servo
        servoTR.write(Output);
      }
        
        
    // Serial.print("Switch Position: ");
    // Serial.println(position);
    //    
    // Serial.println(rudder);
      
    //    
    //  Serial.println("\tY: " + String(mpu.getAngleY()));
    //    delay(50);
    }

    Deep Diver (Fred), david f and C-3PO like this post

    C-3PO
    C-3PO


    Posts : 95
    Join date : 2018-11-21
    Location : Northamptonshire UK

    Cheap Arduino Auto leveler  Empty Re: Cheap Arduino Auto leveler

    Post  C-3PO Sat May 13, 2023 11:23 am

    I have not tried code - but to get it to compile you need to add  < & > as per yellow highlights

    Cheap Arduino Auto leveler  Levell10

    Why do people hammer their code in the loop millions of times per second!!!

    Regards
    Jonathan

    Deep Diver (Fred), david f and geofrancis like this post

    avatar
    17b


    Posts : 9
    Join date : 2023-06-19

    Cheap Arduino Auto leveler  Empty Re: Cheap Arduino Auto leveler

    Post  17b Thu Dec 28, 2023 11:30 pm

    Hi Guys, inspired by this code and the YT Video i made a leveller/depth controller by myself. All work till now is documented on my HP. Unfortunately its only in german.
    Code and Layout can be sent per mail if anyone ist interested.

    This is Work in Progress

    https://www.rc-sub.de/component/content/article/161-lage-tiefenregler-auf-arduino-basis?catid=27:elektronik-mit-arduino&Itemid=2080

    Deep Diver (Fred), david f, C-3PO and geofrancis like this post

    C-3PO
    C-3PO


    Posts : 95
    Join date : 2018-11-21
    Location : Northamptonshire UK

    Cheap Arduino Auto leveler  Empty Re: Cheap Arduino Auto leveler

    Post  C-3PO Fri Dec 29, 2023 8:26 am

    Hi 17b,

    Great project - I cannot remember - you might want to check out i2c pullup resistors - not sure if Pro Mini has them on board


    I2C and pull-up resistors

    For effective data transmission with the Inter-Integrated Circuit (I2C) protocol using Arduino, it’s often necessary to use external pull-up resistors on the designated I2C pins. Most Arduino boards don’t have pre-installed pull-up resistors on these pins, but instead they offer exposed pads for surface mount resistors. This gives more flexibity on how these pins can be used. More specifically:


    Regards
    C-3PO
    avatar
    17b


    Posts : 9
    Join date : 2023-06-19

    Cheap Arduino Auto leveler  Empty Re: Cheap Arduino Auto leveler

    Post  17b Fri Dec 29, 2023 8:47 am

    Hi, the MPU6050 has two 2k2 Resistors onboard. The Leveller works flawlessly

    C-3PO likes this post

    C-3PO
    C-3PO


    Posts : 95
    Join date : 2018-11-21
    Location : Northamptonshire UK

    Cheap Arduino Auto leveler  Empty Re: Cheap Arduino Auto leveler

    Post  C-3PO Fri Dec 29, 2023 9:01 am

    Hi 17b,

    Great - I did not know that - "everyday is a school day..."

    Regards
    C-3PO
    avatar
    geofrancis


    Posts : 323
    Join date : 2021-09-24

    Cheap Arduino Auto leveler  Empty Re: Cheap Arduino Auto leveler

    Post  geofrancis Fri Dec 29, 2023 2:56 pm

    17b wrote:Hi Guys, inspired by this code and the YT Video i made a leveller/depth controller by myself. All work till now is documented on my HP. Unfortunately its only in german.
    Code and Layout can be sent per mail if anyone ist interested.

    This is Work in Progress

    https://www.rc-sub.de/component/content/article/161-lage-tiefenregler-auf-arduino-basis?catid=27:elektronik-mit-arduino&Itemid=2080

    for pid control you should look at this library
    https://github.com/br3ttb/Arduino-PID-Library
    avatar
    17b


    Posts : 9
    Join date : 2023-06-19

    Cheap Arduino Auto leveler  Empty Re: Cheap Arduino Auto leveler

    Post  17b Fri Dec 29, 2023 6:19 pm

    geofrancis wrote:

    for pid control you should look at this library
    https://github.com/br3ttb/Arduino-PID-Library

    I will check it for further improvements. Seems to be easy to use. Exactly the right for me.

    BTW, are there actually any levellers out there which use PID? As i know from german manufacturers like Brüggen or Momo, they only use P for their levellers. I still have some old completely analog levellers from Nils Canditt who use PID, but they are discontinued since maybe 10 years or so.

    Deep Diver (Fred) and david f like this post

    avatar
    geofrancis


    Posts : 323
    Join date : 2021-09-24

    Cheap Arduino Auto leveler  Empty Re: Cheap Arduino Auto leveler

    Post  geofrancis Fri Dec 29, 2023 7:34 pm

    17b wrote:
    geofrancis wrote:

    for pid control you should look at this library
    https://github.com/br3ttb/Arduino-PID-Library

    I will check it for further improvements. Seems to be easy to use. Exactly the right for me.

    BTW, are there actually any levellers out there which use PID? As i know from german manufacturers like Brüggen or Momo, they only use P for their levellers. I still have some old completely analog levellers from Nils Canditt who use PID, but they are discontinued since maybe 10 years or so.


    You can just set the I and d to zero if you dont need it for leveling but you will need it for depth control.

    Deep Diver (Fred) and david f like this post

    avatar
    17b


    Posts : 9
    Join date : 2023-06-19

    Cheap Arduino Auto leveler  Empty Re: Cheap Arduino Auto leveler

    Post  17b Sat May 11, 2024 6:53 pm

    Folks, i nearly finished my depth Controller. As i promised, i will share my Designs and Code. Right now the depth Controller ist very well useable, i use it in my 202 Friedrich Schürer. There is also a second different build with an X-Mixer and no depth sensor. My next step is to merge them into one universal Board, the PCBs from China arrive next week.
    Here is a link to my (german) Webpage:
    https://www.rc-sub.de/elektronik-mit-picaxe/161-lage-tiefenregler-auf-arduino-basis

    Please remember, this is still Work in Progress.

    If you have any questions, feel free to ask.

    Deep Diver (Fred) and geofrancis like this post


      Current date/time is Thu Nov 21, 2024 6:28 am