DS18S20 sensor
-
- Posts: 24
- Joined: 30 Jul 2013 11:51
DS18S20 sensor
All good afternoon! ! ! How to consider serial number and CRC the DS18S20 sensor by means of OneWire library
Re: DS18S20 sensor
AlexanderRUS wrote:All good afternoon! ! ! How to consider serial number and CRC the DS18S20 sensor by means of OneWire library
Its for MikroC Pro for PIC, maybe you will find someting useful:
1-Wire Read Serial Number and Temperature DS18B20 or DS18S20
http://www.libstock.com/projects/view/6 ... or-ds18s20
1-Wire Library for MikroPascal/MikroBasic supports only DS1820 device. In MikroC you can use DS1990, DS2401,.... or other 1-wire devices.
Best regards,
Peter
-
- Posts: 24
- Joined: 30 Jul 2013 11:51
Re: DS18S20 sensor
DS1820 and DS18S20 identicaltpetar wrote:AlexanderRUS wrote:All good afternoon! ! ! How to consider serial number and CRC the DS18S20 sensor by means of OneWire library
Its for MikroC Pro for PIC, maybe you will find someting useful:
1-Wire Read Serial Number and Temperature DS18B20 or DS18S20
http://www.libstock.com/projects/view/6 ... or-ds18s20
1-Wire Library for MikroPascal/MikroBasic supports only DS1820 device. In MikroC you can use DS1990, DS2401,.... or other 1-wire devices.
Best regards,
Peter
Re: DS18S20 sensor
Hello,AlexanderRUS wrote:DS1820 and DS18S20 identical
DS18S20 is marked as DS1820, and today DS1820 is accepted as DS18S20. But old and first serie of this digital sensor (DS1820) have difference. The primary specification difference between the two parts is the temperature conversion time: DS1820 = 500ms (max) and DS18S20 = 750ms (max).
Best regards,
Peter
-
- Posts: 24
- Joined: 30 Jul 2013 11:51
Re: DS18S20 sensor
Hello! ! ! How to read serial number of the DS18S20 sensortpetar wrote:Hello,AlexanderRUS wrote:DS1820 and DS18S20 identical
DS18S20 is marked as DS1820, and today DS1820 is accepted as DS18S20. But old and first serie of this digital sensor (DS1820) have difference. The primary specification difference between the two parts is the temperature conversion time: DS1820 = 500ms (max) and DS18S20 = 750ms (max).
Best regards,
Peter
Re: DS18S20 sensor
AlexanderRUS wrote:Hello! ! ! How to read serial number of the DS18S20 sensor
Hello,
Use array of 8 bytes to store serial number. Read serial number store byte by byte in array, convert array byte by byte to hex and print on LCD.
Use ReadROM command 33h:
Code: Select all
// Reading Serial Number
Ow_Reset(PORTE, 2); // Onewire reset signal
Ow_Write(PORTE, 2, 0x33); // Issue command Read_ROM for Serial Number
Delay_us(120);
Best regards,
Peter
-
- Posts: 24
- Joined: 30 Jul 2013 11:51
Re: DS18S20 sensor
Also define correct port and port pin. You can read both DS18B20 and DS18S20.
Best regards,
Peter[/quote]
Hello,
What to give team I understood. How to read serial number. The Ow_Read team reads on two bytes. I need to read six byte serial number and to write down it in EEPROM
I understood
Ow_Reset(PORTB, 0);
Ow_Write(PORTB, 0, 0x33);
Delay_us(120);
for i:= 0 to 4 do
begin
btemp := Ow_Read(PORTB, 0);
ByteToHex(btemp, output);
if i > 0 then sTemp:= output + sTemp;
Delay_us(120);
end;
Lcd_Out(1, 1, sTemp);
Best regards,
Peter[/quote]
Hello,
What to give team I understood. How to read serial number. The Ow_Read team reads on two bytes. I need to read six byte serial number and to write down it in EEPROM
I understood
Ow_Reset(PORTB, 0);
Ow_Write(PORTB, 0, 0x33);
Delay_us(120);
for i:= 0 to 4 do
begin
btemp := Ow_Read(PORTB, 0);
ByteToHex(btemp, output);
if i > 0 then sTemp:= output + sTemp;
Delay_us(120);
end;
Lcd_Out(1, 1, sTemp);
Last edited by AlexanderRUS on 06 Dec 2013 06:37, edited 1 time in total.
Re: DS18S20 sensor
Hi Alexander,AlexanderRUS wrote:What to give team I understood. How to read serial number. The Ow_Read team reads on two bytes. I need to read six byte serial number and to write down it in EEPROM
Yes, but you can use loop and earlier mentioned array.
Try something like this. I cant test MikroPascal Pro code with AVR right now.
Code: Select all
program serialnumber;
// LCD module connections
var LCD_RS : sbit at PORTB4_bit;
var LCD_EN : sbit at PORTB6_bit;
var LCD_D4 : sbit at PORTB0_bit;
var LCD_D5 : sbit at PORTB1_bit;
var LCD_D6 : sbit at PORTB2_bit;
var LCD_D7 : sbit at PORTB3_bit;
var LCD_RS_Direction : sbit at DDB4_bit;
var LCD_EN_Direction : sbit at DDB6_bit;
var LCD_D4_Direction : sbit at DDB0_bit;
var LCD_D5_Direction : sbit at DDB1_bit;
var LCD_D6_Direction : sbit at DDB2_bit;
var LCD_D7_Direction : sbit at DDB3_bit;
// End LCD module connections
var serialnumber : array[8] of char;
serialnumber_hex : array[2] of char;
i : integer;
col : integer;
.
.
.
// Display Serial Number
procedure Display_SerialNumber();
begin
col := 17;
i := 0;
for i := 0 to 7 do
begin
col := col - 2;
ByteToHex(serialnumber[i], serialnumber_hex);
Lcd_Out(1, col, serialnumber_hex);
end;
end;
.
.
.
begin
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
// Reading Serial Number
Ow_Reset(PORTD, 6); // Onewire reset signal
Ow_Write(PORTD, 6, 0x33); // Issue command Read_ROM for Serial Number
Delay_us(120);
i := 0;
for i := 0 to 7 do
begin
serialnumber[i] := Ow_Read(PORTD, 6);
end;
Display_SerialNumber();
end.
Best regards,
Peter
Re: DS18S20 sensor
Hi,
For writing to uC internal EEPROM you can use EEPROM library, but first check uC datasheet to see what is EEPROM size:
EEPROM Library
http://www.mikroe.com/download/eng/docu ... &width=970
Principe for EEPROM writing is similar as for showing on LCD, use array.
Also you can use external EEPROMs over I2C and SPI (I2C and SPI software librarires).
Best regards,
Peter
For writing to uC internal EEPROM you can use EEPROM library, but first check uC datasheet to see what is EEPROM size:
EEPROM Library
http://www.mikroe.com/download/eng/docu ... &width=970
Principe for EEPROM writing is similar as for showing on LCD, use array.
Also you can use external EEPROMs over I2C and SPI (I2C and SPI software librarires).
Best regards,
Peter
-
- Posts: 24
- Joined: 30 Jul 2013 11:51
Re: DS18S20 sensor
At me everything turned out. Snachalo considered 64 bit code, then:
Ow_Reset(PORTB, 0);
Ow_Write(PORTB, 0, 0xCC);
Ow_Write(PORTB, 0, 0x44);
Delay_ms(1000);
Ow_Reset(PORTB, 0);
Ow_Write(PORTB, 0, 0x55);
for i:= 0 to 7 do Ow_Write(PORTB, 0, serialnumber); // We work with the concrete sensor
Ow_Write(PORTB, 0, 0xBE);
Delay_ms(400);
Thank you very much
Ow_Reset(PORTB, 0);
Ow_Write(PORTB, 0, 0xCC);
Ow_Write(PORTB, 0, 0x44);
Delay_ms(1000);
Ow_Reset(PORTB, 0);
Ow_Write(PORTB, 0, 0x55);
for i:= 0 to 7 do Ow_Write(PORTB, 0, serialnumber); // We work with the concrete sensor
Ow_Write(PORTB, 0, 0xBE);
Delay_ms(400);
Thank you very much