Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ADT7320

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Porelo

Bascom Member



Joined: 23 May 2005
Posts: 52
Location: Portugal

portugal.gif
PostPosted: Sun Jun 30, 2024 7:09 pm    Post subject: ADT7320 Reply with quote

Does anyone have an example to read an AD ADT7320.

I would really appreciate it.

Porelo

(BASCOM-AVR version : 2.0.8.6 )
Back to top
View user's profile Yahoo Messenger
Porelo

Bascom Member



Joined: 23 May 2005
Posts: 52
Location: Portugal

portugal.gif
PostPosted: Sun Jun 30, 2024 11:46 pm    Post subject: Reply with quote

With this code I can do some reading, but I need more, maybe someone will give me an idea.







$regfile = "m128def.dat" ' specify the used microcontroller
$crystal = 16005000 ' used crystal frequency
$hwstack = 550 ' hardware stack size
$swstack = 550 ' software stack size
$framesize = 530 ' frame size

' Configuration of Graphical LCD
Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6

' Configuration of Ports for the ADT7320 temperature sensor
Config Porte.4 = Output ' Para DIN ADT7320
Config Pine.6 = Input ' Para Dout ADT7320
Config Portg.3 = Output ' CS of ADT7320
Config Porte.5 = Output ' SCLK of ADT7320

Config Dp = ","
Set Portc.6 ' MD2_6
Set Portc.7 ' Backlight

' Variables for ADT7320
Dim F_frame7320 As Long
Dim Data7320 As Word
Dim C_byte As Byte
Dim Reset7320 As Long
Dim Bin7320 As String * 32
Dim Contador As Byte ' Contador de tempo inicial
Dim Command As Word
Dim Conf1 As Word
Dim Conf2 As Long
Dim Tfinal As String * 7

' Port Aliases for ADT7320
C_s7320 Alias Portg.3
Dout_7320 Alias Pine.6 'saida
Clock_7320 Alias Porte.5
Din_7320 Alias Porte.4 'entrada

Reset7320 = &HFFFFFFFF
'F_frame7320 = Reset7320
'Conf1 = &H90
' Initialize LCD
Command = &H5400

Cls
Cursor Off
Waitms 70
Cls
Cursor Off
Contador = 0

'Reset ADT7320
Reset C_s7320
Waitms 30
Shiftout Din_7320 , Clock_7320 , Reset7320 , 1 , 32 , 5000
Set C_s7320
Waitms 170


Do
' Select ADT7320
Reset C_s7320


Shiftout Din_7320 , Clock_7320 , Command , 1 , 8 , 5000
' Read 24-bit temperature data from ADT7320
Shiftin Dout_7320 , Clock_7320 , F_frame7320 , 1 , 24 , 5000

' Deselect ADT7320
Set C_s7320
Waitms 170
' Convert read data to binary string for display (optional)
Bin7320 = Bin(f_frame7320)

' Display binary data on LCD (optional)
Conf2 = F_frame7320
Shift Conf2 , Right , 8 , Signed
Conf2 = Conf2 / 128
Tfinal = Str(conf2)
Locate 6 , 1 : Lcd Format(tfinal , "+00.00") ; Spc(2) ; " Temperatura"
Locate 11 , 1 : Lcd Bin7320 ; " Temp"

' Wait before next read
Waitms 250
Contador = Contador + 1
Locate 14 , 1 : Lcd Contador ; " CONTA"

Loop
End
Back to top
View user's profile Yahoo Messenger
Porelo

Bascom Member



Joined: 23 May 2005
Posts: 52
Location: Portugal

portugal.gif
PostPosted: Sun Jul 07, 2024 8:33 pm    Post subject: Reply with quote

Please I need help !
The reason I chose this temperature sensor was:

Temperature accuracy
±0.20°C from −10°C to +85°C at 3.0 V
±0.25°C from −20°C to +105°C at 2.7 V to 3.3 V
16-bit temperature resolution: 0.0078°C
Ultralow temperature drift: 0.0073°C
NIST traceable or equivalent
No temperature calibration/correction required by user
No linearity correction required

With these characteristics it becomes useful for various applications that require reading accuracy and certainty, without the need for calibration as it is NIST certified.

Please I need help ! Crying or Very sad
Back to top
View user's profile Yahoo Messenger
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1079

poland.gif
PostPosted: Sun Jul 07, 2024 10:24 pm    Post subject: Reply with quote

Porelo wrote:
With this code I can do some reading, but I need more, maybe someone will give me an idea.


I saw your post but dont have any clue what it means "but I need more". What exactly do you need?

_________________
Check B-Flash -my MCS bootloader app for Android (updated)
Back to top
View user's profile Visit poster's website
Porelo

Bascom Member



Joined: 23 May 2005
Posts: 52
Location: Portugal

portugal.gif
PostPosted: Wed Jul 10, 2024 9:47 pm    Post subject: Reply with quote

This is the situation:

I can partially read the 8 Registers, I can't read the "0" Register, I don't know why:

I can read it but I think it's wrong?

I can't send the command to read it in 16 Bits.

I ask if anyone can help I would appreciate it.



Code:


$regfile = "m128def.dat"       ' specify the used microcontroller
$crystal = 16005000       ' used crystal frequency
$hwstack = 550       ' hardware stack size
$swstack = 550       ' software stack size
$framesize = 530       ' frame size


' Configuration of Graphical LCD
Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6

' Configuration of Ports for the ADT7320 temperature sensor
Config Porte.4 = Output       ' Para DIN  ADT7320
Config Pine.6 = Input         ' Para Dout  ADT7320
Config Portg.3 = Output       ' CS of ADT7320
Config Porte.5 = Output       ' SCLK of ADT7320

Config Dp = ","
Set Portc.6                   ' MD2_6
Set Portc.7                   ' Backlight

' Variables for ADT7320
Dim F_frame7320 As Long
Dim Reset7320 As Long
Dim Contador As Byte       ' Contador de tempo inicial
Dim Command(8) As Byte
Dim Comando_read2 As Byte
Dim Comando_write As Long
Dim A As Byte
Dim Temp_temp As Long
Dim Final As String * 5

' Port Aliases for ADT7320
C_s7320 Alias Portg.3
Dout_7320 Alias Pine.6       'Output Atmega
Clock_7320 Alias Porte.5
Din_7320 Alias Porte.4       'Input Atmega

Reset7320 = &HFFFFFFFF

Command(1) = &B01000000       'REG 0
Command(2) = &B01001000       'REG 1
Command(3) = &B01010000       'REG 2
Command(4) = &B01011000       'REG 3
Command(5) = &B01100000       'REG 4
Command(6) = &B01101000       'REG 5
Command(7) = &B01110000       'REG 6
Command(8) = &B01111000       'REG 7


Comando_write = &B000010000000000010000000       ' This bit sets the resolution of the ADC when converting , 1 = 16-bit resolution temperature resolution of 0.0078°C.
Comando_read2 = &B01010000       'REG 3
A = 0
Contador = 0

' Initialize LCD
Cls
Waitms 400
Cursor Off Noblink       'hide cursor
Cls


'*************  RESET ADT7320 32 "1"
   'Reset ADT7320
    Reset C_s7320
    Waitms 30
    Shiftout Din_7320 , Clock_7320 , Reset7320 , 0 , 32 , 250
    Set C_s7320
    Waitms 370
'*************  FIM RESET

'*************  ' Read 8 Registers ADT7320
   Reset C_s7320

   While A < 9
       Shiftout Din_7320 , Clock_7320 , Command(a) , 0 , 8 , 250
       Set Din_7320
       Waitms 245
       Shiftin Dout_7320 , Clock_7320 , F_frame7320 , 0 , 24 , 250
       Locate A , 1 : Lcd Hex(f_frame7320) ; " Command " ; A
       Incr A       'increase by one
    Wend
   Set C_s7320
   Set Clock_7320
   Waitms 270
'*************
    Reset C_s7320

    Shiftout Din_7320 , Clock_7320 , Comando_write , 0 , 24 , 250       'Sending Comando_write
    Set Din_7320
    Waitms 245
    Set C_s7320

Do

    Reset C_s7320       ' Select ADT7320

    Shiftout Din_7320 , Clock_7320 , Comando_read2 , 0 , 8 , 250       'Sending Comando_read
    Shiftin Dout_7320 , Clock_7320 , F_frame7320 , 0 , 24 , 250       ' Read 24-bit temperature data from ADT7320
    Set C_s7320
    Waitms 4
    Locate 10 , 1 : Lcd Bin(f_frame7320)

    Temp_temp = F_frame7320
    Shift Temp_temp , Right , 16 , Signed
    Temp_temp = Temp_temp / 2
    Final = Str(temp_temp)
    Final = Format(final , "00.00")
    Locate 13 , 1 : Lcd Final ; " Temperatura"

    Contador = Contador + 1
    Locate 16 , 1 : Lcd Contador ; " CONTA"

    Loop
End
Back to top
View user's profile Yahoo Messenger
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1186
Location: France

france.gif
PostPosted: Thu Jul 11, 2024 3:06 pm    Post subject: Reply with quote

Hi
I know you do a lot of work but somme years ago, i looked at a very precise temp sensor and I found the TMP117 (same kind of result than yours)

Ian Dobson, An expert and friend of the forum help me and do the Bascom work on it.
have look at
https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=14790&highlight=tmp117

Unfortunately, the company that had asked me for the study didn't follow up and I stopped the development.
but the precision was unbelievable: for example, simply bringing your hand close to the sensor increased the temperature by a few hundredths.

I hope it can help you

JP Wink

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Porelo

Bascom Member



Joined: 23 May 2005
Posts: 52
Location: Portugal

portugal.gif
PostPosted: Thu Jul 11, 2024 4:22 pm    Post subject: Reply with quote

Thanks for the help, however I already have the PCBs made, there are 4 of them, in a sandwich.
I didn't know about this "tmp117" sensor, but it seems good, it works on I2C, which is a problem, I don't like I2C, I avoid doing anything with the I2c protocol.

However, I have a new version, of the routine for the ADT7320, it seems to be better, and from what I measured the temperature value is correct.

Thanks


Back to top
View user's profile Yahoo Messenger
Porelo

Bascom Member



Joined: 23 May 2005
Posts: 52
Location: Portugal

portugal.gif
PostPosted: Sun Jul 14, 2024 10:53 am    Post subject: Reply with quote

After a lot of hard work, here is the final product, for anyone who wants to use it.

I think it is well documented, so that anyone who wants can use it to its full potential.

Thank you to everyone who will encourage me.

Miguel
Back to top
View user's profile Yahoo Messenger
dk9uv

Bascom Member



Joined: 07 Jan 2012
Posts: 27

germany.gif
PostPosted: Wed Jul 17, 2024 11:58 am    Post subject: Reply with quote

[quote="Duval JP"]Hi
I know you do a lot of work but somme years ago, i looked at a very precise temp sensor and I found the TMP117 (same kind of result than yours)


New TMP119 is even better than TMP117, unfortunately WSCP package.

I am using the I2C version ADT7410 since many years (less accurate version of ADT7420). I am quite satisfied, but price is relatively high.
I consider using STS40 from Sensirion. Accuracy comparable to ADT7410, but only 0.24 Euro per piece in quantities.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR 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