Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20620

Share your working BASCOM-AVR code here : MAX31855 Thermocouple : NEWTOPIC

$
0
0
Hi, This simple example of reading the MAX31855. Is similar of MAX6675 but, run only in 3V3, in 14 bit and very lower cost. This example is tested whit thermocouple K and MAX31855KASA+ I have used external Quartz and 10nF capacitor on thermocouple leads for reduce the enviroment noise. [code:1:17aa32d4d2] $regfile = "m88def.dat" $crystal = 8000000 $baud = 9600 $hwstack = 40 $swstack = 30 $framesize = 40 ' Config Config Portc.1 = Output ' CS Config Portc.0 = Output ' SCK Config Portc.2 = Input ' S0 ' Alias Cs Alias Portc.1 Sck Alias Portc.0 So Alias Pinc.2 ' Deflault Values Set Cs ' CS1 to Hight Reset Sck ' CSK low Set So ' SO hight Declare Function Get_ext_temperature() As String * 5 Dim Tmp1 As Dword ' 32 bit var Dim Tmp2 As Word ' 16 bit var Do Print "Thermocouple: " ; Get_ext_temperature() Waitms 750 Loop Function Get_ext_temperature() As String * 5 ' TC temperature Reset Cs ' CS1 to low Shiftin So , Sck , Tmp1 , 0 , 32 ' Read 32 bit data from max33855 Set Cs ' CS1 to Hight If Tmp1.0 = 1 Then ' tmp1.0 = 1 = no sensor Get_ext_temperature = "NO_TC" Exit Function Elseif Tmp1.1 = 1 Then ' tmp1.1 = 1 = short circuit to gnd Get_ext_temperature = "SCGND" Exit Function Elseif Tmp1.2 = 1 Then ' tmp1.2 = 1 = short circuit to vcc Get_ext_temperature = "SCVCC" Exit Function Elseif Tmp1.17 = 1 Then Get_ext_temperature = "FAULT" ' 1 if SCV,SCG or OC fault End If Shift Tmp1 , Right , 18 ' Move D0-D17 now the D18-D31 at LSB of tmp1 Tmp2 = Tmp1 ' Cut for 16bit If Tmp2.13 = 0 Then ' tmp2.0 to tmp2.12 = value, tmp2.13 = sign 0=+ 1=- Get_ext_temperature = "+" ' tmp2.14 and .15 is allways 0 Else Get_ext_temperature = "-" Tmp2.13 = 0 End If Tmp2 = Tmp2 / 4 ' for convert to celsius Get_ext_temperature = Get_ext_temperature + Str(tmp2) End Function [/code:1:17aa32d4d2]

Viewing all articles
Browse latest Browse all 20620

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>