Go Down

Topic: ATtiny85 - OneWire.h (Read 4259 times) previous topic - next topic

kosmart2

Hi everyone!
I am going to make a thermometer using ATtiny85 and i have some questions. Code perfectly runs on ATMega328 it measures what i want and shows what i need. But when I changed the pins for example attiny it didn't work. I blame the internal oscilator because it has "only" 8MHz +-1-10% distortion. I know that it is possible to use external Xtal on this tiny processor. But as it doesn't have any bootloader in it I was wondering how to define that. I am using Arduino board with ATMega328 as a programmer via ISP. Or is there any possibility to download any bootloader for ATtiny from internet pages? There is a one last question what should be first maybe. Is it even possible to run OneWire library on this processor. Isn't it to large for handleing it. Thank you guys for anything.

Coding Badly

Hi kosmart2,

But when I changed the pins for example attiny it didn't work. I blame the internal oscilator because it has "only" 8MHz +-1-10% distortion.


Have you tried tuning the oscillator?  Why is the processor clock so important for your application?

Quote
I know that it is possible to use external Xtal on this tiny processor.


Yup.

Quote
But as it doesn't have any bootloader in it I was wondering how to define that.


If you use this core...

http://code.google.com/p/arduino-tiny/

...you can change the fuse settings to an external crystal by selecting the "board" and then "burning a bootloader" (which changes the fuse settings and clears out the Sketch; a bootloader is not included with that core).

Quote
Or is there any possibility to download any bootloader for ATtiny from internet pages?


Could be.  Various people have worked on a bootloader for that 85 processor.

Quote
Is it even possible to run OneWire library on this processor.


How big is the Sketch when compiled for the 328 processor?

kosmart2

Hi Coding Badly!
   I'll start from the bottom.  Sketch for the 328 processor is about 6kB. What I've done that I've token this sketch changed pins for attiny and uploaded. What was weird that the sketch for attiny is smaller (about 3kB). But than i figured out that it will be some parts needed for 328 and not needed for attiny. I didn't tried tuned the oscilator because i don't know how to do that . But why is it important for me? I've read on the internet that this library especially communication on one wire bus can be complicated and it can require even 16MHz. I don't know if this was true or not. I believed that it was...:-)
    I have favour. I don't quiet understand how i will change the fuses. From what i found out. It's needed to pick a board with a ATtiny85 and than i will upload the bootloader for arduino? But i don't know which one. I am sorry for those stupid questions. I am newbie in this area and i need a little bit of help. Thanks for any advice;-)

Coding Badly

Hi kosmart2,

Quote
Is it even possible to run OneWire library on this processor.

Sketch for the 328 processor is about 6kB.


The code will fit.  That's one obstacle out of the way.  At this point, do what I would do, run and see what happens.

Quote
What was weird that the sketch for attiny is smaller (about 3kB). But than i figured out that it will be some parts needed for 328 and not needed for attiny.


Unfortunately, that much of a difference is very suspicious.  It's possible that the OneWire library does not have conditional compilation entries for the ATtiny85.  Where did you get the library?

Quote
I didn't tried tuned the oscilator because i don't know how to do that


Give this a try...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1287558192

Quote
I have favour. I don't quiet understand how i will change the fuses. From what i found out. It's needed to pick a board with a ATtiny85 and than i will upload the bootloader for arduino?  But i don't know which one.


For "burn bootloader" to change the fuse settings, you have to use the core I referenced.  Have you downloaded and installed that core?  Does that core appear to be working for you?  Are you able to build Sketches?

neurostar

I have a question regarding calibration. So, I connect attiny with ftdi converter to computer, then keep press 'x' key on the terminal program. Is that all it need?

Coding Badly

Sort of.  There are two big steps.  The first step is to determine the optimal OSCCAL register value.  The Tiny Tuner code helps with this step.  By feeding 'x' characters the code is able to determine the optimal value.  The value is either output to the terminal or stored in EEPROM depending on which Sketch you run.

The second step is to use the optimal OSCCAL register value.  That is solely your responsibility.  For some applications, it is appropriate to "hard code" the value.  For other applications, reading the value from EEPROM works better.  You have to decide which works best for your application.

Does that help?

neurostar

Absolutely helpful. I read the method while back. Never actually tried it. I will try soon. By the way, I appreciate your arduino-tiny work.
Would briefly explain what applications works better with reading the value from EEPROM? I thought once I get optimal value, hard code is natural.

Coding Badly

Imagine you want the same code to run on 27 processors.  Updating the OSCCAL value just before uploading might get a bit tedious!

neurostar

Thanks again. Now I understood.

Go Up