Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

lsb and msb ? could someone explain please

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

Bascom Member



Joined: 28 Jul 2009
Posts: 3

blank.gif
PostPosted: Mon Aug 17, 2009 1:38 pm    Post subject: lsb and msb ? could someone explain please Reply with quote

Hello

I have been reading the Datasheet for the ds18b20 and would like to know what the Definition for LSB and MSB are. did a search on google and came up empty handed. any info would be great.

thanks
Datasheet http://www.spezial.com/doc/maxim/ds18b20.pdf
Back to top
View user's profile AIM Address
MAK399

Bascom Member



Joined: 23 Jun 2009
Posts: 110
Location: Germany

germany.gif
PostPosted: Mon Aug 17, 2009 2:20 pm    Post subject: Reply with quote

Hi,

least significant byte (LSB) = right byte of the Interger Value = Byte0 of Scratchpad
Most significant byte (MSB) = left byte of the Integer Value = Byte1 of Scratchpad

For Example: 85 C

MSB = 0000 0101 LSB = 0101 0000

MAK399

_________________
Using BASCOM 1.12.0.0
Back to top
View user's profile
mattcro

Bascom Member



Joined: 03 Oct 2007
Posts: 327
Location: Scotland

uk.gif
PostPosted: Mon Aug 17, 2009 3:55 pm    Post subject: Reply with quote

Often LSB and MSB mean least/most significant BIT of a register or variable, but it can also refer to least/most significant byte (eg of a multi-byte variable such as integer or long).

The least significant bit is the rightmost like in mak399's description.

_________________
If all else fails, read the manual. Even better: read the manual before something fails. If you can't find it in the manual, search the forum.
BascomAVR 2.0.8.5
Back to top
View user's profile
cschwemin

Bascom Member



Joined: 28 Jul 2009
Posts: 3

blank.gif
PostPosted: Tue Aug 18, 2009 2:37 am    Post subject: Reply with quote

Thanks for the quick reply, now i have more questions Embarassed I have gone over the source code from here http://www.mcselec.com/index.php?option=com_content&task=view&id=75&Itemid=57 and searched the forums repeatedly. but i am still having no luck with this temperature sensor. all of the examples have so many things i dont really need, like CRC checks, multiple sensors and several decimal places. i am trying to measure a range from 0 to a max of 200~250 degrees Fahrenheit. but i get really bogged down as i am very new to this. This is the source code from what i have written so far. any help would be greatly appreciated.

Code:

'=============================================================================='
'This is a single sensor temperature monitor using the DS18B20. The ATMega32   '                                                                            '
'Sends all data back through rs232.                                            '                                  '
'                                                                              '
'Author: Chris Schwemin                                                                              '
'E-Mail: Cschwemin@marquettewind.com                                                                             '
'08-17-2009                                                                              '
'                                                                              '
'=============================================================================='

$regfile = "m32def.dat"
$crystal = 16000000
$baud = 9600

'Sub routine to start temp conversion on DS18B20
Declare Sub Convertt

'Tell 1wire to use Port C and Pin 1
Config 1wire = Portc.1

'Array for holding data from DS18B20
Dim Sc(9) As Byte

'Variables
Dim Temperature As Byte


Do
 'start conversion
 Convertt

 'Using 2wire bus, no longer delay is needed
 Waitus 200

 1wwrite &HBE
 Sc(1) = 1wread(9)
 Temperature = Sc(1)

 Print Temperature
 Wait 2
Loop

Sub Convertt
 'Bus Reset
 1wreset
 'Skip ROM checking " only one device connected"
 1wwrite &HCC
 'Convert the Temp
 1wwrite &H44
End Sub

'Borrowed some comments from Göte Haluza, Thanks Smile
'DALLAS DS18B20 ROM and scratchpad commands''''''''''''''''''''''''''1wwrite....
'&H 33 read rom - single sensor
'&H 55 match rom, followed by 64 bits
'&H CC skip rom
'&H EC alarm search - ongoining alarm >TH <TL
'&H BE read scratchpad
'&H 44 convert T
 


I have compiled other sources and have verified the wiring to be correct and the devices to work as intended.

-Chris

Bascom ver 1.11.95
Back to top
View user's profile AIM Address
cschwemin

Bascom Member



Joined: 28 Jul 2009
Posts: 3

blank.gif
PostPosted: Tue Aug 18, 2009 2:38 am    Post subject: Reply with quote

Also i have really tried to not come to the forums for help on this as i see alot of topics and i know how annoying the same questions can be over and over again but i ran out of options. your patience is greatly appreciated
Back to top
View user's profile AIM Address
MAK399

Bascom Member



Joined: 23 Jun 2009
Posts: 110
Location: Germany

germany.gif
PostPosted: Tue Aug 18, 2009 7:16 am    Post subject: Reply with quote

Hello,

have you also tried the code from Luciano ?
You can find it here:
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=3993&highlight=ds18b20

It is in my opinion easier to understand and it uses by default no CRC

All Values comming from this sensors are in Celsius.
Conversion from Celsius in Fahrenheit = (( Temp Celsius × 9 ) / 5 ) + 32

The default resolution = 12 Bit and with this resolultion you have to wait
750ms between starting the conversion and reading the scratchpad (where only Byte0 and Byte1 is interesting for you)

MAK399

_________________
Using BASCOM 1.12.0.0
Back to top
View user's profile
MAK399

Bascom Member



Joined: 23 Jun 2009
Posts: 110
Location: Germany

germany.gif
PostPosted: Tue Aug 18, 2009 7:27 am    Post subject: Reply with quote

I forgot to mention that you reading only Byte0 of Scratchpad but the default resolution is 12 Bit so you only read 8Bit from 12Bit of the temperature.

Your Temperature should be Integer Value because the minimun resolution = 9Bit. You always need the second Byte of the Integer Value to store the 9th Bit when you prgroam the DS18B20 to use 9Bit resolution.

MAK399

_________________
Using BASCOM 1.12.0.0
Back to top
View user's profile
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