Tilt Compensated Digital Compass based on AVR
HTML-код
- Опубликовано: 10 сен 2024
- A simple, easy to build eCompass display using AVR ATmega8, HMC5883L magnetometer module, Accelerometer of MPU6050 module and 128x64 SSD1306 OLED display module.
For Source Code with detailed description and build instruction, visit the project page at github:
github.com/vis...
Link to Circuit Diagram:
raw.githubuser...
Very interesting project. Thanks for sharing the code. I plan to modify for my dual axis solar tracker and replace the LDRs.
Good luck with your project
@@MrFrisky88 Thanks again. For anyone else interested in trying this with the QMC5883L, I found header and parameter files. I'm not smart enough to do, so thanks to the author of these also.: api.riot-os.org/dir_5cce5766881baaa3953e3e6827950470.html
Thanks for the video sir. Your source code helped me a lot. I did this with arduino for rapid prototyping purpose.
What changes did you make to the code? I'm trying to do the same. I did find the address for my HMC5883 was 0x0D, but still not working.
@@xt1200z1 it can be qmc5883l chip. registry address are different.
@@kadrimetin Right, found the datasheet and got the correct registers, think also the LSB and MSB are backwards plus the order X,Y,Z. All is working now with atmega328p but compass is not correct. Thinking the data coming from the qmc5883l is different from the original HMC5883L.
Please provide me hex file of this code
Perfect, it cost me only 10$. Nice project!
Please provide me hex file of this code
Thanks for sharing, very useful.
Please provide me hex file of thus code please 🙏🏻
Code was running in arduino IDE software?
Good evening,
it is possible for this code to run on the arduino displaying the azimuth and pitch roll information on the serial monitor.
thanks.
Sorry, code needs modification to send output through serial port.
would it be possible for you to show me how to modify?
It's very important to me.
help me please
thomazedson882@gmail.com
Nice work,
I wonder to understand how does it works. Did you require a MPU6050 calibration to get the readings ? i was doing some tests and nothig was like your results.
I did not calibrate the magnetometer (HMC5883L), but calibration is needed for correcting any magnetic field present in the area. So this is not a perfect solution and may not be very accurate for all case.
MPU6050 is used to get accelerometer reading only and calibration is not needed for this application.
If you examine the code, I have only applied the standard method given by application notes for tilt compensation using magnetometer and accelerometer readings.
Please provide me hex file of thus code 🙏🏻
HELP: Hi, i tried the code and everything but when i run the make all command, i keep getting error "../../common/ssd1306/ssd1306.c:467: warning: 'y' may be used uninitialized in this function"
Please assist.
It's fine. This is not an error, only a warning that you can ignore. The output hex file will be generated anyway.
Please provide me hex file of thus code
Hi
Thanks for code and schematic diagram. It is possible for this code to run on some slightly larger display?
This code will work only for SSD1306 display.
Yes, do you have time to record the whole process of production? Thanks
Sorry, I could not record making this, but it is only a matter of soldering these components together according to the circuit diagram.
Help please. I got the error "cannot set sck period. Upgrade usb firmware "
I guess you can ignore this error and should not be affecting the programming of the chip. (This happens due to the programmer having Chinese firmware which sets SCK automatically)
Are there actually any ecompassing chips available today??
It seems that the market is in limbo between obsolete and very long lead times, apart from all the dev PCB's!
There are many chips having 3D accelerometer + 3D Magnetometer integrated to function as eCompass (like LSM303 from ST). But they are usually available in LGA package, difficult to hand solder. So using their dev. board is ideal for small project like this.
As for the availability, I have no knowledge of the current situation.
Hey, nice project you've made here, What are the configurations of the sensors you have used? Both for the magnetometer and the accelerometer?
Magnetometer (HMC5883L):
Continuous Measurement mode, Output rate: 15Hz
Gain: +/- 1.9 Ga, Averaging: 8 samples
Accelerometer (from MPU6050):
MPU6050 is configured in Accelerator only low power mode.
Accelerometer full scale range: +/- 16g
Hello. The HMC5883L compass X or Y which one will point magnetic north?.
X and Y reading from HMC5883L are used to calculate the Magnetic north direction.
If you hold the module with X arrow directly pointing to North, the X reading will be maximum and Y reading = 0. Similarly if you point Y arrow to North, Y reading = Maximum and X = 0. So, X and Y reading varies according to the module orientation. From the X, Y reading you can find the Azimuth angle, that is angle between Magnetic north and Forward direction. Here, X arrow of the module is used as forward direction. So, if you get Azimuth = 90 deg, you are holding the module with X arrow pointing directly at East.
MCUatWork so in the video X is pointing North, Y is pointing West. is that correct? 0:43
@@sukhee5 No, at 0:43 X is pointing West and Y is pointing South.
@@sukhee5 In this datasheet:
www.jameco.com/jameco/products/prodds/2150248.pdf
on page 21, 22 you can find the formula for Azimuth for different conditions of X and Y.
Hi, Thanks for uploading videos and code. I just want to know whether its possible to get Pitch or Roll in +180 to -180? Currently its + 90 to -90 Degree...
The formula used here for finding Pitch and Roll gives result in the range -90 to 90 only (which sufficient for tilt compensation calculations). To get full 3D rotation angles you will need to change the formula, which I don't have enough knowledge about. I think you can easily find some implementation by little bit of search. Good luck.
Hi could you show me how to programme this?
What is that P and R given on the oled display ?
Pitch and Roll
Cool project, but isn't the needle supposed to rotate in the other direction, so that the needle is stationary? 🤔
Right, the dial should have rotated keeping the needle at centre. But that would take more program memory. For this program, ATmega8 took almost the whole flash memory.
And what is H ?
Heading (or Yaw)
Hi.
Thanks for code. I copied your code, compiled, did everything by the same way, BUT compass is changing when I'm tilting it.
I can't understand what I'm doing wrong.
I'm working in Atmel Studio (Windows) , I'll send you my project, circuit pictures,.can you help me please? I'm begging you, please.
Hi, I guess the magnetometer and accelerometer modules are not aligned perfectly. Make sure that X-axis of magnetometer and accelerometer point in the same direction.
@@MrFrisky88 Hi. I aligned them .
May I add you in skype and send my circuit pictures, code ? Please?
@@emmetray9703 ok, may be email is enogh
@@MrFrisky88 Thank you !
tell me your email please,
my email is "giorgigelava@yahoo.com"
Hi, will this work with just the MPU-9250 alone?
MPU9250 alone is sufficient for the project. But additional code for MPU9250 is required to retrieve magnetometer and accelerometer readings.
@@MrFrisky88 that sounds great! My first tablet had a working compass, which allowed me to use Google Sky Map. My current tablets don't have a compass. I was wondering if there was a way to get Sky Map to see the MPU-9250 ,so that my tablet will show me what star my telescope is pointed at?
@@WagonLoads Great idea. Though, I don't know how you would pass the sensor data to the tablet so it can be used by Sky Map. May be you could use Bluetooth (BLE).
Works like a charm. Is possible change MPU6050 for ADXL345? Can you help me?
Yes, an ADXL345 accelerometer module can be connected instead of MPU6050 module. Code needs to be adjusted for accessing registers of ADXL345. I don't have a module with me and also need to refer the datasheet of ADXL345 to know more.
@@MrFrisky88 Ok. I will be try. Thanks!
Hello. This code works directly on Arduino ? Thanks!
Hi, if it works on ATmega8, it should definitely work on Arduino. Unfortunately, I never worked on Arduino platform, but only with C on AVRs. I think, creating an Arduino project with the source code of this project should work without any problem. Try it.
I want this product brother
will this compass work when installed on a vertical wall
When this compass is installed with its flat face parallel to the wall, the tilt will be 90 degrees (roll or pitch). But the readings will never show 90 degrees. That's a problem in this case. It will show a reading near to 90 deg (85 to 89) for roll or pitch. I think it will be better to install the board perpendicular to vertical wall (parallel to ground) and place the OLED display for vertical reading.
Can I buy that one from you??
please I'm serious message me back.
Thank you
Sorry, I don't have this one with me now. Anyway shipping cost will be much more than cost to build this. I guess you can build this without much difficulty.
MCUatWork I just ordered the parts 👍🏼
Ok