Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

HMC5883L and QMC5883L (3 axis compass)

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 705

poland.gif
PostPosted: Thu Apr 26, 2018 5:08 pm    Post subject: HMC5883L and QMC5883L (3 axis compass) Reply with quote

Hello. This code is for modules named GY-271 or GY-273
GY-271 have simple level translators where GY-273 is "simples/cheap made" or dedicated for 3V3

First I wrote code for HMC5883L and...code dont work for me Very Happy

After some investigation I read that those modules uses two chip manufacturers. So module can be equpped with QM.. or HM..

QM with I2C scanner respond at &H1A where HM should respond at &H3C (I dont have this chip)

So I wrote code for QM "from scratch" with datasheet and it finally work Very Happy

I attach both codes and datasheets for them. WIth this basic readings you can calculate more complex data.
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5119
Location: Holland

blank.gif
PostPosted: Fri Apr 27, 2018 8:40 pm    Post subject: Reply with quote

you are very productive Very Happy
Thanks for sharing your work. Indeed a good idea to run the i2c scanner. That would be my advise too when i2c slave is not working as expected.
A big problem with lot of chips : there are many different versions which look similar. But we have EDC , so no problem Very Happy

_________________
Mark
Back to top
View user's profile Visit poster's website
micro_anne

Bascom Member



Joined: 28 Nov 2014
Posts: 6

PostPosted: Sat Jun 02, 2018 12:07 pm    Post subject: Reply with quote

Hi,

congratulations on your awesome project.

I do have some questions for you and others who may be reading.

I tried in the past to get the MPU9250 9DOF working under bascom. I managed to get the I2C communication working, also reading the registers, writing new settings to the registry, and read the raw data was not a big problem.
What I couldn't do in Bascom was calculate the quaternions based on these raw data.

Calculating valid euler angles should be possible though I didn't find any successful attempt under bascom.

Would you, or anybody else, know how would that be done ?

Second question related to your shared work: Is there a big difference between using accelerometers and gyros to get the Yaw, Pitch, Roll angles and just using a 3 axis compass to accomplish the same thing ? Can I use this module to navigate without the assistance of any other inertial nav. plaforms ?

thanks again for sharing knowledge
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 705

poland.gif
PostPosted: Sat Jun 02, 2018 12:59 pm    Post subject: Reply with quote

MPU means that some of the calculations is made by MPU chip and they are ready to read for chip who want the data.
I dont remember exactly what MPU I use one day 6050 or so.
But more important is that any library/API can be translated to the Bascom.

To be honest and precise: You can drive any device that AVR can drive/use and write library for it by reading device datasheet.
But when one know second language because like learning then translate some of the done work/code is easy.

My point is that : "If you can find any working library for the chip then it can be easy translated"

For HMC i translate Arduino lib , for QMC I work on it from scratch with the datasheet (but with some basic knowledge and maybe nomenclature(naming of variables are same for code compatibility)).

Sensor give you data about X, Y and Z axis, but gyroMPU give you ready to use data about acceleration in the 3D directions and AVR dont need to calculate them. This is the difference between Sensor and the gyroMPU.
Back to top
View user's profile Visit poster's website
autoguider

Bascom Member



Joined: 24 Sep 2007
Posts: 74
Location: Aachen

germany.gif
PostPosted: Wed Jan 13, 2021 3:05 pm    Post subject: Reply with quote

Dear All,
I was digging into the datasheets for the MCU9250 and got lost in the complexity of this device.
https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-9250-Register-Map.pdf
https://3cfeqx1hf82y3xcoull08ihx-wpengine.netdna-ssl.com/wp-content/uploads/2015/02/PS-MPU-9250A-01-v1.1.pdf

I also found a library for Arduino written in C++ https://github.com/asukiaaa/MPU9250_asukiaaa
Cross referencing to the datasheets is a bit difficult to me.
I even could not find the Ic address for the device.
In the block diagram the magnetometer is not shown. So it could be that it has its own Ic address.
Later in the description it says about an auxiliary Ic bus which may contact a magnetometer.
So I am a bit confused.

My intention is to use a GY-91 10DOF device and get the tilt compensated compass heading and the tilt angle from it.
As I did my programmiong with bascom I would like to stay with it and not move to Arduino C.

If you have a recommendation for another suitable device please let me know.

best regards
Christian
Back to top
View user's profile
hgrueneis

Bascom Member



Joined: 04 Apr 2009
Posts: 880
Location: A-4786 Brunnenthal

austria.gif
PostPosted: Wed Jan 13, 2021 4:27 pm    Post subject: Reply with quote

Christian,

a tilt compensated Compass will not work right at 90 degrees tilt.
There are easier ways to determine the direction especially with a lot of iron around, if you have other means like 10-rot pots with calibration possibilities, evaluated by adc sense readings. Optical reading of an offset bar strip will also let you know the count forward and reverse. especially if you power your 'TOWER' rotation with servos. This would also enable you to control the positions of your telescopes to less than a second, which could be very useful in finding distant objects. A compass with Iron around can easily be off by 20 degrees!
I would not go with a compass, but just my thinking.

Regards
Hubert
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum