Show Posts
Pages: [1] 2 3
1  Forum 2005-2010 (read only) / Troubleshooting / Re: accessing math functions in .cpp file, arduino 18 on: February 09, 2010, 09:46:29 am
nothing named round

including "math.h" in the pde worked!  thank you.
2  Forum 2005-2010 (read only) / Troubleshooting / Re: accessing math functions in .cpp file, arduino 18 on: February 08, 2010, 07:49:49 pm
Hello,

pde includes stats.h
stats.cpp includes stats.h and math.h

I wish to gain access to the routine in stats.cpp
3  Forum 2005-2010 (read only) / Troubleshooting / accessing math functions in .cpp file, arduino 18 on: February 08, 2010, 04:32:27 pm
Hello,

I include a file "stats.h" from my main pde.
in stats.cpp, I wish to use the sqrt function.

If I include "math.h", I get the following errors.

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/math.h:439: error: expected unqualified-id before 'double'

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/math.h:439: error: expected `)' before 'double'

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/math.h:439: error: expected `)' before 'double'

these happen with or without actually trying to call the sqrt function.

any help would be great.

thanks,
Lucas
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: Syntax Error causing boolean / byte to be unkn on: April 02, 2008, 08:38:29 am
Quote
Hi,

the datatype boolean is arduino-(wiring-)  specific.
To use "boolean" it in a library you must include the file "WConstants.h" into your cpp-file before "tank.h" that is using the datatype.

Start the cpp-file with :
Code:
#include "WConstants.h"
#include <Wire.h>
#include "tank.h"

Eberhard

easy enough!  thanks
5  Forum 2005-2010 (read only) / Syntax & Programs / Syntax Error causing boolean / byte to be unknown on: April 01, 2008, 08:26:37 pm
I am sure it is some syntax I am doing.   Oddly enough, if I change all the booleans to say, longs, it compiles ok.

I removed the logic out of the .cpp and the main file to make my troubleshooting easier.

At this point I am stuck, so any help is appreciated.
This is all in Arduino 11

error:
(more or less saying every byte and boolean definition is an issue)
Code:
C:\arduino-0011-win\tmp\/tank.h:24: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:25: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:26: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h: In constructor 'deviceStatus::deviceStatus()':


C:\arduino-0011-win\tmp\/tank.h:29: error: 'powerON' was not declared in this scope


C:\arduino-0011-win\tmp\/tank.h:30: error: 'environmentOK' was not declared in this scope


C:\arduino-0011-win\tmp\/tank.h:31: error: 'programmingError' was not declared in this scope


C:\arduino-0011-win\tmp\/tank.h: At global scope:


C:\arduino-0011-win\tmp\/tank.h:38: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:57: error: variable or field 'writeLEDMask' declared void


C:\arduino-0011-win\tmp\/tank.h:57: error: 'byte' was not declared in this scope


C:\arduino-0011-win\tmp\/tank.h:63: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:64: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:67: error: 'boolean' does not name a type

.pde (main window):
Code:
#include <Wire.h>
#include "tank.h"

//remove later, for testing
byte mask1 = B10101010;
byte mask2 = B01010101;

//used to toggle status light
long counter = 0;
byte statusMask;

char* dow[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

 

void setup() {

  Wire.begin();
  Serial.begin(9600);

  // shift register (LED) outputs
  pinMode(SHIFT_REGISTER_CLOCK, OUTPUT);
  pinMode(SHIFT_CLOCK, OUTPUT);
  pinMode(SHIFT_OUT, OUTPUT);
  
  pinMode(LIGHT_POWER, OUTPUT);
  pinMode(HUM_POWER, OUTPUT);
}

void loop() {

}



.h:
Code:
#define SHIFT_OUT                4
#define SHIFT_REGISTER_CLOCK     5
#define SHIFT_CLOCK              6

#define SENSOR_CLOCK             2
#define SENSOR_DATA              3

#define LIGHT_POWER              7
#define HUM_POWER                8

#define readHumMask              B00000101
#define readTempMask             B00000011
#define clearMask                B00011110
#define readStatusMask           B00000111
#define writeStatusMask          B00000110
#define softResetMask            B00011110
#define heatOn                   B00000100
#define heatOff                  0



class deviceStatus {
  public:
    boolean powerON;
    boolean environmentOK;
    boolean programmingError;
  
  deviceStatus() {
    powerON = false;
    environmentOK = false;
    programmingError = false;
  }
};

typedef struct {
  double temp;
  double humidity;
  boolean readError;
} envStatus;


typedef struct {
  int hour;
  int minute;
  int second;
  int month;
  int day_of_week;
  int day;
  int year;
} time;


// TIME
void readTime(time *retTime);

// STATUS DISPLAY
void writeLEDMask(byte mask);

// SHT15
void readSensor(envStatus *retEnv);
double convertHumidity(int data);
double convertTemperature(int data);
boolean turnHeatOn();
boolean turnHeatOff();
int readMeasurement();
int readRegister();
boolean writeByte(byte output);
int readByte();
int shiftIn();
void transmissionStart();
void clearInterface();


.cpp:
Code:
#include "tank.h"
#include <Wire.h>

6  Forum 2005-2010 (read only) / Syntax & Programs / Re: parameters by reference (pointers) on: April 01, 2008, 04:20:04 pm
Quote
You need to #include "tank.h" from tank.cpp.  You might also have some other errors, but they should be relatively straightforward.
Works!  thanks
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: parameters by reference (pointers) on: April 01, 2008, 03:37:52 pm
Thanks everyone,
but still no luck.

I turned on verbose logging but didn't see any new info to put in a command prompt.
I am working with Arduino 11 now.

I looked at the temporary build folder and the .cpp / .h 's there seem fine, do not look garbled.  I can not analyze the .o

here is the exact code I am currently working with.

All the files are included as part of the tank_final project and reside in the same folder as the .pde file.
Files are "tank.cpp" "tank.h" and the main window

With this exact setup on Arduino 11 I still see:
error: variable or field 'readTime' declared void

"tank.h" :
Code:
#define SHIFT_OUT                4
#define SHIFT_REGISTER_CLOCK     5
#define SHIFT_CLOCK              6



#define SENSOR_CLOCK             2
#define SENSOR_DATA              3

#define readHumMask              B00000101
#define readTempMask             B00000011
#define clearMask                B00011110
#define readStatusMask           B00000111
#define writeStatusMask          B00000110
#define softResetMask            B00011110
#define heatOn                   B00000100
#define heatOff                  0


typedef struct {
  int hour;
  int minute;
  int second;
  int month;
  int day_of_week;
  int day;
  int year;
} time;



// TIME
void readTime(time *retTime);


"tank.cpp" :
Code:
#include <Wire.h>


void readTime(time *retTime) {
  
  int hour;
  int minute;
  int second;
  int month;
  int day_of_week;
  int day;
  int year;
  
  // Below required to reset the register address to 0.
  Wire.beginTransmission(104); // transmit to device #104, the ds 1307
  Wire.send(0x00);
  Wire.endTransmission();    // stop transmitting
 
  Wire.requestFrom(104, 7);    // request 7 bytes from slave ds1307, we'll assume it'll send them all even though it doesn't have to
  second = Wire.receive();  
  minute = Wire.receive();  
  hour = Wire.receive();  
  day_of_week=Wire.receive();  
  day = Wire.receive();  
  month = Wire.receive();  
  year = Wire.receive();  
 
  // Convert all the BCD values that might have "tens" to decimal.  Most arduino folks do this w/shifts but this just looks easier to me.
  hour=hour/16 * 10 + hour % 16;
  minute=minute/16 * 10 + minute % 16;
  second=second/16 * 10 + second % 16;
  day=day/16 * 10 + day % 16;
  month=month/16 * 10 + month % 16;
  year=2000 + year/16 * 10 + year % 16;
  
  Serial.print(hour);
  Serial.print(":");
  if (minute < 10) { Serial.print("0"); }
  Serial.print(minute);
  Serial.print(":");
  if (second < 10) { Serial.print("0"); }
  Serial.print(second);
  Serial.print(" ");
  Serial.print(dow[day_of_week-1]);  // array is 0-6, but the dow register holds 1-7, so subtract 1.
  Serial.print(", ");
  Serial.print(month);
  Serial.print("/");
  Serial.print(day);
  Serial.print("/");
  Serial.print(year);
  Serial.print("\n");
  
  retTime->hour = hour;
  retTime->minute = minute;
  retTime->second = second;
  retTime->month = month;
  retTime->day_of_week = day_of_week;
  retTime->day = day;
  retTime->year = year;


}



Main Window:
Code:
#include <Wire.h>
#include "Tank.h"

//remove later, for testing
byte mask1 = B10101010;
byte mask2 = B01010101;

char* dow[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

 
void setup() {

  Wire.begin();
  Serial.begin(9600);

  // shift register (LED) outputs
  pinMode(SHIFT_REGISTER_CLOCK, OUTPUT);
  pinMode(SHIFT_CLOCK, OUTPUT);
  pinMode(SHIFT_OUT, OUTPUT);
}

void loop() {
  
  //time curTime;
  //envStatus environment;

  //write_led_mask(mask1);
  delay(1000);
  
  //write_led_mask(mask2);    
  delay(1000);
  
  Serial.println("SSS on sensor");
  // remember deal with the heat and what not
  Serial.println("TTT on time");
}


8  Forum 2005-2010 (read only) / Syntax & Programs / Re: parameters by reference (pointers) on: March 23, 2008, 08:49:34 am
Quote
If you are running that code in the primary sketch tab, then I suspect the Arduino IDE auto-prototyping is mangling the definition of readTime. Have you tried it in a seperate cpp in a second tab?
Added a new .cpp in a seporate tab and moved the code over there.  Got a few issues so I only left the definition for
void readTime(time * retTime);
and got the same error.

Tried downloading Arduino 009, as I was using 007 - same issue.

Since you say Arduino auto prototypes I tried removing my prototypes and I get the same error.

I'm about to use global variables, but that's going to make that code sloppy.

Any other ideas?

Thanks
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: parameters by reference (pointers) on: March 22, 2008, 04:55:00 pm
that's so weird tho, I'm not returning anything?

that would define a program that takes a pointer and returns a pointer of the same type.

strange,
thanks tho!!

anyone else have some insight?
10  Forum 2005-2010 (read only) / Syntax & Programs / parameters by reference (pointers) on: March 22, 2008, 01:42:49 pm
Call me crazy,
but I am having a very difficult time passing a structure pointer as a parameter.

I am passing structs, which yes probably complicates it a little but I really don't know what is wrong.  I know C/C++ and am just trying to figure out how this lang works.

In the .h :

struct time {
  int hour;
  int minute;
  int second;
  int month;
  int day_of_week;
  int day;
  int year;
};

in the .cpp :

void readTime(time *retTime) {
}

Compiler says:
error: variable or field 'readTime' declared void In function 'void readTime(time*)':

I am at a loss!  I'm not even calling the thing.
on the note of parameters:

Can I pass a c++ style reference? void function(int &refInt);
Can I pass a struct / class pointer?  I know they are the same in c++ but I'm not sure with this environment.  Based on what I just posted it looks like I can't.

Thanks!
Lucas
11  Forum 2005-2010 (read only) / Interfacing / Re: Arduino RX/TX pins to FT232RL Breakout Board on: May 23, 2008, 08:22:47 pm
Darn I mixed myself up.
I never had a parity bit!  I meant one stop bit.

I am playing with it now.  There is only one USB device connected to my computer so it's connecting to the correct port.
No output on either of my FT232RL boards smiley-sad
(I bought two to make sure one wasn't faulty)

Why does the TX led blink when I have USB connected to the arduino but otherwise it doesn't?
Technically it should still be writing to the TX pin right?  Unless it's waiting for some kind of hardware synch.

I'm lost  :-[
12  Forum 2005-2010 (read only) / Interfacing / Re: Arduino RX/TX pins to FT232RL Breakout Board on: May 23, 2008, 11:28:55 am
but it's odd how with the parity it worked when I had the USB connected to the Arduino board directly (rather than the FT232RL Breakout)
13  Forum 2005-2010 (read only) / Interfacing / Re: Arduino RX/TX pins to FT232RL Breakout Board on: May 23, 2008, 11:27:51 am
I was powering with the power supply to avoid having extra USB serial connections.

I will try with no parity!
Thanks
14  Forum 2005-2010 (read only) / Interfacing / Arduino RX/TX pins to FT232RL Breakout Board on: May 23, 2008, 07:39:10 am
I am attempting to use a FT232RL chip to connect to a third party memory card writer.  I eventually want to use the Arduino to control this memory card writer. I am having some issues so I would like to first make sure I can communicate through the FT232RL chip from my computer.  This would allow me to manually send commands to the memory card writer and see what's going on.

I bought a FT232RL breakout board from spark fun.
http://www.sparkfun.com/commerce/product_info.php?products_id=718

I loaded a simple serial_write program and tested it via USB serial to the Arduino and Hyper Terminal.
Hyper Terminal connected with 8 data bits, 1 parity bit, 9600baud, and no flow control.
Works fine I see the output.

Next I would like to do this using the FT232RL and the Arduino RX/TX pins.  This will prove to me that I can read from the FT232RL Breakout correctly using Hyper Terminal.

Plugged the FT232RL breakout into an Arduino Diecimila, as it provides a 3.3v power supply.
I plugged the RX/TX into the Arduino pins 0/1.
I start it up, and nothing.
Hyper Terminal is connecting the same way as to the Arduino directly.

Do I need to do something special in order to get Serial written to pins 0/1?

Thanks!
15  Forum 2005-2010 (read only) / Development / Re: Library for DS1307 Real Time Clock on: November 18, 2007, 09:58:40 pm
I'm using Matt's code for the DS1307.
I bought the breakout package from SparkFun, so it has the oscillator and battery connected.
Anyhow, I am successfully able to read and write the time, but the time does not advance.

I decided to double check my sanity so I read the entire second byte, not just the section that contains the 0-60 seconds.
The value is 0 (as matt's library sets it all to 0 when you do RTC.start(), so the oscillator should be enabled.

Any idea what else I can check for?

thanks
Pages: [1] 2 3