Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpLibrary writers › OneWire library/Wiring/logistical question

Page Index Toggle Pages: 1
OneWire library/Wiring/logistical question (Read 18692 times)
05/20/08 at 14:52:34

N201LJ   Offline
YaBB Newbies
darwin is my copilot
USA

Posts: 13
*
 
I've modified the OneWire library in the arduino distribution to work with Wiring.  This library allows users to communicate with Dallas Semi/Maxim 1-Wire devices (e.g. DS18B20)

What's the most efficient way to contribute it to this project? (It's a little large to post directly in the forum...)
 

alan duncan&&to email me, use: lastname dot firstname @ mac dot com
IP Logged
 
Reply #1 - 05/21/08 at 00:23:21

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
hey this is great, we can add it to the library section of the site with your credits etc, we could also host it on Wiring cvs http://wiring.org.co/source if you want as well.
Just let me know what do you want to do.
 
IP Logged
 
Reply #2 - 05/21/08 at 04:07:31

N201LJ   Offline
YaBB Newbies
darwin is my copilot
USA

Posts: 13
*
 
Thanks - happy to contribute.  I have an e-mail in to the author of the original arduino code to work out permissions.  Just want to get the attributions correct.
 

alan duncan&&to email me, use: lastname dot firstname @ mac dot com
IP Logged
 
Reply #3 - 06/02/08 at 22:04:51

N201LJ   Offline
YaBB Newbies
darwin is my copilot
USA

Posts: 13
*
 
I finally finished adapting the arduino OneWire library to work with Wiring.  This library will let your sketches talk with Dallas Semiconductor/Maxim 1-wire devices (e.g. DS18B20). 

You can find this library for and a quick example sketch at:  http://idisk.mac.com/duncan.alan-Public

If you find bugs, etc. let me know.  It seems to work in my sketches; but I have not tried it with devices other than DS18B20.

Would be happy to document on the library page of the site, if you like.

Cheers,
akd
 

alan duncan&&to email me, use: lastname dot firstname @ mac dot com
IP Logged
 
Reply #4 - 06/02/08 at 23:57:52

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
We could either link your page or create a local version for the reference if you prefer. Also we could include the library with the Wiring distribution as well. Let me know. Thanks for doing this Smiley
 
IP Logged
 
Reply #5 - 06/04/08 at 03:36:09

N201LJ   Offline
YaBB Newbies
darwin is my copilot
USA

Posts: 13
*
 
You know - probably best to set up a local version, if you don't mind.  Happy to include in the distro.
 

alan duncan&&to email me, use: lastname dot firstname @ mac dot com
IP Logged
 
Reply #6 - 06/04/08 at 16:06:56

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
cool, please send me the zip file, I´ll add it to the svn and distribution.
 
IP Logged
 
Reply #7 - 06/07/08 at 02:52:57

N201LJ   Offline
YaBB Newbies
darwin is my copilot
USA

Posts: 13
*
 
You should be able to download it here:  http://idisk.mac.com/duncan.alan-Public/OneWire.zip

akd
 

alan duncan&&to email me, use: lastname dot firstname @ mac dot com
IP Logged
 
Reply #8 - 06/13/08 at 06:31:49

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
hi, I am integrating it into the Wiring libraries, I have a question reagarding the API,
which set of functions are part of the end user API? If all of them it would be nice to rename some of them to be consistent with the Wiring API style, for example writeBit
readBit resetSearch etc. Let me know what do you think.

    OneWire( uint8_t pin);
    uint8_t reset();
    void select( uint8_t rom[8]);
    void skip();
    void write( uint8_t v, uint8_t power = 0);
    uint8_t read();

    void write_bit( uint8_t v);
    uint8_t read_bit();
    void depower();

#if ONEWIRE_SEARCH
    void reset_search();
    uint8_t search(uint8_t *newAddr);
#endif

    static uint8_t crc8( uint8_t *addr, uint8_t len);
#if ONEWIRE_CRC16
    static unsigned short crc16(unsigned short *data, unsigned short len);
#endif

 
IP Logged
 
Reply #9 - 06/14/08 at 01:14:56

N201LJ   Offline
YaBB Newbies
darwin is my copilot
USA

Posts: 13
*
 
Sure - I can rename to make them consistent.  Before I do, is there a written standard, or is it simply lowercaseUppercase (i.e. camel case )

 

alan duncan&&to email me, use: lastname dot firstname @ mac dot com
IP Logged
 
Reply #10 - 06/14/08 at 01:39:40

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
yes that´s it, also verify the coherence of the naming/functions, I am not familiar with OneWire protocol so I have questions about the functions, what does select does? or skip, readBit and writeBit, search etc. in the communication process, perhaps looking at examples will make it clearer to me. Thanks for doing this.
 
IP Logged
 
Reply #11 - 06/14/08 at 12:29:54

N201LJ   Offline
YaBB Newbies
darwin is my copilot
USA

Posts: 13
*
 
OneWire::select will select a given device on the 1W bus.  Because many devices can exist on the same bus, calling select() with the ROM address of the desired device will cause it to listen to the next command.  For example, issuing the following sequence on a 1W bus that contains a DS18B20 temp sensor will start the temperature conversion:

_1W.reset();
_1W.select( rom);
_1W.write(0xBE);

OneWire::skip(), on the other hand, tells all of the devices on the bus to listen to the next command.  Essentially, it means "skip the ROM address."  It would be applicable, for example, on a bus with only one device, where you don't care about its unique ROM.

I changed the naming for read_bit to readBit, etc.  Although most users will only use the byte level routines, I left the bit routines in the public interface in case there are devices that have unique protocols that might require them.

Here's an example reading the temperature from a DS18B20 1W device:
[code]
OneWire    _1W(16);   //initiate 1W on pin 16

int read_DS18B20( byte rom[8] )
{   
    int TReading;
    byte preset = 0;
    byte i;
   
    _1W.reset();
    _1W.select( rom );
    _1W.write(0x44,1);         // 0x44 =start conversion, w/ parasite power on at end
    delay(750);
    _1W.reset();
    _1W.select( rom);
    _1W.write(0xBE);           // 0xBE = read scratchpad
    for(int i = 0; i<8; i++)
    {
       data[i] = _1W.read();
       //Serial.print(data[i]); Serial.print(" ");
    }
    TReading = (data[1] << 8) + data[0];
    return( TReading );
}

void showStatusAmbientTemp()
{
    int TReading = read_DS18B20( ROM_AMBIENT_TEMP );
   
    int signBit = TReading & 0x8000;
    if( signBit )
    {
       TReading = (TReading ^ 0xFFFF) + 1; //2's comp if negative
    }
    float TFloat = TReading * 0.0625;
   
    clearLCD();
    selectLineOne();
    serialPrintMsgByAddress( SERIAL1, MSG_AMBIENT_TEMP_1);
    selectLineTwo();
    printFloatingPoint( TFloat, signBit );
    Serial1.print("C");
    gCurrentAmbientTemp = (int) TFloat;
}[/code]

I can write up a document describing the user API and more detail around this example if that would be better...
 

alan duncan&&to email me, use: lastname dot firstname @ mac dot com
IP Logged
 
Reply #12 - 08/26/08 at 06:22:05

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Dear Alan, I have included the OneWire library in the repository for 0017, please check if things are ok so far. I am Still doing fixes before releasing 0017.
http://wiring.uniandes.edu.co/source/trunk/wiring/lib/OneWire/

Thanks for your help.
best,
Hernando.
 
IP Logged
 
Page Index Toggle Pages: 1