Recent Posts

Pages: 1 ... 8 9 [10]
91
mc-Module / Re: NTC Thermistor Demo
« Last post by AndrewPratt on December 13, 2017, 10:19:07 am »
Quote
That is great, what was the root of the problem?

An idIOT error ;) When I copied the code from the 120 to the 205 I originally left the resistor value at 100k not 10k ::)
92
mc-Module / Re: NTC Thermistor Demo
« Last post by mc-Josh on December 13, 2017, 09:51:14 am »
That is great, what was the root of the problem?

Thanks,

Josh
93
This is my sub-class:
Code: [Select]
Class UART_Debug
    Shared ser As Uart
    Shared Buffer As ListOfByte
   
    Public Sub New()
        //Lplan.SetMidPowerMode(2000)
        ser = Uart.Create(9600, Pin.Pin1, Pin.Pin0) // Pin 1 to Rxd and pin 0 to TxD; Dev-Board default jumper config
        ser.Write("DEBUG-TERMINAL started") ser.Write(13) ser.Write(10)
        Buffer = New ListOfByte
    End Sub
   
    //Shared Event Uart0Receive() Doesn't work in a class so I try to call this in the main-program but it doesn't work either.
    Public Sub UartReceive()
        Dim chr As Integer = ser.Read
        While chr >= 0
            If chr = 13 Then ' CR echo as CR/LF
                ser.Write(10)
                ParseBuffer()
            Else
                Buffer.AddByte(chr.ToByte)
            End If
            ser.Write(chr.ToByte)
            chr = ser.Read()
        End While
    End Sub
   
    Public Sub print(S As String)
        ser.Write(S)
    End Sub
   
    Public Sub println(S As String)
        ser.Write(S)
        ser.Write(13) ser.Write(10)
    End Sub
   
    Private Sub ParseBuffer()
        Dim S As String
        S = Buffer.ToString
        If S = "help" Then
            ser.Write("Wait I'm going to help you\n\r")
        End If
        Buffer.Clear
    End Sub
End Class

And this is my main-program:
Code: [Select]
Class UART_Terminal_v2
    Shared Terminal As UART_Debug
   
    Shared Event Boot()
        Lplan.SetMidPowerMode(2000)
        //Data = New ListOfObject()
        Terminal = New UART_Debug
    End Event
   
    Shared Event Uart0Receive()
        Terminal.UartReceive()
    End Event
   
    Shared Event Every15Seconds() RaiseEvent Every 15000 milliSeconds
       
        Terminal.println("Every 15 seconds")
       
    End Event
   
End Class

The message is printed every 15 seconds. But the Uart0Receive() Event isn't doing anything.  ???
94
mc-Module / Re: NTC Thermistor Demo
« Last post by AndrewPratt on December 12, 2017, 02:45:10 pm »
Thanks Josh I now have it working on the Demo 205 as well using the following.


Define PinMode Pin0 As AnalogInput Alias USP10972_VOLTAGE
Define PinMode Pin6 As DigitalOutput Alias USP10972_DIVIDER_ENABLE

Class ThermistorTheThings
   
    Const USP10972_BETA As Integer = 3892
    Const USP10972_R25 As Integer = 10000 '10kOhm
    Const USP10972_DIVIDER_R1 As Integer = 10000 '10kOhm
   
    Shared USP10972 As NTCTermistor
   
    Shared Event Boot()
        USP10972_DIVIDER_ENABLE = False
        USP10972 = New NTCTermistor(USP10972_BETA, USP10972_R25)
    End Event
   
    Shared Event measureTemperature() RaiseEvent Every 1 Hours
        USP10972_DIVIDER_ENABLE = True
        Device.EnableOpamp()
        Thread.Sleep(10000) 
        Dim thermistorResistance As Float = USP10972_DIVIDER_R1 * (1 / ((Device.BatteryVoltage().ToFloat/ USP10972_VOLTAGE.ToFloat) - 1))
        USP10972_DIVIDER_ENABLE = False
        Device.DisableOpamp()
       
        Dim battShort As Short = Device.BatteryVoltage()
        Dim battFloat As Float = battShort / 1000
        Dim battString As String = battFloat.ToString()
        Dim tempTMP102string As String = Temperature.GetTemp().ToString
        Dim tempPstring As String = USP10972.TemperatureCFromResistance(thermistorResistance).ToString         
       
        Dim LosantTopic As String = "losant/myDeviceID/state"
        Dim losantPayload As Json = New Json       
        Dim mcJson As Json = New Json
       
        mcJson.Add("probeTemp", tempPstring)
        mcJson.Add("temperature", tempTMP102string)
        mcJson.Add("batteryVoltage", battString)
       
        losantPayload.Add("data", mcJson)
        Lplan.Publish(LosantTopic, losantPayload.ToListOfByte)
    End Event
End Class
95
mc-Module / Re: NTC Thermistor Demo
« Last post by mc-Josh on December 12, 2017, 02:05:10 pm »
Andrew,

You don't need the AnalogInputPullUp if you are providing the pullup yourself. The CWF1B104F3950 thermistor does not need an external pullup since it uses the 100k pullup on the mod120. The USP10972 uses the 10k pullup that you added to the circuit.

Josh
96
mc-Module / Re: NTC Thermistor Demo
« Last post by AndrewPratt on December 12, 2017, 11:14:04 am »
Now that I have it working on the mc120 how do you suggest I port it to the 205 given that the 205 doesn't seem to support the AnalogInputPullUp?
97
mc-Module / Re: NTC Thermistor Demo
« Last post by AndrewPratt on December 12, 2017, 11:09:59 am »
Update. I decided that since I only had 1 temp probe attached to the 120 I didn't need to use the resistor and pin's 0 & 6 so I swapped it over to the ground and pin7 approach with the internal pullup and it now works perfectly. This is the new code.

Define PinMode Pin7 As AnalogInputPullUp Alias USP10972_VOLTAGE

Class ThermistorTheThings
   
    Const USP10972_BETA As Integer = 3892
    Const USP10972_R25 As Integer = 10000 '10kOhm
    Const USP10972_DIVIDER_R1 As Integer = 100000 '100kOhm
   
    Shared USP10972 As NTCTermistor
   
    Shared Event Boot() 
        USP10972 = New NTCTermistor(USP10972_BETA, USP10972_R25)
    End Event
   
    Shared Event measureTemperature() RaiseEvent Every 10 Seconds
        Device.EnableOpamp()
        Thread.Sleep(10000) 
        Dim thermistorResistance As Float = USP10972_DIVIDER_R1 * (1 / ((Device.BatteryVoltage().ToFloat/ USP10972_VOLTAGE.ToFloat) - 1)) 
        Device.DisableOpamp()
       
        Dim battShort As Short = Device.BatteryVoltage()
        Dim battFloat As Float = battShort / 1000
        Dim battString As String = battFloat.ToString()
        Dim tempTMP102string As String = Temperature.GetTemp().ToString
        Dim tempPstring As String = USP10972.TemperatureCFromResistance(thermistorResistance).ToString         
       
        Dim LosantTopic As String = "losant/myDeviceID/state"
        Dim losantPayload As Json = New Json       
        Dim mcJson As Json = New Json
       
        mcJson.Add("probeTemp", tempPstring)
        mcJson.Add("temperature", tempTMP102string)
        mcJson.Add("batteryVoltage", battString)
       
        losantPayload.Add("data", mcJson)
        Lplan.Publish(LosantTopic, losantPayload.ToListOfByte)
    End Event
End Class
98
mc-Module / Re: NTC Thermistor Demo
« Last post by AndrewPratt on December 11, 2017, 04:23:01 pm »
So when I measure the 0 and 6 pin's and measure the voltage as I dip the probe in hot and cold water it does change as you'd expect it would.

This is the tempprobe code that I added to the project...

Class NTCTermistor
    Private beta As Integer
    Private R25 As Integer
    Public Sub New(betaIn As Integer, R25In As Integer)
        'set Beta value
        beta = betaIn
        'Set R25 resistance value
        R25 = R25In
    End Sub
    Public Function TemperatureFromResistance(resistance As Float) As Float
        'returns temperature in Kelvin from resistance of thermistor using Beta parameter equation
        Dim temp1 As Float = -1 * beta.ToFloat() / 298.15
        Dim temp2 As Float = resistance / (R25.ToFloat() * temp1.Exp())
        Return (beta / temp2.Log())
    End Function
    Public Function TemperatureFFromResistance(resistance As Float) As Float
        'returns temperature in Fahrenheit from resistance of thermistor
        Return (TemperatureFromResistance(resistance) * (9 / 5)) - 459.67
    End Function
    Public Function TemperatureCFromResistance(resistance As Float) As Float
        'returns temperature in Celcuis from resistance of thermistor
        Return TemperatureFromResistance(resistance) - 273.15
    End Function
End Class
99
mc-Module / Re: NTC Thermistor Demo
« Last post by mc-Josh on December 11, 2017, 04:14:09 pm »
Andrew,

It looks like you have the correct connections but that they may be intermittent since they are not soldered. Can you solder the connections to the thermistor and the resistor? Also, can you measure the voltage being provided to the resistor divider and the voltage at the sensor and ensure that the corresponding voltage is correct for the temperature? We have made quite a few of these and haven't had any issues.

Thanks,

Josh
100
mc-Module / Re: NTC Thermistor Demo
« Last post by AndrewPratt on December 11, 2017, 03:54:57 pm »
sorry I thought I'd included those. The wiring is the same as the demo only I had wire leads added to the mc120 so that we could prototype other things more easily.


Define PinMode Pin0 As AnalogInput Alias USP10972_VOLTAGE
Define PinMode Pin6 As DigitalOutput Alias USP10972_DIVIDER_ENABLE
Pages: 1 ... 8 9 [10]