Arduino Tiny

I would ask a question.
I'm having a strange behaviour using a Tiny84. I've built a circuit prototype on a breadboard using 2 gas sensors, an MQ-4 and an MQ-7.
Using those sensors with an Arduino UNO I get correct readings from them (checked on the serial monitor).

So I decided to build a circuit around a Tiny84. To check if the readings are correct I use NewSoftSerial to send the values to Arduino UNO and then I read them from the serial monitor.
I've noticed that only the first analog read is correct, the second one seems to be influenced by the previous one.
I mean that if I read the first sensor I get, i.e., 274. On the 2nd I get 188. If I connect the 1st sensor to 5V, I get 1023 but on the 2nd one I get ~850. If I connect the 1st to GND I read 0, on the 2nd one I read around 188. Using an Arduino everything is correct and the analog pins connected to the sensors work indipendently.

It seems that I cannot do 2 readings in sequence. Is this normal for the Tinys or is there something in the Core libs?

It is entirely possible that you have encountered a bug in the Tiny Core. While I tried very hard to thoroughly test it, I have been known to occasionally make a mistake. :wink:

I can say that the 0.1 uF capacitor across VCC and GND is critical. In my testing, without the capacitor, analog read values on ATtiny processors are erratic.

Are you using the core from here...
http://hlt.media.mit.edu/?p=1229

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

Are you using AREF?

Have you tried a different pair of analog inputs?

Have you tried performing three reads from the same input to see if the read value approaches the expected value?

Let's start.... :wink:

Only One doesn't make errors, and He does not reside on this planet XD

I can say that the 0.1 uF capacitor across VCC and GND is critical. In my testing, without the capacitor, analog read values on ATtiny processors are erratic.

I always use a 0.1 uF cap between Vcc and Gnd of every micro I use for decoupling.

Are you using the core from here...
http://hlt.media.mit.edu/?p=1229

Or here...
Google Code Archive - Long-term storage for Google Code Project Hosting.

From Google Code.

Are you using AREF?

No. I don't.

Have you tried a different pair of analog inputs?

No. I don't. Nor I've tried a different chip.

Have you tried performing three reads from the same input to see if the read value approaches the expected value?

I use to read the same analog bin about 10-20 times, with a 1 ms delay from each other, and then return the last reading, to let the S&H charge correctly. After I read the first pin my sketch waits for about 50 ms then it starts reading the second one using the same routine.
But I've also tried to read the pin only 1 or 2 times but nothing have changed.

This afternoon I'll try to:

  1. use a different pair of pins
  2. use a different Tiny84

An update.
I've tried a different Tiny and a different couple of pins and it worked.
So I mounted back the first Tiny84 and used a different couple of pins and it worked.

I discovered that I used A0/A1 pins and then A1/A2 pins.
But looking at the datasheet I've found that A0 is also the AREF pin... so it seems that you cannot use the AREF pin as a normal analog input, am I right?

Thank you for testing and for the follow-up.

so it seems that you cannot use the AREF pin as a normal analog input, am I right?

It should work. The datasheet indicates that, when REFS1 REFS0 = 0 0, the AREF pin is free to use as we please. I believe I tested it but it's been many months so I could easily be wrong.

You are not calling analogReference, correct?

Please print the value of ADMUX right after calling analogRead(0) (e.g. Serial.println(ADMUX,HEX);). You do not need to have anything connected to A0.

After calling analogRead(0), is there a stable voltage on the AREF pin?

No, I didn't.

Please print the value of ADMUX right after calling analogRead(0) (e.g. Serial.println(ADMUX,HEX);). You do not need to have anything connected to A0.

0
0
0
0
etc...

After calling analogRead(0), is there a stable voltage on the AREF pin?

4V64

Thanks again for taking the time to run these tests.

Are you calling pinMode or digitalWrite? Maybe there is a pin-mapping bug and A0 is getting turned into an output. Or the internal pull-up is being enabled.

After calling analogRead(0), is there a stable voltage on the AREF pin? 4V64

Does connecting a pull-down resistor to A0 change the voltage?

I'm running out of ideas. Will using A1 and A2 cause any problems?

I'M SO SORRY.... =(
I wasted your time searching non-existing bugs... :roll_eyes:

I didn't notice that I was using A0/D10 as the RX pin for NewSoftSerial..... SORRY.
Deleting it, everything has started to work perfectly!
I was using the serial to debug my sketch and my circuit... Me stupid... :blush:

No need to apologize. We now have documented proof that A0 works. As far as I'm concerned, it was worth the time.

Just another question.

Do you think to support the Tiny861 into your Tiny core in the future?
It should be an interesting micro to work with.

I agree. The 861 is an interesting processor. It seems to be fourth on the "popularity" list: 85 (and 13), 84, 2313, then the 861.

I have one here for testing. I even let it out of its cage about two weeks ago.

At some point, I will add support for it. Unfortunately, too many things keep getting in the way.

Hello,

Thanks again to Coding Badly for work on Tiny.

I have an application I am working on making use of 16 bit Timer1 with interrupts.

If I do not plan to use mills/delay in my app, is it possible for me to disable Timer0 within core, or would the be major surgery?

George

Hi

I have designed a breakout for the Attiny2313, Attiny85 and Attiny84. Please have a look here http://arduino.cc/forum/index.php/topic,82083.0.html for more info.

Hope it can be useful to some people.

Thanks

Just a question.

Atmel has released new versions of ATtinyx4 marked "A" (ATtiny24A/44A/84A) that, it seems, should differ from the previous ones for the adoption of the PicoPower core.

Does the Tiny core support them? Or do you have in mind to add the support for them shortly?

A question about PWM.
Is it me or it isn't possible to use more that 1 PWM signal?

I would like to fade an RGB LED using PWM signals on digital pins 2-3-4 using analogWrite but I'm having strange results. It seems that 3 PWM signals cannot be used together: only the last one appears to work.

Is it a limit of the Tiny core or a limit of the micro itself?

MGeo:
Thanks again to Coding Badly for work on Tiny.

You are welcome.

If I do not plan to use mills/delay in my app, is it possible for me to disable Timer0 within core, or would the be major surgery?

Should not be too difficult. The code in question starts here...
http://code.google.com/p/arduino-tiny/source/browse/trunk/hardware/tiny/cores/tiny/wiring.c

Put a conditional compile around or comment out everything in init (bottom of the file) that starts with "MillisTimer_".

leo72:
Atmel has released new versions of ATtinyx4 marked "A" (ATtiny24A/44A/84A) that, it seems, should differ from the previous ones for the adoption of the PicoPower core.

Does the Tiny core support them? Or do you have in mind to add the support for them shortly?

In core_build_options.h ...
http://code.google.com/p/arduino-tiny/source/browse/trunk/hardware/tiny/cores/tiny/core_build_options.h#63
...there is a section for the X4 family. You may have to add something like this; current code...

#if defined( AVR_ATtiny24 ) || defined( AVR_ATtiny44 ) || defined( AVR_ATtiny84 )
#define AVR_ATtinyX4
#endif

...potential new code...

#if defined( AVR_ATtiny24 ) || defined( AVR_ATtiny44 ) || defined( AVR_ATtiny84 ) || defined( AVR_ATtiny24A ) || defined( AVR_ATtiny44A ) || defined( AVR_ATtiny84A )
#define AVR_ATtinyX4
#endif

You may also have to update boards.txt; current entry...

attiny84at16.build.mcu=attiny84

...potential new entry...

attiny84at16.build.mcu=attiny84a

But I doubt any of those changes are necessary. In any case, please report back with what you find.

leo72:
Is it me or it isn't possible to use more that 1 PWM signal?

In my testing, all available PWM channels worked correctly.

Is it a limit of the Tiny core or a limit of the micro itself?

Should not be a problem with either.

Which processor?

I'm trying to fade an RGB LED using an Attiny84@8 MHz.
Connet an RGB LED to phisical pins 5-6-7 (digital pins 2-3-4) and try this code:

const byte RED=4;
const byte BLUE=3;
const byte GREEN=2;

void setup() {
    pinMode(RED, OUTPUT);
    pinMode(BLUE, OUTPUT);
    pinMode(GREEN, OUTPUT);
}

void loop() {
    for (byte i=0; i<255; i++) {
        analogWrite(RED, i);
        analogWrite(BLUE, i);
        analogWrite(GREEN, i);
        delay(10);
    }
}

You'll see that only the red signal fades; the other 2 stay off.

Huh. How strange. Does digital 5 (physical 8, PA5) work?