Pages: 1 2 [3] 4 5 ... 22   Go Down
Author Topic: Arduino Tiny  (Read 49755 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Very nice!  Thank you for the follow-up.
Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 221
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there any particular reason that the core files for the attiny85 would object to my using a 10mhz external resonator?
The sketch in question doesn't use delay at all, and millis is only used for button debouncing, easy enough to change the numbers to make things work right.

I need (ok, want) two 20khz or so PWM outputs (independant of each other, so using the two PWM registers to count only to 200 wouldn't work as it disables the second PWM pin), setting the prescaler to full blast at 8mhz gives me 15khz or so, 10.5mhz would give me 20khz on the PWM in theory.  It looks like it might be possible to user OCCAL (i think that's it, the calibration register) to wind the clock up that high, though at the sacrifice of EEPROM and flash writability in-sketch.

Anyway, I want to double check that the core files won't flip out or something!


Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there any particular reason that the core files for the attiny85 would object to my using a 10mhz external resonator?

Let's start with the big item... There is not an entry in "boards.txt" for 10 MHz.  You will need to clone the...

attiny85at16.name=ATtiny85 @ 16 MHz  (external crystal; 4.3 V BOD)

...section and then change...

• The entry prefix "attiny85at16" to something appropriate like "attiny85at10".  Be sure to change all the entries for the new section.

• The ".name" entry to something like "ATtiny85 @ 10 MHz (Bobnova)"

• The F_CPU option ".build.f_cpu=16000000L" to ".build.f_cpu=10000000L"

• Any other fuses (like BOD) for your application.  The clock fuses are already correct.

Quote
The sketch in question doesn't use delay at all, and millis is only used for button debouncing,

That's good because millis / micros will not longer be accurate.  The count will be a bit lower than it should be.  Probably about 1%.

Quote
easy enough to change the numbers to make things work right.

I doubt millis will be that different that you'll notice for button debouncing.

Quote
I need (ok, want) two 20khz or so PWM outputs (independant of each other, so using the two PWM registers to count only to 200 wouldn't work as it disables the second PWM pin), setting the prescaler to full blast at 8mhz gives me 15khz or so, 10.5mhz would give me 20khz on the PWM in theory.  

If you're willing to learn about a new type of timer, timer 1 may give you what you need without resorting to a 10 MHz clock speed.  Timer 1 was built for high-speed PWM.

If you decide experiment with timer 1...

• Locate and open the "core_build_options.h" header file

• Change the INITIALIZE_SECONDARY_TIMERS #define to be "0" (without the quotes)

• In the ATtiny85 section, change the TIMER_TO_USE_FOR_MILLIS #define to be "0" (without the quotes)

• Timer 1 is now free to use as you please


Quote
It looks like it might be possible to user OCCAL (i think that's it, the calibration register) to wind the clock up that high, though at the sacrifice of EEPROM and flash writability in-sketch.

Why do you think the EEPROM would be effected by adjusting OSCCAL?
« Last Edit: May 25, 2011, 04:19:23 pm by Coding Badly » Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 221
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm definitely down for playing with the high speed timer if that can get me 20-25khz pwm on two pins (and separate duty cycles on the two pins), I've been trying to convince the 328 to do it, but I'm missing something.
Thanks for the specifics on that.  Now I have something to play with while I wait for a couple $0.50 10mhz oscillators to show up (I need to make a digikey order anyway).  1% on the millis/delay/etc. isn't bad at all, I doubt that'd screw me up even if I were doing something beyond debouncing input buttons.

On OSCCAL:  It's not so much that adjusting it can cause issues as it is that trying to crank the CPU clock way up using it can cause issues.  The OSCCAL datasheet page says that using OSCCAL to get >8.8mhz operation isn't recommended as it doesn't give the EEPROM enough time to write correctly in some cases.  If it's like most things they probably mean it'll drop one write in a thousand or some such thing.

Editing the boards.txt sounds easy enough, thanks for the specific  instructions, that'll make my life easier!

Also, a general thank you!  for creating the port in the first place and jumping in to help us with odd stuff like this.  It's appreciated!
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm definitely down for playing with the high speed timer

Excellent!

Quote
if that can get me 20-25khz pwm on two pins (and separate duty cycles on the two pins),

Timer 1 is very PWM versatile so i'd be very surprised if you could not get what you want.

Quote
I've been trying to convince the 328 to do it, but I'm missing something.

Timer 1 will do it.  I think you need to use "mode 14".  Search for a topic about 10 KHz PWM and "Coding Badly" and "ICR1".  I vaguely recall helping two people so there may be two topics.

Quote
Thanks for the specifics on that.  Now I have something to play with while I wait for a couple $0.50 10mhz oscillators to show up (I need to make a digikey order anyway). 

If you do play with the 85 / timer 1, please follow-up with your experience.  I've wanted to play with the various esoteric ATtiny timers.  They are definitely interesting critters.  I'd really like to here about your experience with it.

Quote
The OSCCAL datasheet page says that using OSCCAL to get >8.8mhz operation isn't recommended as it doesn't give the EEPROM enough time to write correctly in some cases

Got it.  Thanks.

Quote
Also, a general thank you!  for creating the port in the first place and jumping in to help us with odd stuff like this.  It's appreciated!

You are welcome!
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3510
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd have downloaded Arduino Tiny sooner had I known it was so easy to install and use! Is there any reason not to use

Code:
attiny85at1.upload.using=arduino:usbtinyisp

in the boards.txt file? I tried it, and it seems to work just fine, but I thought I'd ask...
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Arduino Tiny ... so easy to install and use!

I agree!

Quote
Is there any reason not to use...

The "arduino:" part tells the IDE to use the common / shared /IDE "programmers.txt" file.  So, no problem at all.
Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 221
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found the thread you were talking about, it looks like if I can make it work in the tiny (the thread was about a 168 or 328) I can have pretty much any PWM speed I want!  The key is that there is another different register that the TOP count value can be compared to, one that isn't the duty cycle register for the other PWM output.
I'm hoping the tiny85 can do it also, that'd be perfect!

Haven't had a chance to play with it, I did get the prototype fan controller perfboarded though.  Might have some time this weekend.
Whenever I do get a chance I will definitely report in with what I find!
Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 221
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you're willing to learn about a new type of timer, timer 1 may give you what you need without resorting to a 10 MHz clock speed.  Timer 1 was built for high-speed PWM.

If you decide experiment with timer 1...

• Locate and open the "core_build_options.h" header file

• Change the INITIALIZE_SECONDARY_TIMERS #define to be "0" (without the quotes)

• In the ATtiny85 section, change the TIMER_TO_USE_FOR_MILLIS #define to be "0" (without the quotes)

• Timer 1 is now free to use as you please.
Did this, my PWM frequency doubled to 31.something khz, slightly higher than needed but not badly.
My millis are toooootally out to lunch, I get about the same debounceness with it set to 1500 millis as I used to with 30, so around 50 times as many millis per second, maybe 60ish.  This isn't really a problem, as that debounce routine is literally the only place I use millis, and delay isn't used at all.
It got rid of the whine in one of two fans tested so far, I call it a success!
(Oddly, millis behaves the same way regardless of whether I upload it with the board set to attiny85@8mhz or @1mhz, something weird there.  Doesn't make a difference to me, but it's strange)

EDIT:
I spent some time with OSCCAL, and got myself an absolutely perfect 25.5khz signal.  It's running the core at 6.5-6.6mhz, right around the ATTINY15 compatibility speed amusingly enough.
« Last Edit: May 30, 2011, 11:10:52 pm by Bobnova » Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My millis are toooootally out to lunch,

How strange.  I know I tested millis on timer 0.  I think I even started with millis on timer 0.  I must have failed a final check after some modification.

What did you end up using for the processor clock?  Internal 8 MHz?

I created an issue...
http://code.google.com/p/arduino-tiny/issues/detail?id=2

Quote
It got rid of the whine in one of two fans tested so far, I call it a success!

Excellent!

Quote
(Oddly, millis behaves the same way regardless of whether I upload it with the board set to attiny85@8mhz or @1mhz, something weird there.  Doesn't make a difference to me, but it's strange)

Do you mean without changing the fuse settings?  (Without performing a Burn Bootloader?)

Quote
EDIT: I spent some time with OSCCAL, and got myself an absolutely perfect 25.5khz signal.  It's running the core at 6.5-6.6mhz, right around the ATTINY15 compatibility speed amusingly enough.

All the benefits of an ATtiny15 without those painful limitations!
Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 221
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First a disclaimer, I'm on Ubuntu 11.4, I don't know if that changes things or not.


Fuses are (manually) set to 8mhz internal operation, using the burn-bootload function wouldn't change them for some reason.  I haven't gone back and tried again as I've been working on other issues.
Now I have a decent stack of attiny85s I'll start playing with a fresh one and see what happens at some point here.


Yes, selecting 1mhz and 8mhz without burning a bootloader or manually changing fuses and then re-uploading an identical sketch doesn't change the behavior of millis.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

First a disclaimer, I'm on Ubuntu 11.4, I don't know if that changes things or not.

It may.  There is problem with the AVR GCC compiler on Linux.  I vaguely recall that delay was effected but I don't remember any mention of millis.  You may want to spend a few minutes searching the forum.  If you do find the the culprit, please report back.  My suspicion is that it is a bug in the core.

Quote
Fuses are (manually) set to 8mhz internal operation, using the burn-bootload function wouldn't change them for some reason.  

Bummer.  I love being able to do that.  I switched a processor to 1 MHz just a few minutes ago.

Quote
Yes, selecting 1mhz and 8mhz without burning a bootloader or manually changing fuses and then re-uploading an identical sketch doesn't change the behavior of millis.

That is strange.  I suspect curiosity will get the better of me and I'll end up working on it over the weekend.  I'll let you know if I have any more questions.
Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 221
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll fire up windows7 and play with the bootoader and millis stuff sometime this weekend and report in.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Coding Badly,

Is there any documentation, example or post to point me to on using TinyDebugSerial?

If it matters, I will be using it with my Pololu USB Programmer as a serial monitor?

Thanks,
George
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there any documentation, example or post to point me to on using TinyDebugSerial?

TinyDebugSerial is a write-only software serial implementation.  It is meant to be a drop-in replacement for Serial.  No one has complained about it so I assume it really is a drop-in replacement.  So, any Arduino Serial examples should compile and run just as they do for other processors.

There is usage information here...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285218245/25#25

Some information about the ATtiny2313 processor and TinyDebugSerial here...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285218245/26#26

This is important for saving precious SRAM or if you plan to use a crystal on your Tiny processor...
http://arduino.cc/forum/index.php/topic,51984.msg370691.html#msg370691

Quote
If it matters, I will be using it with my Pololu USB Programmer as a serial monitor?

Nice!  You will be able to keep your terminal application running and connected while you upload!  I am a big fan of the Pololu USB Programmer!
Logged

Pages: 1 2 [3] 4 5 ... 22   Go Up
Jump to: