Show Posts
Pages: 1 ... 6 7 [8] 9 10 ... 31
106  Development / Other Software Development / Re: Cosa: An Object-Oriented Platform for Arduino programming on: March 20, 2014, 01:34:42 am
TWI bus frequency setting per device.
On the same wires? If so can that work?
No, not really as a device will a lower speed could misinterpret the signalling at higher speed and not "disconnect" correctly (i.e. START/ACK). The use case is simply moving the bus frequency setting from compile time to run time. This makes the frequency setting possible in the sketch instead of the TWI class.

107  Development / Other Software Development / Re: Cosa: An Object-Oriented Platform for Arduino programming on: March 19, 2014, 06:39:41 pm
Some news on the latest update of Cosa.

1. Support for Microduino processor modules; Core, Core32u4 and Core+ (ATmega644, 64K PROM, 4K SRAM).

2. TWI bus frequency setting per device.

3. CDC speed improvement.

108  Using Arduino / Microcontrollers / Re: Arduino @ 8MHz instead of 16MHz on: March 18, 2014, 02:36:49 pm
Why change any hardware (crystal, intern clock, etc)? Why not simply use the prescaling function in ATmega328? See chap. 8.11 System Clock Prescaler. In Cosa the following member function is available.
Power::clock_prescale(uint8_t factor)
  if (factor > 8) factor = 8;
  synchronized {
    CLKPR = (1 << CLKPCE);
    CLKPR = factor;

And then there are all the Power Management functions. Below is a link to a Blink sketch that uses three threads (each with 60 byte environment) that runs on ATtiny85 and uses only 10-15 uA when the LED is off.

Another Cosa low power example sketch is:
This sketch demonstrates a number of different strategies to reduce power.


109  Development / Other Software Development / Re: Fast hashing library on: March 18, 2014, 01:54:59 pm
Did you do your benchmark against AVR standard CRC funtions or just quoting the original post?

What was the performance of this implementation?
And how did you tweak it for the AVR processor?

The original implementation and benchmark was at 1.6 GHz i386 architecture, And "Data is time in seconds taken to hash a random buffer of 256 bytes 5 million times"

How long time would this take on an Arduino ;-)?

I believe the incremental version is more useful for a micro-controller with only 2-4 Kbyte of memory. And there are some tweaks to be done to improve performance on an 8-bit architecture.

Here is an interesting link:

110  Development / Other Software Development / Re: Cosa: An Object-Oriented Platform for Arduino programming on: March 17, 2014, 02:45:48 pm
Gets better all the time.
Thanks! Hope your Quub project is progressing well. Have been following some of the latest changes.

With the size of Cosa (50 KLOC/100+ classes) the Arduino build is starting to become a bottle-neck. More traditional build methods will become necessary. The initial build takes "time" and having pre-compiled libraries for different boards could remove this "delay". This could also allow delivering object code when source code is not "open".

Cosa is approaching the initial project goal; a rapid prototyping environment for Internet-of-Thing devices. With the support for HTTP, SNMP, MQTT and ThingSpeak there is essential support for getting sensor data to a server/cloud and commands back to the device over Internet.

I will be going back to the Wireless device drivers and improve security (encryption), robustness and reliability (acknowledgement/retransmission) and add support for additional wireless device (e.g Wifi, GSM). 

111  Development / Other Software Development / Re: Cosa: An Object-Oriented Platform for Arduino programming on: March 16, 2014, 06:14:18 pm
Some news on the latest development in Cosa.

1. ThingSpeak Channel and TalkBack example sketch
An example sketch that allows the TalkBack commands LED_ON/OFF, SENSOR_ON/OFF, PING/PONG together with post of sensor data to a channel. The command SENSOR_ON will enable post of sensor data (DHT11) to a channel. The command LED_ON/OFF controls a led. Last the command PING demonstrates issuing commands back to the server (PONG).

2. Alarm class
Scheduling functions with seconds level resolution. The callback member function may be called once or periodic. Typical usage is "call function at given time", "call function every hour", etc.

3. Activity class
High level scheduling of functions with start time, duration and period on seconds and minutes level of resolution. The callback member function is periodically called throughout the activity duration. May be used to schedule activities such as "during 10:00 to 14:00 sample sensor every 5 seconds" or "every hour sample sensors every 10 seconds for two minutes", etc.

4. Nucleo (multi-tasking) updates
a. Improved delay handing
The thread level delay function is now based on a delay queue.
b. Performance optimization
The context switch is 11 us, semaphore wait-signal pair is 41 us.
c. Message Passing (Actors)
d. Blink example with threads
Three threads running on an ATtiny85 with 32 bytes stack and 33 byte context per thread. Demonstrates low power when using Cosa Nucleo.

5. Sizeof Benchmark update
List of classes in Cosa and size of instances. Note: static data not included.

6. Cosa example sketches
The example sketch folders have been restructured. There are over 130 test, benchmarking and example sketches in total.
And most of them may be compiled for Tiny, Standard, USB, Mega, Mighty Arduino based boards.

112  International / Fran├žais / Re: programmation avec arduino atmega 1280 on: March 16, 2014, 11:08:08 am

113  Using Arduino / Project Guidance / Re: External Interrupt for MEGA 2560 with SQW from DS1307 on: March 15, 2014, 12:05:49 pm
#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68

volatile int count;

void setup()
  attachInterrupt(0, compteur , RISING);

void compteur()
  count = count + 1;

void loop()
  int c = count;
  while (c == count);
114  Using Arduino / Project Guidance / Re: Counting length of pulses on: March 13, 2014, 02:12:23 am
Im doing a school project and you guys on here are my only hope  smiley-confuse

I will have an input from another microcontroller and i need to count the length of pulses,
there will be 3 different pulses one after another.

So, basically there will be one pulse for lets say 21 seconds, i need to store this,
then 5 seconds or so after that pulse has finished another will start on the same pin for lets say 15 seconds, i need to store this separately,
finally 5 seconds after the previous pulse there will be one last pulse for 3 seconds and i need to store this separately from the other 2 pulses,
What have you learnt in school? What type of problem is this? Do you know what a finite state machine is? And how it can be programmed? Is the signal stable? What is the distance, length of the cable? Is there noise? How do you indent to connect the two microcontrollers? Does the solution have to be low power? Will the microcontrollers run on battery? Are there programming languages for this type of problem?

115  Development / Other Software Development / Re: Writing menu library, need help with #include's on: March 10, 2014, 06:07:30 pm
What is the compiler trying to tell you? It points to the line;

If you define lcd as a local variable in the constructor M16 it is not available after that. It is created on the stack and then removed after the constructor (M16).

"I guess I have to declare lcd somewhere else?" yepp.

116  Using Arduino / Networking, Protocols, and Devices / Re: SNMP Manager example code on: March 09, 2014, 05:59:30 am
Yes it is possible to write that. It is not implemented in that library,

But why not write it as an uint8_t vector instead.

117  Using Arduino / Networking, Protocols, and Devices / Re: SNMP Manager example code on: March 09, 2014, 04:11:43 am
What library are you using? Your code above is wrong as the OID is a string and you are accessing characters and not numbers. Cheers!
118  Using Arduino / Networking, Protocols, and Devices / Re: SNMP Manager example code on: March 08, 2014, 07:26:11 pm
The OID encoding of 247 is; 128+1,247-128=129,119. Which is what you got.

The full OID should be encoded as 1,3,6,1,4,1,129,119,87,0. This should be prefixed with the length of the OID which is 10.

BTW: is an enterprise OID for AEG Electrocom.

119  Using Arduino / Sensors / Re: Real Time Clock DS1307 and Libraries on: March 08, 2014, 04:46:02 pm
Page 8 in the Product Description for DS1307 ( might be of help. The problem is the library that adjusts the year. The chip handles 00-99 year value (in BCD). The library adjusts to 20XX.

Depending on what you are looking for you will have to at least have to modify the library, find another library or write your own.

120  Development / Other Software Development / Re: Changing the CPU clock in real time (run-time), to save some battery power on: March 08, 2014, 04:12:36 pm
This was an interesting approach. I have done some work with Cosa to get low power built-in but only used the power attributes. Below is a sketch I wrote to demonstrate different low power tweaks.
#include "Cosa/Event.hh"
#include "Cosa/Pins.hh"
#include "Cosa/Power.hh"
#include "Cosa/ExternalInterrupt.hh"
#include "Cosa/Watchdog.hh"


OutputPin led(Board::LED);

class Button : public ExternalInterrupt {
  OutputPin* m_led;
  Button(Board::ExternalInterruptPin pin, OutputPin* led) :
    ExternalInterrupt(pin, ExternalInterrupt::ON_LOW_LEVEL_MODE, true),

  virtual void on_interrupt(uint16_t arg = 0)
    if (m_led != NULL) m_led->on();
    Event::push(Event::NULL_TYPE, NULL);

Button wakeup(Board::EXT0, &led);

void setup()
  // 0 uA, already done by startup
  ACSR = _BV(ACD);
  ADCSRA = 0; 
  UCSR0B = 0;
#if defined(USE_DISABLE_PINS)
  // 2 uA, possible uart pin needed disconnecting
  DDRB = 0b11111111;
  PORTB = 0b00000000;
  DDRC = 0b11111111;
  PORTC = 0b00000000;
  DDRD = 0b11111011;
  PORTD = 0b00000100;

void loop()
  // 180 uA - (BOD + PIN disable = 23 uA)
  Event event;
  Event::queue.await(&event, SLEEP_MODE_PWR_DOWN);
  // 180 uA - (BOD + PIN disable = 23 uA)

  // 1,5 mA, 64 ms blink
  Watchdog::begin(16, SLEEP_MODE_PWR_DOWN);
  while (wakeup.is_low()) {
  // 15 mA, 16 ms blink
  while (wakeup.is_low()) {
    for (uint8_t i = 0; i < 4; i++) DELAY(16000U);

Link to the example sketch:

The results are for Arduino Mini Pro, approx. 3 mA idle, power LED on.
 1. Modifications; removed power LED resistor, 1 Kohm.
 2. Powered via FTDI USB/TTY adapter 5 V
     a. Connected to VCC/GND, 180 uA
     b. Connected to RAW/GND, 840 uA
     c. Connected to VCC/GND, + BOD disabled, 160 uA (See Power.hh)
     4. Connected to VCC/GND, + disable pins, 157 uA
 3. Powered with LiPo 3,7 V
     a. Connected to VCC/GND, 32 uA
     b. Connected to RAW/GND, 840 uA
 And for Arduino Lilypad, 8 Mhz, no modifications
  1. Powered via FTDI USB/TTY adapter 5 V, 18 uA
  2. Powered with LiPo 3,7 V, 16 uA
I have added frequency scaling to Cosa but there are ripple effects to consider before testing. Mainly as you write on timers and ADC.

Cheers! And thanks for the inspiration.
Pages: 1 ... 6 7 [8] 9 10 ... 31