Show Posts

Pages: 1 2 [3] 4 5 ... 7

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: #ifndef ITG3200 #define ITG3200
#include "Arduino.h"
class ITG3200 { public: ITG3200(); int readITG3200(byte axis); }; #endif Here is the relevant code in .pde #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: 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 gforce * 10.



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(x1080)*(x1080)
Thank you, I'll give it a shot. How did you calculate it? Where is the x in the function? 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. Yes, but he uses map() which uses long value types and I need a highspeed 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)?



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: 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! 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); }



