www.elektronik.si Seznam forumov www.elektronik.si
Forum o elektrotehniki in računalništvu
 
 PomočPomoč  IščiIšči  Seznam članovSeznam članov  SkupineSkupine  StatisticsStatistika  AlbumAlbum  DatotekeFilemanager DokumentacijaDocDB LinksPovezave   Registriraj seRegistriraj se 
  PravilaPravila  LinksBolha  PriponkePriponke  KoledarKoledar  ZapiskiZapiski Tvoj profilTvoj profil Prijava za pregled zasebnih sporočilPrijava za pregled zasebnih sporočil PrijavaPrijava 

DS2450 in Atmel

 
Objavi novo temo   Odgovori na to temo   Printer-friendly version    www.elektronik.si Seznam forumov -> AVR, LPC900, x51
Poglej prejšnjo temo :: Poglej naslednjo temo  
Avtor Sporočilo
AndrejM
Neznanec
Neznanec



Pridružen-a: Čet 22 Feb 2007 22:55
Prispevkov: 6
Aktiv.: 0.03

PrispevekObjavljeno: Pon Jun 25, 2007 6:47 pm    Naslov sporočila:  DS2450 in Atmel Odgovori s citatom

Zdravo!

Iščem primer programa za branje napetosti s pomočjo ds2450 konverterja ter atmelovega 89cx051. Če mi lahko kdo pomaga se mu že v naprej zahvaljujem.

Pa lep pozdrav!
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
Vlado
Član
Član



Pridružen-a: Sre 03 Mar 2004 21:35
Prispevkov: 563
Aktiv.: 2.38
Kraj: Ljubljana

PrispevekObjavljeno: Tor Jun 26, 2007 7:34 pm    Naslov sporočila:  ds2450 in Atmel Odgovori s citatom

Zdi se mi da je primer za DS2450 v Samples-ih za Bascom AVR (mogoče tudi v Bascom 8051). Nisi napisal v katerem jeziku bi rad primer.
V primeru 1Wire komunikacije med AVR in 8051 ni razlike med ukazi.
Upam da bo pomagalo, če primera ne najdeš povej pa ti ga pošljem.
Vlado
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
milan62
Član
Član



Pridružen-a: Ned 04 Jan 2004 23:19
Prispevkov: 2391
Aktiv.: 10.09
Kraj: Kranj

PrispevekObjavljeno: Tor Jun 26, 2007 9:25 pm    Naslov sporočila:   Odgovori s citatom

Kje pa se da dobiti DS2450 ?

LP
Nazaj na vrh
Skrit Poglej uporabnikov profil Pošlji zasebno sporočilo Pošlji E-sporočilo
smatjaz
Član
Član



Pridružen-a: Pon 10 Nov 2003 16:33
Prispevkov: 846
Aktiv.: 3.57

PrispevekObjavljeno: Tor Jun 26, 2007 9:28 pm    Naslov sporočila:   Odgovori s citatom

Če boš uporabil AVR ali 89C8252, imjo že vgrajen AD pretvornik, tako, da sploh ne rabiš tega.

LP M.

_________________
Električni aparati delujejo na dim ... ko dim iz njih uide ... ne delujejo več!
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
stursc
Član
Član



Pridružen-a: Tor 08 Jun 2004 14:29
Prispevkov: 323
Aktiv.: 1.36

PrispevekObjavljeno: Sre Jun 27, 2007 7:35 am    Naslov sporočila:   Odgovori s citatom

Pozdrav

smatjaz: sam se trudim z omenjenim uC-jem tipati napetost od 0,1 - 2V in mi nikakor ne uspe. Prosil bi . če je mogoče za konkreten, delujoč primer.
Se vnaprej zahvaljujem.


LP, stursc
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
AndrejM
Neznanec
Neznanec



Pridružen-a: Čet 22 Feb 2007 22:55
Prispevkov: 6
Aktiv.: 0.03

PrispevekObjavljeno: Sre Jun 27, 2007 2:57 pm    Naslov sporočila:   Odgovori s citatom

Programiram v Bascomu, ds2450 pa sem dobil kot sample na http://www.maxim-ic.com/ Stvar je taka, da delam malo za zabavo, kao nek control LCD za avto, se pravi navaden 4*16 display, atmel 89c4051 pa DS senzorji, s katerimi sem do sedaj samo meril tempreaturo znotraj ter zunaj, zdaj bi pa rad dodal še napetost akumulatorja, količino goriva v tanku...
Za temperaturo in ds1820 se najde kar precej primerov na internetu, tako da ni bilo problema, tukaj pa se mi ustavi, ker še nimam toliko izkušenj s programiranjem. Vem, da je možno izvest A/D pretvorbo tudi z 89cx51, samo se mi zdi z DS2450 skorajda boljša rešitev.
V Bascom samples sem že gledal, točno za 2450 mislim da ni primera, je pa nasplošno za 1wire.


LP, Andrej
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
Vlado
Član
Član



Pridružen-a: Sre 03 Mar 2004 21:35
Prispevkov: 563
Aktiv.: 2.38
Kraj: Ljubljana

PrispevekObjavljeno: Sre Jun 27, 2007 3:17 pm    Naslov sporočila:  DS2450 in Atmel Odgovori s citatom

Andrej, v nadaljevanju imaš primer uporabe DS2450 za AVR, malo ga prilagodi svojim potrebam:
Koda:
'-----------------------------------------------------------------------------------------------------
'name                     : 1wireDS2450.bas
'copyright                : (c) 1995-2005, MCS Electronics
'purpose                  : demonstrates use of the Dallas Semi Conductor DS2450S 1-Wire A/D convertor
'micro                    : Mega48
'suited for demo          : yes
'commercial addon needed  : no
' pull-up of 4K7 required to VCC from Portb.3
' DS2450S serial A/D Converter connected to Portb.3
'
' Channels A & B are set up for 16bit resolution and 5.12 volt input range
'
' Channels C & D are switched outputs for control
'-----------------------------------------------------------------------------------------------------

$regfile = "m48def.dat"
$crystal = 8000000

$hwstack = 32                                               ' default use 32 for the hardware stack
$swstack = 10                                               'default use 10 for the SW stack
$framesize = 40                                             'default use 40 for the frame space

Config 1wire = Portb.3                                      'use this pin
'On the STK200 jumper B.3 must be inserted
Dim Dummy As Byte , I As Byte , Highbyte(4) As Byte , Lowbyte(4) As Byte
Dim Crcread As Byte , Adval As Word
'Dim Volts As Single , Chvolts As Single

Const 16_bit = 65535

Declare Sub Crc_get()                                       'this sub makes two reads for the CRC16 bytes from the 1-wire bus

'***********************************1-WIRE Command Constants*********************************
Const 1w_readmem = &HAA
Const 1w_writemem = &H55
Const 1w_convertch = &H3C
Const 1w_readrom = &H33
Const 1w_matchrom = &H55
Const 1w_skiprom = &HCC
Const 1w_searchrom = &HF0
Const 1w_conditsrc = &HEC
Const 1w_ovdrvskprom = &H3C
Const 1w_ovdrvmtchrom = &H69
Const 1w_vccoperation = &H40
'***********************************DS2450 Command Summary***********************************
'AAh = Read Memory
'55h = Write Memory(master TXs to the slave in a single drop mode)
'3Ch = Convert (immediately followed by Converson Mask byte and Preset Mask byte)
'33h = Read ROM
'55h = Match ROM (used to identify a single address on 1-wire bus)
'CCh = Skip Rom (can be used on single drop applications)
'F0h = Search ROM (used to search and identify mutiple bus address)
'ECh = Conditional Search
'3Ch = Overdrive Skip ROM (used to skip ROM when in Overdirve TX speed)
'69h = Overdrive Match ROM (used to identify a address when in Overdrive TX speed)

'***********************************END 1-WIRE Command Constants*****************************


'************************************BEGIN DS2450 Setup**************************************


'***************Setup device upon startup*******************************
'IF 1-WIRE device is Vcc powered 40h must be written to address 001Ch.  This causes
'the device to remain powered during conversion and frees the uProcessor to do
'other things and then return to read the conversion results.

  1wreset                                                   'reset the device

'*************************Setup 2450 device for VCC operation*********************************
  1wwrite 1w_skiprom                                        'Skip ROM
  1wwrite 1w_writemem                                       'Write Memory
  1wwrite &H1C                                              'Write to 001C
  1wwrite &H00
  1wwrite 1w_vccoperation                                   'VCC Operation keeps device active!!

  Crc_get                                                   'Read in 2 bytes 16bits
  Dummy = 1wread(1)                                         'read dummy byte

'*************************END Setup 2450 device for VCC operation*********************************

'**************Setup device channels for operations***********************************************
'Channel setup Notes: Memory Page for Channel Setup begins at 08H thru 0FH
'Channel A shown other similar
'Channel A Control register configuration Address 08h
' OE OC DC DC RC3 RC2 RC1 RC0
'msb                      lsb
'OE = Output Enable 1 enables output 0 disables output
'OC = Output Control if OE=1 then OC=1 Output is OFF OC=0 Output is ON
'DC = Dont Care or "0"
'RC3-RC0 = Channel Resolution 0000=16 bits 1111=15 bits
'
'Channel A Control register configuration Address 09h
' POR DC AFH AFL AEH AEL DC IR
'msb                       lsb
'POR = Power On Reset 'set this to 0 to clear after configuration
'DC = Dont Care or "0"
'AFH = Alarm Flag High Limit - ADC result is greater than high alarm limit
'AFL = Alarm Flag Low Limit - ADC result is less than low alarm limit
'AEH = Alarm Enable High limit if AEH=1 then alarm limit is enabled
'AEL = Alarm Enable Low limit if AEL=1 then alarm limit is enabled
'IR = Input Resolution IR=0 2.56V/resolution IR=1 5.12V/resolution
'
'Repeat for other channels incrementing the address accordingly


  1wreset                                                   'reset the device
  'Write to locations beginning at 00 08
  1wwrite 1w_skiprom                                        'Skip ROM
  1wwrite 1w_writemem                                       'Write Memory
  1wwrite &H08                                              'Write to 00 08
  1wwrite &H00


' Set up Channel A for 16 bit resolution
  1wwrite &H00                                              '16 bit resoultion
  Crc_get                                                   'Read in 2 bytes 16bits
  Dummy = 1wread(1)                                         'read dummy byte
' 5.12 Volt range
  1wwrite &H01                                              '5.12 Volt Range
  Crc_get                                                   'Read in 2 bytes 16bits
  Dummy = 1wread(1)                                         'read dummy byte

' Set up Channel B for 16 bit resolution
  1wwrite &H00                                              '16 bit resoultion
  Crc_get                                                   'Read in 2 bytes 16bits
  Dummy = 1wread(1)                                         'read dummy byte
' 5.12 Volt range
  1wwrite &H01                                              '5.12 Volt Range
  Crc_get                                                   'Read in 2 bytes 16bits
  Dummy = 1wread(1)                                         'read dummy byte

  ' Set up Channel C for output 1
  1wwrite &HC0                                              'Output Open/Output OFF C0 is OFF 80 is ON
  Crc_get                                                   'Read in 2 bytes 16bits
  Dummy = 1wread(1)                                         'read dummy byte
' 5.12 Volt range
  1wwrite &H00                                              'Doesn't matter space keeper
  Crc_get                                                   'Read in 2 bytes 16bits
  Dummy = 1wread(1)                                         'read dummy byte

' Set up Channel D for output 0
  1wwrite &HC0                                              'Output Open/Output OFF
  Crc_get                                                   'Read in 2 bytes 16bits
  Dummy = 1wread(1)                                         'read dummy byte
' 5.12 Volt range
  1wwrite &H00                                              'Doesn't matter space keeper
  Crc_get                                                   'Read in 2 bytes 16bits
  Dummy = 1wread(1)                                         'read dummy byte
'************************************END DS2450 Setup**************************************
Do

Wait 1                                                      'misc delay for RS-232 output

'******************************Begin Conversion in DS2450**********************************
'Conversion Notes: When the conversion command is issued h3C it is followed by the
'Conversion Mask byte and then the Preset Mask byte
'the channel can be continously read until the result is FFh which indicates
'conversion has been completed.
'
'Alternatively you can go do other things for a minimum of 160uSec+(no Cha*resolution*80us)
'if the DS2450 is Vcc powered.  If not must provide strong pullup to pin for this time.

'Conversion Mask and Register Preset configuration
'Convert Mask
'DC DC DC DC ChD ChC ChB ChA
'DC = Dont Care or "0"
'ChD-ChA = Set bit to 1 to enable conversion of that channel 0= no conversion
'Preset Mask
'Sd Cd Sc Cc Sb Cb Sa Ca
'S = Set causes data register for channel (a-d)to be set to all 1's
'C = Clear causes data register for channel (a-d)to be set to all 0's


  1wreset                                                   'reset the device

  1wwrite 1w_skiprom                                        'Skip ROM
  1wwrite 1w_convertch                                      'Begin Conversion
  1wwrite &H0F                                              'Convert Mask 0000|DCBA ie 0F=0000|1111
  1wwrite &H00                                              'Preset Mask Set=D Clear=d DdCcBbAa ie 55=0101|0101

  Crc_get                                                   'Read in 2 bytes 16bits

       'Do
        ' Dummy = 1wread(1)                                  'read dummy byte  if you are going to POLL data
       'Loop Until Dummy = &HFF                              'until end of conversion =HFF

  Waitms 6                                                  'use formula to calculate exact duration for channels
'******************************End DS2450 Conversion***************************************

'******************************Read DS2450 Conversion Results******************************
  1wreset                                                   'reset the device
  1wwrite 1w_skiprom                                        'Skip ROM
  1wwrite 1w_readmem                                        'Read Memory
  1wwrite &H00                                              'Read Channel A
  1wwrite &H00                                              'Address 0000 and 0001

  For I = 1 To 4

      Lowbyte(i) = 1wread(1)

      Highbyte(i) = 1wread(1)

  Next
'*************************************Format Results**************************************
  For I = 1 To 4
      Adval = Makeint(lowbyte(i) , Highbyte(i))
' uncomment the two lines below for formatting the output on other than 2k devices

      'Chvolts = Adval \ 16_bit * 5.12
      'Print "ChNo :"; I ; Chvolts
'comment the two lines below for formatting the output on other than 2k devices
      Adval = Makeint(lowbyte(i) , Highbyte(i))
      Print I ; "CHA " ; Adval
      'Print   Bin(lowbyte(i)) ; Bin(highbyte(i))

  Next
'************************************End Format Results**********************************

'******************************End  DS2450 Conversion Results******************************

Loop

Sub Crc_get()                                               'this sub ensures that all crc operations are handled the same
Crcread = 1wread(2)
'Crcread = 1wread()

End Sub

Vlado
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
Pokaži sporočila:   
Objavi novo temo   Odgovori na to temo   Printer-friendly version    www.elektronik.si Seznam forumov -> AVR, LPC900, x51 Časovni pas GMT + 2 uri, srednjeevropski - poletni čas
Stran 1 od 1

 
Pojdi na:  
Ne, ne moreš dodajati novih tem v tem forumu
Ne, ne moreš odgovarjati na teme v tem forumu
Ne, ne moreš urejati svojih prispevkov v tem forumu
Ne, ne moreš brisati svojih prispevkov v tem forumu
Ne ne moreš glasovati v anketi v tem forumu
Ne, ne moreš pripeti datotek v tem forumu
Ne, ne moreš povleči datotek v tem forumu

Uptime: 493 dni


Powered by phpBB © 2001, 2005 phpBB Group