Pages: 1 2 3 [4] 5 6 7   Go Down
Author Topic: 1-Wire Slave  (Read 28877 times)
0 Members and 2 Guests are viewing this topic.
Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 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
Oh I know, the  ATTiny85 is not part in the lib can you give me the pins in the IDE where the ATTiny85 has interrupts so I can adopt it for somethink like this.

Code:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //Arduino Mega
  #if dsslavepin == 2
  #define dsslaveassignedint 0
  #elif dsslavepin == 3
  #define dsslaveassignedint 1
  #elif dsslavepin == 18
  #define dsslaveassignedint 5
  #elif dsslavepin == 19
  #define dsslaveassignedint 4
  #elif dsslavepin == 20
  #define dsslaveassignedint 3
  #elif dsslavepin == 21
  #define dsslaveassignedint 2
  #else
  #error "Not an Interrupt Pin"
  #error "Use 2, 3, 18, 19, 20 or 21"
  #define dsslaveassignedint -1
  #endif

so your uC can be supported.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Any ideas?
Use pin 2 or pin 3.
Logged

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

Hi  Again

Interrupts are available on pins 0, 1, 2, 3, 4 and 5.
The micro-controller details and datasheet are available at the following link http://www.atmel.com/devices/ATTINY85.aspx.

I have attached the pins_arduino.h for the ATTiny

Thank you for your assistance.

Ian

* pins_arduino.h (2.69 KB - downloaded 40 times.)
« Last Edit: November 04, 2013, 02:47:10 pm by ilevans » Logged

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

I added the following to OneWireSlave.h and removed a reference to "Serial" in OneWireSlave.cpp that was not commented out.

Code:
#elif defined(__AVR__) //ATTiny
  #if dsslavepin == 0
  #define dsslaveassignedint 0
  #elif dsslavepin == 1
  #define dsslaveassignedint 1
  #elif dsslavepin == 2
  #define dsslaveassignedint 2
  #elif dsslavepin == 3
  #define dsslaveassignedint 3
  #elif dsslavepin == 4
  #define dsslaveassignedint 5
  #elif dsslavepin == 5
  #else
  #error "Not an Interrupt Pin"
  #error "Use 0, 1, 2, 3, 4 or 5"
  #define dsslaveassignedint -1
  #endif

The 0x44 is working. The 0xBE is not.
After a short while running it no longer is detected by the master does not detect the 0x44.

My program that uses the library does not use any interrupts. Another chip does all the work and communicates using an interruptable shiftIn style communications to pass data to the OWSlave chip. An LED on the second chip informs me that the 0x44 was received and the userdefined function executed. Only 0xFFFF's are reported as being read from the scratchpad.

Ian


Logged

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

More testing today and the library is working as expected. Yeah!!

I still have a problem that it stops responding after awhile, That is a strange one but I have a starting point with working communications.

thanks
Logged

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

More testing today and the library is working as expected. Yeah!!

I still have a problem that it stops responding after awhile, That is a strange one but I have a starting point with working communications.

thanks

How often did you poll your uC to get the informations? The Problem is if the uC is too often called he would get out of sync and can't responce anymore, at the moment I have no idea for it. How fast is the ATTiny?
Logged

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

My testing currently consists of 3 x DS18B20 Temperature Sensors and 1 ATTiny85. All slaves are running on external power.

1) All slaves are issued a Convert Temperature Command individually (0x44)
2) 750ms wait (minimum conversion time for DS18B20)
3) All slaves are Read. (0xBE)
4) 2000ms wait before polling again.

The ATTiny85 running at 8mhz, although the chip is capable of running at 20mhz with external clocking.

cheers
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13471
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
2) 750ms wait (minimum conversion time for DS18B20)
for 12 bits it is, for 9 bits it is substantially less...
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

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

The ATTiny85 running at 8mhz, although the chip is capable of running at 20mhz with external clocking.

Crystal or internal RC?

At the moment I don't know if the Leonardo I tested it sometimes get out of step or it's a load problem, I have run it on two Teensy 3 for hours with one miss on temp conversions.

I know if I let run an Leonardo direct against an other, the on who pretends an DS18B20 can't response in time with 2 real DS18B20 in chain it works most the time, only a few "temp conversions" are dropped.
Logged

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

Th ATTiny85 can clock internally at either 1mhz or 8mhz or externally with a crystal at 20mhz.
I run it a 8mhz.
Logged

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

Th ATTiny85 can clock internally at either 1mhz or 8mhz or externally with a crystal at 20mhz.
I run it a 8mhz.

May the internal RC is not accurate enough for it
Logged

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

More testing today and the library is working as expected. Yeah!!

I still have a problem that it stops responding after awhile, That is a strange one but I have a starting point with working communications.

thanks
Btw. did you make some other changes anyway, may can you post you Sketch?
Logged

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

I added the following to OneWireSlave.h and removed a reference to "Serial" in OneWireSlave.cpp that was not commented out.

Code:
#elif defined(__AVR__) //ATTiny
  #if dsslavepin == 0
  #define dsslaveassignedint 0
  #elif dsslavepin == 1
  #define dsslaveassignedint 1
  #elif dsslavepin == 2
  #define dsslaveassignedint 2
  #elif dsslavepin == 3
  #define dsslaveassignedint 3
  #elif dsslavepin == 4
  #define dsslaveassignedint 5
  #elif dsslavepin == 5
  #else
  #error "Not an Interrupt Pin"
  #error "Use 0, 1, 2, 3, 4 or 5"
  #define dsslaveassignedint -1
  #endif

The 0x44 is working. The 0xBE is not.
After a short while running it no longer is detected by the master does not detect the 0x44.

My program that uses the library does not use any interrupts. Another chip does all the work and communicates using an interruptable shiftIn style communications to pass data to the OWSlave chip. An LED on the second chip informs me that the 0x44 was received and the userdefined function executed. Only 0xFFFF's are reported as being read from the scratchpad.

Ian

Did someone know the rest of the "defined" for the other Arduino Modells so I can maybe complete it better
Logged

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

Hi,

I have attached the sketches I have been testing with for the chips on the slave side. I have kept as much vanilla as possible until debugged. (I am currently selling our house so am not getting time to debug at present)

Counter.ino - sketch to just count pulses on the counter pin and send the count to OWSerial.ino when the trigger pin goes high.
            LED flashes to indicate trigger and pulses.
OWSerial.ino - slave sketch. Acts as a DS18B20 returning the count rather than temperature ( 1 pulse = 1/16 degree)
OneWireSlave.cpp - Your library with mods identified previously
OneWireSlave.h - Your library with mods identified previously


* Counter.ino (4.89 KB - downloaded 95 times.)
* OWSerial.ino (3.17 KB - downloaded 94 times.)
* OneWireSlave.cpp (21.76 KB - downloaded 110 times.)
* OneWireSlave.h (9.51 KB - downloaded 107 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I own an Arduino Due and I am very interested in your project (for home automation).
I needed to replace 'cli()' and 'sei()' instructions by 'noInterrupts()' and 'interrupts()'.
Then, it seems to work fine (only few testings so far in front of my Raspberry PI).

I have several DS18B20 for temperature measurement, and was interested by DS2423 for water consumption measurement (to share the same wires between all probes and my Raspberry PI). Since DS2423 is discontinued, I plan to use software emulation for this device.

Do you plan to adapt your code to emulate this one ?

In any case, thank you for your contribution.

Lionel.
Logged

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