do two things at the same time for GPS / INS intgr

Hello. My english is not good to explain what i meant exactly, sorry about that.

I am working on a project about GPS/INS integration,i need to sample accelerometer and gyros for within 20ms but i from analog inputs, but while i need to get serial info from GPS by serial port at 4800 baud rate. How could i do both of them at the same code, is should be like this

void loop()
{
if( (millis() - lastreda_analog) > 20ms ) // sampling analog inputs 50Hz
{
// reading_analog_value
}

if( (millis() - lastread_gps_value) > 1s) // getting data at 4800 baud rate at 1 Hz
{
// reading GPS values from serial port
}

The RS232 data is already asyncronous. IIRC the buffer is 128 bytes. Just use the normal serial.whatever calls to read data when you're ready for it.

With the sampling interval of 20ms on the gyro, you may need to measure the time on the GPS I/O to make sure it isn't taking too long.

-j