Show Posts
Pages: [1] 2
1  International / Français / Re: Warning on: May 16, 2013, 05:29:21 am
Hi,

To answer the second part of your question: why use Flash/PROGMEM for strings...

There is a lot more Flash than SRAM, and if you fill up SRAM you are in trouble.

See here:

http://www.arduino.cc/en/Reference/PROGMEM

Rgds

Damon
2  International / Français / Re: Warning on: May 16, 2013, 04:03:01 am
Hi,

Please excuse the reply in English: I would mangle an attempt to respond in French!

I see "only initialized variables can be placed into program memory area" when using F("string") to keep the string in Flash and avoid having it copied to SRAM.  It seems harmless.

For "array subscript has type ‘char’", unless it's your code, it's probably harmless.  If it is your code, use int the index variable to an array instead or cast with (int) before using it as such if you know what you are doing and merely need to convince the compiler.

Rgds

Damon
3  Topics / Education and Teaching / Re: Africa Charity - Setting up a program with Arduinos on: May 06, 2013, 02:45:18 am
A mad idea for you to dismiss: I'm intending to try to detect room occupancy from FFT (Fourier) analysis of voice from a small microphone using one of the free Arduino/AVR FFT libraries knocking around.  I haven't done it yet myself.

It might be quite impressive for the students to control their Arduinos by voice or handclap or foot-stomping one way or another.

Rgds

Damon
4  Using Arduino / Microcontrollers / Re: When sleeping helps on: May 05, 2013, 03:56:04 pm
@CB: conversion time may vary from sample to sample depending on the sensor/ADC/etc...

Rgds

Damon
5  Using Arduino / Microcontrollers / Re: When sleeping helps on: May 05, 2013, 02:44:38 pm
I have implemented both 'running the CPU clock with maximum prescaling' (which gets me 31.25kHz) and sleeping with watchdog timer.  I use the former for delays too short for the latter.

See the following for some experiments:

https://sourceforge.net/p/opentrv/code-0/HEAD/tree/trunk/Arduino/test/BlinkPower/BlinkPower.ino

Busy waiting with a slow CPU was taking ~3mA, which is a decent saving over running flat out, but sleeping with the watchdog timer takes maybe 1000th of that for me I think. (I confess that I was measuring power-save sleeping against the async timer 2 clock towards the end, rather than the watchdog, but I the datasheet seems to agree with me.)

Sleeping waiting for an interrupt can also be beneficial, eg for the ADC, if it's not too fast that the interrupt latency is a problem.

Rgds

Damon

6  Using Arduino / Networking, Protocols, and Devices / Re: 1.9kHz TWI/I2C clock with F_CPU = 1000000L on: May 05, 2013, 01:03:28 pm
That's with the AVR running.

(The temp sensor and radio draw another 2uA idle, and of course the *average* current is somewhat higher when I take readings, etc, but the 1.3uA is the AVR running the software RTC.)

Timer 2 in async mode from a 32768Hz crystal waking up the main loop (1MHz CPU from 8MHz built-in RC oscillator) from power-save sleep once every 2 seconds.  That timer-2 int vector also maintains the software RTC (and persists the time in EEPROM in a way that should survive 12 years, and takes 3 bytes to persist time (to h/4) and date through a reset or power removal...

See the project at:

https://sourceforge.net/p/opentrv/code-0/HEAD/tree/trunk/Arduino/V0p2_Main/

and in particular:

https://sourceforge.net/p/opentrv/code-0/HEAD/tree/trunk/Arduino/V0p2_Main/Power_Management.h
https://sourceforge.net/p/opentrv/code-0/HEAD/tree/trunk/Arduino/V0p2_Main/Power_Management.cpp

Rgds

Damon

7  Using Arduino / Networking, Protocols, and Devices / Re: 1.9kHz TWI/I2C clock with F_CPU = 1000000L on: May 05, 2013, 08:22:50 am
Thanks for that!

I'm looking at NG's page too.

Rgds

Damon

PS. Really like your blog!  MCP79410 will be my stand-alone RTC of choice, eg for a PICAXE project, with good supply-voltage range, but with my current AVR project I'm doing the RTC in software, and the whole thing only takes 1.3uA!
8  Using Arduino / Networking, Protocols, and Devices / 1.9kHz TWI/I2C clock with F_CPU = 1000000L on: May 05, 2013, 06:42:17 am
Hi,

I'm using the TWI library to talk to a TMP102 temperature sensor.

It works fine, but I noticed that it was taking rather a long time.

Looking at what the Wire library code was doing (and disassembling) I see:

Code:
  TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
    1f4c: 8d ef        ldi r24, 0xFD ; 253
    1f4e: 80 93 b8 00 sts 0x00B8, r24
  SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
  note: TWBR should be 10 or higher for master mode
  It is 72 for a 16mhz Wiring board with 100kHz TWI */

which gives a TWI clock of somewhat under 2kHz rather than the desired 100kHz, I think!

Rather boldly, after Wire.begin() I have put
Code:
TWBR = 0
which seems to work, and according to the ATmega datasheet should give me a TWI SCL speed of 62.5kHz with my 1MHz CPU clock, which is much nearer the mark.

This seems to work, and much faster, though is hacky, and I feel dirty putting a 0 into a division register!

Can anyone see a problem with this, or a better way to achieve it without giving up the Wire library entirely?

Rgds

Damon
9  Using Arduino / Project Guidance / Re: High Capacity UPS Power Supply, lead-acid battery, multiple devices and voltages on: April 25, 2013, 03:50:24 pm
An efficient car USB power supply will get you to 5V, and a sensible battery charger will keep your SLA happy.

A low-dropout 3.3V regulator or two will get you from 5V to 3.3V.

I run my entire server system from off-grid solar at 12V, with switching regulators and car USB supplies to get me 5V for my SheevaPlug server and other stuff...

http://www.earth.org.uk/note-on-SheevaPlug-setup.html

Rgds

Damn
10  Using Arduino / Programming Questions / Re: Using Serial in a library on: April 22, 2013, 01:26:47 pm
It's not "supposed" to be anything.  And I also said "may", ie depends on circumstances and taste.

It may be important to ensure:

a) that everything is sent before the Serial subsystem is turned off or reset with the .begin() for example

b) that huge amounts of stuff isn't being queued unexpectedly, or even causing overruns and loss later.  The fact that only some of the output was seen was what made me think that flush() might help pin it down.  Synchronous behaviour is easier to understand and debug.

Rgds

Damon
11  Using Arduino / Programming Questions / Re: Using Serial in a library on: April 22, 2013, 05:27:56 am
You may also find flush() useful to ensure that all the text has actually been sent down the wire before you move on to the next item...

Rgds

Damon
12  Using Arduino / Programming Questions / Timer 2 async and CPU clock on: April 20, 2013, 08:51:36 pm
Hi,

Looking at Amtel's app note 2505, talking about running timer 2 in async mode as I am with a 32768Hz crystal, it says:

Note:   The external clock frequency should be in the interval [0 Hz .. 256 kHz] and maximum CK/4.

Now is 'CK' the prescaled or non-prescaled CPU clock?

The reason I ask is that the technique I'm using for low-power timed delays is to drop the CPU speed to minimum (31250Hz, given use of the 8MHz RC clock and a prescaling of 256) while looping in _delay_loop_2().

If that CK is the CPU clock speed after prescaling then I'll need to run the CPU 8x faster, which is a pity, and I may want to find another technique.

Rgds

Damon
13  Topics / Home Automation and Networked Objects / OpenTRV project for Arduino/ATmega328P on: April 20, 2013, 01:56:02 pm
For anyone who wants to follow along, I'm doing the V0.2 implementation of OpenTRV (http://opentrv.org.uk/) here:

https://sourceforge.net/p/opentrv/code-0/HEAD/tree/trunk/Arduino/V0p2_Main/

See timetable:

http://www.earth.org.uk/open-source-programmable-thermostatic-radiator-valve.html#timelineTo201310

This is a bare ATmega328P programmed to run at 1MHz from its internal RC oscillator so it can run off 2xAA NiMH batteries (~2V) and uses a 32768Hz crystal (with timer 2) for accurate time-keeping.

Rgds

Damon
14  Using Arduino / Microcontrollers / Re: ATmega328P targeted at low-power battery use: help needed with baby steps! on: April 17, 2013, 11:38:41 am
So, if I put the .c (etc) files in that directory, how does a hex file built against the correct preprocessor directives (such as F_CPU) happen?

Rgds

Damon
15  Using Arduino / Microcontrollers / Re: ATmega328P targeted at low-power battery use: help needed with baby steps! on: April 17, 2013, 08:57:48 am
Unfortunately I don't currently even have anything as basic as "make" on my ageing Mac, and my puny SheevaPlug doesn't really have space.

I *could*/should try and set up a build/dev environment in the corner of one of my chunky hosted servers, but it somehow feels evil using a big fat machine half around the world away to do my uC builds.  Still, that's the "cloud" I suppose!

Rgds

Damon
Pages: [1] 2