Go Down

Topic: 1-Wire Slave (Read 34933 times) previous topic - next topic

jooray

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. :)

Thanks for doing this!

Coding Badly

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"!   ;)

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. :)


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

Markus_L811

Did you take a look at this?

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

Google will help you to translate.

Coding Badly


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

Markus_L811



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

Markus_L811

#35
Jun 15, 2013, 12:09 pm Last Edit: Jun 15, 2013, 12:24 pm by Markus_L811 Reason: 1
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: [Select]
// 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:

Markus_L811

#36
Jun 15, 2013, 12:15 pm Last Edit: Jun 15, 2013, 12:29 pm by Markus_L811 Reason: 1
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

Markus_L811

#37
Jun 15, 2013, 05:44 pm Last Edit: Jun 15, 2013, 05:52 pm by Markus_L811 Reason: 1
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.

Markus_L811

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

Code: [Select]

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: [Select]
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:

Markus_L811

#39
Jun 18, 2013, 07:49 pm Last Edit: Jun 21, 2013, 12:22 pm by Markus_L811 Reason: 1
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: [Select]
pinMode(12, INPUT);

And this on the void DS18B20() change this line
Code: [Select]
if (difference >= 380 && difference <= 800) {
to
Code: [Select]
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

Markus_L811

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

1nd Analogread for temper

2st Serial in for temper

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

Markus_L811


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

Thank you. I will give them a try.

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

Go Up