December 1st, 2018, 03:21 AM  #21 
Global Moderator Joined: Dec 2006 Posts: 21,029 Thanks: 2259 
My understanding is that signed integer variables don't exist. Hence an externally obtained signed integer (in two's complement format) that occupies 2 bytes could be stored in a Word variable, but its arithmetic value would be treated as unsigned in the range 0 to 65535. When that value has been transferred to a Single variable, if it's in the range 32768 to 65535 (i.e. greater than 32767), it should have 65536 subtracted to give a value in the range 32768 to 1. A statement such as Dim y_sing As Single declares that y_sing is a Single variable. 
December 1st, 2018, 04:13 AM  #22 
Member Joined: Jan 2016 From: Uk Posts: 93 Thanks: 2 
Hi S, My maths skills are not so good, but I think your 2's compliment explanation is correct. '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''' I stopped using 'sing', as I now remember that any calculation needs SINGLES. e,g, y_sing is now Y_C or Y_NC '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''' Each compass module needs calibrating for each application, due to metal and magnets etc. I used a program called MAGMASTER and MAGVIEWER for calculation and visualisation. See attached MAGVIEWER view. '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''' In post #20 there should be a TXT file attached. (I can see it) With this section:  'If y_c > 0 Then#################### 'If x_c > 0 Then 'If x_c / y_c < 1 Then 'deg = Arctan(x_c / y_c) * 57.3 'Endif 'Endif 'Endif  I was advised to move this line: If y_c > 0 Then###### to the top of that group as Y > ZERO must be tested first in Oshonsoft. C. Last edited by camerart; December 1st, 2018 at 04:16 AM. 
December 1st, 2018, 04:54 AM  #23 
Global Moderator Joined: Dec 2006 Posts: 21,029 Thanks: 2259 
To track down the problem, you could try commenting out various parts of the program, and replace them, where necessary, with statements that simply give valid values to variables that will be used later. This can be tedious, but may allow you to determine which part of the program is somehow causing a problem. You might also check that Arctan works correctly (when used in isolation) by comparing the values it produces with values obtained from a calculator.

December 1st, 2018, 06:37 AM  #24 
Member Joined: Jan 2016 From: Uk Posts: 93 Thanks: 2 
Hi S, For anything mathmatic, I need help, as I'm not skilled in that direction, so comparing results on a calculator is out. I only asked the question here, to get the proper way of the ARCTAN equation. I'll carry on checking. Once I've got some stability, I'll post the results. Thanks, C. 
December 1st, 2018, 01:28 PM  #25 
Global Moderator Joined: Dec 2006 Posts: 21,029 Thanks: 2259 
Google would suffice as a calculator. If, say, you type (in lower case) arctan(12/5) in degrees into Google and press Enter, you will be shown its (fairly accurate) value. 

Tags 
360, 360degrees, degrees 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Why 79 degrees instead of 101 degrees?  LBOlson  Trigonometry  3  December 8th, 2015 01:03 PM 
dividing 3.14 (or pi) by 180 degrees  hansolo  Algebra  6  May 1st, 2013 11:10 PM 
Cp at 15 million degrees  Setsuna  Physics  1  September 28th, 2012 07:35 AM 
degrees and bearings, am i right?  mathslog  Algebra  2  April 29th, 2012 11:25 AM 
Why 360 degrees is 2π?  Skyer  Algebra  2  September 12th, 2011 09:15 AM 