Results 1 to 1 of 1
  1. #1
    150+ Forum Groupie skino's Avatar
    Join Date
    Nov 2008
    Location
    germany
    Posts
    299
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Arduino servo compass: simple and inexpensive

    For a friend I made a wet compass in 737 style. The costs are about 10 euros and the effort is very manageable. This was the model which he wanted:



    and this is the result (i am not very skilled so it does not look good):



    The basic principle:
    I use a servo, no stepper. This is easier and more cost-effective. The downside is that it does not rotate continuously 360 degrees but only 180 degrees and then turns back.
    But firstly it happens rather rarely and secondly in a 737 or an A320 the compass is not necessarily the main navigational device ^ ^. The meaning is simply the completion of the Sims not with a dummy but a functioning device.


    Since the servo turns only 180 degrees the compass scale has to be adjusted





    The range from "N" to "N" is used. The scale between them must have half the circumference of the compass drum or disc. This scale is required 2x.I have printed the scale on photo paper. This is so stable that no drum is needed and it is backlit.
    On the servo I screwed the control cross and on it with superglue a disc in the right diameter. A drum would surely be something more professional but that must decide everyone for themselves. The scale is then applied to the disc or drum. 2x, so the front and back look roughly the same. This is necessary, as otherwise an empty range without scale would be visible at 0 or 180 degrees servo position. That looks stupid. I have tested it -un-voluntarily.








    The servo is then connected with 3 cables to the Arduino Uno or Mega. I used a 5 Euro Uno from China (eBay), which works without problems.
    Anyone who wants to use my software has to pay attention that the control cable of the servo is located on Pin # 9. Otherwise the pin in the .INO file must be adapted to myservo.attach (9). Just enter the desired pin instead of the 9.

    Code:
    #include 
    String readString;
    Servo myservo;  // create servo object to control a servo
    
    
    void setup() {
      Serial.begin(9600);
      myservo.attach(9);
      pinMode(13, OUTPUT);
      digitalWrite(13, LOW);





    Then build a suitable housing or print 3D. The hardware is now ready. If-as with me- a Micro or Miniservo is used the servo can be powered via USB. Otherwise, a power supply is required for the Arduino.












    For the background lighting I have a white LED with a 220 Ohm resistor with one leg to ground and the other leg soldered to the switch. From the switch, a wire to + 5 Volt and to + 3.3 Volt to the Arduino to get 2 different brightness (DIM and BRIGHT). In the middle position, the LED is off.
    The switch is an ON-OFF-ON.
    Because all this is soooo beautifully simple I have immediately built a 777 variant for me



    Next, the Arduino is installed and the .INO code is uploaded for this project (included in the ZIP).
    He came from the Arduino Forum, but was adapted. How exactly to upload this to the Arduino please search on Google or YT.
    That's it. Start the FS ,FSUIPC, WideFS or XUIPC required.
    When the flight is loaded start the driver. If everything is OK, the driver minimizes itself immediately. Otherwise it is visible to detect and solve problems.

    It is important to set the correct port for the Arduino. Which is you can see in the device manager.



    The compass value is displayed in the large white field. In the small black field underneath, the value sent to the servo. This is half of the correct value (rounded), since the servo, as explained in the beginning, only turns 180 degrees instead of 360 degrees. The FSUIPC button turns green when connected. If it is not connected can be connected by clicking manually to FSUIPC.
    "Ok" minimizes the program. The rest is self-explanatory. Help explains how to calibrate the compass within certain limits if it is not exactly built on the hardware side.
    The program does not have to be installed and can be placed anywhere on the hard drive. It MUST only be in the same folder as the associated DLL.


    Download here from my dropbox. Contains all necessary files including a scale template.

    https://www.dropbox.com/s/7it1rtywmj...mpass.zip?dl=0


    If you want to try it, have fun and success with the self build

    PS: The sound of the rotating servo is much quieter than expected and contributes more to the cockpit ambience than to disturb.

    Peter





    Attached Files Attached Files

  2. Thanks bizjet999, anijan, BushPilotWannabe thanked for this post