HMC5883L magnetometer Proteus simulation ?

hi guys

i was trying to simulate the HMC5883L magnetometer sensor in Proteus and after a hard time finding it i was able to make it work , at least i think , because there is no change in the position of the sensor i get a reading of 0 , is there is a way to simulate its motion to get any reading ?

|500x301

the code :

#include  //I2C Arduino Library
#include 
LiquidCrystal lcd (4,5,6,7,8,9);
#define addr 0x0D //I2C Address for The HMC5883

void setup() {
lcd.begin(16,2);
  Wire.begin();
  Wire.beginTransmission(addr); //start talking
  Wire.write(0x0B); // Tell the HMC5883 to Continuously Measure
  Wire.write(0x01); // Set the Register
  Wire.endTransmission();
  Wire.beginTransmission(addr); //start talking
  Wire.write(0x09); // Tell the HMC5883 to Continuously Measure
  Wire.write(0x1D); // Set the Register
  Wire.endTransmission();
}

void loop() {

  int x, y, z; //triple axis data

  //Tell the HMC what regist to begin writing data into


  Wire.beginTransmission(addr);
  Wire.write(0x00); //start with register 3.
  Wire.endTransmission();

  //Read the data.. 2 bytes for each axis.. 6 total bytes
  Wire.requestFrom(addr, 6);
  if (6 <= Wire.available()) {
    x = Wire.read(); //MSB  x
    x |= Wire.read() << 8; //LSB  x
    z = Wire.read(); //MSB  z
    z |= Wire.read() << 8; //LSB z
    y = Wire.read(); //MSB y
    y |= Wire.read() << 8; //LSB y
  }

  // Show Values
lcd.setCursor(0,0);
lcd.print(x);
lcd.setCursor(0,1);
 lcd.print(z);
  delay(500);
}

Maybe the Proteus forum knows.

If you simulate, a turn from max value decreases the value by the cosine function, eventually plus an offset. In each direction for 3D moves.

I wonder what else you expect from simulation? Simulation is based on a mathematical model, the same for all such sensors. You only add arbitrary constants, not related to sensor behaviour unless you have a real sensor for parametrization.

DrDiettrich: If you simulate, a turn from max value decreases the value by the cosine function, eventually plus an offset. In each direction for 3D moves.

I wonder what else you expect from simulation? Simulation is based on a mathematical model, the same for all such sensors. You only add arbitrary constants, not related to sensor behaviour unless you have a real sensor for parametrization.

so is there any thing i can do to check if i am getting the right readings from the sensor ? or magnetometers in general cannot be simulated in proteus ?

i didn't expect much from the simulation but i thought that it might have the ability to change position by a potentiometer or any thing (any mimicking technique) , like the lm35 in proteus it has a button to change the temperature .

The HMC5883L sensor includes its own controller. A simulation would need description of a 3D magnetic field and sensor orientation in 3 axes, as well as the settings of all parameters.

Magnetometers are influenced by local magnetic fields more than by earth magnetic field. If you don’t trust a sensor, get some more and compare their outputs.

Hi, Build it in the real world and find out.....

What do you want to do with the sensor?

Tom.... :)

the thing is that i am engaged in something called a summer school for aerospace science and with my team we are supposed to build a space environmental monitor using various sensors including this HMC5883L , but our instructor don't want us to start building with real hardware unless we completed the simulation of all of these sensors in Proteus and made sure that it works?! , any ways i revised my code a little bit and found that i was giving the wrong bus address for 12c , but after changing it to 0x1E it worked :

|500x323

yet no mechanism for changing the values during simulation , but i guess i am satisfied with that result .

but i still have a question : what is the 17159 represent , is it the magnetic field strength in the x direction in some unit ? assuming that the simulation knows what a magnetic field is

ahmed44: our instructor don't want us to start building with real hardware unless we completed the simulation of all of these sensors in Proteus and made sure that it works?!

Can you choose a different project with a more realistic instructor? I bet that s/he cannot tell how to simulate a magnetometer in any software. Not being well grounded is not a reasonable base for aerospace science :-(

DrDiettrich: Can you choose a different project with a more realistic instructor? I bet that s/he cannot tell how to simulate a magnetometer in any software. Not being well grounded is not a reasonable base for aerospace science :-(

unfortunately we cannot change the project , i actually feel sorry for the other members of my team they don't have much experience with Arduino . but i guess with your help guys i think we might pull it off .

Did you already get an Arduino library for the magnetometer? If not look for a better supported sensor.

Hi, If you google

HMC5883L simulating in proteus

You may find what you are looking for.

Tom... :)

DrDiettrich: Did you already get an Arduino library for the magnetometer? If not look for a better supported sensor.

it seems that this sensor uses the I2C protocol so i just used the library and the address of the sensor from the datasheet , i don't think the instructor could change the sensor .

TomGeorge: Hi, If you google

HMC5883L simulating in proteus

You may find what you are looking for.

Tom... :)

i didn't find any thing related to this sensor with Proteus ! , have you found any ?!

ahmed44: it seems that this sensor uses the I2C protocol so i just used the library and the address of the sensor from the datasheet , i don't think the instructor could change the sensor .

You don't have to change the sensor to use the library for the 5883. The library uses I2C. Tom... :) PS, Your instructor needs to get into the real world. Simulators are all and good, but at this level getting down and dirty and BUILDING something will teach you a lot more in my opinion. Go and show your instructor the problem you are having, its his/her job to teach you and point you in the right direction. He/she has to have more knowledge than some of us about Proteus.