kowala's home

kowala's home
這裡是我的學習筆記,陸續增加中。
http://kowala21.blogspot.com

2014-07-21

萬有引力從何而來?

萬有引力從何而來?這是現在最大的謎,解開了話,UFO動力問題也解開了。

簡單的說,目前磁力可以被製造,馬達就是了,但萬有引力沒辦法被製造,只能觀察,
例如你在地球上70KG,上月球就變成42KG了

如果:
我是說如果,我們已經發現萬有引力的機制,那我們可以任意產生個引力,

假如我就產生個>70KG的引力,方向與地球相反

那我就飛起來了,不用噴氣,不用磁場(也許要,也許磁場跟引力有關),不用螺旋槳。

那我就是UFO了,而且好處不只這些,我根本不用考慮慣性問題,不必管那幾個G。

因為我的重力參考原點是我自己,不是地球,所以我的G是我自己控制,根本不用管地球的G

那我就可以任意大於90度轉向,而不會血管爆裂。

這樣說夠迷人吧,這就是解開重力之謎的好處。

2014-07-11

Arduino GY-271 HMC5883L 三軸電子羅盤傳感器測試

下面是 GY-271 廠商的描述
用途:測量地磁方向,測量物體靜止時候的方向,測量傳感器周圍磁力線的方向。註意,測量地磁時候容易受到周圍磁場影響,主芯片HMC5883三軸磁阻傳感器特點:

1,數字量輸出:I2C數字量輸出接口,設計使用非常方便。
2,尺寸小: 3x3x0.9mm LCC封裝,適合大規模量產使用。
3,精度高:1-2度,內置12位A/D,OFFSET, SET/RESET 電路,不會出現磁飽和現象,不會有累加誤差。
4,支持自動校準程序,簡化使用步驟,終端產品使用非常方便。
5,內置自測試電路,方便量產測試,無需增加額外昂貴的測試設備。
6,功耗低:供電電壓1.8V, 功耗睡眠模式-2.5uA 測量模式-0.6mA



連接:
只要連接VCC,GND,SDA,SCL四條線。

Arduino  GY-271
-------------------------
VCC         VCC
GND        GND
A4            SDA
A5            SCL

P.S.我這塊 GY-271 是可以輸入 5V DC,但有的只能輸入3.3V DC,這個要看廠家的說明。

程式碼:

/*
HMC5883L_Example.pde - Example sketch for integration with an HMC5883L triple axis magnetomerwe.
Copyright (C) 2011 Love Electronics (loveelectronics.co.uk)

This program is free software: you can redistribute it and/or modify
it under the terms of the version 3 GNU General Public License as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

// Reference the I2C 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(){
  // Initialize the serial port.
  Serial.begin(9600);
  Serial.println("Starting the I2C interface.");
  Wire.begin(); // Start the I2C interface.
  Serial.println("Constructing new HMC5883L");
  compass = HMC5883L(); // Construct a new HMC5883 compass.   
  Serial.println("Setting scale to +/- 1.3 Ga");
  error = compass.SetScale(1.3); // Set the scale of the compass.
  // If there is an error, print it out.
  if(error != 0) Serial.println(compass.GetErrorText(error));
  // Set the measurement mode to Continuous
  Serial.println("Setting measurement mode to continous.");
  error = compass.SetMeasurementMode(Measurement_Continuous);
  // If there is an error, print it out.
  if(error != 0) Serial.println(compass.GetErrorText(error));
}

// Our main program loop.
void loop(){
  // Retrive the raw values from the compass (not scaled).
  MagnetometerRaw raw = compass.ReadRawAxis();
  // Retrived the scaled values from the compass (scaled to the configured scale).
  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);
 
  // Once you have your heading, you must then add your 'Declination Angle', which is the 'Error' of the magnetic field in your location.
  // Find yours here: http://www.magnetic-declination.com/
  // Mine is: 2� 37' W, which is 2.617 Degrees, or (which we need) 0.0456752665 radians, I will use 0.0457
  // If you cannot find your Declination, comment out these two lines, your compass will be slightly off.
  float declinationAngle = 0.0457;
  heading += declinationAngle;
 
  // Correct for when signs are reversed.
  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;

  // Output the data via the serial port.
  Output(raw, scaled, heading, headingDegrees);

  // Normally we would delay the application by 66ms to allow the loop
  // to run at 15Hz (default bandwidth for the HMC5883L).
  // However since we have a long serial out (104ms at 9600) we will let
  // it run at its natural speed.
  // delay(66);
}

// Output the data down the serial port.
void Output(MagnetometerRaw raw, MagnetometerScaled scaled, float heading, float headingDegrees){
   Serial.print("Raw:(x,y,z)=( ");
   Serial.print(raw.XAxis);
   Serial.print(", ");  
   Serial.print(raw.YAxis);
   Serial.print(", ");  
   Serial.print(raw.ZAxis);
   Serial.print(") Scaled:(x,y,z)=( ");  
   Serial.print(scaled.XAxis);
   Serial.print(", ");  
   Serial.print(scaled.YAxis);
   Serial.print(", ");  
   Serial.print(scaled.ZAxis);
   Serial.print(") Heading: ");
   Serial.print(heading);
   Serial.print(" Radians: ");
   Serial.print(headingDegrees);
   Serial.println(" Degrees.");
   delay(500);
}


執行結果

它只負責讀出三軸方向磁場強度,而角度要自己去算。

下載 HMC5883L LIB
https://www.dropbox.com/s/h062nnde78zts1l/HMC5883L.zip

參考資料
Arduino連接HMC5883L三軸電子羅盤傳感器
http://www.geek-workshop.com/thread-105-1-1.html