Is there a 1-Wire Device Limitation on MicroLan with OneWire library?

Status
Not open for further replies.

cfo215

New member
I have twenty Maxim DS2406 Dual Addressable Switches (TO-92 package which only has PIO-A) on a MicroLan. I can only see 8 of them at a time. My engineer put a scope on the line and "the signaling looks good". I'm a programmer myself, so I have to take his word on it....

Is there a limitation on the number of connected devices that I connect to the MicroLan? I keep reaching a limit of 8 devices sensed.

My simple code follows. My device is an Arduino Mega2560. I'm using Pin 10 to communicate with the MicroLan, and there is nothing else connected to the Mega.

Code:
// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

#include <OneWire.h>

OneWire  ds(10);  // Connect your 1-wire device to pin 10

void setup(void) {

  Serial.begin(9600);
//  discoverOneWireDevices();
}

void discoverOneWireDevices(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];

  Serial.print("Looking for DS2406 1-Wire devices...\n\r");
  ds.target_search(12);

  while(ds.search(addr)) {
    Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
    for( i = 0; i < 8; i++) {
      Serial.print("0x");
      if (addr[i] < 16) {
        Serial.print('0');
      }
      Serial.print(addr[i], HEX);
      if (i < 7) {
        Serial.print(", ");
      }
    }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
        return;
    }
  }
  Serial.print("\n\r\n\rThat's it.\r\n");
  ds.reset_search();
  return;
}


// added 2/5/2014
void discoverOneWireDevices_v2(void) {

  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];

  Serial.println("Reseting the 1-Wire MicroLan");
  if(ds.reset()) {

    Serial.println("Looking for DS2406 1-Wire devices...");
    ds.target_search(12);

    // Look for the next device via ds.search(addr).
    // Returns 1 if a new address has been returned.
    // Loops until you have retrieved all of them.
    // see Notes in OneWire.h for more info.

    while(ds.search(addr)) {

      Serial.println("\n\rFound \'1-Wire\' device with address:");
      for( i = 0; i < 8; i++) {
        Serial.print("0x");
        if (addr[i] < 16) {
          Serial.print('0');
        }
        Serial.print(addr[i], HEX);
        if (i < 7) {
          Serial.print(", ");
        }
      }
      if ( OneWire::crc8( addr, 7) != addr[7]) {
          Serial.print("CRC is not valid!\n");
          return;
      }
    }
    Serial.print("\n\r\n\rThat's it.\r\n");

    // Clear the search state so that if will start from the beginning again.
    ds.reset_search();

    return;
  }
  else
  {
    Serial.println("No 1-Wire device or the bus is shorted or otherwise held low for more than 250uS.");
    return;
  }
}
void loop(void) {
    discoverOneWireDevices_v2();
    delay(1000);
}
 
My teensynet project uses the 1-wire library, and I've had up to 36 devices (DS18B20, DS2406, etc) on the microlan with no problems.
 
Status
Not open for further replies.
Back
Top