User Name Remember Me? Password

 Trigonometry Trigonometry Math Forum

 November 28th, 2018, 08:47 AM #11 Global Moderator   Joined: Dec 2006 Posts: 20,919 Thanks: 2202 Does the code below give you any incorrect results? Code: If x_c <> 0 Then deg = -Arctan(y_c / x_c) * 57.3 Else deg = 90 If y_c < 0 Then deg = -90 Endif Endif If x_c > 0 Then If deg < 0 Then deg = deg + 360 Endif Else deg = deg + 180 Endif November 29th, 2018, 12:26 AM   #12
Member

Joined: Jan 2016
From: Uk

Posts: 93
Thanks: 2

Quote:
 Originally Posted by skipjack Does the code below give you any incorrect results? Code: If x_c <> 0 Then deg = -Arctan(y_c / x_c) * 57.3 Else deg = 90 If y_c < 0 Then deg = -90 Endif Endif If x_c > 0 Then If deg < 0 Then deg = deg + 360 Endif Else deg = deg + 180 Endif
Hi S,
Yes, Oshonsoft gives an error 'Too many arguments' for this line:
deg = -Arctan(y_c / x_c) * 57.3

Previously This line 'x_c = - x_c' had to be changed to 'Xc = - 1 * Xc' To get it to work in Oshonsoft. I tried similar with your CODE, but the results were much too variable.

C. November 29th, 2018, 12:34 AM #13 Global Moderator   Joined: Dec 2006 Posts: 20,919 Thanks: 2202 Can you post an example of the values of x_c and y_c and the resulting value of deg that you thought was incorrect? November 29th, 2018, 08:53 AM   #14
Member

Joined: Jan 2016
From: Uk

Posts: 93
Thanks: 2

Quote:
 Originally Posted by skipjack Can you post an example of the values of x_c and y_c and the resulting value of deg that you thought was incorrect?
Hi S,
Oshonsoft won't compile until the error has been corrected, so no examples.

I tried 'deg = -1*Arctan(y_c / x_c) * 57.3' instead of 'deg = -Arctan(y_c / x_c) * 57.3', but the results were all over the place.

I can try again, if you want, the first results were deleted.
C.

Last edited by camerart; November 29th, 2018 at 08:59 AM. November 29th, 2018, 10:32 AM #15 Global Moderator   Joined: Dec 2006 Posts: 20,919 Thanks: 2202 That change to let it run would be okay. I'd like to know some results, so that I can understand what you meant by "all over the place". November 30th, 2018, 12:58 AM   #16
Member

Joined: Jan 2016
From: Uk

Posts: 93
Thanks: 2

Hi S,
When I set the program to output X,Y,Z, I could see there is something very wrong. In my program, I have a Y Negate, plus a calibration by Magmaster to centralise everything. I had to revert to older programs before them, showing RAW X,Y,Z DATA.

Here is a READout with X,Y,Z and DEGREES, using this:
If x_sing <> 0 Then
''''deg = -Arctan(y_sing / x_sing) * rad'57.3 'ORIGINAL
deg = -1 * Arctan(y_sing / x_sing) * 57.3
Else
deg = 90
If y_sing < 0 Then
deg = -90
Endif
Endif
If x_sing > 0 Then
If deg < 0 Then
deg = deg + 360
Endif
Else
deg = deg + 180
Endif
Attached Files CW 360.txt (1.4 KB, 1 views) November 30th, 2018, 02:30 AM #17 Global Moderator   Joined: Dec 2006 Posts: 20,919 Thanks: 2202 In the data, why are X, Y and Z always integers? I find it strange that the values shown for the calculated angle are often approximately what I would expect, but are sometimes some "random" value with a leading character that isn't even a digit. November 30th, 2018, 03:06 AM   #18
Member

Joined: Jan 2016
From: Uk

Posts: 93
Thanks: 2

Quote:
 Originally Posted by skipjack In the data, why are X, Y and Z always integers? I find it strange that the values shown for the calculated angle are often approximately what I would expect, but are sometimes some "random" value with a leading character that isn't even a digit.
Hi S,

The RAW DATA is READ as two BYTEs, in a two's complement form. So two READing for each axis.

This then passes through a two's complement 'correction'

'vvvvvvvvvvvvvvvvvvvvvvvvvvvv 2 'S COMPLEMENT CALC VVVVVVVVVVV
If x_sing > 32767 Then
x_sing = x_sing - 65536
x_sing = x_sing + 1
Endif
If y_sing > 32767 Then
y_sing = y_sing - 65536
y_sing = y_sing + 1
Endif
If z_sing > 32767 Then
z_sing = z_sing - 65536
z_sing = z_sing + 1
Endif
'AAAAAAAAAAAAAAAAAAAAAAAAAAAA 2'S COMPLEMENT CALC AAAAA

Does this answer the first part of you question?

Could the other error, be caused by very irregular RAW READings? If so I can look into a DATA READY section of the DATA SHEET. At the moment, I'm simply READing the DATA 1 to 6 in the way I've got working in Oshonsoft.

Also, could the non-digit outputs be an Oshonsoft calculation error e,g, divide by zero?
C.

Last edited by skipjack; November 30th, 2018 at 09:29 AM. November 30th, 2018, 10:04 AM #19 Global Moderator   Joined: Dec 2006 Posts: 20,919 Thanks: 2202 You can use "0 - Arctan(y_sing / x_sing) * 57.3" instead of "-1 * Arctan(y_sing / x_sing) * 57.3". The value will be the same. How are the variables x_sing and y_sing declared? You shouldn't do "x_sing = x_sing + 1", "y_sing = y_sing + 1" and "z_sing = z_sing + 1". They relate to a different method of creating a correctly signed value. What code do you use to give x_sing, y_sing and z_sing their initial values? I doubt that the non-digit outputs would be due to division by zero. December 1st, 2018, 12:43 AM   #20
Member

Joined: Jan 2016
From: Uk

Posts: 93
Thanks: 2

Quote:
 Originally Posted by skipjack You can use "0 - Arctan(y_sing / x_sing) * 57.3" instead of "-1 * Arctan(y_sing / x_sing) * 57.3". The value will be the same. How are the variables x_sing and y_sing declared? You shouldn't do "x_sing = x_sing + 1", "y_sing = y_sing + 1" and "z_sing = z_sing + 1". They relate to a different method of creating a correctly signed value. What code do you use to give x_sing, y_sing and z_sing their initial values? I doubt that the non-digit outputs would be due to division by zero.
Hi S,
NOTE: SING is from previous programs to remind me that the numbers were SINGLES. Now 'NC' = Not calibrated. 'C' = Calibrated.

TWO'S COMPLIMENT:

Can you confirm that this is the correct way of calculating 2's compliment?
'VVVVVVVVVVVVVVVVVVVVVVVVVVVV 2'S COMPLIMENT CALC VVVVVVVVV
If x_nc > 32767 Then 'ALL SINGLES
x_nc = x_nc - 65536
Endif
If y_nc > 32767 Then
y_nc = y_nc - 65536
Endif
If z_nc > 32767 Then
z_nc = z_nc - 65536
Endif
'AAAAAAAAAAAAAAAAAAAAAAAAAAAA 2'S COMPLIMENT CALC AAAAAAAAA

Does DECLARED mean 'calculated'? If so here is the program:

I'll investigate the 'none digit outputs' If you look at the line marked ################ in the program. This line was moved to the top of that group, because I was told to check for 'divide by zero' first' (Oshonsoft)

C.
Attached Files Program.txt (12.3 KB, 3 views)

Last edited by camerart; December 1st, 2018 at 12:55 AM. Tags 360, 360degrees, degrees Thread Tools Show Printable Version Email this Page Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Similar Threads Thread Thread Starter Forum Replies Last Post LBOlson Trigonometry 3 December 8th, 2015 01:03 PM hansolo Algebra 6 May 1st, 2013 11:10 PM Setsuna Physics 1 September 28th, 2012 07:35 AM mathslog Algebra 2 April 29th, 2012 11:25 AM Skyer Algebra 2 September 12th, 2011 09:15 AM

 Contact - Home - Forums - Cryptocurrency Forum - Top

Copyright © 2019 My Math Forum. All rights reserved.       