نمایش نتایج: از 1 به 10 از 49
Like Tree23 لایک

موضوع: آی ام یو ( 10dof imu / ahrs ) نه محوره gy-80 - ماژول قطب نمای دیجیتال ، سنسور شتاب

Threaded View

  1. #2
    Junior Member
    تاریخ عضویت
    Sep 2013
    محل سکونت
    Iran
    نوشته ها
    22

    Hmc5883l

    برای راه اندازی این ماژول و هر چهار سنسور اون فقط کافیه 5 سیم اول رو طبق عکس به آردوینو متصل کنید و هیچ نیازی به وصل کردن سیم های دیگه نیست
    برای دیدن سایز بزرگ روی عکس کلیک کنید

نام: Screenshot (1).jpg
مشاهده: 692
حجم: 21.5 کیلو بایت

    برای راه اندازی سنسور HMC5883L یا همون قطب نمای خودمون باید فایل HMC5883L.zip رو دانلود کنید و بعد از اکسترکت کردن اون رو تو پوشه Library برنامه آردوینو قرار بدید
    و بعد از نمونه کد زیر استفاده کنید

    این نمونه کد خروجی قطب نما رو به دو صورت زاویه و رادیان نمایش میده.

    کد:
    #include <Wire.h>
    // Reference the HMC5883L Compass Library
    #include <HMC5883L.h>
    
    // Store our compass as a variable.
    HMC5883L compass;
    // Record any errors that may occur in the compass.
    int error = 0;
    
    // Out setup routine, here we will configure the microcontroller and compass.
    void setup()
    {
      Serial.begin(9600);
      Wire.begin(); // Start the I2C interface.
      compass = HMC5883L(); // Construct a new HMC5883 compass.
      error = compass.SetScale(1.3); // Set the scale of the compass.
      if(error != 0)
      error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous
      if(error != 0)
      Serial.println(compass.GetErrorText(error));
    }
    
    void loop()
    {
      MagnetometerRaw raw = compass.ReadRawAxis();
      MagnetometerScaled scaled = compass.ReadScaledAxis();
      
      // Values are accessed like so:
      int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis)
    
      // Calculate heading when the magnetometer is level, then correct for signs of axis.
      float heading = atan2(scaled.YAxis, scaled.XAxis);
      
      float declinationAngle = 0.0457;
      heading += declinationAngle;
      
      if(heading < 0)
        heading += 2*PI;
        
      // Check for wrap due to addition of declination.
      if(heading > 2*PI)
        heading -= 2*PI;
       
      // Convert radians to degrees for readability.
      float headingDegrees = heading * 180/M_PI; 
      
       Serial.print("Heading: ");
       Serial.print(heading);
       Serial.print(" Radians ");
       Serial.print(headingDegrees);
       Serial.println(" Degrees");
    }
    فایل های پیوست شده فایل های پیوست شده
    ویرایش توسط ehsan_1990 : 02-04-2014 در ساعت 07:35 AM

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  

SEO by vBSEO