Show Posts
Pages: 1 2 [3] 4 5 ... 7
31  Using Arduino / Programming Questions / Re: Class initializer problem on: July 31, 2012, 06:41:35 pm
Thanks! You're awesome  smiley-cool
32  Using Arduino / Programming Questions / Class initializer problem on: July 31, 2012, 06:06:11 pm
Howdy,
I'm sure this is one of those problems dancing right in my face and I don't see it, but I can't for the life of me figure it out. I'm getting an error that says "Expected constructor, destructor, or type conversion..."

I don't think the problem is in .cpp so I'll just post .h for now:
Code:
#ifndef ITG3200
#define ITG3200

#include    "Arduino.h"

class ITG3200
{
public:
    ITG3200();
    int readITG3200(byte axis);
};
#endif

Here is the relevant code in .pde
Code:
#include "ITG3200.h"

ITG3200  gyro;

I appreciate any help!
33  Using Arduino / Programming Questions / Re: Fast scaling accelerometer readings on: July 26, 2012, 08:10:09 pm
I decided to go with a memory efficient version of the map() function:
Code:
uint8_t mapAccel (uint8_t x, uint8_t in_min, uint8_t in_max, uint8_t out_min, uint8_t out_max)
{
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

I scaled the values to g-force * 10.
34  Using Arduino / Programming Questions / Re: Fast scaling accelerometer readings on: July 26, 2012, 07:33:23 pm
Yes that's correct. I was using a function, but it uses FP math. Of course that is not the most time efficient method of calculation, so I was wondering if there is an alternative means of execution.
35  Using Arduino / Programming Questions / Fast scaling accelerometer readings on: July 26, 2012, 05:20:43 pm
What is the fastest (I do not mean most convenient) way to scale accelerometer readings to represent radians?
36  Topics / Science and Measurement / Re: Manipulating the behavior of an exponential function (Math gurus needed!) on: July 25, 2012, 12:54:09 pm
I'm using unsigned 16 bit integers (uint16_t) so I'd assume that will work? I'll give it a shot. @MichaelMeissner also suggested using this method of calculation (not in this thread).
37  Topics / Science and Measurement / Re: Manipulating the behavior of an exponential function (Math gurus needed!) on: July 23, 2012, 02:43:38 pm
For the curious, here is the equation I am now using: y=((1/897.8 )*(x-1080)^2)+1500
38  Topics / Science and Measurement / Re: Manipulating the behavior of an exponential function (Math gurus needed!) on: July 23, 2012, 02:16:18 pm
See if this has a noticeable effect:

y = 1500 + .004455(x-1080)*(x-1080)

Wow. Genius. I should have thought of that earlier! smiley-razz
39  Topics / Science and Measurement / Re: Manipulating the behavior of an exponential function (Math gurus needed!) on: July 23, 2012, 12:25:13 pm
See if this has a noticeable effect:

y = 1500 + .004455(x-1080)*(x-1080)

Thank you, I'll give it a shot. How did you calculate it?


Where is the x in the function? smiley

I apologize:  y = (1500 / ((4/3)^(1/670))^1080) • ((4/3)^(1/670))^x


How would you implement the "basic" function if it was between the points (0,0) and (1,1) ? If you can define that the rest is scaling.

Thank you! I believe you just answered my question. With a little trig and elbow grease I think that will work. smiley

Easiest option is to use - http://arduino.cc/playground/Main/MultiMap - which can mimic all non linear functions

Yes, but he uses map() which uses long value types and I need a high-speed function, so I'm trying to stay away from 32 and 64 bit numbers. (although I have to use 32 bit because Arduino doesn't support 16 bit float values?)
40  Topics / Science and Measurement / Re: Manipulating the behavior of an exponential function (Math gurus needed!) on: July 22, 2012, 12:25:43 pm
So, other thread didn't help much?

You must be confused.
The other thread answered all of my questions. I got that function working just fine.

The simple solution is Excell, or LibreOffice, where you play around with math, and see how it affects a  chart. Only when you like what you see, you ready to transfer it in C.

I've been doing that, and I disagree with you. I have been doing research online and playing with graphs, and it would seem in this case the simple solution is to ask a forum with over 120,000 people who actually have an idea of what I'm talking about.
41  Topics / Science and Measurement / Manipulating the behavior of an exponential function (Math gurus needed!) on: July 22, 2012, 04:01:07 am
Hello,
I'm working with an exponential function, and I need a bit of help with manipulating its behavior. Basically, I have two points that I would like to maintain whilst "dragging" the curve of the function outwards in order to exaggerate the exponential behavior of the function. Here is the application: I have an input value (x) which I would like to scale from 1080 and 1750 to an output value (y) within 1500 and 2000. I do not want to use a linear equation, because I would like to create the effect where lower x values output y values incrementing at a much slower rate than output y values increment from higher x input values.

I am currently using this function to achieve my goal: y = (1500 / ((4/3)^(1/670))^1080) • ((4/3)^(1/670))

Unfortunately, the effect of the exponential behavior is very minor and unnoticeable in the application I am using it for in my program. How can I exaggerate the exponential behavior of the function whilst maintaining the two points (1080, 1500) and (1750, 2000)?
42  Using Arduino / Programming Questions / Re: pow() function issue on: July 21, 2012, 04:02:15 pm
**facepalm**
Thank you.
43  Using Arduino / Programming Questions / Re: pow() function issue on: July 21, 2012, 03:15:12 pm
I apologize, I did not make myself clear.
The first argument in pow() doesn't matter.
I just noticed that the scale() function worked fine when the number was static, but as soon as I made it variable, it didn't work.

So let me rephrase my question:

I am trying to create an exponential function. The input values I am using are from 1500 to 2000. This is the function I made:
Code:
uint16_t scale(uint16_t input) {
  return (1500 / pow((pow((4 / 3), (1 / 670))), 1080)) * pow((pow((4 / 3), (1 / 670))), input);
}

Obviously, this did not work because of the limitation of pow(). I am curious, how I can get this working?
44  Using Arduino / Programming Questions / pow() function issue on: July 21, 2012, 02:46:35 pm
Can anyone explain to me why this scale function doesn't work with variable input? Is there a solution/workaround? Thanks!

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

void loop()
{
  delay(500);
  long val = random(2000);
  Serial.print(val);
  Serial.print("\t");
  Serial.println(scale(val));
}

long scale(long input) {
  return pow(2.0, input);
}
45  Using Arduino / Programming Questions / Re: Multiple of value type vs array on: July 21, 2012, 12:00:47 pm
Ok thanks. That's what I figured, but I had some hope that there might be a technique similar to packing several true/false values into a single byte.
Pages: 1 2 [3] 4 5 ... 7