cachomachine
Senior Member
Has anyone succeeded in getting an accurate reading of the X axis in real degrees on a GY-271 HMC5883L 3-Axis Magnetic Electronic Compass Module?
; Demo Values
w1 = 1234 : call showW1signed
w1 = 2048 : call showW1signed
w1 = -4096 : call showW1signed
w1 = 65500 : call showW1signed
end
showW1signed: ; Send a 2's complement value in w1 to the terminal
w2 = w1
if w2 => $F800 then
w2 = -w2
sertxd(" -")
endif
if w2 = $F000 then
sertxd(" OVERFLOW ")
else if w2 => 2048 then
sertxd(" ERROR ")
else
sertxd(#w2," ")
endif
return
Hi Alan,
I am in the process of designing a Fish Seeker using plastic water pipes. That will use a Picaxe to control it.
(123) Fish Seeker Instructional Video - YouTube
It needs a magnetic compass to make it go straight away from the beach.
You indicated:
I've written several Code Snippets (of varying complexity) for the required ATAN2 function.
Is it possible to get a copy of the ATAN2 function code and maybe scaling software to scale down the X, Z, Y from the HMC5883L to suit the ATAN2 function.
Hoping that you may be able to help.
I plan to publish the project when finished.
Thanks,
Rod.
Yes, a search of the forum for "ATAN2" and my user name should lead you HERE , but I didn't include that link before because it's a complex function which didn't seem appropriate for the OP (i.e. the Original Post); it uses quite (or even very) "Advanced" Programming concepts (to a typical PICaxe user). The link should lead directly into my recent "Update" post, particularly for the ATAN2 application, but you should also read the thread from the beginning (i.e. post #1) for a full introduction.... I've written several Code Snippets (of varying complexity) for the required ATAN2 function.
Hi,
You need two Axes (X-Y , X-Z or Y-Z) to determine an angle. Have you managed to read any (signed) values from the device?
One you have data (field strengths) for two (orthogonal) Axes, I've written several Code Snippets (of varying complexity) for the required ATAN2 function.
Cheers, Alan.
The 28X1 is an "obsolete" chip (it's normally now a 28X2) and a 20X2 might be a better choice because it fits in the same socket as a 20M2 (which is basically similar to the 18M2, but has minor improvements on it). However, IMHO (In My Opinion) the SIN and COS functions are not a good reason for upgrading from the M2 to X2 family. Note that details of these (and many similar) functions can be found in the "Variables - Unary Mathematics" section of the PICaxe User Manual (Part 2). You can also test out the functions by using the PICaxe Simulator within PE5 or PE6. For example, try the following (which can also indicate which functions are available in each chip), seeing if you can understand the value it produces (197) :I only have a Picaxe 18M2 chip. So I need to order a 28X1 that has Sin and Cos functions.
#picaxe 20x2
#terminal 9600 ; Use 4800 for M2 family
b1 = cos 135 ; Degrees
sertxd(#b1)
do : loop ; Keep Terminal window open in PE5 simulator