Pages: 1 2 [3] 4 5 ... 7   Go Down
Author Topic: 1-Wire Slave  (Read 29307 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just started coding similar project, just for fun (the goal is to send serial as slave to another arduino as a master). I can not seem to get the timing right though.

Do you have any ideas for testing?

I started with master library and changing it with the PIC code as an example.

I played with some iButtons and this is my first Arduino project besides lighting LEDs. smiley

Thanks for doing this!
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 199
Posts: 12768
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I started with master library and changing it with the PIC code as an example.

Don't do that.  You can find a ready to use well documented master library here...
http://pjrc.com/teensy/td_libs_OneWire.html

Quote
I just started coding similar project, just for fun

You have a perverse sense of "fun"!   smiley-wink

Quote
Do you have any ideas for testing?

Work in very tiny increments.  Create code that can reliably detect a Reset.  Add code that reliably detects the Device Present pulse.  Add code that reliably determines the end of the Reset.  Et cetera.

Quote
(the goal is to send serial as slave to another arduino as a master). I can not seem to get the timing right though.

The slave timing is definitely tricky.  I've identified three potential problems...

1. Interrupt latency.

2. Master variations.

3. Loose protocol.

Quote
I played with some iButtons and this is my first Arduino project besides lighting LEDs. smiley

An eclectic set.

Quote
Thanks for doing this!

Don't thank me yet!  At the rate I'm going we all may expire before I finish.

This is not very Arduino friendly but I suspect that it works well...
http://old.nabble.com/1wire-slave-codebase-%28AVR%29-td28214218.html
https://github.com/smurfix/owslave
Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you take a look at this?

http://robocraft.ru/blog/arduino/302.html

Google will help you to translate.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 199
Posts: 12768
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I had not seen that.  Thank you for the tip.
Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I had not seen that.  Thank you for the tip.

Not for that i've seen that few days ago, i'am looking too, to get an emulation of an 1-Wire Slave, this looks like the most simple projekt, for other typs of devices the libary must expand in my opinion, bevor i've seen that i was thinking about an interrupt driven lib, in combination with an final state maschine but this would be to complex. But this modified lib looks nice maybe with some extra code for different typs of devices and "jump marks" it can be an solution for 1-Wire Slaves. So that you tell the lib what it is and only the conf or informations would be set in the Sketches.

B.R.

Markus
Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's about time to move some dust.

Moving from this http://robocraft.ru/blog/arduino/302.html way there to this https://digistump.com/board/index.php/topic,887.0.html. Thanks to all that Guys what they did.

I was able to start this. Files in the Attachment.

DS18B20_Slave.ino                        --> the Slave in Arduinostyle
OneWireSlave.cpp/.h                    --> the library for it
(did not work on Due or Teensy 3)

DS18x20_Temperature_edited.ino   --> an little edited Version of Paul Stoffregen's File from the last OneWirelib (2.2)

The Arduino pretend on with the DS18B20_Slave to be an DS18B20 with an temp of 155°C (clearly above the capabilities of the DS18B20 (125)) parasite powered. But under heavy duty.

What didn't work is the DallasTemperature Library from Miles Burton there are some problems with reset_search and the reset at the end of some parts.

Code:
// reads the device's power requirements
bool DallasTemperature::readPowerSupply(uint8_t* deviceAddress)
{
  bool ret = false;
  _wire->reset();
  _wire->select(deviceAddress);
  _wire->write(READPOWERSUPPLY);
  if (_wire->read_bit() == 0) ret = true;
  _wire->reset();     --> this line is not good fore the cloned DS18B20 without it works
  return ret;
}

May someone can help drive this forward to getting an working and universal library. Perhaps an interrpt driven Initiaization Timing can bring success but I'm not an expert for that.

This is really experimental. Nothing is convenient on this.

Pictures below:

* DS18B20_Slave.ino (1.11 KB - downloaded 133 times.)
* OneWireSlave.h (1.88 KB - downloaded 101 times.)
* OneWireSlave.cpp (18.03 KB - downloaded 162 times.)
* DS18x20_Temperature_edited.ino (3.12 KB - downloaded 99 times.)
« Last Edit: June 15, 2013, 05:24:46 am by Markus_L811 » Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1st the Hardware
 Black-Board an Vinciduino, Powered by an supply
 Blue-One an Arduino Nano Powered by USB
 And 3 real DS18B20 Powered from the Nano external.

2nd the Serial from the Nano
 4 DS18B20
 The last is the Arduino-Slave what you can see parasite Powered and burning@155°C


* Hardware.jpg (3150.05 KB, 2560x1920 - viewed 309 times.)

* Onewire Slave.JPG (61.82 KB, 639x480 - viewed 215 times.)
« Last Edit: June 15, 2013, 05:29:26 am by Markus_L811 » Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Surprise to my self.

Now an expedition into interrupts.

Quick an dirty with interruptsroutine for recognizing the Master Tx Reset Pulse...

But now the  DallasTemperature Library from Miles Burton works too, for it on the other side, and recognize it as well.

* DS18B20_Slave_Interrupt.ino (1.39 KB - downloaded 91 times.)
* OneWireSlave.cpp (19.18 KB - downloaded 76 times.)
* OneWireSlave.h (1.93 KB - downloaded 59 times.)
« Last Edit: June 15, 2013, 10:52:58 am by Markus_L811 » Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some improvement with support for the 44h command and set the "power supply" from the outsite the library.

Code:
ds.attach44h(temper);

-----------------------------------------

void temper() {
  scratchpad[1] = scratchpad[1] + 1;
  ds.setScratchpad(scratchpad);
}

Sometimes the "Slave did something wrong think he didn't get the Master reset.

Code:
ROM = 28 AD DA CE 0F 00 11 5B
  Chip = DS18B20
  Data = FF FF FF FF FF FF FF FF FF  CRC=C9
  Powersupply = Parasite Powered
  Temperature = -0.06 Celsius, 31.89 Fahrenheit

All FF so there is some miss.

New added:

* OneWireSlave.cpp (19.37 KB - downloaded 72 times.)
* OneWireSlave.h (2.06 KB - downloaded 57 times.)
* DS18B20_Slave_Interrupt.ino (1.52 KB - downloaded 68 times.)
Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now support for Teensy 3.0 and Arduino Due added.

For proper work with the T3 some changes must be done:

Add this on the void setup()
Code:
pinMode(12, INPUT);

And this on the void DS18B20() change this line
Code:
if (difference >= 380 && difference <= 800) {
to
Code:
if (difference >= 325 && difference <= 500) {

Thanks to Paul.

For the Due the Sample must be changed read this page about the interrupts.

http://arduino.cc/en/Reference/AttachInterrupt

Update:

Allowing to set resolution from Master or per command from slave side

* OneWireSlave.cpp (19.11 KB - downloaded 102 times.)
* OneWireSlave.h (5.17 KB - downloaded 119 times.)
* DS18B20_Slave_Interrupt.ino (1.71 KB - downloaded 98 times.)
« Last Edit: June 21, 2013, 05:22:46 am by Markus_L811 » Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some new Sketches to play with for the 1-Wire-Slave:

1nd Analogread for temper

2st Serial in for temper

* DS18B20_Slave_Interrupt_T3_analogread.ino (2.47 KB - downloaded 93 times.)
* DS18B20_Slave_Interrupt_T3_Serial.ino (3 KB - downloaded 87 times.)
Logged

Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been playing around with your libraries for programming an ATTiny85 at 8Mhz but find that it is failing to detect the 0x44 - Convert Temperature when sent. The 0xBE - Read Scratchpad  works only from your sample master and not from my program with nearly identical code that works with DS18B20 temperature sensors.

My master program detects, converts DS18B20 temperature sensors without any problem.

Not having an oscilloscope I am at a loss as to where the problem may be. I am assuming a timing issue but am not sure where to look next.

Any ideas would be most welcome.

Ian
Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been playing around with your libraries for programming an ATTiny85 at 8Mhz but find that it is failing to detect the 0x44 - Convert Temperature when sent. The 0xBE - Read Scratchpad  works only from your sample master and not from my program with nearly identical code that works with DS18B20 temperature sensors.

My master program detects, converts DS18B20 temperature sensors without any problem.

Not having an oscilloscope I am at a loss as to where the problem may be. I am assuming a timing issue but am not sure where to look next.

Any ideas would be most welcome.

Ian

I have there some newer version may that will help..., let me know

* OneWireSlave.cpp (21.76 KB - downloaded 129 times.)
* OneWireSlave.h (9.07 KB - downloaded 100 times.)
* keywords.txt (0.85 KB - downloaded 94 times.)
Logged

Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you. I will give them a try.
Logged

Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am receiving the following errors when compiling

. . ./OneWireSlave.h:133:4: error: #error "Not an Interrupt Pin"
. . ./OneWireSlave.h:134:4: error: #error "Use 2 or 3"

Any ideas?

Ian
Logged

Pages: 1 2 [3] 4 5 ... 7   Go Up
Jump to: