Pages: 1 ... 8 9 [10] 11 12 ... 31   Go Down
Author Topic: Cosa: An Object-Oriented Platform for Arduino programming  (Read 94413 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 2
Posts: 59
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi MarsWarrior.

You really don't like reading documentation ;-). I was under the impression that you had already installed Cosa previously and was now attempting to use it with Code::Blocks and a new version of Arduino. I understand now that this assumption was wrong. Sorry about that.

Well, yes I don't like reading documentation as I am a visual thinker. Still I did read your blog. Started with the first application, but managed to skip the whole installation blog  smiley-grin I did however compile Cosa a few months back on another PC, but didn't know the special install anymore as you have noticed...

Quote
Cosa is not an Arduino library. The Arduino preprocessor cannot handle sub-directories within a library. I like to structure things so the include is "Cosa/XXX.hh" for header file and then there is even more structure like "Cosa/LCD.hh" and "Cosa/LCD/Driver/HD44780.hh".

Now how can we get the Arduino preprocessor (compiler include path) to recognize this? We put the Cosa directory into the arduino header/source directory! So the installation procedure is:

1. Download Cosa as a zip file.
2. Unzip in your libraries folder in your sketches folder.
3. Move the Cosa (source/header) folder to the Arduino source/header folder. For 1.0.5 that is the folder "arduino-1.0.5/hardware/arduino/cores/arduino".

You havn't done step 3 yet. That's all.

Thanx for the explanation. During my search I came accross some problems about subdirectories & libraries and the fact that this was filed as a bug, accepted, but then again rejected and considered as an Arduino feature! On the other side I use multiple libraries for my own projects (I was told to do so), and guess not able to use subdirectories is a reason, but I never realized this...

I wonder if Code::Blocks suffers from the same problem, as I'm using the Arduino compatible version, but haven't had time to check this.
Code::Blocks btw caches already compiled files, so should be a lot faster, certainly if Cosa is compiled for each sketch, as pito mentioned.

Update: Result from compiling CosaPins.ino in Code::Blocks with the Cosa library in the Arduino folder:
Code:
-------------- Build: Arduino Uno in CosaPins (compiler: GNU AVR GCC Compiler)---------------

Compiling: CosaPins.ino
Linking console executable: build\CosaPins_uno.elf
CosaPins.ino: In function 'void setup()':
CosaPins.ino:83: warning: only initialized variables can be placed into program memory area
CosaPins.ino:86: warning: only initialized variables can be placed into program memory area
CosaPins.ino:89: warning: only initialized variables can be placed into program memory area
CosaPins.ino:90: warning: only initialized variables can be placed into program memory area
CosaPins.ino:91: warning: only initialized variables can be placed into program memory area
CosaPins.ino:92: warning: only initialized variables can be placed into program memory area
CosaPins.ino:93: warning: only initialized variables can be placed into program memory area
CosaPins.ino:94: warning: only initialized variables can be placed into program memory area
CosaPins.ino:95: warning: only initialized variables can be placed into program memory area
CosaPins.ino:96: warning: only initialized variables can be placed into program memory area
CosaPins.ino:97: warning: only initialized variables can be placed into program memory area
CosaPins.ino:98: warning: only initialized variables can be placed into program memory area
CosaPins.ino:99: warning: only initialized variables can be placed into program memory area
CosaPins.ino:100: warning: only initialized variables can be placed into program memory area
CosaPins.ino:113: warning: only initialized variables can be placed into program memory area
CosaPins.ino:115: warning: only initialized variables can be placed into program memory area
CosaPins.ino:117: warning: only initialized variables can be placed into program memory area
CosaPins.ino:119: warning: only initialized variables can be placed into program memory area
CosaPins.ino: In function 'void loop()':
CosaPins.ino:131: warning: only initialized variables can be placed into program memory area
CosaPins.ino:134: warning: only initialized variables can be placed into program memory area
CosaPins.ino:138: warning: only initialized variables can be placed into program memory area
CosaPins.ino:143: warning: only initialized variables can be placed into program memory area
CosaPins.ino:146: warning: only initialized variables can be placed into program memory area
CosaPins.ino:147: warning: only initialized variables can be placed into program memory area
CosaPins.ino:148: warning: only initialized variables can be placed into program memory area
CosaPins.ino:149: warning: only initialized variables can be placed into program memory area
build\CosaPins.o: In function `global constructors keyed to _Z11free_memoryv':
CosaPins.ino:(.text._GLOBAL__I__Z11free_memoryv+0x8): undefined reference to `ExternalInterrupt::ExternalInterrupt(Board::ExternalInterruptPin, ExternalInterrupt::Mode)'
CosaPins.ino:(.text._GLOBAL__I__Z11free_memoryv+0xec): undefined reference to `PWMPin::set(unsigned char)'
CosaPins.ino:(.text._GLOBAL__I__Z11free_memoryv+0x120): undefined reference to `vtable for AnalogPin'
CosaPins.ino:(.text._GLOBAL__I__Z11free_memoryv+0x122): undefined reference to `vtable for AnalogPin'
C:\Users\xyz\My Documents\CosaPins\build\/core_uno_16.a(main.cpp.o): In function `main':
main.cpp:(.text.main+0x8): undefined reference to `setup'
main.cpp:(.text.main+0x10): undefined reference to `loop'
Process terminated with status 1 (0 minutes, 4 seconds)
6 errors, 28 warnings (0 minutes, 4 seconds)

Hmmm. Almost there, but not yet  smiley Never seen such errors, but I already discovered that Code::Blocks seems to be more strict than the Arduino IDE.
I don't have an Arduino IDE installed here, but assume that Cosa will compile if installed right!
« Last Edit: July 10, 2013, 09:09:34 am by MarsWarrior » Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 473
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

MarsWarrior, I see that you are back trying to get Cosa up and running on Code::Blocks. Below are a few hints on how to interpret the warning and error messages from the compiler.

1. The warnings have to do with the PSTR()/PROGMEM macro from AVR. It is not correctly defined in AVR. The same in Arduino. Requires a fix in AVR so for now just ignore "warning: only initialized variables can be placed into program memory area".
2. The errors are interesting as they reference free_memory() which is very strange. This might have to do with the preprocessing.
3. The link also seems to miss the object file for the preprocessed .ino file as setup() and loop() are missing.

You need to provide your compiler and link options to make sense of this. Also as I mentioned before this post/topic on this forum is mainly for Cosa updates and not support. Please use the github issue handling instead. I don't really provide support for stuff that is not on the project plan. Sorry about that.

When porting I start with something a bit simpler than CosaPins.ino and work my way upwards. This example sketch does use a lot of Cosa advanced stuff. It is not my first choice when going for a new IDE.  

Last, the issue that pito mentioned. It isn't as bad as that. Yes, Cosa is compiled with the Arduino core when a sketch is built for the first time in a session (start of the IDE). A recompile of both the Arduino core and Cosa is forced when a new board is selected. Compiling another sketch in the same session with the same board setting will not force a new build of Cosa (or the Arduino core). All the object files are reused.

Cheers!
« Last Edit: July 11, 2013, 05:49:01 pm by kowalski » Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 59
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I will follow your suggestion by using simpler examples, but a collegue of mine, who has more knowledge of C++ than I have said that this error is normally related to:
  • A common reason of the "vtable" message is not declaring a virtual function equal to zero, for example virtual foo(); instead of virtual foo() = 0;
  • Methods are not implemented in the subclass, while they should be as they are defined in the header file
  • Ordering problem with the linker if the included header files are in the wrong order

If I find something related to Cosa I will either PM you, or add an issue in Github.
Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 473
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Cosa I2C slave LCD driver is now completed. The initial design has been refactored to a new Virtual LCD class (VLCD) which allows any Cosa LCD device driver to be connected (not just the HD44780 driver). The VLCD class contains two parts; 1) the client part acts as a LCD proxy, translating LCD API calls to I2C messages, 2) the server part acts as an adapter that decodes the I2C messages and calls the LCD implementation.



Below is the CosaLCDslave sketch. It uses the new Virtual LCD class and binding to the HD44780 driver with the 4-bit parallel port IO. This sketch is compiled for an ATtiny84 in the example above but may be compiled for any Cosa supported Arduino.

Code:
#include "Cosa/Watchdog.hh"
#include "Cosa/LCD/Driver/HD44780.hh"
#include "Cosa/VLCD.hh"

// Use a 4-bit parallel port for the HD44780 LCD (16X2 default)
HD44780::Port port;
HD44780 lcd(&port);

// And use the LCD for the implementation of the Virtual LCD slave
VLCD::Slave vlcd(&lcd);

void setup()
{
  Watchdog::begin();
  lcd.begin();
  vlcd.begin();
}

void loop()
{
  Event event;
  Event::queue.await(&event);
  event.dispatch();
}

The benchmark CosaLCDspeed.ino binds to the Virtual LCD and runs the measurements. It is the Arduino Nano in the picture above that runs this sketch. See the code on github.

https://github.com/mikaelpatel/Cosa/blob/master/examples/LCD/CosaLCDspeed/CosaLCDspeed.ino
https://github.com/mikaelpatel/Cosa/blob/master/examples/TWI/CosaLCDslave/CosaLCDslave.ino

By implementing the IOStream::Device methods puts(), puts_P() and write() the performance can be boosted to 50-98% of the performance of the I2C IO expander at 400kHz. Below are some results from the benchmarking. The first table shows the performance (operations per second/frames per second), and compares the 4-bit and I2C IO expander implementations (at 100khz and 400 khz).



The above results are used as the baseline for the comparison with the second table below which is the ATtiny84 (internal clock 8Mhz) compiled version and the VLCD version. The comparison is between the 4-bit implementation and then the VLCD implementation (with optimizations).



VLCD  may be viewed as a "template" for how to construct I2C slave devices.
http://dl.dropboxusercontent.com/u/993383/Cosa/doc/html/d1/d1f/classVLCD.html

Cheers!

For more details on the development of VLCD and the LCD optimizations see http://forum.arduino.cc/index.php?topic=175702.0
« Last Edit: July 13, 2013, 11:41:48 am by kowalski » Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 473
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The next step; a USI based TWI master for ATtiny and the ported LCD support. Below is the LCD benchmark running on a LCD with I2C IO expander and an ATtiny85 (internal clock 8 MHz, internal pull-up). The benchmark result is 39 operations per second (32 characters plus 2 set cursor per op). The result for the Cosa LCD driver with I2C IO on a standard Arduino (Uno, Nano, etc) is 53 fps.



The latest I2C optimizations include packaging larger I2C block (32 IO expander commands for 8 characters) on puts() and write().

Cheers!
« Last Edit: July 18, 2013, 07:24:37 am by kowalski » Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 473
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here are the numbers from the latest improvements of the Cosa LCD device driver. The table also contains the ratio compared to the New LiquidCrystal Library benchmark.
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home#!performance-and-benchmakrs
Please note that the ATtiny84/85 benchmarking uses the internal 8Mhz clock.



Read more on "Arduino Forum :: Using Arduino :: Displays :: Cosa/Boosting LCD 1602 I2C performance beyond 130 fps" http://forum.arduino.cc/index.php?topic=175702.msg1318096#msg1318096 and the blog http://cosa-arduino.blogspot.se/2013/07/object-oriented-lcd-management.html

Cheers!
« Last Edit: July 17, 2013, 09:47:46 am by kowalski » Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2086
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Every time I see your pictures with your 8pin attiny it comes across my mind how difficult would be to port Cosa onto LPC810M (8pin DIP as well) smiley
« Last Edit: July 16, 2013, 04:55:10 pm by pito » Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 473
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Every time I see your pictures with your 8pin attiny it comes across my mind how difficult would be to port Cosa onto LPC810M (8pin DIP as well) smiley
LOL - Guess that would be in another forum!

Anyway after browsing through the LPC810M spec I actually think the ATtiny85 has the better cost/performance, though 1Kbyte SRAM is a small improvement, 4Kbyte PROGMEM is very limiting.

When the Arduino/AVR Cosa project starts to drops in velocity I will need to considering porting to other micro-controllers or starting a new project. ARM is the obvious next step even if it will not happen shortly as I still have tons to do.  

Cheers!
« Last Edit: July 17, 2013, 05:15:49 pm by kowalski » Logged

nr Bundaberg, Australia
Online Online
Tesla Member
***
Karma: 130
Posts: 8620
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you ever think about porting it to LPCs (122x especially) let me know.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2086
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Cosa CosaBenchmarkPins.ino has been successfully built within the new UECIDE with Cosa library located in libraries..
http://forum.arduino.cc/index.php?topic=176498.msg1319940#msg1319940
 smiley
« Last Edit: July 17, 2013, 02:03:16 pm by pito » Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 473
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Cosa CosaBenchmarkPins.ino has been successfully built within the new UECIDE with Cosa library located in libraries..
http://forum.arduino.cc/index.php?topic=176498.msg1319940#msg1319940
 smiley
@pito

Great job! Thanks for testing that. Appreciate any feedback from the port to UECIDE. Read some of the dialogue in the topic above. And there seems to be some alternative installation strategy i.e. Cosa as a core instead of within the Arduino core.

As Cosa has grown build speed is becoming vital. I see that this has been discussed and is being addressed. Hope that a solution will soon be available also for the Arduino IDE.

Cheers!
« Last Edit: July 17, 2013, 04:32:31 pm by kowalski » Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 473
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A new Cosa blog post is available. It is an introduction to the Cosa 1-Wire device driver support. The example sketch is a simple DS1990A iButton reader.



http://cosa-arduino.blogspot.se/2013/07/object-oriented-1-wire-introduction.html

Cheers!
« Last Edit: July 17, 2013, 04:41:42 pm by kowalski » Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 473
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you ever think about porting it to LPCs (122x especially) let me know.
@Graynomad

What LPC122X development board/environment would you recommend? The hardware resources in the LPC122X have much in common with the ATmega so this might be of interest later on this fall.

The current Cosa project backlog top five are:

  • SR (74HC595) LCD IO driver
  • LCD menu system
  • Sensor driver framework and some additional sensors 9-10DOF, etc
  • Next increment on the Socket and NRF24L01+ driver
  • Socket/Ethernet driver

Cheers!
Logged

nr Bundaberg, Australia
Online Online
Tesla Member
***
Karma: 130
Posts: 8620
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What LPC122X development board/environment would you recommend?
I can't compare them because I've only used one, that being the LPCXpresso board and IDE (Eclipse-based). I'm well happy with both, the boards cost 20 Euro and the IDE is free for C, not for C++ although I believe it's easy enough to use it for C++, just not as turnkey as one might like.

I reckon the LPC1227 is roughly equivalent to the Mega1284, both are "just right" in terms of features IMO.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2086
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

BTW, LPC11xx, LPC11Uxx, LPC12xx, LPC13xx are similar, and there is almost no difference at c source level with drivers. I've been toying with lpcxpresso 1343 and 11U14. For the purpose of Cosa port you may consider all the same (maybe except USB and DMA stuff). All have got an uart bootloader in a rom, plus other drivers there (it depends on the model).
Logged

Pages: 1 ... 8 9 [10] 11 12 ... 31   Go Up
Jump to: