• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Twos compliment in Oshonsoft and Compass calibration

#81
Hi J and M,
Here is the latest program:

360 CW + CNTL1 shows:
BYTES = 3x Outputs after twos compliment calc inside [ ], then the CNTL1 BYTE=18 shows the compass is in CONTINUOUS MODE and 16BIT.

DATA = 6x RAW BYTEs

All from a Terminal while rotating 360 CW.
C.
I made a mistake, sorry.
I was looking about taking absolute value of 16bit word in 2's complement

In the conversions there should be:

Xsing = Xsing - 65536 instead of 65536 - Xsing
Ysing = Ysing - 65536
Zsing = Zsing - 65536


Now the first row becomes: - 89, 51, - 238
the last: - 71, 55, - 97
 
Last edited:

camerart

Active Member
Thread starter #82
I made a mistake, sorry.
I was looking about taking absolute value of 16bit word in 2's complement

In the conversions there should be:

Xsing = Xsing - 65536 instead of 65536 - Xsing
Ysing = Ysing - 65536
Zsing = Zsing - 65536


Now the first row becomes: - 89, 51, - 238
the last: - 71, 55, - 97
Hi J,
New 360 CW + CNTL1 :)
Now got to put the result in the correct format.
C
 

Attachments

camerart

Active Member
Thread starter #83
Hi J and M,
Success!!
Here's a Magviewer view, showing a circle.
Next figure out how to change the BIAS setting to centralise it.
Thanks to all, for your time and patience.
C.
 

Attachments

#85
Hi,
Orienting the compass module in Magmaster needs a bit of practice (For me anyway) Here is my first result, does it look ok?
C
Are these the raw values?
Did you input them manually?
From the d/s and from the previous msg #82, values of Z should be always negative ( if raw values )
I guess that the coefficients, which Magmaster calculates, M11, M22, M33 should be near 1 and the others near 0.
 
Last edited:

camerart

Active Member
Thread starter #86
Are these the raw values?
Did you input them manually?
From the d/s and from the previous msg #82, values of Z should be always negative ( if raw values )
I guess that the coefficients, which Magmaster calculates, M11, M22, M33 should be near 1 and the others near 0.
Hi J,
I'm using Magmaster and the instructions (See #50 link)
I tried again and the results are similar.
My set-up doesn't allow the box type arrangement as instructed, so I'm orientating the PCB/Battery/compass by hand.
Post #82 shows a 360 Deg horizontal revolution.
C.
 
#87
Are the values in the Magmaster window the raw values from the sensor, after converting from 2's complement ?
Are you sure that the 12 orientations which Magmaster needs, are correct?
 

camerart

Active Member
Thread starter #88
Are the values in the Magmaster window the raw values from the sensor, after converting from 2's complement ?
Are you sure that the 12 orientations which Magmaster needs, are correct?
Hi J,
Here is an output TXT, as sent to Magmaster from a Terminal instead, while moving in all orientations.
I think the orientations are correct in #84, but more practice and checking should confirm this.
C.
 

Attachments

#89
Hi J,
Here is an output TXT, as sent to Magmaster from a Terminal instead, while moving in all orientations.
I think the orientations are correct in #84, but more practice and checking should confirm this.
C.
Where did you get the output txt in Magmaster window
msg # 84?
The first row, X+ point 0° has value - 299
The second, X+ point 180° has value - 317
In msg #82 ( rotated horisontally) the lowest value of X is - 183. There is 73% difference??
 
#92
Why you then used different format in Magmaster msg #84?
The first X+ is - 299. Did you calculate it manually and how?
The compass program gives xxx. 00 and much smaller absolute values.
 
#94
I have asked four times how these values are generated, because they are different from sensors floating point values
You say they are readouts from terminal.
- how terminal got them?
- are they somehow made from sensor data?
 
Last edited:

camerart

Active Member
Thread starter #95
I have asked four times how these values are generated, because they are different from sensors floating point values
You say they are readouts from terminal.
- how terminal got them?
- are they somehow made from sensor data?
Hi J,
Sorry! I thought I'd answered everything.

You will recall, that we've just changed the program, (Big/little endian....getting the READings in the correct order etc)
I'm sure you know, that the PIC READs the compass module, then outputs DATA with a HSEROUT, that SENDS DATA via a USB/serial board and an HC-12 radio module.

The computer also has an HC-12/Serial/USB, as connection input. The input DATA can be READ using either a Terminal (Termite)(TXT) or the Magviewer or the Magmaster, all using LIVE DATA from the PIC output.

Using the attached 'Magmaster matrix': Hold the Compass module in the ORIENTATION as each of the 12x positions. At each position, press the Magmaster 12x POINTX BUTTON. This enters the DATA into the program, as the results in #93 (Latest with this program)
Latest program here:

C.
 

Attachments

Last edited:

camerart

Active Member
Thread starter #98
Hi,
I'm still stuck!

I've now made a box, as instructions, which helps me carry out tests more consistently.

Here is a Magmaster matrix and the 'how to use the results' box.

How are the calculations done? Is this one calculation or three separate ones?

C.
 

Attachments

#99
1. Subtract the bias values from uncalibrated values Xnc, Ync, Znc
( floating point values after converting from 2's complement 16bit integer)

X0 = Xnc-Bx
Yo = Ync-By
Z0 = Znc-Bz

2. Multiply these with the matrix M11... M33:

Xc = M11*X0 + M12*Y0 + M13*Z0
Yc = M21*X0 + M22*Y0 + M23*Z0
Zc = M31*X0 + M32*Y0 + M33*Z0

Xc, Yc, Zc are the calibrated values.
 

camerart

Active Member
Thread starter #100
1. Subtract the bias values from uncalibrated values Xnc, Ync, Znc
( floating point values after converting from 2's complement 16bit integer)

X0 = Xnc-Bx
Yo = Ync-By
Z0 = Znc-Bz

2. Multiply these with the matrix M11... M33:

Xc = M11*X0 + M12*Y0 + M13*Z0
Yc = M21*X0 + M22*Y0 + M23*Z0
Zc = M31*X0 + M32*Y0 + M33*Z0

Xc, Yc, Zc are the calibrated values.
Hi J,
Thanks, I'll try to WRITE it into the program.
C
 

Latest threads

EE World Online Articles

Loading

 
Top