Arduino Forum

Using Arduino => Microcontrollers => Topic started by: Spyrakos88 on Feb 26, 2014, 01:09 pm

Title: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 26, 2014, 01:09 pm
Hello! I have an attiny85. I have flashed it with blink and is working well.

The problem is with serial. I burned the bootloader to use serial with no errors. I have tryied differnent cores with differents ide's with no success. I still getting junk letters from the serial . I used arduino duemilanove as isp . Is it possible the chip has failed and only serial doesnt work?

I also removed the atmega from arduino and replaced the capacitor with a jumper wire.Thanks
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: cjdelphi on Feb 26, 2014, 01:19 pm
There are no hardware serial ports.

Use softwareSerial over 3v  (5v)
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 26, 2014, 02:01 pm
Thanks for the reply!! Do you mean to power the attiny with 3 volts?
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: cjdelphi on Feb 26, 2014, 02:12 pm
Under 3.3v softwareSerial acts up (when powering the attiny85)
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 26, 2014, 03:47 pm
Thanks! The attiny was powered with 5 volts :( but i can't check it right now if it is working with 3.3 volts. I think that if i use the arduino 3.3v output i can get some readable data from serial. I will reply in about 4 hours..
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Erni on Feb 26, 2014, 03:47 pm
If you use this core:

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

there are several options for serial output.

A simple example below.
The serial output will be pin PB3. Connect a serial/USB converter to that pin.

This might be of interest:

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

Code: [Select]
void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println("Testing..");
}

Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 26, 2014, 07:08 pm
I just tested with 3.3 volts from arduino duemilanove and i get the same junk letters...with this code for example which uses the previous core i get this "ðððððððúððððððððûðððððððððððððððøððúððððððøððúððððððððð" in straight line.

Is there any problem that windows isn't in english language? I think i have tryied everything...
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Erni on Feb 26, 2014, 07:37 pm
How are you connecting the tiny to your Arduino.

Why are you powering the tiny with 3.3V
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 26, 2014, 08:49 pm
Hello my friend here is the tutorial that i used.http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/

I succesfully flashed it with blink sketch but with serial... no luck!

I powered with 3.3volts because today i learned that serial working only under this voltage. But with both voltages i keep reaciving
these letters.

Now im thinking if the problem is the chip itself or the duemilanove...

I accept any help thanks
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Erni on Feb 26, 2014, 09:03 pm
Quote
I powered with 3.3volts because today i learned that serial working only under this voltage.


That proves that you should not trust everything you read, it is nonsens.

I don't know the core you are using, as I said in previous post I am using this one:

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

Quote
is there any problem that windows isn't in english language? I think i have tryied everything...


No mine windows is danish, and that dosn't give me any trouble.

Are you using SoftWareSerial for communication ?

Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: (deleted) on Feb 26, 2014, 09:23 pm
(deleted)
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 26, 2014, 09:44 pm
Are you sure about that? I left that as a final solution (before i throw it to the garbage)because it has a lot of reading. So there are attinys that are ok and some others that need this "calibration"?? Bad luck then...
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: (deleted) on Feb 26, 2014, 09:50 pm
(deleted)
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 26, 2014, 10:03 pm
Thanks my friend. I cant check it right now because i need to read several things about that (im using attiny for first time) and i will reply asap.  I found pour man's tiny tuner. Is that the way to go or you have a better-faster way?
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: (deleted) on Feb 26, 2014, 10:05 pm
(deleted)
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: cjdelphi on Feb 26, 2014, 11:25 pm

I just tested with 3.3 volts from arduino duemilanove and i get the same junk letters...with this code for example which uses the previous core i get this "ðððððððúððððððððûðððððððððððððððøððúððððððøððúððððððððð" in straight line.

Is there any problem that windows isn't in english language? I think i have tryied everything...


You need 5v...... 3v is no good for softserial!
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: cjdelphi on Feb 26, 2014, 11:31 pm
People read my post and read something I never said, I was making sure you used 5v! And not 2aa batteries ...

Then
a. You switch to 3v?.
B. What I typed was " nonsense "


I was trying to help you by making sure you used 5v
.

Fair enough if you're a non english speaker... but what's the excuse for the rest who posted!
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 27, 2014, 10:43 am
Ok here is the results with tiny tuner. I upload the sketch "Interactive_to_Serial_with_Details"

here is the instructions from the sketch

ATtiny85 Instructions...
 
 - Note: This Sketch is too large to fit on the ATtiny45 processor.  Use the
   Interactive_to_Serial example instead.
   
 - Select the correct board / serial port
 
 - Upload this Sketch to the processor
 
 - Connect PB3 / Pin 3 to receive on the serial converter
 
 - Connect PB4 / Pin 4 to transmit on the serial converter
 
 - Start your favorite terminal program, open the correct serial port, change
   the baud rate to 9600
   
 - Reset the processor.  A welcome message should be displayed.
 
 - Continue sending single 'x' characters (no carriage-return; no line-feed)
   until the calibration finishes

All good until i reset the processor. When i reset i receive nothing but junk letters no welcome message.. i send  the "x" characters the rx led is blinking when i send them but i still receiving this.

I think that the attiny i bought is crap.

Edit: I see that we can use external crystals with attiny85 which are extremely cheap. I think i will try them thanks.

Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Paul__B on Feb 27, 2014, 11:02 am

I think that the ATtiny I bought is crap.


Whilst that is always possible, the general feeling here is that nearly all faults are the result of just not getting everything quite right.  (Digital chips mostly work, or do not work.)  The problem is figuring out just what it is that is not quite right.

May I suggest you write a sketch to toggle a LED every ten seconds, and run it for a minute or two to see just how far out of step it gets over that period.  This will demonstrate the success - or otherwise of the calibration.  I do not quite understand what the calibration process does, so it may be necessary to add code to the sketch (and indeed any sketch) to implement the actual calibration.
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 27, 2014, 08:20 pm
I just did what you said! The results...

The chip is not crap.. It needs tune for sure... I updated the blink example and instead of 1 second (1000ms) delays 10 seconds!!!It is tuned one zero ahead!! I need to learn how i can tune this thing...
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: fungus on Feb 27, 2014, 08:29 pm

I think that the attiny i bought is crap.


The internal oscillator isn't guaranteed to be accurate. It says so in the datasheet.

Worse: It *is* guaranteed to vary with voltage and temperature.

Even if you set it up 'perfectly', it might work on hot days but not on cold days. If you run off batteries it will vary as the battery drains, etc.

Do a search for "software serial doesn't work" on this forum. See how many millions of messages there are. Ask yourself why.

Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Coding Badly on Feb 27, 2014, 11:41 pm
I do not quite understand what the calibration process does...


Measure the time (in CPU cycles) of a single 'x' character sent at 9600 baud.  If the processor is running fast, the time measured is too big.  If the processor is running slow, the time measured is too small.  After each character OSCCAL is adjusted to bring the measured time closer to the wall-clock time (actually, the serial converter's time but we assume it is accurate / matches a wall-clock).  The end result is a tuned processor with the corresponding OSCCAL value sent to the serial terminal.

Quote
...so it may be necessary to add code to the sketch (and indeed any sketch) to implement the actual calibration.


It is.  The OSCCAL value is not sticky.  It has to be set at run-time.  The top of setup should be this...
Code: [Select]
void setup( void )
{
  OSCCAL = 0x63;

...where 0x63 is the value from Tiny Tuner.
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Coding Badly on Feb 27, 2014, 11:45 pm
Even if you set it up 'perfectly', it might work on hot days but not on cold days. If you run off batteries it will vary as the battery drains, etc.


I don't think that's correct.  I recall serial communications should be reliable over the entire envelope.  I'll check later today if I remember.
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: fungus on Feb 28, 2014, 11:01 am

Even if you set it up 'perfectly', it might work on hot days but not on cold days. If you run off batteries it will vary as the battery drains, etc.


I don't think that's correct.  I recall serial communications should be reliable over the entire envelope.  I'll check later today if I remember.



That's going to depend on your baud rate. You *could* tune it to a particular baud rate I suppose...

The point is that SoftwareSerial is still hit/miss after many years of development.

A better solution is needed (IMHO). People only ever want SoftwareSerial  to print stuff in the serial console and there has to be a better way to achieve that than SoftwareSerial (ie. try to emulate the timing of signals designed by a telephone engineer in the 1960s).

eg. signals that are based on an 8MHz frequency, or signals that measure the pulses starting at the rising edge of each bit not some time in the past...

Either that or drop the baud rate down to something that's foolproof. 1200 baud if necessary.

Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Paul__B on Feb 28, 2014, 12:37 pm

That's going to depend on your baud rate. You *could* tune it to a particular baud rate I suppose...



Either that or drop the baud rate down to something that's foolproof. 1200 baud if necessary.


This seems to be a common "urban" mythology.  Since we are talking of proportional variations, the actual baudrate is irrelevant.  If 10% error at 57.6 kbaud causes problems, 10% error at 1200 will cause just the same problems.

The only reason a lower baudrate will work more reliably is where there is an error caused by the divisor used to derive the baud clock from the current crystal frequency, and in that situation, it is possible to use OSCCAL to deliberately move the clock frequency to better suit the divisor.
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Erni on Feb 28, 2014, 02:57 pm
I did an experiment with SoftwareSerial

ATtiny85V - 10 @ 8MHz
10 kOHM resistor from reset to VCC
0.1 uF from VCC to grnd

Tuned at 21 degree Celcius, and 5V (USB power)
Test sketch below:
Serial @ 9600

I started it at 21 degree and then put it in my frezer at -18 degree for half an hour.
Result: nothing - no garbled text it just continued to write flawlessly.

Then I stuck it on a room heater for another half hour at 30 degree, and it just kept on without failure

Lastly I borrowed my wife's hairdryer,the temperature now +50 degree and still no errors.

Next step was to try to lower VCC

At 1.9V the text began to be garbled
Under 1.8V it stopped and resat
At 2V No problems at all.

So not bad, atleast it is good enough for me.
I can only guess that the problems with SoftwareSerial that is reported is because of lack of tuning.

Code: [Select]
#include <SoftwareSerial.h>

SoftwareSerial mySerial(3,4 ); //rx=3,tx=4 setup of software serial
unsigned int x=0;

void setup() {
  OSCCAL = 0x68; 
  mySerial.begin(9600);
  x=0;
}

void loop() {
  x++;

  mySerial.print("Test= "); 
  mySerial.println(x);
  delay(500);
}
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: fungus on Feb 28, 2014, 04:39 pm

If 10% error at 57.6 kbaud causes problems, 10% error at 1200 will cause just the same problems.


Sure ... if your serial implementation is bone-headed enough to only change the master clock frequency instead of tuning the number of "cycles-per-bit".

Changeing cycles-per-bit at 1200 baud could give you very fine tuning.
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: fungus on Feb 28, 2014, 04:43 pm

So not bad, atleast it is good enough for me.


Did you measure the difference it made? eg. Flash a LED at a fixed interval and time it.


I can only guess that the problems with SoftwareSerial that is reported is because of lack of tuning.


No, the problems with SoftwareSerial are:
a) Tuning is very difficult
b) It's a stupid way to solve the problem of "printing some text for debugging".

(surely you see the madness of trying to use a protocol that requires precise timing on a chip that has no precise clock source...)
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: fungus on Feb 28, 2014, 06:33 pm

Tuned at 21 degree Celcius, and 5V (USB power)


Hate to bring some real engineering practice into it but the datasheet has a whole section dedicated to internal oscillator accuracy (section 22.9 "Internal Oscillator Speed")

Variation is about 5% between 3V and 5V Vcc  (eg. when powered with 3xAA batteries).

Variation is about 5% for every 20 degrees difference in temperature (a difference easily possible from summer to winter).

5% variation is enough to make it fail.
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Coding Badly on Feb 28, 2014, 07:50 pm
The only reason a lower baudrate will work more reliably is where there is an error caused by the divisor used to derive the baud clock from the current crystal frequency, and in that situation, it is possible to use OSCCAL to deliberately move the clock frequency to better suit the divisor.


And longer cables (more capacitance) where the rise-fall times are "long".
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Coding Badly on Feb 28, 2014, 08:04 pm
Hate to bring some real engineering practice into it...


Going to have to do the same to you @fungus.

Quote
Variation is about 5% between 3V and 5V Vcc  (eg. when powered with 3xAA batteries).
Variation is about 5% for every 20 degrees difference in temperature (a difference easily possible from summer to winter).


For the entire envelope I get a total a variance of 5.3125%.  Centered at 8 MHz, the variance is +1.5625% / -3.75%.

Quote
5% variation is enough to make it fail.


That's 1/2 bit error which a modern hardware receiver easily deals with by sampling an odd number of quanta greater than one and tweaking the clock.

A modern UART should have little to no trouble receiving data over the entire temperature / voltage range.
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Coding Badly on Feb 28, 2014, 08:05 pm
I did an experiment with SoftwareSerial


Thank you for doing that and reporting back the results.
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Spyrakos88 on Feb 28, 2014, 08:20 pm
Hi again.  I would like to say that i want to enable serial because i want to connect a bluetooth module.

After a lot of research i found that:http://forum.arduino.cc/index.php?topic=183180.0 this guy managed to succesfully tune an attiny2313A. I will try to do what he did but i have several questions about the procedure. I cant find a step by step guide to tune this thing and this is an advance procedure.

How can i learn what is the right value for my attiny that will be compared from the tuner? Is this a fuse that i try to tune? If i tune it will post here.

Another option is to use avrdude to disable the internal oscilator and use an external 16mhz...
Title: Re: [ATTINY85]Nothing but junk appears on my serial monitor... :(
Post by: Coding Badly on Feb 28, 2014, 08:56 pm
How can i learn what is the right value for my attiny that will be compared from the tuner?


If you were getting output here...
http://forum.arduino.cc/index.php?topic=221482.msg1610819#msg1610819
...then you already have the right value.

Quote
Is this a fuse that i try to tune?


No.  It is a one byte value that you assign to the OSCCAL register in setup.