OneWire & DS2401 IC as addressable daisy chained input

Status
Not open for further replies.

mortonkopf

Well-known member
Hi all, anyone had experience of using DS2401 as a cheap method of daisy chaining addressable input locations? Using the one-wire library (thank you Paul and others) I am considering a project whereby the one wire library is used to sense the presence pulse on startup of multiple individual location addresses (network node identification?). I would like to associate a ‘state bit’ with each address. I wonder whether this chip can provide a high/low state report as input, this would indicate whether a switch associated with the address was either off or on.

For a state bit, would I be better off going with the switch version (DS2413), although the cost difference looks small, this would soon mount up in a long daisy chain.

DS2401 ‘Maxim Integrated’ IC
https://www.maximintegrated.com/en/products/digital/memory-products/DS2401.html

Paul’s OneWire lib support page
https://www.pjrc.com/teensy/td_libs_OneWire.html

DS2413
https://www.maximintegrated.com/en/products/interface/controllers-expanders/DS2413.html

The gathered on-off states for each address location will be stored in an array. A number of arrays will be available and used as presets via the OneWire library to reset the switches at the associated addresses to a given stored value. In this respect, the DS2401 would be required to also have its state bit set from the Teensy.

As always, feel free to suggest alternatives that hit the mark.
 
Well, I ran some tests with a string of DS2413, and have code that grabs all addresses and puts them into an array. Unfortunately, due to the device search protocol, there is no way of knowing where on the string run each address is. It can be done manually, but not via code. It looks like I have to change chip and use the Maxim DS28EA00. This chip is addressable, has two PIO, and has a chainable function that allows you to determine where on the string of chips the IC address is.
https://datasheets.maximintegrated.com/en/ds/DS28EA00.pdf

On the other hand, if anyone wants the code for grabbing all DS2413 addresses on a string and putting them all into an array, I'm your man.
 
finally managed to get daisy chained addressable pins using the ds28ea00 chips from Maxim working. These are 8pin uSOP SMD parts only as far as I can find. Found a very nice breakout board for prototyping. The helpful people at Maxim send over some code for accessing the chain location function if anyone is interested. It is copyright Maxim, but licensed freely to use. So now I am hopefully able to fulfil the requirement of the original brief of accessing a chainable location, with an individual address, and both sending and retrieving pin state.

image1.jpg
image2.jpg
 
Last edited:
@mortonkopf I'm running your github code for the DS28EA00. I don't have the LCD screen and I've commented out the LCD lines as noted in the comments. The ds28ea00_detect_num_devices() function works nicely, shows the serial numbers and they are different. I'm not able to get the ds28ea00_convert_temperature() function to return anything but 85. Here are results from the print_bus_data() function as seen in the serial monitor. Thoughts, suggestions?

DS28EA00 #1
64-bit ROM code = 4261B846000000D1
Power Mode = 0
Raw Temperature = 550
High Alarm = 0
Low Alarm = 0
Configuration Register = 7F
Temperature = 85.000000000000000
Pin State = 0
 
@Paolo, I ran a test on this today, using four DS28EA00 and it does produce good results. I placed my finger on #1 chip for a couple of secs to see the temp change.

temp_test1.jpg
 
as a follow up on daisy chaining these chips, It was a successful project, each chip has an individual address which can be found automatically, and stored in the correct chain location automatically, and this is then associated with a switch and an RGB led that can be controlled via FastLed calls. The outcome of this is that you can have a single bus connected in a single chain and listen to switches/button to control the RGB led at that location (or associated with that switch). This can be used to create an RGB LED button matrix without the matrix! or any other layout. The bus has five wires; +ve, -ve, led data, IO onewire, and PIO (location). the RGB LED switches developed just connect together as many as wanted, and were as below (1. housing, 2. switch mechanism, 3. ws2812b led, 4.ds28ea00 chip, 5. cable bus). second image; 1.connection, 2.switch housing, 3. micro controller

onewire_switch2.jpg

OneWire_led_bus.jpg
 
Last edited:
@Paolo, I ran a test on this today, using four DS28EA00 and it does produce good results. I placed my finger on #1 chip for a couple of secs to see the temp change.

@mortonkopf Here's how I have them wired.

9-3-2016 1-06-39 PM.png <<< Edit: This schematic doesn't work, see message #9 for more info and #12 for working schematic.


and here's the modified code. (The original code can be found here: https://github.com/mortonkopf/OneWire_DS28EA00)

Code:
/**********************************************************************
* File: DS28EA00
* Programmer: Maxim Integrated Systems Apps
* Started: 22JAN14
* Updated: 23JAN14
*
* Description: Demonstration of using the DS28EA00 1-wire devices.
*              Program supports up to 10 sensors on the bus.
*              Sensors can be added/removed from the bus while the 
*              program is running to test CHAIN feature of the DS28EA00
*
* This project requires the OneWire library which can be found at the
* following link - http://www.pjrc.com/teensy/td_libs_OneWire.html
*
* To make this library visible to the Arduino IDE follow the 
* instructions at the following link - http://arduino.cc/en/Guide/Libraries
*
* This project was developed using the following hardware:
* 1. Arduino UNO - http://arduino.cc/en/Main/ArduinoBoardUno
* 2. Osepp LCD Shield - http://osepp.com/products/shield-arduino-compatible/16x2-lcd-display-keypad-shield/
* 3. DS28EA00EVKIT - http://www.maximintegrated.com/datasheet/index.mvp/id/5489
*
* One of the EVKIT boards was modified to provide breadboard access to 
* the 1-wire data pin on the board.  The rest of the boards were 
* connected with the provided cables.
*
* The following is how the dip-switches on each DS28EA00EVKIT board 
* were configured:

* Board 1 - This board must be connected directly to the Arduino.
*   switch 1 - closed LEDA
*   switch 2 - closed LEDB
*   switch 3 - open   A1
*   switch 4 - open   A2
*   switch 5 - open   B EXT
*   switch 6 - closed B GND
*   switch 7 - closed Vcc
*
* Board 2 and 3 - The position of these boards is irrelevant.
*                 Changing the positions of these boards on the fly
*                 demonstrates the CHAIN feature of the device
*   switch 1 - closed LEDA
*   switch 2 - closed LEDB
*   switch 3 - open   A1
*   switch 4 - open   A2
*   switch 5 - closed B EXT
*   switch 6 - open   B GND
*   switch 7 - closed Vcc
* 
* The Osepp LCD Shield is not required for this project to work.
* Simply comment out the LCD relevant code (5 lines in setup, 4 lines 
* in the main loop) and make sure the function print_bus_data is 
* uncommented in the main loop.
**********************************************************************/

#include <LiquidCrystal.h>
#include <OneWire.h>
#include "DS28EA00.h"


/**********************************************************************
*Following is specific to the Osepp LCD Shield
**********************************************************************/

//select the pins used on the LCD Shield
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int lcd_key     = 0;
int adc_key_in  = 0;

#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5
/*********************************************************************/
 
//Set up ow_bus.  Pin can be changed in header file
OneWire ow_bus(OW_BUS_PIN);

//This is an array of structs
ds28ea00_t ds28ea00_array[10];

unsigned char num_ds28ea00_on_bus = 0;
unsigned char old_num_devices = 0;
unsigned char selected_ds28ea00 = 0;
unsigned char idx = 0;
unsigned char idy = 0;
unsigned char data;

void setup() 
{
  /*lcd.begin(16, 2);        // start the library
  lcd.setCursor(0,0);
  lcd.print("DS28EA00# ="); 
  lcd.setCursor(0, 2);
  lcd.print("Temp = "); */
  Serial.begin(9600);
  delay(500);
  while (!Serial) {
      yield();  // THIS IS BLOCKING. The sketch will not run until the serial monitor is opened.
    }
  Serial.println("-----------------------------------");
  ds28ea00_detect_num_devices(ds28ea00_array);
  old_num_devices = num_ds28ea00_on_bus;
  ds28ea00_config_bus();
}

void loop() 
{
  //See if DS28EA00 sensors have been added/removed from bus
  ds28ea00_detect_num_devices(ds28ea00_array);
  
  //If they have, configure them
  if(old_num_devices != num_ds28ea00_on_bus)
  {
    ds28ea00_config_bus();
  }
  old_num_devices = num_ds28ea00_on_bus;
  
  //Test for user input
  if(read_LCD_buttons() == btnSELECT)
  {
    selected_ds28ea00++;
    
    if(selected_ds28ea00 >= num_ds28ea00_on_bus)
    {
      selected_ds28ea00 = 0;
    }
  }
  
  //Display Current Device
  //lcd.setCursor(12, 0);
  //lcd.print(selected_ds28ea00 + 1);
  
  //Convert the temperature on selected device
  //ds28ea00_convert_temperature(selected_ds28ea00);
  
  //Display temperature
  //lcd.setCursor(7, 1);
  //lcd.print(ds28ea00_array[selected_ds28ea00].temperature);
  
  // comment the following if print_bus_data() is used
  //delay(100);
  
  //The following prints the members of each devices struct to a rolling terminal
  //The array of structs updates dynamically when devices are added removed.
  
  print_bus_data();
}


/**********************************************************************
*Function Defenitions - The arduino ide creates function prototypes 
*                       when the sketch is compiled, therefore none are 
*                       included in the header file as would be done in
*                       a normal c or cpp project.  Please refer to the 
*                       following link for more details about the 
*                       arduino build process.
*                       http://www.arduino.cc/en/Hacking/BuildProcess
**********************************************************************/


/**********************************************************************
* Function: ds28ea00_detect_num_devices
* Parameters: ds28ea00_t *device_array - Pointer to an array of type 
*                                        ds28ea00_t
* Returns: none
*
* Description: Detects devices on the bus
**********************************************************************/
void ds28ea00_detect_num_devices(ds28ea00_t *device_array)
{
  int state = 0;
  
  do
  {
    state = ds28ea00_sequence_discoverey(device_array);
    if(state == -1)
    {
      Serial.println("Error!");
    }
  }
  while(state == -1);
  
  return;
}
/********** END ds28ea00_detect_num_devices****************************/


/**********************************************************************
* Function: ds28ea00_config_bus
* Parameters: none
* Returns: none
*
* Description: Populates structs of devices with desired configuration
               and writes to devices on bus
**********************************************************************/
void ds28ea00_config_bus(void)
{
  for(idx = 0; idx < num_ds28ea00_on_bus; idx++)
  {
    ds28ea00_get_pwr_mode(idx);
    
    //see header file for #defines of the following
    ds28ea00_array[idx].temp_lo_alm = LO_ALARM;
    ds28ea00_array[idx].temp_hi_alm = HI_ALARM;
    ds28ea00_array[idx].config_register = RES_12_BIT;
    
    ds28ea00_write_scratchpad(idx);
    ds28ea00_copy_scratchpad(idx);
    
    ds28ea00_convert_temperature(idx);
  }
  
  return;
}
/********** END ds28ea00_config_bus************************************/


/**********************************************************************
* Function: ds28ea00_sequence_discoverey
* Parameters: ds28ea00_t *device_array - Pointer to an array of type 
*                                        ds28ea00_t
* Returns: none
*
* Description: Detects devices on the bus and populates the 64-bit rom
*              codes of the device_array
**********************************************************************/
int ds28ea00_sequence_discoverey(ds28ea00_t *device_array)
{
  unsigned char test_end_of_bus;
  
  idx = 0;
  idy = 0;
  
  ow_bus.reset();
  ow_bus.skip();
  ow_bus.write(CHAIN);
  ow_bus.write(CHAIN_ON);
  ow_bus.write(~CHAIN_ON);
  
  data = ow_bus.read();
  if(data != VALID_SEQUENCE)
  {
    return(-1);
  }
  
  do
  {
    ow_bus.reset();
    ow_bus.write(CONDITIONAL_READ_ROM);
    
    test_end_of_bus = 0xFF;
    for(idy = 0; idy < 8; idy++)
    {
      data = ow_bus.read();
      test_end_of_bus &= data;
      device_array[idx].rom_code[idy] = data;
    }
    
    if(test_end_of_bus == 0xFF)
    {
      break;
    }
    
    idx++;
    num_ds28ea00_on_bus = idx;
    ow_bus.reset();
    ow_bus.write(PIO_ACCESS_WRITE);
    ow_bus.write(CHAIN);
    ow_bus.write(CHAIN_DONE);
    ow_bus.write(~CHAIN_DONE);
  
    data = ow_bus.read();
    if(data != VALID_SEQUENCE)
    {
      return(-1);
    }
  }
  while(test_end_of_bus != 0xFF);
  
  ow_bus.reset();
  ow_bus.skip();
  ow_bus.write(CHAIN);
  ow_bus.write(CHAIN_OFF);
  ow_bus.write(~CHAIN_OFF);
  
  data = ow_bus.read();
  if(data != VALID_SEQUENCE)
  {
    return(-1);
  }
  return(0);
}
/********** END ds28ea00_sequence_discoverey***************************/


/**********************************************************************
* Function: ds28ea00_get_pwr_mode
* Parameters: unsigned char device - ds28ea00 struct offset in array
* Returns: none
*
* Description: Initiates a READ_PWR_MODE command with the selected 
*              ds28ea00 device and updates the power mode member of 
*              the device's struct.
**********************************************************************/
void ds28ea00_get_pwr_mode(unsigned char device)
{
  ow_bus.reset();
  ow_bus.select(ds28ea00_array[device].rom_code);
  ow_bus.write(READ_PWR_MODE);
  
  ds28ea00_array[device].pwr_mode = ow_bus.read();

  return;
}
/********** END ds28ea00_get_pwr_mode**********************************/


/**********************************************************************
* Function: ds28ea00_set_resolution
* Parameters: unsigned char device - ds28ea00 struct offset in array
*             unsigned char val - byte representing resolution of 
*                                 device
* Returns: none
*
* Description: writes 'val' to configuration register of 'device'
**********************************************************************/
void ds28ea00_set_resolution(unsigned char device, unsigned char val)
{
  ds28ea00_array[device].config_register = val;
  ds28ea00_write_scratchpad(device);
  ds28ea00_copy_scratchpad(device);
  
  return;
}
/********** END ds28ea00_set_resolution********************************/


/**********************************************************************
* Function: ds28ea00_set_hi_alarm
* Parameters: unsigned char device - ds28ea00 struct offset in array
*             unsigned char val - byte representing hi alarm
*
* Returns: none
*
* Description: writes 'val' to hi alarm register of 'device'
**********************************************************************/
void ds28ea00_set_hi_alarm(unsigned char device, unsigned char val)
{
  ds28ea00_array[device].temp_hi_alm = val;
  ds28ea00_write_scratchpad(device);
  ds28ea00_copy_scratchpad(device);
  
  return;
}
/********** END ds28ea00_set_hi_alarm*********************************/


/**********************************************************************
* Function: ds28ea00_set_lo_alarm
* Parameters: unsigned char device - ds28ea00 struct offset in array
*             unsigned char val - byte representing lo alarm
*
* Returns: none
*
* Description: writes 'val' to lo alarm register of 'device'
**********************************************************************/
void ds28ea00_set_lo_alarm(unsigned char device, unsigned char val)
{
  ds28ea00_array[device].temp_lo_alm = val;
  ds28ea00_write_scratchpad(device);
  ds28ea00_copy_scratchpad(device);
  
  return;
}
/********** END ds28ea00_set_lo_alarm*********************************/


/**********************************************************************
* Function: ds28ea00_read_scratchpad
* Parameters: unsigned char device - ds28ea00 struct offset in array
* Returns: none
*
* Description: Reads the selected device's scratchpad
**********************************************************************/
void ds28ea00_read_scratchpad(unsigned char device)
{
  int temp_lo_byte;
  int temp_hi_byte;
  
  ow_bus.reset();
  ow_bus.select(ds28ea00_array[device].rom_code);
  ow_bus.write(READ_SCRATCHPAD);
  temp_lo_byte = ow_bus.read();
  temp_hi_byte = ow_bus.read();
  ds28ea00_array[device].temp_hi_alm = ow_bus.read();
  ds28ea00_array[device].temp_lo_alm = ow_bus.read();
  ds28ea00_array[device].config_register = ow_bus.read();
  //last three bytes of scratchpad reserved so we don't care
  ow_bus.reset();
  
  //build temp into single signed int
  ds28ea00_array[device].raw_temp = ((temp_hi_byte << 8) | temp_lo_byte);
  
  return;
}
/********** END ds28ea00_read_scratchpad*******************************/


/**********************************************************************
* Function: ds28ea00_write_scratchpad
* Parameters: unsigned char device - ds28ea00 struct offset in array
* Returns: none
*
* Description: Writes the desired temperature alarms and configuration 
               register to the selected device's scratchpad
**********************************************************************/
void ds28ea00_write_scratchpad(unsigned char device)
{
  
  ow_bus.reset();
  ow_bus.select(ds28ea00_array[device].rom_code);
  ow_bus.write(WRITE_SCRATCHPAD);
  ow_bus.write(ds28ea00_array[device].temp_hi_alm);
  ow_bus.write(ds28ea00_array[device].temp_lo_alm);
  ow_bus.write(ds28ea00_array[device].config_register);
  ow_bus.reset();
  
  return;
}
/********** END ds28ea00_write_scratchpad******************************/


/**********************************************************************
* Function: ds28ea00_copy_scratchpad
* Parameters: unsigned char device - ds28ea00 struct offset in array
* Returns: none
*
* Description: Copies scratchpad of selected device to its EEPROM
**********************************************************************/
void ds28ea00_copy_scratchpad(unsigned char device)
{
  
  ow_bus.reset();
  ow_bus.select(ds28ea00_array[device].rom_code);
  ow_bus.write(COPY_SCRATCHPAD);
  
  do
  {
    data = ow_bus.read();
  }
  while(data != 0xFF);
  
  return;
}
/********** END ds28ea00_copy_scratchpad*******************************/


/**********************************************************************
* Function: ds28ea00_convert_temperature
* Parameters: unsigned char device - ds28ea00 struct offset in array
* Returns: none
*
* Description: Initiates a temperature conversion on selected device
**********************************************************************/
void ds28ea00_convert_temperature(unsigned char device)
{
  int temp_lo_byte;
  int temp_hi_byte;
  
  ow_bus.reset();
  ow_bus.select(ds28ea00_array[device].rom_code);
  ow_bus.write(CONVERT_TEMP);
  
  do
  {
    data = ow_bus.read();
  }
  while(data = 0);
  
  ow_bus.reset();
  ow_bus.select(ds28ea00_array[device].rom_code);
  ow_bus.write(READ_SCRATCHPAD);
  temp_lo_byte = ow_bus.read();
  temp_hi_byte = ow_bus.read();
  //we just want temp bytes so reset
  ow_bus.reset();
  
  //build temp into single signed int
  ds28ea00_array[device].raw_temp = ((temp_hi_byte << 8) | temp_lo_byte);
  
  ds28ea00_format_temperature(device);
  
  return;
}
/********** END ds28ea00_convert_temperature***************************/


/**********************************************************************
* Function: ds28ea00_format_temperature
* Parameters: unsigned char device - ds28ea00 struct offset in array
* Returns: none
*
* Description: Formats the raw temperature conversion 
**********************************************************************/
void ds28ea00_format_temperature(unsigned char device)
{
  float f_temp = 0;
  int r_temp = ds28ea00_array[device].raw_temp;
  unsigned char sign = POSITIVE;
 
  if(r_temp & 0x8000)
  {
    sign = NEGATIVE;
    r_temp = ~r_temp + 1;
  }
  
  switch(ds28ea00_array[device].config_register)
  {
    case RES_9_BIT:
      r_temp = ((r_temp >> 3) & 0x1FF);
      f_temp = (r_temp >> 1);
      
      if(r_temp & 0x001)
      {
        f_temp += 0.5;
      }
      break;
      
    case RES_10_BIT: 
      r_temp = ((r_temp >> 2) & 0x3FF);
      f_temp = (r_temp >> 2);
      
      for(idy = 0; idy < 2; idy++)
      {
        if(r_temp & (1 << idy))
        {
          f_temp += (1.0/(1 << (2 - idy)));
        }
      }
      break;
      
    case RES_11_BIT:  
      r_temp = ((r_temp >> 1) & 0x7FF);
      f_temp = (r_temp >> 3);
      
      for(idy = 0; idy < 3; idy++)
      {
        if(r_temp & (1 << idy))
        {
          f_temp += (1.0/(1 << (3 - idy)));
        }
      }
      break;
      
    default :
      f_temp = (r_temp >> 4);
      
      for(idy = 0; idy < 4; idy++)
      {
        if(r_temp & (1 << idy))
        {
          f_temp += (1.0/(1 << (4 - idy)));
        }
      }
  }
  
  if(sign == NEGATIVE)
  {
    ds28ea00_array[device].temperature = (-1*f_temp);
  }
  else
  {
    ds28ea00_array[device].temperature = f_temp;
  }
  
 
  return;
}
/********** END ds28ea00_format_temperature***************************/


/**********************************************************************
* Function: ds28ea00_pio_read
* Parameters: unsigned char device - ds28ea00 struct offset in array
* Returns: none
*
* Description: Reads the PIO status register of the selected device
**********************************************************************/
void ds28ea00_pio_read(unsigned char device)
{
  ow_bus.reset();
  ow_bus.select(ds28ea00_array[device].rom_code);
  ow_bus.write(PIO_ACCESS_READ);
  
  ds28ea00_array[device].pio_state = ow_bus.read();
  
  ow_bus.reset();
  
  return;
  
}
/********** END ds28ea00_pio_read**************************************/


/**********************************************************************
* Function: ds28ea00_pio_write
* Parameters: unsigned char device - ds28ea00 struct offset in array
* Returns: none
*
* Description: Writes to the PIO assignment register of the selected 
*              device
**********************************************************************/
int ds28ea00_pio_write(unsigned char device, unsigned char val)
{
  ow_bus.reset();
  ow_bus.select(ds28ea00_array[device].rom_code);
  ow_bus.write(PIO_ACCESS_WRITE);
  ow_bus.write(val);
  ow_bus.write(~val);
  
  data = ow_bus.read();
  if(data != VALID_SEQUENCE)
  {
    return(-1);
  }
 
  ds28ea00_array[device].pio_state = ow_bus.read();
  
  ow_bus.reset();
  
  return(0);  
}
/********** END ds28ea00_pio_write*************************************/


/**********************************************************************
* Function: print_bus_data
* Parameters: none
* Returns: none
*
* Description: Prints how many devices are on the bus and the members
*              of their structs.
**********************************************************************/
void print_bus_data(void)
{
  Serial.print("Number of DS28EA00 on bus = ");
  Serial.println(num_ds28ea00_on_bus);
  Serial.println("");
  
  for(idx = 0; idx < num_ds28ea00_on_bus; idx++)
  {
    ds28ea00_convert_temperature(idx); 
    Serial.print("DS28EA00 #");
    Serial.println(idx + 1);
    Serial.print("64-bit ROM code = ");
    
    for(idy = 0; idy < 8; idy++)
    {
      data = ds28ea00_array[idx].rom_code[idy];
      if(data > 0x0F)
      {
        Serial.print(data , HEX);
      }
      else
      {
        Serial.print(0);
        Serial.print(data , HEX);
      }
    }
    Serial.println("");
    
    Serial.print("Power Mode = ");
    Serial.println(ds28ea00_array[idx].pwr_mode, HEX);
    
    Serial.print("Raw Temperature = ");
    Serial.println(ds28ea00_array[idx].raw_temp, HEX);
    
    Serial.print("High Alarm = ");
    Serial.println(ds28ea00_array[idx].temp_hi_alm, HEX);
    
    Serial.print("Low Alarm = ");
    Serial.println(ds28ea00_array[idx].temp_lo_alm, HEX);
    
    Serial.print("Configuration Register = ");
    Serial.println(ds28ea00_array[idx].config_register, HEX);
    
    Serial.print("Temperature = ");
    Serial.println(ds28ea00_array[idx].temperature, HEX);

      Serial.print("Pin State = ");
    Serial.println(ds28ea00_array[idx].pio_state, HEX);
    
    Serial.println("");
  }
  
  delay(2500);
  
  return;
}
/********** END print_bus_data*****************************************/


/**********************************************************************
*Following is specific to the Osepp LCD Shield
**********************************************************************/

/**********************************************************************
* Function: read_LCD_buttons
* Parameters: none
* Returns: A int representing button pressed
*
* Description: Taken from Osepp LCD Shield example.  The shield uses a 
*              voltage divider network with different taps to represent
*              each button based on the analog voltage read in on A0.
**********************************************************************/
int read_LCD_buttons()
{
 adc_key_in = analogRead(0);  
 
 //btnNone read first for speed since most likely case
 if (adc_key_in > 1000) return btnNONE; 
 if (adc_key_in < 50)   return btnRIGHT; 
 if (adc_key_in < 195)  return btnUP;
 if (adc_key_in < 380)  return btnDOWN;
 if (adc_key_in < 555)  return btnLEFT;
 if (adc_key_in < 790)  return btnSELECT;  
 
 return btnNONE;  // when all others fail, return this...
}
/********** END ow_receive_conformation********************************/


/**********************************************************************
* Function: 
* Parameters: 
* Returns: 
*
* Description: 
**********************************************************************/


/********** END function**********************************************/

/**********************************************************************
* Copyright (C) 2013 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
**********************************************************************/

Does anything stand out as not kosher?

EDIT: I moved the ds28ea00_convert_temperature() function call to the print_bus_data() function call. The original code required a button press to call the ds28ea00_convert_temperature() function for each sensor.
 
Last edited:
I just copied and pasted your code into a new sketch and ran it with my finger on sensor 1. The output seems correct, with the sensor higher than room temp, see below image. Did you unplug the usb port and plug in then upload sketch again after changes the sensor connections. Mine reads 85 when this process has not been followed.

i.e hot plugging does not seem to work

ds28ea_paolo_screengrab1.jpg
 
Last edited:
@mortonkopf, this may come down to my (mis) understanding of control function flowchart in the spec sheet.

convert temp.png

If I power VDD I get valid temperatures.

I assumed that if VDD wasn't powered the DS28EA00 charged an internal capacitor from the IO line that powered the ADC.
In rereading the spec sheet I now think I need to use a pin on the Teensy and a transistor to pullup the IO line.
 
@Paolo, a couple of points. According to the spec sheet page 5, Parasitic mode requires pin8 of the chip (VDD) to be connected to GND. I don't use parasitic mode, and have VDD of the chip connected to Vin of Teensy 3.2. This is outputting 5v as Teensy is obtaining power from USB connection. There is a 1k resistor before the first chip between the IO pin and power (2.2k also works).

Parasite mode wasn't working out for me, lots of strange readings and additional small circuit (like you have pointed to, there is a v short time pull up requirement), and as the buttons require 5v, I decided to go with the powered option. Just a much easier solution for my use, which is all about just plugging any length of switches together in a string.
 
@mortonkopf There's a part of me that would love to see the parasitic mode working, I'll probably spend an hour or two and see how far I get. That said I'm rolling my own boards so the difference between 2 and 3 traces is in the noise.

Just for thread completeness would you mind posting the part numbers and schematic for your switch/led/temp array. I can imagine building one sometime in the future. I'll post an updated schematic for my temp array, I've already edited the previous post noting the schematic doesn't work.
 
@paulo, below is my schematic for a five wire chained addressable RGB switch using DS28EA00. thanks for posting working schematic for operation. Polling of the state line is used in the loop and the state is stored in an array. state is changes by connecting state line to gnd. the array states are read at end of each loop, and this then tells the programme whether a switch has changed state, and then to do something if it has. Each array position is linked to the DS28EA00 individual address and so location within the chain is known. FastLED is then used to generate the ws2812b colour dependent on the state case.

5wire_concept_single_unit.jpg
 
Last edited:
thanks for posting working schematic for parasitic operation.

FYI, The schematic is for standard mode. I haven't had a chance to work on parasitic mode.

Each array position is linked to the DS28EA00 individual address and so location within the chain is known.

This is a clever use of the DS28EA00. Do you use the temp function for anything? Maxim should sell a chip just for location?
 
Yep, I use just the automated chain position/location feature, I have no use for the temp feature right now. It is a really useful automated discovery option, and you can associate anything via the useful state pin PIOA. Good idea to keep that one in the "could be useful at some point" bag. Once the address value is in the array, you can manipulate commands to associated peripherals by simple 'for loops' and 'case' functions as position is all you need.
 
Last edited:
Status
Not open for further replies.
Back
Top