Show Posts
Pages: 1 [2] 3 4 ... 7
16  Using Arduino / Programming Questions / Re: Subtraction convenience on: August 17, 2012, 09:34:09 pm
I figured out the issue. It was part of a different process.
17  Using Arduino / Programming Questions / Re: Subtraction convenience on: August 17, 2012, 09:14:57 pm
I was posting relavent code.
18  Using Arduino / Programming Questions / Subtraction convenience on: August 17, 2012, 09:04:18 pm
I would like to take advantage of the fact that large numbers subtracted from small numbers returns negative numbers, but this doesn't seem to work in arduino. I am curious why this doesn't work? So:
Code:
int small = 1000;
int large = 1500;
serial.println(small - large); //I get something like 6500 rather than -500. I smell binary issues.
19  Using Arduino / Programming Questions / Re: PinChangeInt within a custom library on: August 05, 2012, 03:12:29 pm
It just occurred to me that the shield I'm using for my project prevents me from being able to use INT0 and INT1. I'll keep an eye on your blog though, I may end up doing another RC project!
Thank you for the help.
20  Using Arduino / Programming Questions / Re: PinChangeInt within a custom library on: August 05, 2012, 02:26:00 am
This is my first RC project so I got a cheapie: http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=8338
21  Using Arduino / Programming Questions / Re: PinChangeInt within a custom library on: August 04, 2012, 04:02:41 pm
I'll need to buy more diodes (As of now I have 2 haha). I'm using a 4ch Tx with a 6ch Rx, but I'm assuming you're using interrupts for timing so that shouldn't cause any problems right?
22  Using Arduino / Programming Questions / Re: PinChangeInt within a custom library on: August 04, 2012, 02:42:42 am
Hahaha this is perfect... smiley-lol

My library is actually based off of one of your blog posts I found some weeks ago. I absolutely loved the way you integrated interrupts and unsigned value types for time efficiency. I very much appreciate the time you've invested in your blog.

I am in the testing stages of a library which drops some of the flexibility to give a smaller, faster, more accurate RC Solution.

If you are at the bench stage of your project, let me know if you would be interested in doing some bench testing of the new library.

That sounds awesome. I would love to try it out.
23  Using Arduino / Programming Questions / Re: PinChangeInt within a custom library on: August 03, 2012, 10:35:23 pm
Thank you so much!
It's too bad there isn't a more convenient and conservative way, but it works!
24  Using Arduino / Programming Questions / PinChangeInt within a custom library on: August 03, 2012, 09:10:31 pm
Howdy,
I'm working with PinChangeInt in my custom library, and I am curious how to use the attach interrupt function with a private function in my class? Here is my code:
.h:
Code:
#ifndef RXTX_H
#define RXTX_H
#include    "Arduino.h"

class RxTx
{
public:
    RxTx(byte ch1, byte ch2, byte ch3, byte ch4, byte bat);
    ...
private:
    void calcThrottle();
    void calcAileron();
    void calcElevator();
    void calcRudder();
};

#endif
.cpp:
Code:
#include    <Arduino.h>
#include    <RxTx.h>
#include    "/Applications/Arduino.app/Contents/Resources/Java/libraries/PinChangeInt/PinChangeInt.h"

...

byte throttle;
byte aileron;
byte elevator;
byte rudder;

...


RxTx::RxTx(byte ch1, byte ch2, byte ch3, byte ch4, byte bat)
{
    init();

    pinMode(ch1, INPUT);
    pinMode(ch2, INPUT);
    pinMode(ch3, INPUT);
    pinMode(ch4, INPUT);
    pinMode(bat, OUTPUT);
   
    digitalWrite(bat, LOW);
   
    throttle = ch3;
    aileron = ch1;
    elevator = ch2;
    rudder = ch4;
   
    //This is where I'm attaching the interrupts
    PCintPort::attachInterrupt(throttle, calcThrottle, CHANGE); // This doesn't work.
    PCintPort::attachInterrupt(aileron, calcAileron, CHANGE); //   It brings up an error that says
    PCintPort::attachInterrupt(elevator, calcElevator, CHANGE);// "No matching function for call to 'PCintPort::attachInterrupt
    PCintPort::attachInterrupt(rudder, calcRudder, CHANGE); //     (byte&, <unresolved overloaded runction type>, int)'"
}

...

//These are the private functions I am trying to attach

void RxTx::calcThrottle()...

void RxTx::calcAileron()...

void RxTx::calcElevator()...

void RxTx::calcRudder()...

As always, help is greatly appreciated! smiley
25  Using Arduino / Programming Questions / Re: "Request for member ' ' in ' ', which is of non class type ' '" on: August 03, 2012, 06:15:56 pm
Ohhh right! Hahahahaha thanks!
26  Using Arduino / Programming Questions / "Request for member ' ' in ' ', which is of non class type ' '" on: August 03, 2012, 05:13:56 pm
You know what the error (title) means. I'm sure you've probably run across it too... If so, I'd appreciate some help!  smiley-sweat
I've been coming close to banging my head against the table for the last hour or so trying to figure out why I'm getting this error. Again. I'd really appreciate some help figuring out why I'm getting this error: "request for member 'measureIMU/readIMU' in 'vector', which is of non-class type 'IMU () ()'"

.ino:
Code:
#include <IMU.h>

//Macros
#define  X  0

IMU  vector();

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

void loop()
{
  vector.measureIMU();
  Serial.print(vector.readIMU(X));
  Serial.println();
}

.h:
Code:
#ifndef IMU_H
#define IMU_H
#include    "Arduino.h"

class IMU
{
public:
    IMU();
    void measureIMU();
    byte readIMU(byte axis);
private:
    ...
};

#endif

.cpp:
Code:
#include    <Arduino.h>
#include    "IMU.h"

...

//Initializer
IMU::IMU()
{
    init();
    ...
}

byte IMU::readIMU(byte axis)
{
    ...
}

void IMU::measureIMU()
{
    ...
}
...
27  Using Arduino / Programming Questions / Re: sbyte? on: August 03, 2012, 03:30:34 pm
Awesome. Thanks.
28  Using Arduino / Programming Questions / sbyte? on: August 03, 2012, 03:24:47 pm
Does Arduino have a close alternative to sbyte? Or is short the smallest signed value type possible?
29  Using Arduino / Programming Questions / Re: Custom class is preventing code execution? on: July 31, 2012, 10:53:12 pm
Thanks! You rock!
30  Using Arduino / Programming Questions / Custom class is preventing code execution? on: July 31, 2012, 07:13:43 pm
I have converted a set of functions into a library. I know that the functions work properly, and because of this I know that something in my class outside of the functions is keeping my program from executing (setup() and loop() aren't executing). My suspicion is that there is an undetected error with the inclusion of "Wire.h" within the custom class. I believe this one is over my head and I'd really appreciate some help.

.h:
Code:
#ifndef ITG3200_h
#define ITG3200_h

#include    "Arduino.h"

class ITG3200
{
public:
    ITG3200();
    int readITG3200(byte axis);
private:
    unsigned char itgRead(char address, char registerAddress);
    void itgWrite(char address, char registerAddress, char data);
};
#endif

.cpp:
Code:
#include    <Arduino.h>
#include    "ITG3200.h"
#include    "/Applications/Arduino.app/Contents/Resources/Java/libraries/Wire/Wire.h"

//Macros
#define X   0
#define Y   1
#define Z   2

//Parameters
char WHO_AM_I = 0x00;
char SMPLRT_DIV = 0x15;
char DLPF_FS = 0x16;
char GYRO_XOUT_H = 0x1D;
char GYRO_XOUT_L = 0x1E;
char GYRO_YOUT_H = 0x1F;
char GYRO_YOUT_L = 0x20;
char GYRO_ZOUT_H = 0x21;
char GYRO_ZOUT_L = 0x22;

//Settings
char DLPF_CFG_0 = 1<<0;
char DLPF_CFG_1 = 1<<1;
char DLPF_CFG_2 = 1<<2;
char DLPF_FS_SEL_0 = 1<<3;
char DLPF_FS_SEL_1 = 1<<4;

//I2C address
char itgAddress = 0x69;


ITG3200::ITG3200()
{
    Wire.begin();
   
    //Set the gyroscope scale for the outputs to +/-2000 degrees per second
    itgWrite(itgAddress, DLPF_FS, (DLPF_FS_SEL_0|DLPF_FS_SEL_1|DLPF_CFG_0));
   
    //Set the sample rate to 100 hz
    itgWrite(itgAddress, SMPLRT_DIV, 9);
}

void ITG3200::itgWrite(char address, char registerAddress, char data)
{
    //Write a value to a register on the itg-3200
    Wire.beginTransmission(address);
    Wire.write(registerAddress);
    Wire.write(data);
    Wire.endTransmission();
}

unsigned char ITG3200::itgRead(char address, char registerAddress)
{
    unsigned char data = 0;
   
    //Send the register address to be read.
    Wire.beginTransmission(address);
    Wire.write(registerAddress);
    Wire.endTransmission();
   
    //Ask the I2C device for data
    Wire.beginTransmission(address);
    Wire.requestFrom(address, 1);
   
    //Wait for a response from the I2C device
    if(Wire.available()){
        data = Wire.read();
    }
   
    Wire.endTransmission();
   
    return data;
}

int ITG3200::readITG3200(byte axis)
{
    int data = 0;
   
    if (axis == X) {
        data = itgRead(itgAddress, GYRO_XOUT_H)<<8;
        data |= itgRead(itgAddress, GYRO_XOUT_L);
    } else if (axis == Y) {
        data = itgRead(itgAddress, GYRO_YOUT_H)<<8;
        data |= itgRead(itgAddress, GYRO_YOUT_L);
    } else if (axis == Z) {
        data = itgRead(itgAddress, GYRO_ZOUT_H)<<8;
        data |= itgRead(itgAddress, GYRO_ZOUT_L);
    }
   
    return data;
}

.pde:
Code:
#include "Wire.h"
#include "ITG3200.h"

#define  X  0
#define  Y  1
#define  Z  2

ITG3200  ITG;

void setup()
{
  Serial.begin(9600);
  Serial.println("Setup"); //This isn't printing
}

void loop()
{
  Serial.println("Loop"); //This isn't printing
  Serial.print(ITG.readITG3200(X));
  Serial.print("\t");
  Serial.print(ITG.readITG3200(Y));
  Serial.print("\t");
  Serial.print(ITG.readITG3200(Z));
  Serial.println();
}
Pages: 1 [2] 3 4 ... 7