Attached is the code for a Sine function, and a main program to demo it. The function itself is very short and sweet. The demo portion is the long part, just to show you the results on an LCD.
This is totally generalized. The argument may be positive, negative or zero, and there is no limit on the size of the argument, either. The results are accurate to four decimal places.
The lookup table for quadrant I is stored in program memory, and the usual trigonometric identities are used to expand this to include all quadrants, and for positive or negative angles of any size. It really is universal.
It seems that storing a table of words in EEPROM is buggy in GC Basic. At least, I wasn't able to make that work. So, I just stored the table in program memory which works just fine.
I had a look at the code regarding EEPROM and writing WORD values.
The code today supports BYTE values only. It would be practical to add WORD (I just created a test version with WORD support) but it then caused an issues with pages et, and, it may mean you would on be able to store 126 WORDs in a table.
Something for the summer to look into. I will add the list of things to investigate.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello All,
Attached is the code for a Sine function, and a main program to demo it. The function itself is very short and sweet. The demo portion is the long part, just to show you the results on an LCD.
This is totally generalized. The argument may be positive, negative or zero, and there is no limit on the size of the argument, either. The results are accurate to four decimal places.
The lookup table for quadrant I is stored in program memory, and the usual trigonometric identities are used to expand this to include all quadrants, and for positive or negative angles of any size. It really is universal.
It seems that storing a table of words in EEPROM is buggy in GC Basic. At least, I wasn't able to make that work. So, I just stored the table in program memory which works just fine.
Thomas Henry
I had a look at the code regarding EEPROM and writing WORD values.
The code today supports BYTE values only. It would be practical to add WORD (I just created a test version with WORD support) but it then caused an issues with pages et, and, it may mean you would on be able to store 126 WORDs in a table.
Something for the summer to look into. I will add the list of things to investigate.
Very nice. Thank you. I just ported to 16F887a and terminal all this is very good code!
Most grateful. This is code I could include in the Help File it this is acceptable to you?
Last edit: Anobium 2014-03-20