Sine function
Moskog
Posts: 554
in Propeller 1
Hello again!
For my new project i need to find the sine values of numbers, like in this formula used to determine solar declination at a given date (or more correct day of year, d):
I have looked at the sine table code example in the Propeller manual (page 385 I think) but I'm not familiar with PASM and I also get an error when compiling that code using a standard object template.
Does anyone have a good idea on using that code or is it a more simple way to find SIN and also INV SIN?
KjellO
For my new project i need to find the sine values of numbers, like in this formula used to determine solar declination at a given date (or more correct day of year, d):
I have looked at the sine table code example in the Propeller manual (page 385 I think) but I'm not familiar with PASM and I also get an error when compiling that code using a standard object template.
Does anyone have a good idea on using that code or is it a more simple way to find SIN and also INV SIN?
KjellO
Comments
Hopefully my program will make it easier to understand how the table works.
http://forums.parallax.com/discussion/160994/my-attempt-to-understand-the-sine-table
forums.parallax.com/discussion/103610/accessing-sin-cos-tables-in-spin
But I think you will need floating point math to solve such a formula, and the float objects have there own sine functions.
IMO it makes not much sense to calculate the delta angles at runtime anyway. Just precalculate the angle for every day on the PC, and store a table with the 360 values in a DAT section for Spin.
Andy
-Phil
http://obex.parallax.com/object/551
So, a few words on my project: I'm building two solar heaters both a little more then one square meters. They will both be placed on a kind of frame in parallell, and be able to track the sun in two axis.
Tracking will probably start at 8am and end at 6 or 7pm. Not earlier because of nearby buildings, not later because of less solar energy at night.
The azimut bearing will not be tilted but stay in level, just because of the construction itself. Tracking the sun's different elevation during the hours will be left to the Propellers software and the servos. I guess one adjustment/hour will be good enough. Also for calculating declination, once every week would probably be good enough, I do agree with Ariba and Phil here.
The heaters will be run from first week of february and until end of october, the rest of the year they will be in the shade due to the hills and mountains. I also plan to use a closed circuit of anti freeze liquid and heat exchangers for the heat transportation up the house. Purpose is to pre heat water for the main water heater. Gets lots of useful ideas from my friend Peter LA6WNA who is heavy into such kind of things!
Will post pictures here showing the progress of the project.
All you need is a clock!
Crank the thing to a know starting position every morning and start winding it around at a known starting time. At a constant rate of 1 degree every 4 minutes.
Set the start position and start time up once and it will always be correct. Don't use local time with daylight saving adjustments, use the Proper time (GMT ).
Back in late seventies when this sort of thing was all the rage due to the oil crisis at the time a guy in my tech college built such a tracking solar heater. It used a big old wind up clock work mechanism turning a wooden "gear" that was simply a semicircle of plywood.
btw. you can simplify the formula to
declination[degree] = 23.4 * sin(360° * (284+x)/365) = 23.4 * sin(360° * (x-81)/365)
because arcsin(sin(23.4°)) is 23.4°
but like Heater say, a clock is all you need
;-) Reinhard
see attached zip file with prop-gcc project
;-) Reinhard