Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Peripheral Communications Protocol Poll
Page 2 of 2 | |||||
Author | Message | ||||
donmck Guru Joined: 09/06/2011 Location: AustraliaPosts: 1313 |
BTW I haven't removed 1-wire comms from any poll. It is still there. Cheers Don... https://www.dontronics.com |
||||
Keith W. Senior Member Joined: 09/10/2011 Location: AustraliaPosts: 118 |
For Ray and anyone else interested. Reading the DS1721 chips mentioned above was easy. I thought that I might have fried the first chip as I had mounted it reversed and used a heat gun to remove it, then re-soldered. But it works OK. I found that I already had a program from “Crackerjack” to read DS1621 chips which must be similar. Here is a program which I have kept simple but with comments. My little boards have 3 jumpers to set the individual thermometer address pins high or low, then only a 0.1 uF cap across the supply plus provision for mounting pull up resistors on the two I2C bus pins if required. A 6 pin connector for 0 volts , + 5 volts, SDA and SCL plus a pin for the chips temperature comparator output pin, still to be tried. The individual address is sent to the chip embedded in the I2C address byte. Note that the chip in 12 bit mode reads in sixteenths of a degree, not tenths. I am not against adding 1Wire protocol to the Maximite but it is slipping down my list. Keith W. > list 10 ' Read DS1721 Thermometers 20 ' 30 DIM TempBuff(16) ' room for 8 but just 1 thermometer to start 40 ' 50 PRINT 60 INPUT "Enter Thermometer # (1 to 8) ? " , T$ 70 ' 80 i2caddr = &H48 + (VAL(T$) - 1) 'embed thermometer address 90 ' 100 I2CEN 100,100 ' enable I2C @ 100 KHz and 100 mS timeout 110 I2CSEND i2caddr,1,2, &HAC, &H0C ' config reg = 12 bits and continuous conversion 120 I2CSEND i2caddr,0,1,&H51 ' Begin conversions command 130 ' 140 PAUSE 1000 ' wait for conversion, 750 ms for 12 bit reso. --first time anyway 150 ' 160 I2CSEND i2caddr, 1,1, &HAA 'read temperature command 170 I2CRCV i2caddr,0,2, TempBuff(1) ' get 2 bytes from chip 180 I2CDIS ' Disable I2C 190 ' 200 temp = (TempBuff(1) * 256 + TempBuff(2)) 'convert 2 bytes into 1 number 210 ' 220 temp = temp / 256 ' shift down for fraction of a degree 230 ' 240 Qneg = TempBuff(1) AND &H80 ' test for most sig bit = negative temperature 250 IF Qneg = &H80 THEN temp = temp - 256 260 ' 270 PRINT " Temperature for thermometer " T$ " is" temp " Degrees" 280 PRINT 290 END > > run Enter Thermometer # (1 to 8) ? 2 Temperature for thermometer 2 is 26.125 Degrees |
||||
Ray B Senior Member Joined: 16/02/2007 Location: AustraliaPosts: 219 |
Thanks Keith for the example and the link to CrackerJack's original example post as follows: http://www.thebackshed.com/forum/forum_posts.asp?TID=4096 RayB from Perth WA |
||||
Ray B Senior Member Joined: 16/02/2007 Location: AustraliaPosts: 219 |
Further to Keith W and CrackerJack's posts here is a comparison between DS18B20 (1-Wire Device) and DS1721 and DS1621 (2-Wire/I2C devices) Keith W (or anyone else) would it be correct to assume that the sample code above would not work with a 1-Wire Device like the DS18B20 which I just happen to have and not the other I2C components. Regards RayB from Perth WA |
||||
Keith @ Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 167 |
Hi Ray I wasn't able to read the image you posted ... could you redo it as a URL. I have included the following link which gives basic info on the alternatives to I2C. http://www.i2c-bus.org/alternatives/ With the little that I know I would say that 1-Wire's software requirements are more demanding then I2C mainly due to the strict timing demands. Horses for courses ... Clydesdales will never win the Melbourne Cup but will pull more weight then a spindly filly. Equally 1-Wire has advantages over I2C. regards Keith The more we know, the more we know we don't know ! |
||||
Ray B Senior Member Joined: 16/02/2007 Location: AustraliaPosts: 219 |
Keith @ I've reposted the comparison off the MAXIM web page below as it shows some differences. This is a filtered page which can't really be sent as a URL due to the filters not showing up but here goes....http://para.maxim-ic.com/en/results.mvp?fam=temp_sen s My preference for the DS18B20 because I have those at hand from using them with PicAxe and the fact that I can buy 10 for A$14 from HongKong on ebay inc post (takes 2 weeks). Someone mentioned DS1621 on special at 50 cents each from Rockerby but their freight alone in Aussie is over $10. Much a muchness I suppose... 2011-10-25_105919_Compare_DS18B20_-_DS1721_-_DS1621.pdf RayB from Perth WA |
||||
boss Senior Member Joined: 19/08/2011 Location: CanadaPosts: 268 |
Good morning to all from rainy Vancouver, what I'm looking for is the way to send data in to some chip(s) requiring less or more bits than 8 i.e. DAC7611 D/A converter (requires 12bit). Unfortunately SPI command doesn't allow to limit number of Tx bits or I missed something? |
||||
Page 2 of 2 |
Print this page |