Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

LM75 sensor on different boards reads different temperatures

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Various
View previous topic :: View next topic  
Author Message
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Tue Nov 07, 2017 8:54 am    Post subject: LM75 sensor on different boards reads different temperatures Reply with quote

Hello,

I am using a LM75 i2c temperature sensor in an application running on ATMEGA32A running at 16MHz.

I have noticed that the same sensor when plugged into different production boards reports different temperatures when inexactly he same environment. Suspecting a power supply issue, this board features a LM2575 regulator to produce the 5V required for the board to operate, have checked all he board voltages they are more or less he same within 5.01 o 5.07V. Yet i see his difference. unable to understand the problem.

Appreciate any help in his regard.

Compiler Version 2.0.8.0
Compiler Build 2.0.8.0.001
IDE Version 2.0.8.0.006

Windows OS Windows 10 Pro (latest update)


Regards

Madhav Tenneti

(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.7.8 )
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Tue Nov 07, 2017 11:48 am    Post subject: Reply with quote

hi,
I read the datasheet :

Temperature Accuracy −25°C to 100°C ±2°C(max)
and VCC from 3 to 5.5v So it is not the problem

Try different LM75 on the same board and same Lm75 on different board
also did you check your program, do you have a error management for I2C translation ?

You did'nt give enough informations ,
what range of difference ?
it seems this components is sensible in noisy environments.
maybe let us a part of program ?

JP
Back to top
View user's profile Visit poster's website
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 586
Location: Cleveland, OH

usa.gif
PostPosted: Tue Nov 07, 2017 7:16 pm    Post subject: Reply with quote

As mentioned above: How big a difference in temperature measurements?

Also, are you talking about using the same, single device, moved from board to board, or are you saying several boards, all with their own LM75, give different readings?

Is the LM75 mounted on the PCB, or on wires, and if so how long are the wires? (Not likely an issue).

Do you have a 0.1 uF cap across the LM75 power supply terminals, as close to the device as possible?

JC
Back to top
View user's profile Visit poster's website
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Wed Nov 15, 2017 2:59 am    Post subject: lm75 isssue, same devuce on multiple boards Reply with quote

Sorry was away, couldn't reply back earlier....

Yes it is one Lm75 mounted on a smt to dip conversion pcb connected to different microcontroller boards, shows different temperatures.
Yes have a cap across supply and gnd on the Lm75 pcb, the difference is substantial, properly working boards reads 25 deg, others are reading about 37-40 deg.

My room thermometer matches the working board temperature, i have checked more than 3 Lm75 sensors similarly mounted with these microcontroller boards, the results are similar and consistent, i.e the ones showing higer temperatures are showing nearly the same and those working are working perfectly across all three sensors, hence i dont suspect code issues....
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Wed Nov 15, 2017 11:07 am    Post subject: Reply with quote

well...
did you see https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=11760&highlight=lm75
Paul use integer as variable. did you ?
without code it is difficult for the forum

JP Wink
Back to top
View user's profile Visit poster's website
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 586
Location: Cleveland, OH

usa.gif
PostPosted: Wed Nov 15, 2017 11:48 pm    Post subject: Reply with quote

Do all of the boards have a Mega32, and are they all running the same, exact, version of the software?

Are the boards commercial boards, or of your own design?

Are the working and the non-working boards identical boards, or different designs?

If the boards are your design, can you post an accurate schematic of your circuit?

JC
Back to top
View user's profile Visit poster's website
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Sun Nov 19, 2017 5:08 pm    Post subject: Reply with quote

Yes all Boards have ATMEGA32A and all boards are running the same software.
The Board is my own design as requested I have attached the Schematic here, as had informed earlier, the LM75 is soldered on to a SMT to DIP converter board and attached to the i2C connector, yes also close to the Board is a 0.1mfd disc cap soldered between the power rails.As requested have attached the code for a Pressure and Temperature set point controller.
Code:
$Regfile="m32adef.dat"
$crystal = 16000000
$hwstack = 256
$swstack = 128
$framesize = 156
$baud = 9600
MCUCR = &h03

Config Timer0 = TIMER, prescale = 8

Config ADC = Single, Prescaler = Auto
Config PortB =Output

Co2On Alias PortB.0
Chiller Alias PortB.1
Co2Prob Alias PortB.2
ChillerProb Alias PortB.3


Config SCL = PortC.0
Config SDA = PortC.1
i2cinit

Config LCD = 16 * 2
Config LCDbus = 4
Config LCDpin = pin, DB4 = PortC.4, DB5 = PortC.5, DB6 = PortC.6, DB7 =  PortC.7, E =  PortC.3, Rs = PORTC.2

Config PinD.3 = Output
Config Pind.4 = Input
Config PinD.5 = Input
Config PinD.6 = Input
Config PinD.7 = Input

SW_TInc alias PinD.4
SW_TDec Alias PinD.5
SW_PInc Alias PinD.6
SW_PDec Alias PIND.7

DDIR Alias PortD.3
Reset DDIR
RESET Co2Prob
Reset ChillerProb

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Variavles
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Dim Value as Byte, Waddress as Byte, Raddress as Byte, Rundel as byte
Dim Rng_min As Byte , Rng_max As Byte , User_sel As Byte, Kyscncod as Byte
Dim Rxbyte as Byte,  Srlcnt as Byte, Chno As Byte , DEl as word
Dim Micsecs as byte, Milsecs as word, Secs as byte, Mins as Byte, Hrs as byte

Dim PSV as single, PCV as single, TSV as Single , TCV as single
Dim byt_psv as byte, byt_Tsv as byte, Run as byte, Keypress as bit, Srlint as bit
Dim Tsv_txt as string * 4,Psv_Txt as string * 4, Pcv_txt as string * 4, TCv_txt as string * 4


Dim Rcdata(10) As Single ,Adcfiltval As Single, Temp as single, Prsur as Single
Dim M_add as word


Dim MsgL1 as string * 20, MsgL2 as String * 20,




'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          Subroutine Declarations
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Declare Sub Splash()
Declare Sub Alert()
Declare Sub Delayy()
Declare Sub Get_systemsetngs()
Declare Sub Chk_ky()
Declare Sub Disp()


Declare Sub Chk_adc()


Declare sub delus25()
Declare Sub Delayy1()
Declare Sub Read_eeprmc64(byref M_add As Word , Byref Value As Byte)
Declare Sub Write_eeprmc64(byref M_add As Word , Byref Value As Byte)
Declare Sub Pcf8574read()
Declare Sub Pcf8574write(byval Value As Byte)

Declare sub Maintain_temp()
Declare Sub Maintain_Prsur()

Declare Sub Read_LM75()
Declare Sub Write_LM75()
Declare Sub Onbrdadc()
Declare Function Get_adc(byref Chno As Byte) As Single

Declare Sub Service_mnu()
Declare sub ChkAi()
Declare Sub Chk_outputs()
Declare Sub Run_system()
Declare Sub Recall_setngs()

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          System Main Routine
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Const Msg0  =  "SODA HUB"
Const Msg1  =  " +91 9989488598 "


Enable Interrupts
Enable Int0
Enable Urxc
Enable Timer0

On Int0 Kybisr
On Urxc Srlisr
On Timer0 Tmr0isr

Load Timer0, 200
Start Timer0

CLS
Cursor OFF
PortB = &H00

Call Splash


Do
   Call Run_System


Loop
End
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Splash Screen
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Splash()
   Call Write_Lm75
   MsgL1 = Msg0
   MsgL2 = Msg1
   CLS
   Lcd MsgL1
   Lowerline
   LCD MSGL2
   Wait 2
   Cls

   Milsecs=0
   Micsecs = 0
   SEcs = 0
   Call Recall_setngs
Do
   If Sw_Tdec = 0 then
      Call Service_mnu
   End if
Loop until Secs >= 5
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Splash Screen
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Recall_setngs()
   For M_add = 10 to 11
      Call Read_eeprmc64(M_add, Value)
      Select case M_add
         Case is = 10:
             If Value >= 10 And Value <= 255 then
                byt_Tsv = Value
             Else
                Byt_Tsv = 40
             End if
             TSV = byt_Tsv / 10
             Tsv_txt = fusing(Tsv, "#.#")
         Case is = 11:
             If Value >= 1 And Value <= 60 then
                byt_Psv = Value
             Else
                Byt_Psv = 25
             End if
             PSV = byt_Psv / 10
             Psv_txt = fusing(Psv, "#.#")
      End select
   Next
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Service Menu
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Service_mnu()
   Rng_min = 0
   Rng_max = 1
   User_sel = 0
   Cls
   LCD "SELECT AN OPTION"
   Do
      Call Chk_ky
   Loop until Sw_Tinc = 0 And SW_TDec = 0
End sub

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Disp Screen
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Disp()

   Locate 1,1
   Lcd "TS:" ; Tsv_txt ; " TP:" ; Tcv_txt ; " "
   Locate 2,1
   Lcd "PS:" ; Psv_txt ; " PP:" ; Pcv_txt ; " "
   waitms 50
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                 Run System
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Run_system()
   Run = 1
   Call Chk_ky
   Call Chk_Adc
   Call Read_LM75
   Call Maintain_Temp
   Call Maintain_Prsur
   Call Disp
   If Sw_Tinc = 0 And Sw_TDec = 0 then
      M_add = 10
      Value = Byt_Tsv
      Call Write_eeprmc64(M_add, Value)
      Keypress = 0
      Enable Int0
      Cls
      LCD "Written to EEP"
      Waitms 200
   End if
   If Sw_Pinc = 0 And Sw_PDec = 0 Then
      M_add = 11
      Value = Byt_Psv
      Call Write_eeprmc64(M_add, Value)
      Keypress = 0
      Enable Int0
      Cls
      LCD "Written to EEP"
      Waitms 200
   End if
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                       Common Temp & Pressure Controls
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Maintain Temp
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Maintain_temp()
   Local TempHigh as Single
   Local TempLow as Single
   Local Terr_High as single
   Local TErr_low as single
   TempHigh = TSV + 1
   TempLow = Tsv - 1
   Terr_high = TSV + 3
   Terr_Low = Tsv + 1
   If TCV  >= TempHigh then
      Set Chiller
   Elseif TCV <= Templow then
      Reset Chiller
   End if
   If TCv >= Terr_High then
      Set Chillerprob
   Elseif TCV <= Terr_low then
      Reset Chillerprob
   End if
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                            Maintain Pressure
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Maintain_prsur()
   Local PrsurHigh as Single
   Local PrsurLow as single
   Local Perr_high as single
   Local Perr_low as single
   Local Crit_Prsur as single
   PrsurHigh = PSV + 0.1
   PrsurLow = PSV - 0.1
   Perr_high = Psv - 0.25
   Perr_low = Psv - 0.5
   Crit_Prsur = Psv + 0.5
   If PCv >= PrsurHigh then
      ReSet Co2On
   Elseif PCV <= Prsurlow then
      set Co2On
   End if
   If PCv >= Perr_high then
      ReSet Co2Prob
   Elseif PCv <= Perr_Low then
      set Co2Prob
   End if
   If Pcv >= Crit_Prsur then
      Set Co2Prob
   End if
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Read LM 75
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Read_LM75()
   Local Hi_data as byte
   Local Lo_data as byte
   Local Portdata as word
   Local Tmp_data as Byte
   Local Chk15bit as byte
   Local Chk8bit as byte
   Waddress = &h90
   Raddress = &h91
   I2cstart                                                 'generate start
   I2cwbyte Waddress                                        'slave adsress
   I2cwbyte &h00
   I2crepstart                                                 'repeated start
   I2cwbyte Raddress                                        'slave address (read)
   I2crbyte Hi_data , ack
   I2crbyte Lo_data , Nack                                   'read byte
   I2cstop

   Chk15bit = Hi_data AND &H80
   Chk8bit = Lo_data AND &H80
   If Chk15bit = &H80 then
      Tmp_data = Hi_data - 1
      Tmp_data = Tmp_data XOR &HFF
      Temp = Tmp_data * -1
      If Chk8bit = &h80 then
         Temp = Temp - 0.5
      End if
   Else
      Temp = Hi_data
      If Chk8bit = &h80 then
         Temp = Temp + 0.5
      End if
   End if
   Tcv = Temp
   Tcv_txt = Fusing(Tcv, "#.#")
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Write LM 75
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Write_LM75()
   Waddress = &h90
   Raddress = &h91
   I2cstart
   I2cwbyte Waddress
   I2cwbyte &h01
   I2cwbyte &h06
   I2cstop
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             ADC Function On Board ADC
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Function Get_adc(chno) As Single
   Local Filtvolt As Single
   Local Rcvlt As Single
   Local Smpl As Byte
   Local Lpp As Byte

     Rcvlt = 0
     For Smpl = 1 To 10
        Call Onbrdadc
        Rcvlt = Rcvlt + Adcfiltval
     Next
     Rcvlt = Rcvlt / 10
     Get_adc = Rcvlt
End Function
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          Get ADC Data After Median
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Onbrdadc()
   Local Pdata As Word
   Local Smplno As Byte
   Local Th_high As Single
   Local Th_low As Single
   Local Volt As Single
   Local Avg10 As Single
   Local Filtsmpl As Byte

   Avg10 = 0
   For Smplno = 1 To 10
      Pdata = Getadc(chno)
      Volt = Pdata * 0.0048828125
      Avg10 = Avg10 + Volt
      Rcdata(smplno) = Volt
   Next
   Avg10 = Avg10 / 10
   Th_high = Avg10 + 0.005
   Th_low = Avg10 - 0.005
   Adcfiltval = 0
   Filtsmpl = 0
   For Smplno = 1 To 10
      If Rcdata(smplno) > Th_low And Rcdata(smplno) < Th_high Then
         Adcfiltval = Adcfiltval + Rcdata(smplno)
         Incr Filtsmpl
      End If
   Next
   If Filtsmpl > 0 Then
      Adcfiltval = Adcfiltval / Filtsmpl
   Else
      Adcfiltval = Avg10
   End If
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Check ADC
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Chk_adc()
   Local Volt as single
   Local Volt1 as single
   Local Volt2 as single
   Local mcur4 as single
   Local Mcur5 as single
   Local C420ma4 as single
   Local C420ma5 as single
   Chno = 0
   Volt1 = Get_adc(chno)
   Mcur4 = Volt1 / 0.25
   If Mcur4 > 4.0 then
      C420ma4 = Mcur4 - 4
      Prsur = c420ma4 * 0.6373 ' for Kg/cm2
   Else
      c420mA4 = 0
      Prsur = 0
   End if
   Pcv = Prsur
   Pcv_Txt = Fusing(Pcv, "#.#")
End sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                IIC Bus Drivers
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          Read IIC EEPROM
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Read_eeprmc64(byref M_add As Word , Byref Value As Byte)
   Local M_ladd As Byte
   Local M_hadd As Byte
   Waddress = &HA0
   Raddress = &HA1
   M_ladd = Low(m_add)
   M_hadd = High(m_add)
   I2cstart                                                 'generate start
   I2cwbyte Waddress                                        'slave adsress
   I2cwbyte M_hadd
   I2cwbyte M_ladd                                          'address of EEPROM
   I2cstart                                                 'repeated start
   I2cwbyte Raddress                                        'slave address (read)
   I2crbyte Value , Nack                                    'read byte
   I2cstop                                                  'generate stop
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          Write IIC EEPROM
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Write_eeprmc64(byref M_add As Word , Byref Value As Byte)
   Local M_ladd As Byte
   Local M_hadd As Byte
   Waddress = &HA0
   Raddress = &HA1
   M_ladd = Low(m_add)
   M_hadd = High(m_add)
   I2cstart
   I2cwbyte Waddress
   I2cwbyte M_hadd
   I2cwbyte M_ladd
   I2cwbyte Value
   I2cstop
   Del = 10
   Call Delayy
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                                Delay
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sub Delayy()
   Micsecs = 0
   Milsecs = 0
   Do

   Loop Until Milsecs >= Del
End Sub
'###########################################################################
'###########################################################################
'                             Keyboard Scan Routines
'###########################################################################
'###########################################################################

'###########################################################################
'                                Chk Keys
'###########################################################################
Sub Chk_ky()
   Debounce Sw_TInc , 0 , T_inc , Sub
   Debounce Sw_TDec , 0 , T_dec , Sub
   Debounce Sw_PInc , 0 , P_Inc , Sub
   Debounce Sw_PDec , 0 , P_Dec , Sub
   Keypress = 0
   Enable Int0
End sub
'###########################################################################
'                                Sw F4
'###########################################################################
T_Inc:
   If Run= 1 then
      Rng_min = 10
      Rng_max = 255
      If byt_Tsv  < Rng_Max then
         byt_Tsv = byt_Tsv + 5
         TSV = byt_Tsv / 10
         Tsv_txt = fusing(Tsv, "#.#")
      End if
   Else

   End if
Return
'###########################################################################
'                                Sw F3
'###########################################################################
T_Dec:
   If Run= 1 then
      Rng_min = 10
      Rng_max = 255
      If byt_Tsv  >Rng_Min then
         byt_Tsv = byt_Tsv - 5
         TSV = byt_Tsv / 10
         Tsv_txt = fusing(Tsv, "#.#")
      End if
   Else

   End if
Return
'###########################################################################
'                                Sw F2
'###########################################################################
P_Inc:
   If Run= 1 then
      Rng_min = 1
      Rng_max = 60
      If byt_Psv  < Rng_Max then
         byt_Psv = byt_Psv + 1
         PSV = byt_Psv / 10
         Psv_txt = fusing(Psv, "#.#")
      End if
   Else

   End if
Return
'###########################################################################
'                                Sw F1
'###########################################################################
P_Dec:
   If Run= 1 then
      Rng_min = 1
      Rng_max = 60
      If byt_Psv  > Rng_Min then
         byt_Psv = byt_Psv - 1
         PSV = byt_Psv / 10
         Psv_txt = fusing(Psv, "#.#")
      End if
   Else

   End if
Return
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                          System interrupt routines
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Int0 interrupt service
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Kybisr:
   Disable Int0
   Keypress = 1
Return
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Serial Interrupt
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Srlisr:
   Rxbyte = UDR
   Srlint = 1
Return
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             Timer0 interrupt service
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Tmr0isr:
   Incr Micsecs
   If Micsecs >= 10 then
      Micsecs = 0
      Incr Milsecs
      If Milsecs >= 1000 then
         Milsecs = 0
         Incr Secs
         If Secs > 60 then
            Secs = 0
            Incr Mins
            If Mins >= 60 then
               Mins = 0
               Incr Hrs
               If Hrs >= 23 then
                  Hrs = 23
               End if
            End if
         End if
      End if
   End if
   Load Timer0 , 200
Return
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'                             System Data Tables
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Srvcmnu:
Data "CHECK ANALOG INPUTS ","CHECK OUTPUTS       "

OcrdO1:
Data "OUTPUT - 1 ON       ","OUTPUT - 1 OFF      "
OcrdO2:
Data "OUTPUT - 2 ON       ","OUTPUT - 2 OFF      "
OcrdO3:
Data "OUTPUT - 3 ON       ","OUTPUT - 3 OFF      "
OCrdO4:
Data "OUTPUT - 4 ON       ","OUTPUT - 4 OFF      "
OCrdO5:
Data "OUTPUT - 5 ON       ","OUTPUT - 5 OFF      "
OCrdO6:
Data "OUTPUT - 6 ON       ","OUTPUT - 6 OFF      "
OCrdO7:
Data "OUTPUT - 7 ON       ","OUTPUT - 7 OFF      "
OcrdO8:
Data "OUTPUT - 8 ON       "
Back to top
View user's profile Visit poster's website
laborratte

Bascom Expert



Joined: 27 Jul 2005
Posts: 299
Location: Berlin

germany.gif
PostPosted: Sun Nov 19, 2017 7:09 pm    Post subject: Reply with quote

I2C needs 4K7 Pullup resistors to VCC, 10K is too much. Also no 330R in series needed. Thats probaly the reason for unstable reads.
Back to top
View user's profile
madhav1080

Bascom Member



Joined: 06 Jan 2008
Posts: 41
Location: Hyderabad

india.gif
PostPosted: Mon Nov 20, 2017 2:46 am    Post subject: Reply with quote

Thank you for the prompt reply, will try with 4.7K and no series resistor, however i have been using this configuration of ages more than (15 years) without any issues, Oh yes i have multiple devices too like MAX127 (2 Nos) ADC, DS1307, FM24C64 (2nos), etc on several boards and have never had any issue.

Frankly, I don't think that could be an issue.

Anyways, will definitely try, thanks once again.
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Mon Nov 20, 2017 3:33 am    Post subject: Reply with quote

Do You have enabled Code Explorer? My CodeExplorer "crying red" and I think this is the prompts to resolve this.
When you use Word "Call" you must use brackets(and in them define value of declared variables)

Without "word" "Call" You must understand that syntax is "Sub First_value, Second_if_neded_but _without brackets"

Call Dosomething(1,2)


near similar another way' (without brackets )

Dosomething 1, 2

Call must have brackets...
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Mon Nov 20, 2017 10:15 am    Post subject: Reply with quote

since you use the same software, the cause is in the hardware.
either the processors are different, the sensors, the hardware, wiring, or environment.

_________________
Mark
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Mon Nov 20, 2017 10:38 am    Post subject: Reply with quote

It seems 2 version of LM75 old device : 9bits, new only 7. see Paulvk code
I read your sub to read the LM75
read the Paul version.
I really prefer the Paul ' s one :

Function Lm75read(byval Num As Byte) As Single
Local Lm75temp As Integer
Local Waddress As Byte
Local Raddress As Byte

Waddress = Lm75ad(num) 'using address stored in EEPROM
Raddress = Waddress + 1

I2csend Waddress , 0
I2creceive Raddress , Lm75temp , 0 , 2

Swap Lm75temp 'swap the bytes as I2creceive reverses them
If Lm75temp.15 = 1 Then 'its a negative number

Shift Lm75temp , Right , 5 ' 5 unused bits plus the sign bit above
' Shift Lm75temp , Right , 7 'for older 9 bit devices

'as its a neagative number the first 5 bits are "1"
Toggle Lm75temp.15
Toggle Lm75temp.14
Toggle Lm75temp.13
Toggle Lm75temp.12
'-for 9 bit devices
'Toggle Lm75temp.11
'Toggle Lm75temp.10

Else 'its a positive number

Shift Lm75temp , Right , 5 ' 5 unused bits plus the sign bit above
' Shift Lm75temp , Right , 7 'for older 9 bit devices

End If

Lm75read = Lm75temp * 0.125 'now we have the binary value

End Function

Maybe you used both version ?
JP Question
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Various All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum