Pages: 1 ... 4 5 [6] 7   Go Down
Author Topic: i2c Pressure Sensor  (Read 9935 times)
0 Members and 1 Guest are viewing this topic.
London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Has anyone had success using this library with the most recent distribution 0018?

The code posted compiles without errors on 0018, although I have only tested this on a windows machine.

What errors did you get?
Logged

Halifax, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Don't anthropomorphize computers. They hate that.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I get two errors with the newer sketch. I'm running Ubuntu Linux 9.04 and Arduino release 0018 (with the revisions to Wiring.h as prescribed earlier in this thread):

/home/mbl/Desktop/arduino-0018/hardware/arduino/cores/arduino/HardwareSerial.cpp: In member function 'void HardwareSerial::begin(long int)':

/home/mbl/Desktop/arduino-0018/hardware/arduino/cores/arduino/HardwareSerial.cpp:144: error: 'abs' was not declared in this scope


Thanks for the quick response... I'm anxious to get the new sketch working since, as you say, it may give more reliable data than the original one through averaging.
Logged

Halifax, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Don't anthropomorphize computers. They hate that.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The changes that I made to wiring.h broke other sketches in 0018, so I restored wiring.h back to its original state.

With the original wiring.h, I receive a different set of errors:

/usr/lib/gcc/avr/4.3.2/../../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

/usr/lib/gcc/avr/4.3.2/../../../avr/include/stdlib.h:111: error: expected `)' before 'int'

/usr/lib/gcc/avr/4.3.2/../../../avr/include/stdlib.h:111: error: expected `)' before 'int'


These errors look familiar to me but I don't know my way around things well enough to make sense of this.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the errors are because there are some definitions in wiring.h that cause conflicts with the standard C libraries.

try replacing the includes in the HP03.cpp library  so just the following are included:

#include <avr/pgmspace.h>
#include <WProgram.h>
#include <FrequencyTimer2.h>
#include <Wire.h>
#include "HP03.h"


The top of the file should look like this:
Code:
/*
  HP03.cpp - Arduino library support for HP03 Pressure sensor
Copyright (c)2008 Michael Margolis All right reserved

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  Version:   1.0 - July14 2008
*/

// Note that this code uses the return values in Arduino version 0012 wire.c library

#include <avr/pgmspace.h>
#include <WProgram.h>
#include <FrequencyTimer2.h>
#include <Wire.h>
#include "HP03.h"

#if !defined(NULL)
#define NULL 0
#endif

The rest of the file should be unchanged
« Last Edit: March 14, 2010, 09:23:25 am by mem » Logged

Halifax, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Don't anthropomorphize computers. They hate that.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks! I'll take a look later today.

Is it easy to explain why the second include does not have a "#" in front of it?
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

its a cut and paste errror

I have modifed the post to show the correct includes
Logged

Halifax, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Don't anthropomorphize computers. They hate that.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No joy. Precisely the same errors (as I last mentioned in reply 77) remain. One thing I did not notice earlier is that in the upper sketch code portion of the window, the FrequencyTimer2 include is highlighted, suggesting that the problem is there...?

[glow]#include <FrequencyTimer2.h>[/glow]
« Last Edit: March 14, 2010, 01:46:44 pm by nscadarduino » Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If the problem is in FrequencyTimer2 then try moving this include:
  #include <wiring.h>
from FrequencyTimer2.h to  FrequencyTimer2.cpp
Logged

Halifax, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Don't anthropomorphize computers. They hate that.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

When I moved the include as instructed, I encountered these errors:

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.h:30: error: 'uint8_t' does not name a type

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp:27: error: 'uint8_t FrequencyTimer2::enabled' is not a static member of 'class FrequencyTimer2'

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::setPeriod(long unsigned int)':

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp:96: error: 'enabled' is not a member of 'FrequencyTimer2'

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::enable()':

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp:146: error: 'enabled' is not a member of 'FrequencyTimer2'

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::disable()':

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp:156: error: 'enabled' is not a member of 'FrequencyTimer2'


I thought that maybe I should have not removed the include from FrequencyTimer2.h, so I put it back in, but this did not change the situation from the three errors encountered before.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

try including only <WProgram.h> in FrequencyTimer2.h
Logged

Halifax, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Don't anthropomorphize computers. They hate that.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks mem, it works, and it's a beautiful thing! If I'm ever in London I'll buy you a beer.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

good to hear you have it going.

Have fun
Logged

Halifax, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Don't anthropomorphize computers. They hate that.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I ran the sketch overnight but at some point it hung, giving an indeterminate number of error statements in red. I had hoped to be able to transcribe the error but Arduino 0018 has frozen and the window is now white. I remember that it mentioned that it was a JAVA out of memory error.

I realize that this could be caused by a wide variety of factors, but we did make some changes to some of the libraries and I thought I should mention it.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like its the Serial monitor, do you have another serial program you could use to view the serial output  to ensure that is ok.

I don't think anything that was changed on the arduino side would cause the Serial Monitor to freeze.
Logged

Halifax, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Don't anthropomorphize computers. They hate that.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you're right; I restarted 0018 and left the Serial Monitor open. When I returned about 6 hours later the program had hung again.

I just installed a program called "GtkTerm"--also known as "Serial Port Terminal"--and when I started it up and selected the USB port that connects to my Duemilanove, the data streamed right in.

I'll be jettisoning the Serial Monitor anyway in favour of an LCD display (for now anyway). Thanks again.
Logged

Pages: 1 ... 4 5 [6] 7   Go Up
Jump to: