Show Posts
Pages: [1] 2 3 ... 140
1  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 07, 2014, 06:48:57 am
It seems the library has got a problem with the reading the float string with a leading space.
Reading:
Code:
dtostrf(e, 7, 5, buffer);
eb = buffer;
works as the buffer = "0.72348"

This does not read into bignumber:
Code:
dtostrf(e, 8, 5, buffer);
eb = buffer;
as the buffer = "_0.72348"

 smiley-surprise


2  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 07, 2014, 06:26:17 am
This gives the correct result with above sketch:

Code:
dtostrf(e, 8, 5, buffer);
eb = "0.72348";//buffer;
Code:
200695574004932
8847360
8859392.000000000000000000000000000000
0.72348
8859392.723480000000000000000000000000
22653423.351809387532795061757446641905

And this fails:
Code:
dtostrf(e, 8, 5, buffer);
eb = buffer;
Code:
200695574004932
8847360
8859392.000000000000000000000000000000
0
8859392.000000000000000000000000000000
22653425.201744318345999364290461467333

Any hint? smiley
3  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 07, 2014, 05:03:44 am
This gives at least the integer calcs correctly, but still an issue with the float value e..
Code:
// BigNumber library
#include "BigNumber.h"

void setup() {  

Serial.begin(115200);  

BigNumber::begin(30);  // initialize library

BigNumber result, ab, bb, cb, db, eb, to16;

unsigned long a, b;
unsigned int c, d;  // or unsigned long
double e;

to16 = "65536";

// an example of typical values (vars, not constants):

a = 23948398;
b = 8380334;

c = 135;
d = 12032;

e = 0.72348;

//ab = a;
//bb = b;
//cb = c;
//db = d;
//eb = e;

char buffer [40];
ltoa(a, buffer, 10);
ab = buffer;
ltoa(b, buffer, 10);
bb = buffer;
ltoa(c, buffer, 10);
cb = buffer;
ltoa(d, buffer, 10);
db = buffer;

dtostrf(e, 8, 5, buffer);
eb = buffer;

// the actual formula:
// result = (a * b) / (c * 65536 + d + e);
// shall be result = 22653423.351809387532795061757447

// casted to bignum
// result = (ab * bb) / (cb * to16 + db + eb);

// Serial.println(result);
// printBigNum(result);

BigNumber t1 = ab * bb;  //   ( a * b )
Serial.println(t1);

BigNumber t2 = cb * to16;  //   ( c * 65536 )
Serial.println(t2);

BigNumber t3 = t2 + db;  //   ( c * 65536  + d )
Serial.println(t3);

Serial.println(eb);    // print eb = 0.72348

BigNumber t4 = t3 + eb;  //   ( c * 65536  +  d  +  e )
Serial.println(t4);

BigNumber t5 = t1 / t4;  //   ( a * b ) / ( c * 65536  +  d  +  e )
Serial.println(t5);

}

void loop() {
};
Code:
200695574004932
8847360
8859392
0
8859392
22653425

The float to string conversion gives proper result, but still, assigning the string (with float) to a bignumber fails..
Code:
dtostrf(e, 8, 5, buffer);
Serial.print(buffer);
prints   0.72348

but

dtostrf(e, 8, 5, buffer);
eb = buffer;
Serial.print(eb);
prints  0
4  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 07, 2014, 03:48:38 am
I've PMed to Nick so maybe he can help..
A possible workaround:
       
Code:
char buffer [40];
//ab = a;
ltoa(a, buffer, 10);
ab = buffer;
        //bb = b;
ltoa(b, buffer, 10);
bb = buffer;
Gives a correct (a*b)..
5  Using Arduino / Programming Questions / Re: TFT ILI9341 on: September 06, 2014, 11:21:30 am
That module
http://www.ebay.com/itm/2-2-Serial-SPI-TFT-Color-LCD-Module-Display-240X320-w-PCB-Adpater-SD-Socket-/200935977876
works with adafruit's ili9341 driver fine here with 1284p.
Double check the wiring, and use a resistor (ie. 15-33ohm) from 5V to LED.
Mind the module is 3.3V one (so the signals shall be). The adfruit's one (http://www.adafruit.com/products/1480) has got a 5V/3.3V level shifter.

https://github.com/adafruit/Adafruit_ILI9341

Code:
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

//    J2 header on ili9341 2.2inch tft module (from the top):
//    All signals 3.3V
// =======================================================
//   1   Vcc 5V (regulated to 3.3V on the module's pcb)
//   2   GND
//   3   CS  
//   4   RESET (must be kept High when not wired/used)
//   5   D/C   (must be used)
//   6   MOSI
//   7   SCK
//   8   LED   (wired to Vcc via a resistor ~15ohm)
//   9   MISO  (must not be wired/used when writing to the display only)
6  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 06, 2014, 08:31:54 am
Compiled and run on 1284p so no issue with ram space..
Not sure the BigNumber lib can work with float/int/long/long_long variables as the input to the calculation. Would be great if it could..
 smiley-confuse
7  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 06, 2014, 08:13:15 am
Code:
// BigNumber library
#include "BigNumber.h"

void setup() {  

Serial.begin(115200);  

BigNumber::begin();  // initialize library

BigNumber result, ab, bb, cb, db, eb, to16;

unsigned long a, b;
unsigned int c, d;  // or unsigned long
double e;

to16 = "65536";

// an example of typical values (vars, not constants):

a = 23948398;
b = 8380334;

c = 135;
d = 12032;

e = 0.72348;

ab = a;
bb = b;
cb = c;
db = d;
eb = e;

// the actual formula:
        // result = (a * b) / (c * 65536 + d + e);
        // shall be result = 22653423.351809387532795061757447

        // casted to bignum
// result = (ab * bb) / (cb * to16 + db + eb);

// Serial.println(result);
// printBigNum(result);

BigNumber t1 = ab * bb;  //   ( a * b )
printBigNum(t1);

BigNumber t2 = cb * to16;  //   ( c * 65536 )
printBigNum(t2);

BigNumber t3 = t2 + db;  //   ( c * 65536  + d )
printBigNum(t3);

BigNumber t4 = t3 + eb;  //   ( c * 65536  +  d  +  e )
printBigNum(t4);

BigNumber t5 = t1 / t4;  //   ( a * b ) / ( c * 65536  +  d  +  e )
printBigNum(t5);

}

void loop() {
};


//function to display a big number and free it afterwards
//modified println to print
void printBigNum (BigNumber n)
{
char * s = n.toString ();
Serial.println (s);
free (s);
}  // end of printBignum

Code:
-229669692
8847360
8859392
8859392
-25
8  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 06, 2014, 07:52:59 am
Paul, I did all that in past (see my first post). Spent days..
It seems we need somebody from Bletchley Park to help smiley
Or Nick's advise, of course..
9  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 06, 2014, 07:43:41 am
Clear:
Code:
// BigNumber library
#include "BigNumber.h"

void setup() {   

Serial.begin(115200); 

BigNumber::begin();  // initialize library

BigNumber result, ab, bb, cb, db, eb, to16;

unsigned long a, b;
unsigned int c, d;  // or unsigned long
double e;

to16 = "65536";

// an example of typical values:

a = 23948398;
b = 8380334;

c = 7883;
d = 12032;

e = 0.72348;

ab = a;
bb = b;
cb = c;
db = d;
eb = e;

// the actual formula:

result = (ab * bb) / (cb * to16 + db + eb);

Serial.println(result);
printBigNum(result);
}

void loop() {
};


//function to display a big number and free it afterwards
//modified println to print
void printBigNum (BigNumber n)
{
char * s = n.toString ();
Serial.print (s);
free (s);
}  // end of printBignum


Result:
0
0

And so on..
10  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 06, 2014, 07:37:08 am
cut and paste issue - see above corrected results..
11  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 06, 2014, 07:33:51 am
I did.. For example (added the printBigNum() ):

Code:
// BigNumber library
#include "BigNumber.h"

void setup() {  

Serial.begin(115200);  

BigNumber::begin();  // initialize library
BigNumber result, ab, bb, cb, db, eb;

unsigned long a, b;
unsigned int c, d;  // or unsigned long
double e;

// an example of typical values:

a = 23948398;
b = 8380334;

c = 7883;
d = 12032;

e = 0.72348;

ab = a;
bb = b;
cb = c;
db = d;
eb = e;

// the actual formula:

result = (ab * bb) / (cb * 65536 + db + eb);

Serial.println(result);
printBigNum(result);
}

void loop() {
};


//function to display a big number and free it afterwards
//modified println to print
void printBigNum (BigNumber n)
{
char * s = n.toString ();
Serial.print (s);
free (s);
}  // end of printBignum

It does not compile, overloading issues:
Code:
D:\MyCode\Arduino\BigNumber_test\BigNumber_test.ino: In function 'void setup()':
D:\MyCode\Arduino\BigNumber_test\BigNumber_test.ino:35: error: ambiguous overload for 'operator*' in 'cb * 65536l'
D:\MyCode\Arduino\BigNumber_test\BigNumber_test.ino:35: note: candidates are: operator*(long int, long int) <built-in>
D:\MyCode\Arduino\libraries\BigNumber/BigNumber.h:67: note:                 BigNumber BigNumber::operator*(const BigNumber&) const
Failed compiling sketch
12  Using Arduino / Programming Questions / Re: BigNumber - a practical issue on: September 06, 2014, 07:06:14 am
I did my best with various castings, splittings, reordering..
If somebody may show me the actual mod of the above code giving the correct result I would be very smiley
13  Using Arduino / Programming Questions / BigNumber - a practical issue on: September 06, 2014, 06:38:19 am
I have quite a practical need to use the BigNumber library finally.
I need to calculate this simple formula:

Code:
// BigNumber library
#include "BigNumber.h"

void setup() {  

Serial.begin(115200);  

        BigNumber::begin ();  // initialize the library

        BigNumber result;

unsigned long a, b;
unsigned int c, d;  // or unsigned long
double e;

// an example of typical values (these values are not constants,
        // they come from an external measurement system):

a = 23948398;
b = 8380334;

c = 135;
d = 12032;

e = 0.72348;

// the actual formula:

result = (a * b) / (c * 65536 + d + e);

        // the result = 22653423.351809387532795061757447

Serial.println(result);
}

void loop() {
};

It compiles, gives 0 (or, when playing with types/castings - compile errors or results ignoring some variables values).
I've tried to use these libs, with all possible variations of operand's types, splitting the formula, etc.
http://cerebralmeltdown.com/forum/index.php?topic=342.0
http://forum.arduino.cc/index.php/topic,85692.0.html
Any hint how to do it??
Thanks!
14  Products / Arduino Due / Re: How to store Data fast in RAM on: August 25, 2014, 12:03:08 pm
1MB/sec to write on a sdcard is possible with DUE, imho. You need to buffer the data into an fifo to eliminate the sdcard's write latency.
That fifo buffering while writing to an sdcard has been discussed dozen times on this forum already.
15  Products / Arduino Due / Re: How to store Data fast in RAM on: August 25, 2014, 04:24:24 am
This is 8MB of an external RAM easy to connect to DUE (driver available):
http://forum.arduino.cc/index.php?topic=220918.0
Pages: [1] 2 3 ... 140