Arduino Forum

Using Arduino => Microcontrollers => Topic started by: Osgeld on Jun 08, 2012, 04:38 am

Title: What is the status of serial on a tiny85
Post by: Osgeld on Jun 08, 2012, 04:38 am
I have use for software serial on a ATTINY85 using arduino tiny, what is the status of serial communications? I started to design a board and thought I better check, using the 1.0 included lib results in issue 49 ... any work arounds? I just need to receive streams of characters

Thanks
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jun 08, 2012, 05:00 am

I have not tried it myself.  As far as I know, the solution is...
http://arduino.cc/forum/index.php/topic,58756.msg422560.html#msg422560
http://arduino.cc/forum/index.php/topic,51984.msg472041.html#msg472041
Title: Re: What is the status of serial on a tiny85
Post by: Osgeld on Jun 08, 2012, 05:47 am
cool, I will play around with it tomorrow and over the weekend (search was failing me)

at work they tore down quite a few old test carts that were in storage, our lab is now the proud owners of 7 boards containing 24, 60 volt, 3 amp SSR's each, and I would rather not use the old ISA machines they were attached to ... FTDI cable + tiny + 595's = happy
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jun 08, 2012, 06:27 am
cool, I will play around with it tomorrow and over the weekend (search was failing me)


Please report back with a thumbs-up or thumbs-down.

Quote
at work they tore down quite a few old test carts that were in storage, our lab is now the proud owners of 7 boards containing 24, 60 volt, 3 amp SSR's each,


60 volts?  What were they controlling?  Motors?

Quote
and I would rather not use the old ISA machines they were attached to ... FTDI cable + tiny + 595's = happy


If you use the internal oscillator, how have you been tuning (or do you)?
Title: Re: What is the status of serial on a tiny85
Post by: Osgeld on Jun 09, 2012, 01:37 am
Quote
Please report back with a thumbs-up or thumbs-down.


will do

Quote
60 volts?  What were they controlling?  Motors?


no light testers @ 13VDC, the current was the important part

Quote
If you use the internal oscillator, how have you been tuning (or do you)?


I havent been before
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jun 09, 2012, 03:04 am

If you decide to tune let me know.  I have something that should make the process painless.
Title: Re: What is the status of serial on a tiny85
Post by: Osgeld on Jun 11, 2012, 01:15 am
ok well the software serial included in 1.0...

Quote
formerly NewSoftSerial


does not contain the lines given in the link above, so I am going to get the older verion and see what happens
Title: Re: What is the status of serial on a tiny85
Post by: Osgeld on Jun 11, 2012, 01:34 am
here is what I am getting with the "new" software serial included in 1.0

Quote
In file included from Blink.cpp:1:0:
/usr/share/arduino/libraries/SoftwareSerial/SoftwareSerial.h:92:18: error: conflicting return type specified for 'virtual size_t SoftwareSerial::write(uint8_t)'
/usr/share/arduino/hardware/arduino/cores/tiny/Print.h:71:18: error:   overriding 'virtual void Print::write(uint8_t)'
Title: Re: What is the status of serial on a tiny85
Post by: Osgeld on Jun 12, 2012, 06:29 am
nothing I try seems to work, and I cant find a older version of new soft serial

crap  =(
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jun 12, 2012, 07:52 am

NewSoftwareSerial 10c from this post does not work?
http://arduino.cc/forum/index.php/topic,58756.msg422560.html#msg422560
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jun 12, 2012, 07:56 am
here is what I am getting with the "new" software serial included in 1.0 ...error: conflicting return type specified for 'virtual size_t SoftwareSerial::write(uint8_t)'


Several folks are complaining about that problem.  I'll try to get it knocked out this week.  The problem is that the Tiny Core still includes Print.* from 0022.  You may be able to drop in the two files from 1.0.  Wait, that probably won't work.
Title: Re: What is the status of serial on a tiny85
Post by: Osgeld on Jun 13, 2012, 02:18 am
it doesnt :)
Title: Re: What is the status of serial on a tiny85
Post by: Osgeld on Jun 17, 2012, 06:55 am
I used

http://hlt.media.mit.edu/?p=1695

and its quite crappy but I was able to get 2400 baud to work properly once tonight @8Mhz, maybe with a arduino tiny tuneup I can get it consistant, and maybe faster (though I am sending 3 whole bytes at a time speed isnt really an issue here)
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jun 17, 2012, 09:20 am

Perfect!  That is exactly what I needed to know.  I've been trying to set aside some time to run that exact test.  Thank you for posting!

I can now go back to mucking with the TIny Core.

Quote
maybe with a arduino tiny tuneup I can get it consistant, and maybe faster


If you want to test drive an experimental replacement let me know.
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jul 09, 2012, 09:48 am

Please give this a try...
http://arduino-tiny.googlecode.com/files/arduino-tiny-0100-0014.zip

Only support for the ATtiny85 family was added.  After a few folks have tested it, I will add support for the ATtiny84 family and the ATtiny2313 family.

If anyone reading this tests SoftwareSerial with the Tiny Core, please report back.
Title: Re: What is the status of serial on a tiny85
Post by: Erni on Jul 10, 2012, 01:31 pm
Success.
I tried with attiny85 at 8Mhz and it worked just fine.
I only tried with 4800, but will  test with higher baudrate.

my test sketch:

Code: [Select]


#include <SoftwareSerial.h>
const int rx=2;
const int tx=3;


SoftwareSerial mySerial(rx, tx);

int i=0;
char buf[10];

void setup()
{
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
   mySerial.begin(4800);
 
}

void loop()
{
  if (mySerial.available()>0){
   
    buf[i]= mySerial.read();
   
    if (int(buf[i])==13 || int(buf[i])==10 ){  //If Carriage return has been reached
 
        mySerial.println(buf);
       
      for(int x=0;x<=8;x++){
      buf[x]=' ';
      }
     i=0;  //start over again
   
    } //if enter
    i++;
    } //IF mySerial.available
   
}//LOOP
Title: Re: What is the status of serial on a tiny85
Post by: JohnO on Jul 10, 2012, 05:42 pm
Hi, I am keen to see this fix in the tiny84 currently I get the compile error:
~~~~
C:\Users\John\Documents\arduino\libraries\jeelib/Ports.h:325: error: conflicting return type specified for 'virtual void UartPlug::write(byte)'
C:\Dropbox\SKETCHES\hardware\tiny\cores\tiny/Print.h:73: error:   overriding 'virtual size_t Print::write(uint8_t)'
~~~~
Title: Re: What is the status of serial on a tiny85
Post by: Erni on Jul 10, 2012, 06:05 pm

In the first sketch I used the serial monitor as input.

Now I tried this sketch on my Uno, connected UNO tx->tiny rx
It works as it should, no garbled characters and at 9600 baud.

I use a CP2103 serial/USB converter from Ebay to test the output from the Tiny

Code: [Select]

int x=0;
char buffer[10];

void setup()
{
   Serial.begin(9600);

}

void loop()
{
  sprintf(buffer, "Test:%03d",x);
Serial.println(buffer);
  x++;
  delay(500);
}//LOOP
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jul 10, 2012, 07:59 pm
Hi, I am keen to see this fix in the tiny84 currently I get the compile error:


With the version in Reply #14 (http://arduino.cc/forum/index.php/topic,109081.msg853308.html#msg853308)?
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jul 10, 2012, 08:00 pm

@Erni: Thanks!
Title: Re: What is the status of serial on a tiny85
Post by: JohnO on Jul 10, 2012, 08:18 pm
With the version in Reply #14?

Hi, I tried the above version before posting. It doesn't appear to clear the issue for me.
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jul 10, 2012, 09:00 pm

Where did you get this file...
C:\Users\John\Documents\arduino\libraries\jeelib/Ports.h
Title: Re: What is the status of serial on a tiny85
Post by: JohnO on Jul 10, 2012, 09:10 pm
Hi,

This file is part of the jeelib library: https://github.com/jcw/jeelib/

Do you think the issue is in this library?
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jul 11, 2012, 06:55 am
Hi,

This file is part of the jeelib library: https://github.com/jcw/jeelib/
Do you think the issue is in this library?


You will have to use a previous version of the Tiny Core...
http://arduino-tiny.googlecode.com/files/arduino-tiny-0100-0013.zip
Title: Re: What is the status of serial on a tiny85
Post by: JohnO on Jul 11, 2012, 11:18 am
No joy yet I'm afraid:

In file included from TinyRF12_Demo.cpp:7:
C:\Users\John\Documents\arduino\libraries\SoftwareSerial/SoftwareSerial.h:92: error: conflicting return type specified for 'virtual size_t SoftwareSerial::write(uint8_t)'
C:\Dropbox\SKETCHES\hardware\tiny\cores\tiny/Print.h:71: error:   overriding 'virtual void Print::write(uint8_t)'

I replaced my tiny & tools directory with the ones in arduino-tiny-0100-0013.zip

Thank you for spending time on this.
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jul 11, 2012, 10:34 pm

Please post the sketch you are trying to compile.
Title: Re: What is the status of serial on a tiny85
Post by: JohnO on Jul 11, 2012, 11:15 pm
Here is the sketch.
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jul 12, 2012, 10:14 am

I hate to be a pain but in the long run it will be worth it...

• Remove the previous version of the Tiny Core (arduino-tiny-0100-0013.zip).

• Install the latest version of the Tiny Core...
http://arduino-tiny.googlecode.com/files/arduino-tiny-0100-0014.zip

• Navigate to the [font=Courier New]libraries/JeeLib[/font] directory

• Locate and open [font=Courier New]Ports.h[/font] in a text editor

• Towards the top of the file make this change...

Quote
[font=Courier New]// keep the ATtiny85 on the "old" conventions until arduino-tiny gets fixed
#if ARDUINO >= 100 // && !defined(__AVR_ATtiny84__) && !defined(__AVR_ATtiny85__) && !defined(__AVR_ATtiny44__) && !defined(__AVR_ATtiny45__)
#define WRITE_RESULT size_t
#else
#define WRITE_RESULT void
#endif[/font]


• Save and close [font=Courier New]Ports.h[/font]

• If the Arduino IDE was running, close it and restart it

• Try again to compile the sketch
Title: Re: What is the status of serial on a tiny85
Post by: JohnO on Jul 12, 2012, 02:33 pm
You are certainly not a pain! I have made the changes you recommended and you have indeed move the problem forward. I am now seeing:
C:\Users\John\Documents\arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':
C:\Users\John\Documents\arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:396: error: 'digitalPinToPCICR' was not declared in this scope
C:\Users\John\Documents\arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:398: error: 'digitalPinToPCICRbit' was not declared in this scope
C:\Users\John\Documents\arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:399: error: 'digitalPinToPCMSK' was not declared in this scope
C:\Users\John\Documents\arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:399: error: 'digitalPinToPCMSKbit' was not declared in this scope
C:\Users\John\Documents\arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':
C:\Users\John\Documents\arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:414: error: 'digitalPinToPCMSK' was not declared in this scope
C:\Users\John\Documents\arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:415: error: 'digitalPinToPCMSKbit' was not declared in this scope
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Jul 12, 2012, 08:03 pm

Do you have an ATtiny25, ATtiny45, or ATtiny85 board selected?
Title: Re: What is the status of serial on a tiny85
Post by: JohnO on Jul 12, 2012, 08:31 pm
Hi,

I have ATTiny84 selected.
Title: Re: What is the status of serial on a tiny85
Post by: JohnO on Jul 14, 2012, 11:49 am
A flash of light this morning suggested adding the following lines to cores\tiny\pins_arduino.h
~~~~
// Pinched from https://raw.github.com/mharizanov/TinySensor/master/NewSoftSerial_Attiny84/NewSoftSerial.cpp
#elif defined(__AVR_ATtiny84__)
#define digitalPinToPCICR(p)    (((p) >= 0 && (p) <= 10) ? (&GIMSK) : ((uint8_t *)NULL))
#define digitalPinToPCICRbit(p) (((p) <= 2) ? 5 : 4)
#define digitalPinToPCMSK(p)    (((p) <= 2) ? (&PCMSK1) : (((p) <= 10) ? (&PCMSK0) : ((uint8_t *)NULL)))
#define digitalPinToPCMSKbit(p) (((p) <= 2) ? (p) : (((p) - 10) * -1))
~~~~
to reveal a new challenge:
~~~~

c:/users/john/documents/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o: In function `__vector_default':
(.vectors+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_1' defined in .text.__vector_1 section in core.a(WInterrupts.c.o)
c:/users/john/documents/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o: In function `__vector_default':
(.vectors+0x16): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_11' defined in .text.__vector_11 section in core.a(wiring.c.o)
c:/users/john/documents/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x0): relocation truncated to fit: R_AVR_13_PCREL against symbol `main' defined in .text.main section in core.a(main.cpp.o)
c:/users/john/documents/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in c:/users/john/documents/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)
TinyRF12_Demo.cpp.o: In function `saveConfig':
C:\Users\John\AppData\Local\Temp\build2326828889045529077.tmp/TinyRF12_Demo.cpp:93: relocation truncated to fit: R_AVR_13_PCREL against symbol `Print::println(char const*)' defined in .text._ZN5Print7printlnEPKc section in core.a(Print.cpp.o)
TinyRF12_Demo.cpp.o: In function `showString':
C:\Users\John\AppData\Local\Temp\build2326828889045529077.tmp/TinyRF12_Demo.cpp:117: relocation truncated to fit: R_AVR_13_PCREL against symbol `Print::print(char, int)' defined in .text._ZN5Print5printEci section in core.a(Print.cpp.o)
C:\Users\John\AppData\Local\Temp\build2326828889045529077.tmp/TinyRF12_Demo.cpp:118: relocation truncated to fit: R_AVR_13_PCREL against symbol `Print::print(char, int)' defined in .text._ZN5Print5printEci section in core.a(Print.cpp.o)
TinyRF12_Demo.cpp.o: In function `showHelp':
C:\Users\John\AppData\Local\Temp\build2326828889045529077.tmp/TinyRF12_Demo.cpp:124: relocation truncated to fit: R_AVR_13_PCREL against symbol `Print::println(char const*)' defined in .text._ZN5Print7printlnEPKc section in core.a(Print.cpp.o)
C:\Users\John\AppData\Local\Temp\build2326828889045529077.tmp/TinyRF12_Demo.cpp:143: relocation truncated to fit: R_AVR_13_PCREL against symbol `Print::print(int, int)' defined in .text._ZN5Print5printEii section in core.a(Print.cpp.o)
C:\Users\John\AppData\Local\Temp\build2326828889045529077.tmp/TinyRF12_Demo.cpp:144: relocation truncated to fit: R_AVR_13_PCREL against symbol `Print::print(char const*)' defined in .text._ZN5Print5printEPKc section in core.a(Print.cpp.o)
C:\Users\John\AppData\Local\Temp\build2326828889045529077.tmp/TinyRF12_Demo.cpp:145: additional relocation overflows omitted from the output
~~~~
Title: Re: What is the status of serial on a tiny85
Post by: JohnO on Jul 14, 2012, 01:41 pm
Wow, I was pointed at:
~~~~
http://arduino.cc/forum/index.php?topic=91491.0
~~~~
and now it compiles. Further testing of the actual image is ahead.
Title: Re: What is the status of serial on a tiny85
Post by: Coding Badly on Aug 01, 2012, 10:02 am

The Tiny Core now works with SoftwareSerial (the one included with Arduino 1.0).  Sorry the update took so long.