Go Down

Topic: Using Arduino vs. AVR vs . AVRstudio/CrossPack (Read 2383 times) previous topic - next topic

NJavrGuy

Hey everyone,

New here, but not really new to AVR.

I have a general question about what sacrifices you make using Arduino IDE vs. AVRstudio or CrossPack for robotics projects.

I have done a few projects in c++ in AVR studio, with a board I made myself, and have tried a few prototypes using arduino boards.

My first impressions are obviously Arduino is a million times easier to use, they handle a ton of the overhead for you, which is very, very nice.

I have also built a few of my own libraries in Arduino and used them successfully, so I love that you an do that, as it gives you control.

My assumption is that since it is so much easier to use, that you must lose something.

So, my question is what do you give up by using Arduino vs. straight up AVR through one of the above mentioned methods?

Do you lose speed, do you lose some flexibility?

Any comments would be appreciated.

Paresh Mathur

I too have gone the other way around. I was working with the ATmega series for a long time, then I got an arduino uno as a gift and have used it for quite a few things. The one thing I have found the Arduino most useful in is testing new chips. When you are working with an unfamiliar chip (unfamiliar to you or new chip in general) you can generally write some code for the arduino and be sure that the arduino is not the problem. This is one of the most annoying things in hardware hacking, when testing you are not sure where the point of failure is. Having an arduino, or similar boards for that matter, eliminates the lurking suspicions that maybe the test gears is the problem instead of the chip being tested.

NJavrGuy


I too have gone the other way around. I was working with the ATmega series for a long time, then I got an arduino uno as a gift and have used it for quite a few things. The one thing I have found the Arduino most useful in is testing new chips. When you are working with an unfamiliar chip (unfamiliar to you or new chip in general) you can generally write some code for the arduino and be sure that the arduino is not the problem. This is one of the most annoying things in hardware hacking, when testing you are not sure where the point of failure is. Having an arduino, or similar boards for that matter, eliminates the lurking suspicions that maybe the test gears is the problem instead of the chip being tested.



This makes sense, and I can see how this would be the case.

I am about to embark on a pretty big library development effort, and I am currently leaning towards doing it for arduino rather than straight AVR.

I will develop the libraries in c++, so it probably won't be too difficult to change them, but I want to make sure I understand the downside of using arduino vs. AVR development before I do this.

Osgeld

you do loose speed in many arduino functions, you do loose specific hardware advantages in some situations, you do gain more portability, and it is easier to rapidly produce software due to the core libraries and the abundance of setup being done for you.

http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

NJavrGuy


you do loose speed in many arduino functions, you do loose specific hardware advantages in some situations, you do gain more portability, and it is easier to rapidly produce software due to the core libraries and the abundance of setup being done for you.




Interesting,

Thanks for this, this is what I suspected.

Can anyone expand upon where you lose speed, and the magnitude of the loss?

Also, same for the hardware advantages?

Another quick question, is there anyway to work around these issues by say creating your own libraries for these instances?

Osgeld

The most obvious is digital write vs PORT, digital write might take 40us  PORTB |= (1<<PB2); might take 4us. Or lets say you want to talk to a serial device that uses odd parity, you might have to go out and tickle some registers manually.

Quote
Another quick question, is there anyway to work around these issues by say creating your own libraries for these instances?


yea theres nothing stopping you from dropping AVRGCC (which is not the same as whats used in studio, but its AVR and C++) or ASM code in the middle of an avr sketch or library other than its harder for average users to read / change, and narrowing portability (like registers dont always stay the same in different AVR's)
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

retrolefty

Quote
My assumption is that since it is so much easier to use, that you must lose something.

So, my question is what do you give up by using Arduino vs. straight up AVR through one of the above mentioned methods?

Do you lose speed, do you lose some flexibility?

Any comments would be appreciated.


You don't have to lose anything in that you are free not to use any of the arduino defined functions and libraries if you don't want to. About the only thing that the arduino includes into every sketch is the timer0 interrupt function stuff to support millis() and micros() commands, which you could disable in your setup function if you wished to.

Arduino is using the gcc C/C++ compiler so you can pretty much fly solo if you wish and still work inside the arduino IDE. Having to use the predefined setup() and loop() functions is not that big a deal to work with or around.

Lefty


NJavrGuy


The most obvious is digital write vs PORT, digital write might take 40us  PORTB |= (1<<PB2); might take 4us. Or lets say you want to talk to a serial device that uses odd parity, you might have to go out and tickle some registers manually.

Quote
Another quick question, is there anyway to work around these issues by say creating your own libraries for these instances?


yea theres nothing stopping you from dropping AVRGCC (which is not the same as whats used in studio, but its AVR and C++) or ASM code in the middle of an avr sketch or library other than its harder for average users to read / change, and narrowing portability (like registers dont always stay the same in different AVR's)


Makes sense, thanks!

My biggest concern for speed is twofold:

1) serial communication speed
2) I2C speed

Do you lose any speed with either of these using Arduino?

Osgeld

not that I am aware of i2c supports normal and fast mode, serial supports 2400-115200 baud out of the box, with people pushing that up to 1Mbps,  since they use the internal hardware
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

NJavrGuy


not that I am aware of i2c supports normal and fast mode, serial supports 2400-115200 baud out of the box, with people pushing that up to 1Mbps,  since they use the internal hardware


Thanks much for your help!

Go Up