Tuesday, September 23, 2008

Code

Here is the first bit of code for the Testing stage of the project. The program will get temps, and time and then display it and log it. This is revision 3. Revision 4 will include datalogger code. 

OBJ
delay: "delays"                 'Delay Object
text : "tv_text"                'TV Object
logger: "DataloggerSPI"         'Datalogger Object
A2D : "MCP3208"                 'A to D Object
VAR
word CHT 'Cylinder Head Temp
long EGT 'Exhaust Gas Temp
long counter
word gnd
long Temp
long T2

Pub main
  init   'Init Devices
  counter :=0
  repeat
      text.str(string($0D,$0D,"Temperature is: ")) 
      CHT := A2D.in(0)
      gnd :=A2D.in(1)
      Temp:= ((CHT - gnd)/(1024/125))  'Take CHT - floating gnd / A2D constant = temp
      text.dec(Temp)
      text.str(string($0D,$0D,"Time running is: "))
      counter++
      text.dec(counter)
  
     
    delay.DelaySec(1)
    text.out($00)   
  
                                                                   
  
 
PUB init
  'Init our devices
   text.start(12) 'init TV out
   A2D.start(5,4,6,%1111111)       'DI/DO,CLK,CS,PINS
  'logger.DataloggerSPI (0,1,2,3)

Chris Mountain
N.M.E. Design Team 

No comments: