Show Posts
Pages: 1 [2] 3 4 ... 136
16  Using Arduino / Programming Questions / Re: Convert Arduino (AVR) float to Microchip float on: April 13, 2014, 09:04:01 pm
Code:
    block.bytes[3]=block.bytes[0];
    block.bytes[0]=block.bytes[3];
    block.bytes[1]=block.bytes[2];
    block.bytes[2]=block.bytes[1];

What is this supposed to be doing ?    It is not swapping the bytes around,  nor reversing their order.

Assigning bytes[0]  to bytes [3]   and then assigning bytes[3]  to bytes[0]     results in the original value of bytes[0]  now being in both bytes[3] and bytes[0],   and the original value of bytes[3] being gone.

17  Using Arduino / Programming Questions / Re: Negative pulse generator with Arduino ???? on: April 13, 2014, 08:56:43 pm
Are you trying to create negative voltages ?

The Arduino cannot do that directly,   but there are ways it can be done ,  indirectly.
18  Using Arduino / Programming Questions / Re: Boat autopilot - PID not centralizing rudder. on: April 13, 2014, 08:54:32 pm
It would depend on whether your error was expressed as a positive or negative number.  And the format of your equation.  "Negative feedback" is perfectly normal,  in fact it is the only useful kind of feedback.
19  Using Arduino / Programming Questions / Re: If/else statement broken,and for-loop that will not stop after the set cycle # on: April 13, 2014, 08:38:16 pm
Why do you have that pointless declaration of repetitions in setup( ) ??
20  Using Arduino / Programming Questions / Re: Data Logging Stops After Losing GPS Signal on: April 13, 2014, 07:27:07 pm
I checked the current version of SD,   it is now OK to open two files.

However,  one issue I can see in your code,   is that you open your two files,   and then further down  you  check  "if ( datafile ) ",   and then proceed to write into the two files.   This code would rely on the conventional assumption that if you had actually failed to open datafile,  the value of the  File object or pointer or handle or whatever it actually is,  would be null and the if ( datafile )  would fail.

The specific problem in your case,   is that for some unknown reason,  datafile could be good and  gpsfile  could be bad.   For this reason,  it would be better to write

Code:
if ( datafile )
{  // write stuff to datafile
}

if ( gpsfile )
{  // write stuff to gpsfile
}

The other problem,  is where you are getting the values out of the gps object  when the various  isUpdated()  accessor functions are true.   What happens when you have received a new GPS string,   and all of the parameters are updated ?   What will happen,   is that you will get your first variables,   and then  all the  else if's  after that won't get checked,   so the velocity and time and stuff won't get updated.    That is probably not the functionality that you intended.



21  Using Arduino / Programming Questions / Re: Data Logging Stops After Losing GPS Signal on: April 13, 2014, 07:10:04 pm
The default output for float variables in Serial.print() is 2 decimal places.   They will get printed to that resolution,   even if the actual floating point number is not an exact multiple of 0.01  

I believe you can change this by writing  Serial.print(  longitude, 4 ) ,   which would print the value with 4 decimal places.  Be aware that the total resolution of a float on the Arduino is around 6 significant figures,   so if the number is big,   like 12345.1234,   you already have 5 of those significant figures on the left hand side of the decimal point,    so only one of the figures on the right hand side of the decimal point is going to be any good,    even though you have printed four of them.    But if your number is 1.1234 ,   then there is no reason why all five digits are not good.

I've had quite a lot of trouble logging data to SD cards.   You go and log some data,   and then take out the card and put in the PC,   and the PC says it is unreadable and has to be re-formatted.   So the entire experiment has to be done over again.  This is an annoying problem to track down,   it could be a defective card,  or a defective reader,  or some incompatibility in the FAT version,  or an incorrectly terminated file,  or a host of other things.   I've tried dozens of things to reduce this problem.   Opening and closing the file for every write operation seems to work best ( but not perfectly) ,   but has quite a long latency time which can interfere with other things the Arduino is suppoed to be doing.   Part of the problem here,  is that Arduino sketches just run forever.  There is no orderly way to turn the thing off,  unless you implement one somehow.   Even if you only open and close the file every time you write to it,   you can still cut off the power supply in the middle of the write operation,   which may leave the file on the card defective.
22  Using Arduino / Programming Questions / Re: Kalman filter and processing power? on: April 13, 2014, 06:43:56 pm
Apart from issues of processing power,  you run into a fundamental problem with Kalman because the Kalman method is based on some assumptions about the linearity of the problem,  which do not apply to the flight dynamics problem in three dimensions,  except in a limited sense,  such as only processing a single input,  or reducing the problem to one dimension.
23  Using Arduino / Programming Questions / Re: Data Logging Stops After Losing GPS Signal on: April 13, 2014, 06:36:12 pm
Quote
However, a problem arises when the GPS runs AFTER acquiring a first signal, and then subsequently losing it. The Arduino completely stops writing anything to the SD card after a fix is lost.

... 10 more post.

Quote
michinyon, writing the code to the SD file as is works just fine.
Alrighty then,  all solved,  is it ?

Unless it has been improved since last year,  the SD file system only allows you to access one file at a time.    You seem to be writing to two of them.  How are you doing that,  then ?   I see you closing the files a lot,  but never where you open them .  How does that work, then ?  You say that the data logging stops unexpectedly ( see the thread title,  and the first post ),   but you are convinced that writing to the SD card is working "just fine".   Well,  which is it ?

 
24  Using Arduino / Programming Questions / Re: Data Logging Stops After Losing GPS Signal on: April 13, 2014, 06:27:38 pm
So,   Serial.print(  gps.getLattitude( ) ,  8 );    prints the number you want with 8 decimal places,   but when you put it into your SD file,   you don't get 8 decimal places ?

I can't see the code where you are doing that,   but the suggestion occurs,   if you are using the sprintf( ) function,   well there is a bug ( of some kind ) in it,  and it doesn't work properly.  This is a problem that has come up before.   There is a workaround for it,  but I forget exactly what it is.
25  Using Arduino / Programming Questions / Re: I2C between Trinkets and Mega not working on: April 13, 2014, 06:03:05 pm
Your code for receiving data from the I2C looks exactly the same as the usual code for receiving Serial data.

None of the code I have for I2C,  looks exactly the same as Serial,  in the way that yours does.  But maybe,  the code I have is always for the I2C master device,   I didn't write any code where the arduino acted as the slave device,  so maybe that explains it.   My code has a bunch of "beginTransmission"  and "endTransmission"  function calls in it,  which I don't see in yours anywhere.

I2C can have only one master device.

If you have your two trinkets working together,   then wouldn't one have to be the master and one the slave ?    But when you connect them both to the arduino,  then you got three devices,   which is the master then ?

26  Using Arduino / Programming Questions / Re: I2C between Trinkets and Mega not working on: April 13, 2014, 05:49:40 pm
Quote
ARE YOU SURE IT SHOULDN'T BE if(c==0) ?

if ( 0 == c  )

is perfectly valid,   and is recommended practise by some experts.   Possibly,  the same experts who recommend ++i  instead of i++,   for no good reason in 99.9% of usages.

The ostensible reason for writing this way,    is that if you write   ( by mistake )

if ( 0 = c )

you will get a compilation error.

But if you write  ( also by mistake )

if ( c = 0 )

then you won't get a compilation error,   you will get a bug which sometimes may be very difficult to track down.


27  Using Arduino / Programming Questions / Re: Trying to respond to a long string to be retrieved from Serial port? ??? on: April 13, 2014, 05:42:46 pm
I'd suggest getting rid of the String class.

Your algorithm also seems to assume that an entire message will arrive during the execution of one iteration of the loop( ) function.  In general,  this is a somewhat unwise assumption.   It isn't called "asynchronous" communication for nothing,  although most people have forgotten that.   For short messages from a known source,  you can probably get away with using that delay(10) that you have there.   As long as you can be sure that the sending end doesn't start sending messages very quickly -  and then you get other problems.   It is not a very robust solution.

The whole b/s problem of where a "newline" character is a  CR,  a LF,  or a CR and a LF,   goes back to antique hardware requirements  and some kind of dispute between MS-DOS  and the Unix universe 30 years ago.     It still seems to annoy me every day when I open some text readme,txt file using Notepad   and the whole contents come up on a single line thousands of characters long.  A pox on both their houses.

28  Using Arduino / Programming Questions / Re: Boat autopilot - PID not centralizing rudder. on: April 13, 2014, 05:28:03 pm
Quote
Basically, the PID need to decrease Output when error is decreasing. Maybe PID is not the way to go here at all?

If this is really your problem,   then you need to reduce the value of the gain for the "D" component in the P-I-D formula.   That's what it is there for.
29  Using Arduino / Programming Questions / Re: Boat autopilot - PID not centralizing rudder. on: April 13, 2014, 05:25:54 pm
I think this is not a programming question,  but a boat control question.

You seem to be assuming,  that when the boat is on the correct course,   the rudder should be centralised.  This is,  in general,  not a valid assumption.   For a sailing boat,  or a motor boat,  any effect such as wind or even currents  will cause the boat's course to change.  To maintain the desired course,  even in the absense of transient disturbance,  may require some rudder condition that is not "central".   You can minimise this requirement by correct boat design,  but you cannot eliminate it.
30  Using Arduino / Programming Questions / Re: Data Logging Stops After Losing GPS Signal on: April 13, 2014, 12:08:16 pm
Your code looks wrong to me.   

There are two ways to write files on SD cards.

You can open the file once,   and keep writing to it.

or

You can open the file,  write something to it,  and the close it.   And the next time you want to write something,  open it again.  And then close it again.

Both of these methods seem to have reliability issue on the arduino.

But your method seems to be to open the file once,   write some stuff,   and then  close it.   And when you get the next gps fix,   you try to write more stuff ( without opening the file ),   and then close it again.  And so on.   I am pretty sure that you cannot open the file once and then close it many times,  and expect it to work.






Pages: 1 [2] 3 4 ... 136