Well, unless you absolutely needed the extra distance of the one-wire interface, I would try something like the DS1620 first. Why?, because you provide your own three wire 'SPI like' interface, and create your own timing, using a software clock and latch. Otherwise, maybe try an I2C or Uart bus master and let it do the timing. And lastly, make your own timing routines.
Nothing to be sorry about, just that no one has posted one wire code yet. It is a software solution, not a compiler issue, so the community will need to work it out. It is a goal of mine, and maybe others, to get this going. To start, here would be some constant defines required whether using a bus master chip or not:
'=========Function Commands for 1-Wire DS2482-100========================
#define DRST = oxF0 '(240)Command for device reset
#define SRP = oxE1 '(225)Command for single slave
#define WCFG = oxD2 '(210)Command for write configuration
#define OneWRS = oxB4 '(180)Command for 1-Wire reset
#define OneWSB = ox87 '(236)Command for 1-Wire single bit
#define OneWWB = oxA5 '(165)Command for 1-Wire write byte
#define OneWRB = ox96 '(150)Command for 1-Wire read byte
#define OneWT = ox78 '(120)Command for 1-Wire triplet
'=========ROM Commands for 1-Wire DS18S20========================
#define SearchRom = oxF0 '(240)Command for identifying Slave Rom codes, use as many times as needed
#define ReadRom = ox33 '(051)Command for single slave
#define MatchRom = ox55 '(085)Command for master to identify a specific slave code
#define SkipRom = oxCC '(204)Command for addressing all devices simultaneously
#define AlarmSearch = oxEC '(236)Command is same as Search Rom to identify any alarm flags
'==========Function Commands for for 1-Wire DS18S20==============
#define ConvertT = ox44 '(68)Protocol for Single Temp Conversion
#define WriteScratch = ox4E '(78)Protocol for Write Scratchpad
#define ReadScratch = oxBE '(190)Protocol for Read Scratchpad
#define CopyScratch = ox48 '(72)Protocol for copying Scrtchpad TH and TL registers to EEPROM
#define RecallE2 = oxB8 '(187)Protocol for recalling alarm trigger values from EEPROM
'---------------------------------------------------
The easiest way to get a single temp reading is to follow example three of the DS18S20 data sheet.
Do Master Reset
Detect presence pulse
Issue Skip Rom command
Issue Convert T command
Do Master Reset
Detect presence pulse
Issue Skip Rom command
Issue Read Scratchpad command
So hope this helps. And sorry it is not yet so simple as issue a One Wire ReadTemp command and print out on LCD.
Kent
P.S. I may have misinterpreted you original post, so please excuse me if you were trying to talk directly to the GCBasic developers, you can disregard above.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello team of GCBASIC, I´ll like to know how to put a work a Dallas 18B20 Thermometer. I would appreciate so much!, advanced thanks to you.
Well, unless you absolutely needed the extra distance of the one-wire interface, I would try something like the DS1620 first. Why?, because you provide your own three wire 'SPI like' interface, and create your own timing, using a software clock and latch. Otherwise, maybe try an I2C or Uart bus master and let it do the timing. And lastly, make your own timing routines.
As you may already know, the Dallas/Maxim site has software routines in their app notes in 'C' and assembler. Here is a PicList page that might help you on your way: http://www.piclist.com/techref/microchip/ds1820-code.htm
Or, a PicBasic Pro page: http://www.rentron.com/PicBasic/one-wire2.htm
In the end, its read the datasheet 10 times and follow the given flow charts precisely.
Regards,
Kent
P.S. You need to put the data pin on a Pic with an open drain output. If this were a school project, I would go with a thermistor device.
I´am very sorry, really!
Nothing to be sorry about, just that no one has posted one wire code yet. It is a software solution, not a compiler issue, so the community will need to work it out. It is a goal of mine, and maybe others, to get this going. To start, here would be some constant defines required whether using a bus master chip or not:
'=========Function Commands for 1-Wire DS2482-100========================
#define DRST = oxF0 '(240)Command for device reset
#define SRP = oxE1 '(225)Command for single slave
#define WCFG = oxD2 '(210)Command for write configuration
#define OneWRS = oxB4 '(180)Command for 1-Wire reset
#define OneWSB = ox87 '(236)Command for 1-Wire single bit
#define OneWWB = oxA5 '(165)Command for 1-Wire write byte
#define OneWRB = ox96 '(150)Command for 1-Wire read byte
#define OneWT = ox78 '(120)Command for 1-Wire triplet
'=========ROM Commands for 1-Wire DS18S20========================
#define SearchRom = oxF0 '(240)Command for identifying Slave Rom codes, use as many times as needed
#define ReadRom = ox33 '(051)Command for single slave
#define MatchRom = ox55 '(085)Command for master to identify a specific slave code
#define SkipRom = oxCC '(204)Command for addressing all devices simultaneously
#define AlarmSearch = oxEC '(236)Command is same as Search Rom to identify any alarm flags
'==========Function Commands for for 1-Wire DS18S20==============
#define ConvertT = ox44 '(68)Protocol for Single Temp Conversion
#define WriteScratch = ox4E '(78)Protocol for Write Scratchpad
#define ReadScratch = oxBE '(190)Protocol for Read Scratchpad
#define CopyScratch = ox48 '(72)Protocol for copying Scrtchpad TH and TL registers to EEPROM
#define RecallE2 = oxB8 '(187)Protocol for recalling alarm trigger values from EEPROM
'---------------------------------------------------
The easiest way to get a single temp reading is to follow example three of the DS18S20 data sheet.
Do Master Reset
Detect presence pulse
Issue Skip Rom command
Issue Convert T command
Do Master Reset
Detect presence pulse
Issue Skip Rom command
Issue Read Scratchpad command
So hope this helps. And sorry it is not yet so simple as issue a One Wire ReadTemp command and print out on LCD.
Kent
P.S. I may have misinterpreted you original post, so please excuse me if you were trying to talk directly to the GCBasic developers, you can disregard above.
This is too much cumbersom for me, better a termistor and a lookup table to calibrate reading. Thanks so much.