Pages: [1]   Go Down
Author Topic: Attiny 84/85 serial comm  (Read 1490 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm new in this forum, I'm trying to send/receive data via serial protocol, 9600 baud is enough, from/to attiny 84/85 processors but I can't find complete guide, I'm a bit confused with cores, pins, clocks, and what is the correct library to use.
Maybe it could be useful also to other people to write a summary of all is needed because all that I can't find is a big mix of everything.
If someone has succeded in serial comm, could you please summarize these steps:

 - core to use and it's link, which is the speed to select to have succesfull data sent/received
 - which library to use serial, softwareserial, tinyserialdebug, other...
 - ports to use, if mandatory on the 84 and the 85, or any
 - capacitor if needed between output and ground or other
 - sample working code

I'm trying to send data to a 44780 lcd display via a serial adapter but I see always bad data on the display while with arduino it was working properly. I'm using a usb tiny isp as a programmer. I'm trying with an attiny 85 and an 84.

Hope someone will help me, thank you in advance
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1057
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You could start with this:

http://www.ernstc.dk/arduino/tinycom.html

It is based on this core:

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

0
Offline Offline
Full Member
***
Karma: 0
Posts: 117
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very useful... goes into my bookmark folder.
Logged

Pottstown, PA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 317
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Me, I'm really confused about this. For one thing, is Tiny Isp software or hardware? I've been trying to understand the directions on the pages Erni posted as well as this tutorial, but it's still not clear to me. The end goal for me is to be able to debug and reprogram at will. What I don't understand is if this can be done with an Attiny 85. Must there be additional hardware such as an USB to serial converter or a TinyISP AVR Programmer or an Arduino? If both debugging and programming can be available without switching hardware, how is the hardware connected to an Attiny 85? - Scotty
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1057
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
is Tiny Isp software or hardware?

It is software, it is a  a sketch, just like the normal ArduinoISP you have in your example menu in the Arduino IDE

If you want to program an ATtiny you need a programmer.
It can be a Arduino with the ArduinoISP, or TinyISp
or any other programmer like USBAsp, Pololu programmer and so on

If you want the debug output in your Serial monitor, you can use a USB/Serial converter, and you can use your Arduino as such.

If you want both of the above (like you are used to from Arduino), you can use Arduino (hardware) with the TinyISP sketch (software) loaded, and the KnockBang sketch (software) on yor Attiny.
You connect it  like this

http://www.ernstc.dk/arduino/attiny85.html
« Last Edit: May 20, 2013, 08:13:50 am by Erni » Logged

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


ERNI,

thank you for your help, I have succeded in having output from attiny 84/85 with your documentation, my mistake was only using port PA0 instead of PB0 on ATTINY84.
Now I'm trying also to receive serial data with ATTINY84/85 chips, but using SoftwareSerial I am not able to receive any data, I'm thinking it could be an issue linked to clock tuning.
Now I'm struggling with the Tiny Tuner, probably I've missed a library, I've tried to use the example:
- Interactive with NewsoftSerial
but it gives me some compilation error, is there another easy way to tune the internal oscillator? I have an old Fluke scopemeter so I was thinking to use this to calibrate.
Everybody writes many things difficult to understand without attaching a simple schema, also docs of TinyTuner has no schema, and examples use different pins each other, I'm a bit confused.   smiley-sad
Logged

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 29
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Out of 20 - 30 ATtiny84's I've never had to use TinyTuner to get SoftwareSerial to work correctly.

What clocking and baud rate are you using?
What kind of serial test are you trying?

Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1057
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Now I'm struggling with the Tiny Tuner, probably I've missed a library, I've tried to use the example:
- Interactive with NewsoftSerial
but it gives me some compilation error,

Please post the errors you get.
You should have your tiny's running at 8MHz, when you are using  SoftwareSerial .

Select board -> Attiny85@8MHZ
Select ->Tools->Programmer->YourProgrammer
select ->Tools->Burn Bootloader


Quote
Everybody writes many things difficult to understand without attaching a simple schema, also docs of TinyTuner has no schema

If you open the sketch Interactive_to_Serial_with_Details you will find a detailed description of how to make the connections for both ATtiny85 and ATtiny84,

Quote
Out of 20 - 30 ATtiny84's I've never had to use TinyTuner to get SoftwareSerial to work correctly.

Me neither, but there has been quite many posts about others having trouble, so maybe we have just been lucky ?

Quote
I have an old Fluke scopemeter

If it can measure frequence, you can use the sketch below. It outputs 1MHz on pin PB0, if your
tiny is running @8MHz

You connect a potmeter with the wiper to pin PB4. Then turn the potmeter until your meter show 1 MHz.
You can then use the OSCCAL value in the setup like this:

Code:
void setup(){
  OSCCAL = 0x9F;  //example value
}

void loop(){
}


« Last Edit: June 10, 2013, 05:33:14 am by Erni » Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5351
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If it can measure frequence, you can use the sketch below. It outputs 1MHz on pin PB0, if your
tiny is running @8MHz

You connect a potmeter with the wiper to pin PB4. Then turn the potmeter until your meter show 1 MHz.
You can then use the OSCCAL value in the setup like this:

Just do this:

Code:
void setup()
{
  delay(2000);
  Serial.begin(57600);   // Or even 115200...
  for (int i=0; i<256; ++i) {
    OSCCAL  = i;
    delay(1);
    Serial.println();
    serial.print("This was printed with OSCCAL=");
    serial.print(i);
  }
}
void loop()
{
}

Pick a value in the middle of the range that displays something legible.
« Last Edit: June 10, 2013, 06:07:32 am by fungus » Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

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

Hello all,

I've succedeed in using the sketch   Interactive_to_Serial_with_Details  and I've get the following parameters for the two chip I have:

attiny 85 OSCCAL = 0x59
attiny 84 OSCCAL = 0xAD

So step by step I'm arriving to the final work, but I have still some questions:

- only the ports mentioned in Interactive_to_Serial_with_Details sketch could be used or can I use different ports?
- if I have to add the OSCCAL = 0xAD to a sketch which are the needed includes?
- what command to use to get data from serial port, will this work?

        Serial.begin(9600);
  or
        RFID.begin(9600)

     while(i == 0)
       {
         if(RFID.available())
           {
             char c=RFID.read();
             Serial.print(c);
             i=1;
           }
       }

In the end I will post every details and schemas of the success, I hope  smiley

Regards, Simone
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1057
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
- only the ports mentioned in Interactive_to_Serial_with_Details sketch could be used or can I use different ports?

If you mean pin numbers, they can be changed - but why?

Quote
- if I have to add the OSCCAL = 0xAD to a sketch which are the needed includes?

In Setup() , see the example below

Quote
- what command to use to get data from serial port

In this example pin 4 is the receiving pin, and pin 3 the transmitting pin

Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(4, 3); // RX, TX

void setup()  
{
  OSCCAL = 0x59; //ATiny85
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop()
{
  if (mySerial.available()){
    mySerial.println(mySerial.read());
  }
}
« Last Edit: June 27, 2013, 02:07:13 pm by Erni » Logged

Pages: [1]   Go Up
Jump to: