Changeset 13157 for fact


Ignore:
Timestamp:
03/20/12 14:37:05 (13 years ago)
Author:
ogrimm
Message:
FSC resistances converted into temperature for online display
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/FSCctrl/FSCctrl.cc

    r10956 r13157  
    55#include <sys/socket.h>
    66#include <netdb.h>
     7#include <math.h>
    78
    89#include "Evidence.h"
     
    2324
    2425const unsigned int MAX_VAL = TEMP_OFF + TEMP_NUM +100;
     26
     27// Parameters for PT1000
     28const float R0 = 1000, A = 3.9083e-3, B = -5.775e-7;
    2529
    2630using namespace std;
     
    7680
    7781  // Send start command to FSC board
    78   snprintf(Buffer, sizeof(Buffer), "m");
     82  snprintf(Buffer, sizeof(Buffer), "m\n");
    7983  Result = write(Socket, Buffer, 1);
    8084  if (Result != 1) S.Message(S.ERROR, "Could not write to socket (%s)", strerror(errno));
     
    120124        }
    121125
     126        // Translate resistance to temperatures
     127        for (unsigned int i=0; i<TEMP_NUM; i++) {       
     128          Val[i+TEMP_OFF] = -A/(2*B)-sqrt(pow(A/(2*B),2)-(R0-Val[i+TEMP_OFF])/(B*R0));
     129        }
     130       
    122131        // Update DIM service
    123132        Temperature.updateService();
Note: See TracChangeset for help on using the changeset viewer.