Re: [nmglug] Spa algorithm, para port, hiliostat project.

Aaron Birenboim <[email protected]> Thu, 08 Jan 2009 09:33:57 -0700
Newsgroups gmane.org.user-groups.nmlug
Message-ID <[email protected]>
akaluta wrote:
> Dear Glug Persons;
> Now,I am able to access my parallel port,significant to me and thanks
> again to all.
> .
> CONCEPT IN QUESTION: read the pertinent part of the spa.c
> http://rredc.nrel.gov/solar/codesandalgorithms/spa/ , output,to a
> stepper motor control program driving motors x,y respectively.
>  
> QUESTION PER SE: looking for an analogous sample program or snippet
> which could a read "spa",in this instance every twenty seconds, and
> write to a stepper program. suspect the solution would include time.h. 
> 
> Anyone able to point me in the direction? Best Regards, Anthony K

Took a look at spa.
Here's a little program to print the current solar angle...

> 
> #include <stdio.h>
> #include <time.h>
> #include "spa.h"  //include the SPA header file
> 
> static void printFracHour(const char *lbl, const double hr)
> {
>   float min,sec;
> 
>   min = 60.0*( hr - (int)hr);
>   sec = 60.0*(min - (int)min);
>   fprintf(stderr,"%s :   %02d:%02d:%.2f GMT\n",lbl,
> 	   (int)hr, (int)min, sec);
> }
> 
> int main (int argc, char *argv[])
> {
>     spa_data spa;  //declare the SPA structure
>     int result;
>     struct tm *tg;
>     time_t tp;
>     
>     //enter required input values into SPA structure
> 
>     spa.year          = 2003;
>     spa.month         = 10;
>     spa.day           = 17;
>     spa.hour          = 12;
>     spa.minute        = 30;
>     spa.second        = 30;
>     spa.timezone      = -7.0;
>     spa.delta_t       = 67;
>     spa.longitude     = -105.1786;
>     spa.latitude      = 39.742476;
>     spa.elevation     = 1830.14;
>     spa.pressure      = 820;
>     spa.temperature   = 11;
>     spa.slope         = 30;
>     spa.azm_rotation  = -10;
>     spa.atmos_refract = 0.5667;
>     spa.function      = SPA_ALL;
> 
>     /* overwrite with NOW */
>     tp = time(NULL);
>     tg = gmtime(&tp);
>     spa.year   = tg->tm_year + 1900;
>     spa.month  = tg->tm_mon+1;
>     spa.day    = tg->tm_mday;
>     spa.hour   = tg->tm_hour;
>     spa.minute = tg->tm_min;
>     spa.second = tg->tm_sec;
>     spa.timezone = 0;
> 
>     result = spa_calculate(&spa);
> 
>     /* Print diagnostics to stderr */
>     fprintf(stderr,"%d/%02d/%02d %02d:%02d:%02d GMT\n",
> 	    spa.year,spa.month,spa.day,spa.hour,spa.minute,spa.second);
>     fprintf(stderr,"%.2lfN %.2lfE %.1lf (met, alt)\n",
> 	    spa.latitude, spa.longitude, spa.elevation);
> 
>     if (result)
>       {
> 	fprintf(stderr,"spa error code : %d\n",result);
> 	return(result);
>       }
> 
>     fprintf(stderr,"Solar angle %.1lf E of N, %.1lf\n",spa.azimuth,
> 	    spa.zenith);
>     fprintf(stderr,"Incidence: %.1lf deg\n",spa.incidence);
>     printFracHour("Sunrise",spa.sunrise);
>     printFracHour("Transit",spa.suntransit);
>     printFracHour("Sunset ",spa.sunset);
> 
>     /* Print the stuff we REALLY need to stdout, in case
>        a perl script or similar wants to parse it from a redirect */
>     printf("%.1lf %.1lf\n", spa.azimuth, spa.zenith);
>     return 0;
> }
>

_______________________________________________
NMLUG mailing list
[email protected]
http://lists.b9.com/cgi-bin/mailman/listinfo/nmlug
smime.p7s (application/x-pkcs7-signature, 3.2 KB) - not displayed