Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / TinyGPS library and GPS accuracy - decimal place truncation on: March 14, 2012, 10:18:07 am
Hi all,

have been using the tiny gps library and  a venus GPS ( . Got it reading the GPS today and parsing the data using the library. Thing is the data comes from the GPS latitude and longitude minutes to 6 decimal places but the library only returns 5.

The 6th dp wanders a little but is still useful. There is plenty of room in the long int that stores the lat and long - full data for each of latitude and longituse will be 8 numbers, i.e. 2 numbers for minutes and 6 decimal places.

No idea why you would truncate data like this!

Have looked in the library and being cpp is a little opaque for me who only generally uses C and matlab. It looks like the offending function is:
unsigned long TinyGPS::parse_degrees()
  char *p;
  unsigned long left = gpsatol(_term);
  unsigned long tenk_minutes = (left % 100UL) * 10000UL;
  for (p=_term; gpsisdigit(*p); ++p);
  if (*p == '.')
    unsigned long mult = 1000;
    while (gpsisdigit(*++p))
      tenk_minutes += mult * (*p - '0');
      mult /= 10;
  return (left / 100) * 100000 + tenk_minutes / 6;

 Any ideas how to tweak this so that i can retain the last dp that i can see is there on the raw stream?

The basic code to get the data is below.

btw there is a method to get the data out as a float but it is still truncated.

#include <TinyGPS.h>
#include <NewSoftSerial.h>

TinyGPS gps;
#define RXPIN 10
#define TXPIN 11
NewSoftSerial nss(RXPIN, TXPIN);

long lat, lon;
unsigned long age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;
bool newdata;

void setup()
  Serial.begin(57600); // Radio serial
    // set the data rate for the SoftwareSerial port
  // prints title with ending line break

void loop()
  while (nss.available())
    int c =;
  gps.get_position(&lat, &lon, NULL);
    Serial.print("Latitude:  "); Serial.println(lat);
    Serial.print("Longitude:  "); Serial.println(lon);


static bool feedgps()
  while (nss.available())
    if (gps.encode(
      return true;
  return false;
2  Forum 2005-2010 (read only) / Interfacing / Re: Problem with MATLAB to Arduino MEGA on: November 11, 2009, 11:39:31 am
'i' here as in idle
3  Forum 2005-2010 (read only) / Interfacing / Re: Problem with MATLAB to Arduino MEGA on: November 11, 2009, 11:38:35 am
I get round this by getting matlab to check the connection status first:

Comtest = arduino.TransferStatus; % check port status before trying to write
    if Comtest(1) == 'i';
            fwrite(arduino, ServoValue, 'uint8','async')

Hope this helps
4  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and robotis dynamixel servo on: November 24, 2009, 11:43:50 am
fduf news, you are a legend, well spotted. It works now!
5  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and robotis dynamixel servo on: November 24, 2009, 06:23:53 am
So here's an update.... This has turned out be a bit of a nightmare. After much faffing I managed to set up an Arduino to arduino network to test the rs485 communication. Pretty much everything i needed to know was here:

That way i could set up the instuction packets as per the rx-64 manual. So far so good. Right so now powered up the servo, and send the data across, just to test comms by turning the LED on the servo on and off aaaannnndd........ Nothing, nada, rien.

Have checked the message is ok, wiring is same as the working ard-ard rs485 network. Have tried serial.print(0xFF, byte) and serial.print(0xFF, BIN) and neither work....

Someone out there must have done this before!

Here is my code to turn the light on and off, please tell me if you can see anything wrong..

// Xbee to dynamixel via rs485

// Define/preallocate parameters
int ledPin =  13;    // LED connected to digital pin 13
int i = 0;
byte startAddress;
byte servoID= 0x01;
byte ledOn = 0x01;
byte ledOff = 0x00;

// Run setup Function
void setup() {
//int DEPin= 2; // The pin to be used for enable/disable signal
//digitalWrite(DEPin, HIGH); // tell max485 to transmit

// Run main Function
void loop() {
//Transmission section

if (i%2 ==0){
activateServos(servoID, ledOn);
activateServos(servoID, ledOff);

if (i>1000){

//Function Definitions

void activateServos (byte servoID, byte newValue){
  int checksum_ACK;
  byte notchecksum;
  startAddress = 0X19;     // Turning on led
  checksum_ACK =  servoID + 0x03 + 0x03 + startAddress + newValue;
  notchecksum = ~checksum_ACK;
  digitalWrite(2,HIGH);     // Notify max485 transciever to accept tx
  delay(5);                 // Allow this to take effect

  Serial.print(0xFF,BYTE);  // 1.These 2 bytes are 'start message'
  Serial.print(0xFF,BYTE);  // 2.These 2 bytes are 'start message'
  Serial.print(servoID,BYTE);  // 3.Address 1 is target servo or 0xfe which is broadcast mode
  Serial.print(0x03,BYTE);  // 4.Length of string
  Serial.print(0x03,BYTE);  // 5.Ping read write or syncwrite 0x01,2,3,83
  Serial.print(startAddress,BYTE);  // 6.Start address for data to be written
  Serial.print(newValue,BYTE);  //  7.Turning on signal
  Serial.print(notchecksum,BYTE); //8. the notchecksum
  delay(3); // allow last byte to go through

6  Forum 2005-2010 (read only) / Interfacing / Arduino and robotis dynamixel servo on: November 12, 2009, 09:45:51 am
Hi there,
have been using an arduino to control some hi-tec servos, but due to the high strength and some other nice features like compliance, lots of data feedback etc I want to use the robotis dynamixel servo, (the rx-64).

Does anyone have any experience of using these? it is going to be a long weekend of hacking about otherwise!

They use RS485 for comms and I'm going to use a MAX485 IC chip to get the Arduino rs232 to talk to the servos. Any advise would be appreciated, will update on progress to save other people time in future.
Pages: [1]