Show Posts
Pages: 1 ... 36 37 [38] 39 40
556  Forum 2005-2010 (read only) / Development / Re: shiftOutFast - much faster than normal shiftOut on: October 02, 2009, 10:01:05 pm
while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission

with something much more readable

while (!(SPSR & (1<<SPIF))); // exact same thing, looks neater

or even better

loop_until_bit_is_set(SPSR, SPIF);

if that macro is not available, then add #include <avr/sfr_defs.h>

if your program doesn't get too complicated, i think it's ok to have many SPI transmissions inside a timer ISR, provided that you disable the ones built into Arduino's core
557  Forum 2005-2010 (read only) / Development / Re: shiftOutFast - much faster than normal shiftOut on: October 02, 2009, 09:15:31 am
sounds like you should be using hardware SPI instead, software SPI is not good for time critical applications like PWM
558  Forum 2005-2010 (read only) / Development / Re: Library Repository? on: October 06, 2009, 11:16:59 am

is that what you are looking for?
559  Forum 2005-2010 (read only) / Development / Re: Webcam->Arduino on: October 01, 2009, 01:00:40 pm
RoboRealm has built-in image processing, VB scripting, and a serial port module that can output variables from your script. Tell the image processing pipeline to outline the object's area (use image differencing, aka compare frames looking for different pixels), store the center of that area into a variable with the script, have the serial port output that variable to your arduino, arduino tells servo to move, done

Damn it, RoboRealm used to be free software... now it costs $90
but they'll give it to you for free if you post your project on the internet
560  Forum 2005-2010 (read only) / Development / Re: Library Build Procedure on: September 21, 2009, 04:00:52 pm
i was wondering how the environment knows what the user has imported, i think i found the answer, i'm going to implement the same thing with regular expressions searching for the preprocessor include statements.

the environment rebuilds the library every time you click verify i believe, several versions before i think they were compiled when you started the environment, very annoying.
561  Forum 2005-2010 (read only) / Development / Library Build Procedure on: September 21, 2009, 12:02:16 pm
I'm writing a AVR integrated development environment and I'm trying to figure out how Arduino handles the building of libraries.

Since Arduino boards now have 6 different chips and 2 common clock speeds, the libraries would need to be recompiled for every different build.

But it seems like the only thing the sketch writer needs to do is to write the include preprocessor statement with <angle brackets> to add a library to their sketch.

So how does the environment know which files to compile? Search for the directory that matches the include statement and then scan that entire folder for .c and .cpp files to compile?

(EDIT, ok I peeked into the java source code, it does look like there's something that scans for preprocessor includes, maybe copying everything into a temporary build folder, which makes me wonder what happens if a name conflict occurs?)
562  Forum 2005-2010 (read only) / Development / Re: Using Wire Library with WinAVR on: February 23, 2008, 12:18:41 am
Does Arduino use C or C++?

Also, I gave up on including the library, I found example code on the AVRlib website for TWI, I think I have the basic operation down except checking for status.

void i2cInit()
      cbi(DDRD, 0);
    cbi(DDRD, 1); // input state for now
      cbi(PORTD, 0);
    cbi(PORTD, 1); // disables pull up
      // pull up resistors are external

      TWBR = 1; // fast i2c
      TWSR = 0b00000011; // prescale 64, fast i2c
      TWCR = 0b01000101; // i2c on, interrupt enable, ack enable

      TWAR = 0b00111010; // slave address for accelerometer
      // apparently this is only used for slave mode, but keep it here

void i2cStop()
      while ((TWCR & _BV(TWINT)) == 0);
      TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); // stop

void i2cStart()
      while((TWCR & _BV(TWINT)) == 0); // wait
      TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN); // start

void i2cSLA_R()
      TWDR = 0b00111011;
      while ((TWCR & _BV(TWINT)) == 0);
      TWCR = _BV(TWINT) | _BV(TWEN); // clear int to start transmission

void i2cSLA_W()
      TWDR = 0b00111010;
      while ((TWCR & _BV(TWINT)) == 0);
      TWCR = _BV(TWINT) | _BV(TWEN); // clear int to start transmission

void i2cWrite(uint8_t data)
      TWDR = data;
      while ((TWCR & _BV(TWINT)) == 0);
      TWCR = _BV(TWINT) | _BV(TWEN); // clear int to start transmission

void i2cReadStart()
      while ((TWCR & _BV(TWINT)) == 0);
      TWCR = _BV(TWINT) | _BV(TWEN) | _BV(TWEA); // clear int to start transmission

uint8_t i2cRead()
      while ((TWCR & _BV(TWINT)) == 0);
      return TWDR;

With only one device on the bus, I think checking for status isn't really needed. (I haven't encountered any malfunctioning devices yet, fingers crossed)

Anything wrong with the code? I have all the waiting loops before the instruction so other functions can be executed during that time if needed (I have some floating point calculations that I plan to insert in a non-linear fashion)
563  Forum 2005-2010 (read only) / Development / Using Wire Library with WinAVR on: February 22, 2008, 12:49:29 am
I've copied the entire Wire folder into "WinAVR-20071221\avr\include\avr", and I put #include <avr/Wire/wire.h> in my program, during compile, this is the error:

c:/winavr-20071221/bin/../avr/include/avr/Wire/wire.h:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TwoWire'
c:/winavr-20071221/bin/../avr/include/avr/Wire/wire.h:64: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Wire'
In file included from ../all_header.h:37,
                 from ../ACTOR_robot.c:1:
../i2c.h: In function 'accRead':
../i2c.h:21: error: 'Wire' undeclared (first use in this function)
../i2c.h:21: error: (Each undeclared identifier is reported only once
../i2c.h:21: error: for each function it appears in.)
make: *** [ACTOR_robot.o] Error 1
Build failed with 5 errors and 0 warnings...

How can I use this library with WinAVR and AVR Studio?
564  Forum 2005-2010 (read only) / Troubleshooting / Burnt Out Chip? on: December 18, 2007, 08:37:13 pm
Chip appears working, it still "runs", but I can't upload anything else, the error is

avrdude: verification error, first mismatch at byte 0x0002
         0x5b != 0x5c
avrdude: verification error; content mismatch

I then used my AVR programmer, and got

avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

It's fried, right?
565  Forum 2005-2010 (read only) / Development / Re: Removing a drill hole from Eagle library part? on: October 03, 2010, 10:11:38 pm
edit the original, then save, then rename the edited package, after that you can re-import the original package
566  Forum 2005-2010 (read only) / Development / Re: Making an Arduino Clone, rules? on: October 03, 2010, 12:57:25 am
What are the rules on using the VID and PID of the Uno?
567  Forum 2005-2010 (read only) / Development / Re: atmega328 setup help on: October 15, 2009, 10:59:23 pm
you don't need a resonator or crystal if you program the fuses to use the internal 8mhz clock and use the 8mhz version of the bootloader

you do not need a pull up resistor on the reset pin, there's one built into the chip
568  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Recommendations for next iteration of Arduino on: November 15, 2010, 01:36:18 am
I wonder if the Arduino team has taken any hints from any derivative designs

mini-USB connector since USB-B is too tall for bigger shields

reset button moved to the side so shields don't cover the button

extra row of headers with standard spacing instead of weird spacing so people can make their own shields out of perf board

569  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: ATmega8U2 on: November 15, 2010, 10:55:46 pm
I am not sure you have understood what I've told...

I want to avoid to use an external programmer for burn the bootloader on Atmega328. Could we use the ATmega8u2 isp port for this function (as programmer master)?

I did understand, the ISP port is the SPI bus

You can activate the bootload on the ATmega8U2, load code from on there (you'll need to modify it slightly I think), and then wire up the ISP headers
570  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: ATmega8U2 on: November 15, 2010, 01:27:42 am
this is a good question, the ATmega8U2 could be connected to the SPI bus of the ATmega328P, and just left floating until the right command comes along. This wouldn't interfere with backward compatibility or any devices at all.
Pages: 1 ... 36 37 [38] 39 40