Show Posts
Pages: 1 2 [3] 4 5 6
31  Using Arduino / Project Guidance / Polling BMP085 Barometric Pressure Sensor with Interrupts? on: June 01, 2012, 11:38:35 am
I want to read the barometric pressure with a BMP085 pressure sensor, at (say) 5 second intervals.

I've checked the sensor with the simple sketch provided with the Adafruit_BMP085 library, and it works fine.

Ideally I want to poll the sensor with interrupts, so with this in mind I tried the example sketch from the TimerOne library, which just flashes an led, and that worked fine.

I then tried to patch the code for reading the BMP085 sensor into the ISR of the TimerOne example, but it doesn't work - it seems to get stuck in the ISR. I left the code for cycling the led for troubleshooting.

This is the sketch I tried:

Code:
#include <TimerOne.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>

Adafruit_BMP085 bmp;

float t;
unsigned int p;
 
void setup()
{
  pinMode(13, OUTPUT);   
  Serial.begin(9600);
  bmp.begin();
 
  Timer1.initialize(100000);
  Timer1.attachInterrupt(timerIsr);
}
 
void loop()
{
  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.println(" C");
  Serial.print("Pressure = " );
  Serial.print(p * 7.5006168E-3);
  Serial.println(" mmHg");
}
 
/// --------------------------
/// Custom ISR Timer Routine
/// --------------------------
void timerIsr()
{
  digitalWrite( 13, digitalRead( 13 ) ^ 1 );
  t = bmp.readTemperature();
  p = bmp.readPressure();
}

I've got a feeling that I'm missing something regarding interrupts, and would be grateful for any suggestions, please.

Jim
32  Development / Other Software Development / Re: In what IDE do you write libraries for Arduino? on: May 17, 2012, 08:58:34 am
Quote
emacs
I didn't know that anyone had gone and done an arduino-mode !

It looks like there is an "arduino-mode.el" that does basic C-style stuff, but compilation/upload is part of CEDET instead?
http://www.emacswiki.org/emacs/CollectionOfEmacsDevelopmentEnvironmentTools

I had CEDET installed and Semaintic and EDE enabled. The frustrating thing is that initially the compilation and upload to an arduino worked so well!

Jim
33  Development / Other Software Development / Re: In what IDE do you write libraries for Arduino? on: May 16, 2012, 08:48:30 am
Is anyone using the arduino-mode for Emacs?

I installed it in emacs 23 (and also a 24 snapshot), and initially it worked fine. I got highlighting of the code and best of all was able to compile and upload it to the arduino using EDE. I also got a serial window. It seems to be broken now, and all I get is the highlighting, but not the compile/upload/serial window functions.

I've tried uninstalling and reinstalling emacs, but it makes no difference.

Does anyone know what the problem might be, please?

Jim
34  Using Arduino / Project Guidance / Re: Anyone using Emacs with the CEDET package for project management? on: April 23, 2012, 01:03:46 pm
I decided to install emacs 24 to try to get the full features of CEDET, and grabbed the 24.1.50.1 snapshot.

It installed fine and initially I was able to compile, upload to the board and display a serial terminal, it worked well and looked like I was in business.

I now find that I can't get the EDE arduino features - upload and serial terminal, and for the life of me can't find out why!

I've tried un-installing and re-installing  all the emacs stuff, including renaming the ~/.emacs file and ~/.emacs.d directory, to no effect. I'm now at a loss as to what to try next and would welcome suggestions.

Jim
35  Using Arduino / Project Guidance / Re: Anyone using Emacs with the CEDET package for project management? on: April 17, 2012, 11:25:07 am
Thanks for the reply, Eric.

I'm try altering the version number as you suggest and see how I get on. I'll have a look at joining the mailing list as well.
36  Using Arduino / Project Guidance / Anyone using Emacs with the CEDET package for project management? on: April 13, 2012, 08:12:57 am
I like Emacs for text editing and have used it for years. I'm currently using it as an external editor from Arduino projects.

I've installed the CEDET package, which should enable me to manage an Arduino project fully from within Emacs. but am having trouble getting a handle on it. I've had a google, but can't find a tutorial on using EDET with the Arduino.

I've had a tentative play with the EDE tools, but whatever I do I seem to get the error:

"Invalid versions syntax: '0022ubuntu0.1' "

Which appears to refer to the Arduino IDE version number.

Can anyone suggest a tutorial to get me started, or have any other suggestions, please?

Jim
37  Using Arduino / Programming Questions / Re: Global variables and scope on: April 12, 2012, 05:07:04 pm
Thanks for the reply 'skyjumper' - I'll give it a try.

Jim
38  Using Arduino / Programming Questions / Re: Global variables and scope on: April 12, 2012, 02:57:58 pm
Thanks for the reply.

I was afraid the 'e' word would get mentioned - I've never really got to grips with the subject!

I thought variables defined outside of any function were external anyway, and are visible throughout the program!

Jim
39  Using Arduino / Programming Questions / Global variables and scope on: April 12, 2012, 01:49:48 pm
I've always understood that variables declared outside of a function, including setup() and loop() had global scope and are accessible from any function, but are variables global if they're declared in separate project files, but still outside of a function?

My project is spilt into several 'pde' files and in each file I have a variable that's outside of any function. I assumed that these variables would have global scope and be visible to all functions, but it seem not to be so as the compiler is complaining that they haven't been declared where I want to use them. Is there a 'workaround' for this problem, please?

Jim
40  Using Arduino / Programming Questions / Re: PROGMEM problems. on: April 12, 2012, 01:37:09 pm
Thanks again Nick, you've been a great help.

As you demonstrated, the answer was to break the code down into smaller chunks.

Jim
41  General Category / General Discussion / Re: If a program could program itself?.... (AI) on: April 11, 2012, 03:00:23 pm
Quote
with just one more pair of square brackets needed to push them over the edge!
LISP uses round parentheses, hence the acronym Lots of Infuriating Silly Parentheses

Yeah I forgot. The memory had been mercifully erased from my brain!

Jim
42  General Category / General Discussion / Re: If a program could program itself?.... (AI) on: April 11, 2012, 11:48:45 am
I suspect that if such a program could be written, it would be done using 'LISP'.

LISP is (or has been) much used for 'Expert Systems'. I had a look at it years ago, but left it feeling that it could push a person to the edge of insanity - with just one more pair of square brackets needed to push them over the edge!

Jim
43  Using Arduino / Programming Questions / Re: PROGMEM problems. on: April 11, 2012, 11:39:54 am
I've stripped my problem down to the bare bones and it appears to be related to a simple loop as shown in this example:

The following program just prints out character by character parts of the strings. I want to be able to do this rather than do a string copy, because I need to select just the elements that I need.   

With the outer loop commented out, the following works and I can 'hard-wire'  various indexes (within range) for the string_table, and it works fine. If I uncomment the outer loop I just get rubbish printed - not even sensible values for the index 'i'.

I can't understand it - it's as if the outer loop somehow corrupts the inner one.

Code:
#include <avr/pgmspace.h>

const char string_0[] PROGMEM = "String 0";
const char string_1[] PROGMEM = "String 1";
const char string_2[] PROGMEM = "String 2";
const char string_3[] PROGMEM = "String 3";

const char *string_table[] PROGMEM =  \
{   
  string_0,
  string_1,
  string_2,
  string_3
};

char buffer[40];

void setup()  
{
  Serial.begin(9600);

  int i = 0; // Counter for string_table.
 
  // while(i < 4) {

    Serial.println(i); // Show position in string_table.

    int j = 2; // Counter for characters in strings (starting at 'r').
   
    char c;
   
    while((c = pgm_read_word(&string_table[i][j++])))
      Serial.print(c); // Show string character by character, starting at 'r'.
   
    //i++;
  //}
}

void loop() {}


I'm not sure where to go to next. I might just have to copy each string into a buffer in flash memory in turn, and do the substring stuff there, if it's a restriction in using PROGMEM.

Jim
44  Using Arduino / Programming Questions / Re: PROGMEM problems. on: April 11, 2012, 09:40:52 am
Hang on!

while((c = pgm_read_word(&rcs_strings[array_index][string_index++]))" _Does_ work - 'c' returns the characters in the  strings OK, but I've got some extreme weirdness going on in the outer loop!

Embedding it into a loop breaks it. Basically I can hard wire any numbers I like into the array subscript and get sensible results, but as soon as I set up an outer loop to step through the array of strings it falls over.

I'll try to set up an example stripped own to the bare bones to illustrate it!

Jim
45  Using Arduino / Programming Questions / Re: PROGMEM problems. on: April 11, 2012, 04:19:59 am
Thanks again Nick.

It's still got me beat - the lie down didn't help!

You mean from:

"while((c = pgm_read_byte(pgm_read_word(&rcs_strings[array_index][string_index++])))"

to:

"while((c = pgm_read_word(&rcs_strings[array_index][string_index++]))"

which doesn't work.

I'm starting to get desperate and using every combination of pgm_read_word, pgm_read_byte, &, (char*) and brackets that I can think of!

Jim
Pages: 1 2 [3] 4 5 6