Here is my code:
Define PinMode Pin0 As AnalogInput Alias thermistorVoltage
Define PinMode Pin6 As DigitalOutput Alias enableThermistorVoltage
Class HighTempBeltBar3
Public Function GetTemperatureFromResistance(resistance As Float) As Float
Dim resistanceA As Float
Dim temperatureA As Float
Dim resistanceB As Float
Dim temperatureB As Float
Dim isValid As Boolean = False
Dim TempLookup As ListOfFloat = {-40,-38.2,-36.4,-34.6,-32.8,-31,-29.2,-27.4,-25.6,-23.8,-22,-20.2,-18.4,-16.6,-14.8,-13,-11.2,-9.4,-7.6,-5.8,-4,-2.2,-0.399999999999999,1.4,3.2,5,6.8,8.6,10.4,12.2,14,15.8,17.6,19.4,21.2,23,24.8,26.6,28.4,30.2,32,33.8,35.6,37.4,39.2,41,42.8,44.6,46.4,48.2,50,51.8,53.6,55.4,57.2,59,60.8,62.6,64.4,66.2,68,69.8,71.6,73.4,75.2,77,78.8,80.6,82.4,84.2,86,87.8,89.6,91.4,93.2,95,96.8,98.6,100.4,102.2,104,105.8,107.6,109.4,111.2,113,114.8,116.6,118.4,120.2,122,123.8,125.6,127.4,129.2,131,132.8,134.6,136.4,138.2,140,141.8,143.6,145.4,147.2,149,150.8,152.6,154.4,156.2,158,159.8,161.6,163.4,165.2,167,168.8,170.6,172.4,174.2,176,177.8,179.6,181.4,183.2,185,186.8,188.6,190.4,192.2,194,195.8,197.6,199.4,201.2,203,204.8,206.6,208.4,210.2,212,213.8,215.6,217.4,219.2,221,222.8,224.6,226.4,228.2,230,231.8,233.6,235.4,237.2,239,240.8,242.6,244.4,246.2,248,249.8,251.6,253.4,255.2,257,258.8,260.6,262.4,264.2,266,267.8,269.6,271.4,273.2,275,276.8,278.6,280.4,282.2,284,285.8,287.6,289.4,291.2,293,294.8,296.6,298.4,300.2,302,303.8,305.6,307.4,309.2,311,312.8,314.6,316.4,318.2,320,321.8,323.6,325.4,327.2,329,330.8,332.6,334.4,336.2,338,339.8,341.6,343.4,345.2,347,348.8,350.6,352.4,354.2,356,357.8,359.6,361.4,363.2,365,366.8,368.6,370.4,372.2,374,375.8,377.6,379.4,381.2,383,384.8,386.6,388.4,390.2,392,393.8,395.6,397.4,399.2,401,402.8,404.6,406.4,408.2,410,411.8,413.6,415.4,417.2,419,420.8,422.6,424.4,426.2,428,429.8,431.6,433.4,435.2,437,438.8,440.6,442.4,444.2,446,447.8,449.6,451.4,453.2,455,456.8,458.6,460.4,462.2,464,465.8,467.6,469.4,471.2,473,474.8,476.6,478.4,480.2,482,483.8,485.6,487.4,489.2,491,492.8,494.6,496.4,498.2,500,501.8,503.6,505.4,507.2,509,510.8,512.6,514.4,516.2,518,519.8,521.6,523.4,525.2,527,528.8,530.6,532.4,534.2,536,537.8,539.6,541.4,543.2,545,546.8,548.6,550.4,552.2,554,555.8,557.6,559.4,561.2,563,564.8,566.6,568.4,570.2,572}
Dim ResistanceLookup As ListOfFloat = {336479,314904,294848,276194,258838,242681,227632,213610,200539,188349,176974,166356,156441,147177,138518,130421,122847,115759,109122,102906,97081,91621,86501,81698,77190,72957,68982,65246,61736,58434,55329,52407,49656,47066,44626,42327,40159,38115,36187,34368,32650,31029,29498,28052,26685,25392,24170,23013,21918,20882,19901,18971,18090,17255,16463,15712,14999,14323,13681,13072,12493,11942,11419,10922,10450,10000,9572,9165,8777,8408,8057,7722,7402,7098,6808,6531,6267,6015,5775,5545,5326,5117,4917,4725,4543,4368,4201,4041,3888,3742,3602,3468,3340,3217,3099,2986,2878,2774,2675,2579,2488,2400,2316,2235,2157,2083,2011,1942,1876,1813,1752,1693,1637,1582,1530,1480,1432,1385,1340,1297,1255,1215,1177,1140,1104,1070,1037,1005,973.8,944.1,915.5,887.8,861.2,835.4,810.6,786.6,763.5,741.2,719.6,698.7,678.6,659.1,640.3,622.2,604.6,587.6,571.2,555.3,539.9,525,510.6,496.7,483.2,470.1,457.5,445.3,433.4,421.9,410.8,400,389.6,379.4,369.6,360.1,350.9,341.9,333.2,324.8,316.6,308.7,301,293.5,286.3,279.2,272.4,265.8,259.3,253.1,247,241.1,235.3,229.7,224.3,219,213.9,208.9,204.1,199.4,194.8,190.3,186.1,181.85,177.71,173.69,169.77,165.96,162.25,158.63,155.12,151.7,148.36,145.12,141.96,138.88,135.88,132.95,130.11,127.33,124.63,122,119.43,116.92,114.48,112.1,109.78,107.52,105.31,103.16,101.06,99.01,97.02,95.07,93.16,91.31,89.49,87.72,86,84.31,82.67,81.06,79.49,77.96,76.46,75,73.57,72.17,70.81,69.48,68.18,66.9,65.66,64.44,63.26,62.09,60.96,59.85,58.76,57.7,56.66,55.65,54.65,53.68,52.73,51.8,50.89,50,49.13,48.27,47.44,46.62,45.82,45.04,44.27,43.52,42.78,42.06,41.36,40.67,39.99,39.33,38.68,38.04,37.42,36.81,36.21,35.62,35.05,34.49,33.93,33.39,32.86,32.34,31.83,31.33,30.84,30.36,29.89,29.43,28.97,28.53,28.09,27.66,27.24,26.83,26.42,26.03,25.64,25.26,24.88,24.51,24.15,23.8,23.45,23.11,22.77,22.44,22.12,21.8,21.49,21.18,20.88,20.58,20.29,20.01,19.73,19.45,19.18,18.91,18.65,18.39,18.14,17.89,17.65,17.41,17.17,16.94,16.72,16.49,16.27,16.06,15.84,15.63,15.43,15.23,15.03,14.83,14.64,14.45,14.26,14.08,13.9}
For i As Integer = 0 To TempLookup.Count- 2
If ResistanceLookup(i) >= resistance And ResistanceLookup(i + 1) <= resistance Then
resistanceA = ResistanceLookup(i)
temperatureA = TempLookup(i)
resistanceB = ResistanceLookup(i + 1)
temperatureB = TempLookup(i + 1)
isValid = True
Exit For
End If
Next
If isValid Then
Return temperatureA + (temperatureB - temperatureA) * (resistance - resistanceA) / (resistanceB - resistanceA)
End If
Return Nothing
End Function
Const PublishTopic As String = "Altizon/Datonis/abfd5a7723/event"
Shared Event Report() RaiseEvent Every 30 Seconds
enableThermistorVoltage = True 'turn on voltage divider
Thread.Sleep(20000) 'sleep 20ms for voltage to stabilize
Dim voltage As Float = thermistorVoltage 'return thermistor voltage in mv
Dim voltagestring As String = voltage.ToString()
'convert voltage to resistance'
Dim VBatt As Float = Device.BatteryVoltage
Dim ThermR As Float = 10000 * (VBatt / thermistorVoltage) - 10000
Dim TempR As Float = GetTemperatureFromResistance(ThermR)
'convert battery voltage into a percent
Dim batt_level As Float = (VBatt / 3000) * 100
Dim Payload As Json = New Json
Dim JvaluesList As ListOfJValue = New ListOfJValue
Dim Jtemp As Json = New Json
Jtemp.Add("id", "abfd5a7723.Temperature")
Jtemp.Add("v", TempR)
JvaluesList.Add(New JValue(Jtemp))
Jtemp = New Json
Jtemp.Add("id", "abfd5a7723.batt_level")
Jtemp.Add("v", batt_level)
JvaluesList.Add(New JValue(Jtemp))
Payload.Add("values", JvaluesList)
Payload.Add("Authorization", "I removed this piece since it is a unique identifier")
Dim Str As String = Payload.ToString
Lplan.Publish(PublishTopic, Payload.ToListOfByte)
End Event
End Class
It doesn't matter where I place the break, it fails when I step over. Most recently it was at line 47: Dim batt_level As Float = (VBatt / 3000) * 100
Here is the log:
11:33:57.119 ------ mcStudio Started -------
11:36:32.490 ------ mcStudio Started -------
11:40:13.812 ---Gateway '00.01.13.CC' Process AckDeviceList
11:40:13.881 ---Gateway '00.01.13.CC' Process NewDevice(Uid=000115B6, Name=, Version=0.7-411)
11:40:13.950 ---Gateway '00.01.13.CC' Process NewDevice(Uid=000115B1, Name=, Version=0.7-411)
11:40:14.012 ---Gateway '00.01.13.CC' Process NewDevice(Uid=000115B4, Name=, Version=0.0-0)
11:40:14.081 ---Gateway '00.01.13.CC' Process NewDevice(Uid=000114A0, Name=, Version=0.0-0)
11:40:18.281 Gateway 'Virtual Gateway' Disconnect function. Uid=00.00.FF.00
11:40:18.297 Gateway 'Virtual Gateway' ConnectionPing to 00.00.FF.00 Value=0
11:40:18.297 ***VirtualGW Receive Message Disconnect
11:40:18.297 Gateway '00.01.13.CC' Connect function. Uid=00.01.15.B1
11:40:18.297 ---Gateway 'Virtual Gateway' Process AckDisconnect
11:40:18.297 ***VirtualGW Receive Message ConnectionPing
11:40:18.297 ---Gateway '00.01.13.CC' Process AckConnect
11:40:18.297 Gateway '00.01.13.CC' ConnectionPing to 00.01.15.B1 Value=60
11:40:36.364 ---Gateway '00.01.13.CC' Process Connected(Uid=000115B1, Name=, Version=0.7-411)
11:40:45.045 Gateway '00.01.13.CC' Load Init function
11:40:45.497 ---Gateway '00.01.13.CC' Process AckInit
11:40:45.497 Gateway '00.01.13.CC' Load Code function (sector=0)
11:40:45.998 ---Gateway '00.01.13.CC' Process AckLoadCode
11:40:45.998 Gateway '00.01.13.CC' Load Code function (sector=1)
11:40:46.498 ---Gateway '00.01.13.CC' Process AckLoadCode
11:40:46.498 Gateway '00.01.13.CC' Load Code function (sector=2)
11:40:46.989 ---Gateway '00.01.13.CC' Process AckLoadCode
11:40:46.989 Gateway '00.01.13.CC' Load Code function (sector=3)
11:40:47.498 ---Gateway '00.01.13.CC' Process AckLoadCode
11:40:47.498 Gateway '00.01.13.CC' Load Code function (sector=4)
11:40:47.999 ---Gateway '00.01.13.CC' Process AckLoadCode
11:40:47.999 Gateway '00.01.13.CC' Load Strings function (sector=0)
11:40:48.499 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:48.499 Gateway '00.01.13.CC' Load Strings function (sector=1)
11:40:48.999 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:48.999 Gateway '00.01.13.CC' Load Strings function (sector=2)
11:40:49.486 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:49.486 Gateway '00.01.13.CC' Load Strings function (sector=3)
11:40:50.001 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:50.001 Gateway '00.01.13.CC' Load Strings function (sector=4)
11:40:50.664 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:50.664 Gateway '00.01.13.CC' Load Strings function (sector=5)
11:40:51.116 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:51.116 Gateway '00.01.13.CC' Load Strings function (sector=6)
11:40:51.616 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:51.616 Gateway '00.01.13.CC' Load Strings function (sector=7)
11:40:52.119 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:52.119 Gateway '00.01.13.CC' Load Strings function (sector=8)
11:40:52.621 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:52.621 Gateway '00.01.13.CC' Load Strings function (sector=9)
11:40:53.121 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:53.121 Gateway '00.01.13.CC' Load Strings function (sector=10)
11:40:53.624 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:53.624 Gateway '00.01.13.CC' Load Strings function (sector=11)
11:40:54.124 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:54.124 Gateway '00.01.13.CC' Load Strings function (sector=12)
11:40:54.624 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:54.624 Gateway '00.01.13.CC' Load Strings function (sector=13)
11:40:55.113 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:55.113 Gateway '00.01.13.CC' Load Strings function (sector=14)
11:40:55.616 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:55.616 Gateway '00.01.13.CC' Load Strings function (sector=15)
11:40:56.118 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:56.118 Gateway '00.01.13.CC' Load Strings function (sector=16)
11:40:56.627 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:56.627 Gateway '00.01.13.CC' Load Strings function (sector=17)
11:40:57.126 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:57.126 Gateway '00.01.13.CC' Load Strings function (sector=18)
11:40:57.627 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:57.627 Gateway '00.01.13.CC' Load Strings function (sector=19)
11:40:58.130 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:58.130 Gateway '00.01.13.CC' Load Strings function (sector=20)
11:40:58.626 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:58.627 Gateway '00.01.13.CC' Load Strings function (sector=21)
11:40:59.129 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:59.129 Gateway '00.01.13.CC' Load Strings function (sector=22)
11:40:59.627 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:40:59.627 Gateway '00.01.13.CC' Load Strings function (sector=23)
11:41:00.116 ---Gateway '00.01.13.CC' Process AckLoadLiterals
11:41:00.116 Gateway '00.01.13.CC' Reset function
11:41:00.616 ---Gateway '00.01.13.CC' Process AckReset
11:41:00.616 Gateway '00.01.13.CC' SetBreakpoints function (202)
11:41:01.116 ---Gateway '00.01.13.CC' Process AckBreakpoints
11:41:01.116 Gateway '00.01.13.CC' Run function (StopAfterReturn=False, BreakAtNext=-1, BreakAtBranch=-1)
11:41:01.618 ---Gateway '00.01.13.CC' Process AckRun
11:41:01.756 ---Gateway '00.01.13.CC' Process ReturnRun PC=202, ErrNbr=0, ErrData=0, ErrPC=0, PinValues=00000000, ThreadPrio=1
11:41:01.771 Gateway '00.01.13.CC' GetFrameStack function
11:41:02.255 ---Gateway '00.01.13.CC' Process AckFrameStack
11:41:02.255 Gateway '00.01.13.CC' GetValVariableStack function
11:41:02.771 ---Gateway '00.01.13.CC' Process AckValVariableStack
11:41:02.771 Gateway '00.01.13.CC' GetRefVariableStack function
11:41:03.255 ---Gateway '00.01.13.CC' Process AckRefVariableStack
11:41:03.255 Gateway '00.01.13.CC' GetObject function
11:41:03.817 ---Gateway '00.01.13.CC' Process AckObject
11:41:03.839 Gateway '00.01.13.CC' GetObject function
11:41:04.254 ---Gateway '00.01.13.CC' Process AckObject
11:41:12.913 Gateway '00.01.13.CC' Load Init function
11:41:13.374 ---Gateway '00.01.13.CC' Process AckInit
11:41:16.544 Gateway '00.01.13.CC' Disconnect function. Uid=00.01.15.B1
11:41:16.544 Gateway '00.01.13.CC' ConnectionPing to 00.01.15.B1 Value=0
11:41:16.997 ---Gateway '00.01.13.CC' Process AckDisconnect