Sending data quickly between two Teensy 3.1's

Status
Not open for further replies.

GOB

Active member
Hi Folks,

I am working on a project where I am sending GPS data from one Teensy to another wirelessly using two xBees.

The unit sending needs to send its data rather quickly.

I am using EasyTransfer to help send the data.

The system works well for 30 seconds so, but after a bit the stream freezes. As soon as I power off and power on the sending unit, the stream (reading on the receiver end) comes back immediately.

Code:
#include "GPSdefs.h"        //this has variables and definitions for This Unit's GPS
#include <EasyTransfer.h>

//create object
EasyTransfer ET; 

struct SEND_DATA_STRUCTURE{
  //put your variable definitions here for the data you want to send
  //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
  int LEADnorth;
  int LEADeast;
};

//give a name to the group of data
SEND_DATA_STRUCTURE mydata;

void setup() {
  Serial.begin(9600);       //for debugging and local
  Serial2.begin(115200);    //GPS on serial 2
  Serial3.begin(115200);      //Serial for xBee
  
  //Start EasyTransfer on Serial3
  ET.begin(details(mydata), &Serial3);
}

void loop() {
  //Read from GPS on serial2 
  while (Serial2.available () > 0)
    {
        processIncomingByte (Serial2.read (),timestamp,north,east,latitude,longitude, newdata);
    }


    if (newdata==true)
    {
        Serial2.flush();
        
        //for local reading and debugging
        Serial.print("timestamp ");
        Serial.print(timestamp);
        Serial.print(F(" north "));
        Serial.print((north));
        Serial.print(F(","));
        Serial.print(F(" east "));
        Serial.print((east));
        Serial.print(F(","));
        Serial.print(" latitude ");
        Serial.print(latitude,7);
        Serial.print(" longitude ");
        Serial.print(longitude,7);
        Serial.println();
        
        //Send to follower unit over xBee on serial3 using EasyTransfer
       
        //this is how you access the variables. [name of the group].[variable name]
        mydata.LEADnorth = north;
        mydata.LEADeast = east;
        //send the data
        ET.sendData();
        
        
    }
    else {
       mydata.LEADnorth = 999999;;
       mydata.LEADeast = 999999;  
    } 
}

Some trouble shooting notes:

When I monitor the output from the transmitting unit ON the transmitting unit (via Serial output) -- it doesn't freeze. So somehow the transmit part of it gets overloaded and causes the freeze on the receiver side. Again, powering off and on the transmitter unit immediately resolves it.

Could someone help me out with what I assume is a buffer/memory size issue? Or could I be running into the byte limit of EasyTransfer? (has to be under 255)

Thanks!
 
Last edited:
Seems like the problem might be in one of the 2 libraries not included.

Also what type of GPS unit are you using? does it support 115200 baud?

remember the forum rule:
Always post complete source code & details to reproduce any issue!
 
Thanks for the reply, fretless.

No libraries missing; Communication with this GPS unit is at 115200;

I think I got to the source of the issue: I needed a slight bit more delay on the transmitter side. I added a delay(20) and that seems to do the trick, along with the increase Serial buffer size.
 
I'm glad you got it working.

Thanks for the reply, fretless.

No libraries missing; Communication with this GPS unit is at 115200;

what I meant here is your posted code does not compile on my installation of Arduino / teensyduino I don't know what in the libraries mentioned here:
Code:
#include "GPSdefs.h"        //this has variables and definitions for This Unit's GPS
#include <EasyTransfer.h>
where did you put the delay? in the main loop?

I'm curious as I am working on a project which will (hopefully) use XBee to communicate between several t3 powered units and at least one will have a GPS for time / position data.

Cheers Kb
 
Hi Fretless -
The GPSdefs.h just contains definitions I use for the code that interacts with my GPS device.
The EasyTransfer library is from here: http://www.billporter.info/2011/05/30/easytransfer-arduino-library/

I did put the delay in the main loop. I was getting away with no delay when I was doing testing with smaller amounts of data but once I went to the GPS streaming data at a high rate I guess it overwhelmed things.
 
Interesting, I've had data 'lost' i.e. bit drops, but I've not yet seen a lockup. but then I've not done a lot of testing with the teensy & Xbee. I've just soldered pins on a couple more t3 I'll have to see what type of results I get. I'll post if there is anything interesting to report.

Kb
 
Status
Not open for further replies.
Back
Top