Show Posts
Pages: 1 2 [3] 4 5 6
31  Forum 2005-2010 (read only) / Development / Re: radio frequency broadcasting on: January 11, 2007, 12:35:01 am
Good point, so yeah, 776 kHz is the ceiling. That would explain my problem with the AM radio.  Of course, it would be a square wave and not sine unless you ran it through some sort of filter.
32  Forum 2005-2010 (read only) / Development / Re: radio frequency broadcasting on: January 10, 2007, 08:15:33 pm
By successive approximation, I found that a for loop that only toggles a port pin can do 1,552,450 square waves per second, which is 3.1236 (hmm, similar to pi) times 497 KHz, the radio frequency CosineKitty picked up this signal on.  I tuned in 1550 on the dial of an AM radio and held it nearby but got nothing that changed when I reset the Atmega.
33  Forum 2005-2010 (read only) / Development / Re: radio frequency broadcasting on: January 10, 2007, 06:25:42 pm
All kinds of good ideas.  I ran an experiment with a new test algorithm that still uses longs but doesn't do anything inside the loop except toggle a digital output line.  I saved millis, went into a million-iteration loop, and then checked millis again, and had only used 644 of them.  That's a ceiling of 1.54 MHz for square waves, well within my desired range (and good enough for AM radio!).

Here's the code:

long millisAtStart=0;
long millisAtEnd=0;
long i=0;
 
 
#define BINARY(a,b,c,d,e,f,g,h) ((a)<<7|(b)<<6|(c)<<5|(d)<<4|(e)<<3|(f)<<2|(g)<<1|(h))

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

void loop()
{
    millisAtStart=millis();
    for(i=0; i<1000000; i++)
    {
      PORTD ^= BINARY(1,0,0,0,0,0,0,0);  
    }

     millisAtEnd=millis();
 
     Serial.print(millisAtStart);
     Serial.print(" ");
     Serial.print(millisAtEnd);    
     Serial.print(" ");
     Serial.print(millisAtEnd-millisAtStart);
     Serial.println();
}
34  Forum 2005-2010 (read only) / Development / Re: radio frequency broadcasting on: January 10, 2007, 03:41:28 pm
I'm not near my Arduino (acutally, it's an Olimex board with an Atmega168 in a ZIF) right now but I did try ints instead of longs and saw no performance increase.  Given that millis() looks to be expensive, I will rewrite the code when I get a chance, and have it do a skad of operations and check the millis() after it and divide by the time (instead of calling millis() several times for EVERY loop).  Thanks both of you for your help.

In the end I'll probably end up using a 555 timer for my 100 KHz application, since it won't actually need any configuration.  But my first thought had been "I'll bet I can get an Atmega8 to serve as a cheap, precise arbitrary square wave generator."
35  Forum 2005-2010 (read only) / Development / Re: programming atmega168 boot with parallel prog on: October 23, 2006, 11:15:04 pm
i had similar problems a few days ago with my custom parallel port gizmo.  double check the values of your resistors and the quality of your solders.  the fact that you don't have more errors means your thing is mostly working but you might have a short or something.

are you saying  - and this isn't clear - that this same parallel port thing you made was successful a programming an atmega8 but now fails with an atmega168?
36  Forum 2005-2010 (read only) / Development / Re: Ok, on to Atmega32 on: December 03, 2006, 06:46:45 pm
Actually, a lot more i/o.  and double the flash of the atmega168 and quadruple the atmega8.   Anything with half the storage of my old commodore 64 should be able to do a lot of fun stuff.  Still, at this point in Moore's Law I don't know why Atmel can't make a processor with a megabyte of storage that fits in the Atmega8 footprint.  Imagine what that could do!
37  Forum 2005-2010 (read only) / Development / Ok, on to Atmega32 on: October 21, 2006, 10:16:56 pm
Ok, I feel like I really know the Atmega168 now, so now I'm just pushing dev like the kind of project manager we have all hated at some point during our careers. Shoot me if this is going too far.  I have an Atmega32. This thing rocks, hardware-wise.  If Arduino can go  here, at least in the software world, there is no end to what it can do. I see that the Arduino Atmega168 bootloader supports it.  The question is:  what are we going to need to add to the Arduino IDE to support it?  I want an item in the dropdown.  I just tried burning the Atmega168-compatible software to an Atmega32 in an Olimex AVR-P40-USB board and, well, nothing much happened when I then tried to upload an Arduino sketch.  Perhaps someone can shine a light on the differences between an Atmega168 and an Atmega32 and how that applies to the dropdown in the Arduino IDE.  
38  Forum 2005-2010 (read only) / Development / Re: Atmega328P bootloader. etc. on: March 13, 2009, 10:15:20 pm
hmm, well i think you're right nkcelectronics because i have tried several bootloader/sketch upload  cycles, and i can reliably get the sketch to upload precisely once, immediately after uploading a new bootloader.  you've seen the fuses i tried setting. looking around, i've also found the following fuse settings on http://wolfpaulus.com/journal/embedded/arduino4.html:


UNLOCK
avrdude -p m328p   -b56000 -Pcom2 -cponyser   -V -e -U lock:w:0x3F:m -U hfuse:w:0xD8:m


LOCK 328
avrdude -p m328p  -b56000 -Pcom2  -cponyser   -V -U lock:w:0x0F:m


but i'm still getting the same results.  does anyone know the proper AVRdude commands for setting the fuses correctly?  i don't really care to know what the various fuse bits mean (everyone seems to want to talk about this but it just makes my eyes glaze over), i just want the setup that leads to a functional Arduino.
39  Forum 2005-2010 (read only) / Development / Re: Atmega328P bootloader. etc. on: March 13, 2009, 12:40:22 pm
there's definitely something not quite right about Atmega328 support in the stock Arduino 0014 IDE or in my experimentally-modified version.  I suspect there is something subtly wrong with the bootloader (and I've tried several at this point). I can write the bootloaders okay, but 328s with these bootloaders are not plug-in compatible with Atmega168s in an Arduino board (the board I am using is an old NG modified with a 0.1 microfarad capacitor to act like a Diecimila). In the IDE I change the board settings to Duemilanove with Atmega328 and try to upload a sketch and it almost never works. It worked precisely once, causing me to start this thread, but it seems now this success was a fluke.  Does the Diecimila board (or the modified NG board I'm using) not support the atmega328 with bootloader?  Has the auto-reset timing been changed with the Duemilanove?  
40  Forum 2005-2010 (read only) / Development / Re: Atmega328P bootloader. etc. on: March 12, 2009, 11:47:07 pm
i tried the easy way and it kept NOT working. this was partly due to the fact that WinAVR as shipped in Arduino IDE 0014 does not have any references to the Atmega328, so it can't possibly burn a bootloader.  at the minimum you're going to need the latest copy of WinAVR (or whatever AVRdude works in your environment).

with the setup i'm describing, i'm guessing you could use other methods to burn a bootloader, including perhaps the parallel burner.
41  Forum 2005-2010 (read only) / Development / Atmega328P bootloader. etc. on: March 12, 2009, 09:52:34 pm
I'm just collecting together the info I needed to successfully burn an Arduino bootloader onto a 328, which (for those who don't know) gives me twice the RAM, Flash, and EEPROM of an Atmega168.  Getting my setup working wasn't easy, and I had a lot of false starts.

1. Get and install the latest version of the Arduino IDE, which as I write is 0014.
http://arduino.cc/en/Main/Software
2. Get the latest copy of AVRdude. I'm working on Windows so I got WinAVR. I actually got the latest release candidate, which is  20090306rc1.  You can pick it up here:
http://sourceforge.net/project/showfiles.php?group_id=68108
3. Inside the Arduino installation folders is this location:
NAME_OF_ARDUINO_FOLDER\hardware\tools\avr.
I replaced everything in there with the freshest copy of WinAVR.
4.  In NAME_OF_ARDUINO_FOLDER\hardware\tools\avr\etc is a file called avrdude.conf.  I replaced it with the copy I picked up here:
http://wolfpaulus.com/sys/arduino/avrdude.conf
5. I have an ICSP programming board made from a cheap Olimex board I bought from Sparkfun.com.  I used a serial ICSP connection on COM2 to burn the bootloader found here:
http://wolfpaulus.com/sys/arduino/AT328.hex
using this command-line command launched from within the WinAVR folder (where I'd put a copy of AT328.hex).

avrdude -F -pm328p -cponyser -Pcom2 -b56000 -u -v  -Uflash:w:AT328.hex

that worked. I then did something I don't fully understand to the fuses:

avrdude -F -pm328p -b56000 -Pcom2  -cponyser  -V -U lock:w:0xCF:m

I took the Atmega328 out and popped it into an Arduino NG board, set the IDE to Arduino Duemilenove w/ Atmega328, hit reset on the board (unnecessary on more modern boards) and successfully uploaded a sketch.  

Twice the Flash means twice the awesomeness!  There were things that had been impossible that now are quite possible.
42  Forum 2005-2010 (read only) / Development / Brownout Detection on: August 11, 2008, 08:56:05 am
Here's a question for those who understand AVR chips inside and out.  I've read that these chips have "brownout detection," though I've never found a good reference for how this is supposed to work.  I'm wondering if brownout detection is entirely a hardware thing or if it is a state that can be read and acted upon by software (possibly requiring an end-run around the normal Arduino environment).  Here's why I'm interested:

My current Arduino project has a "shutdown routine" wherein it writes certain data to EEPROM just before it goes dead (this is mostly to keep the EEPROM from being written to too often and exceeding its 100,000 write cycle limit, although it could have other useful features as well, depending on the answer to this question.)

If brownout detection can be read by software, it would be possible for the Arduino to execute its brief shutdown routine whenever power failed, since there is always enough power left in its discharging capacitors for it to run for a few seconds following a power failure.  This brief source of power quickly falls to a level triggering brownout detection and then, if I can read this from software, I run my shutdown routine.  Please tell me if this makes no sense at all.  Thanks!
43  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: April 07, 2007, 04:21:22 pm
Not that this discussion should be happening here, but I did mail them.

It seems there's a downside to depending on international mail to make people happy.
Obviously, if they don't arrive then you get a refund.
44  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: March 07, 2007, 12:15:06 am
I can assure you that you are imagining the speed difference.  I have used Atmega8s and Atmega168s in the same socket with the same circuitry and have never seen speed differences when executing identical programs, some of which do nothing but record the time, iterate through thousands of loops, and then record the time again.  

Of course, if you have the fuse settings set wrong, it's possible to, say, have the Atmega168 cranking along at only 1MHz, but in those cases its serial port will not work with the default settings for the Arduino IDE and you'd have an objective sense of the problem instead of the subjective one you describe.
45  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: December 03, 2006, 06:50:10 pm
Ok - I made a real page for someone to go to to buy Atmega168/8s preloaded with Arduino firmware.
http://asecular.com/arduino/
Pages: 1 2 [3] 4 5 6