Javalin code for HM55B Compass
Javalin
Posts: 892
All,
Attached is Java example code for Parallax's HM55B compass module.
Think it works (my compass has not been calibrated yet...) - but best test yourselves to be sure!!
You'll need to save the files and rename them .java (for some reason the forums dont seem to allow .java uploads??!)
The trig.java and unsignedintclass.java need to go in the \lib\stamp\math directory under the GUI's install.
The the HM55B_Compass.java just save and run.
Have fun,
James
Post Edited (Javalin) : 1/12/2006 10:32:16 PM GMT
Attached is Java example code for Parallax's HM55B compass module.
Think it works (my compass has not been calibrated yet...) - but best test yourselves to be sure!!
You'll need to save the files and rename them .java (for some reason the forums dont seem to allow .java uploads??!)
The trig.java and unsignedintclass.java need to go in the \lib\stamp\math directory under the GUI's install.
The the HM55B_Compass.java just save and run.
Have fun,
James
Post Edited (Javalin) : 1/12/2006 10:32:16 PM GMT
Comments
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/peripheral/sensor/compass/HM55B/
This particular class allows a single pin for data input and output.
Why does this not work in your class?
To use a single pin, you connect a 1k resistor between Din and Dout,
then connect Din to the Javelin·pin used for data.
regards peter
·
Thanks for that. I am not sure why it does not work - I will try the resister and see what happens.
Cheers
james
What does this class give as results?
I noticed the first class (the one you use) mirrored the bits in the command constants
and then using CPU.SHIFT_LSB.
The other class uses the normal command constants and CPU.SHIFT_MSB.
Both techniques should give the same result but the 2nd class makes more sense
since it uses the command constants as given by the HM55B manual.
I have no HM55B so I cannot test it for myself.
regards peter
Thanks,
Ritu
public static void main()
{
static HM55B cp1 = new HM55B(cp1_DinDout,cp1_Clk,cp1_En);
boolean repeat = true;
while( repeat=true)
{
cp1.start();
cp1.poll();
if(result = true)
{
System.out.println("X-axis:");
System.out.println(getCompassX());
System.out.println("Y-axis:");
System.out.println(getCompassY());
System.out.println("Compass Angle:");
System.out.println(getCompassAngle());
}
else()
{
repeat= false;
}
}
}
regards peter