Show Posts
Pages: [1] 2 3 ... 10
1  Using Arduino / Networking, Protocols, and Devices / GPS $PMTK220 versus $PMTK300 on: July 30, 2014, 04:47:06 pm
Attached is the "GlobalTop PMTK Command Packet" document which spells out the various PMTK commands for their GPS products based on MediaTek GPS chips. I have the Adafruit Ultimate which has latest MT3339 capable of 10Hz

I've successfully changed the rate my GPS updates fixes and reports sentences to 300ms using the command $PMTK300,300,0,0,0,0*

I've found posts (on Adafruit forum) suggesting $PMTK220 increases reporting rate but not fix rate, i.e. the fixes in consecutive sentences are the same until GPS actually takes a new fix.

My question: What is purpose of $PMTK220 command,  it seems $PMTK300 does it all?

thanks
2  Using Arduino / Project Guidance / Re: Too much NMEA data from a GPS. on: June 19, 2014, 03:55:24 pm
Here's a little sketch that allows you to send configuration packets to a GPS via Arduino. This code runs on an Arduino Mega2650...

Thanks for that sketch, just what I needed!

One of these days, if I get time and feel ambitious, I want to write a PC program that will have a good GUI, and allow setting configuration easily.

I assume you're aware of the existing MiniGPS GUI mentioned at bottom of this Sparkfun GPS module page: https://www.sparkfun.com/products/8975 ?

It doesn't do the rarer commands like $GPRMB, but that's where your sketch comes to the rescue.
3  Using Arduino / Programming Questions / Re: Interrupt numbering mismatch: MEGA 2560 on: May 08, 2014, 03:52:52 am
Since posting I adapted my code to use timer/counter 3, interrupt 3 and Attach/DetachInterrupt 5, and it works perfectly on my MEGA2560. So my listing of the numbering mismatch above seems to be correct.

If anyone is interested, here is the code:
Code:
#define CJ_ID "Wavelength2560 version:C"

/* Frequency counter using Timer 3 to work out the interval  (i.e wavelength)
by counting between two consecutive rising interrupts (leading edge) on pin D18 (int3).

Based on Nick Gammon's similar program for Atmel 328P processor, here:
http://www.gammon.com.au/forum/?id=11504

Adapted for MEGA2560 by Chris Jennings, 8 May 2014.

Timer 3 is a high-precision 16-bit timer. By using no prescaler the timer counts
every clock cycle (62.5nS at 16 MHz). We deduce the frequency by multiplying the
counts between the leading edges by 62.5.

An advantage of this method is the quick calculation. e.g. at 10kHz the period
is 1/10000sec (100µS) so we  get our result in just 100µS.

Note: Beware the mismatch in interrupt numbers used on MEGA2560 versus the Arduino
Attach/DetachInterrupt commands, as follows:

  Arduino             MEGA2560
int.0 pin D2   interrupt/counter 4
int.1 pin D3   interrupt/counter 5
int.2 pin D21  interrupt/counter 0
int.3 pin D20  interrupt/counter 1
int.4 pin D19  interrupt/counter 2
int.5 pin D18  interrupt/counter 3 (THIS IS WHAT IS USED BELOW) */

volatile boolean first;
volatile boolean triggered;
volatile unsigned long overflowCount;
volatile unsigned long startTime;
volatile unsigned long finishTime;

void isr () {                      // here on rising edge
  unsigned int counter = TCNT3;    // quickly save it
  if (triggered) return;           // wait until we noticed last one
  if (first) {
    startTime = (overflowCount << 16) + counter;
    first = false;
    return;  
    }
  finishTime = (overflowCount << 16) + counter;
  triggered = true;
  detachInterrupt(5);               // interrupt 3 off
  }

ISR (TIMER3_OVF_vect) {overflowCount++;}// timer overflows (every 65536 counts)

void prepareForInterrupts (){      // get ready for next time
  EIFR = bit (INTF3);              // clear flag for interrupt 3
  first = true;
  triggered = false;               // re-arm for next time
  attachInterrupt(5, isr, RISING); // initialise interrupt 3
  }

void setup () {
  Serial.begin(115200); Serial.println(CJ_ID);
  Serial.println("Calculate frequency on pin D18 from wavelength");
  TCCR3A = 0;                      // reset Timer 3
  TCCR3B = 0;
  TIMSK3 = bit (TOIE3);            // Timer 3 - enable interrupt on overflow
  TCNT3 = 0;                       // zero it
  overflowCount = 0;  
  TCCR3B =  bit (CS30);            // start Timer 3, no prescaling
  prepareForInterrupts ();         // set up for interrupts
  }

void loop (){
  if (!triggered) return;
  unsigned long elapsedTime = finishTime - startTime;
  float freq = F_CPU / float (elapsedTime);  // each tick is 62.5 nS at 16 MHz
  Serial.print ("Counts: "); Serial.print (elapsedTime);
  Serial.print ("  Freq: "); Serial.print (freq); Serial.println ("Hz. ");
  delay (500);
  prepareForInterrupts ();  
  }
4  Using Arduino / Programming Questions / Re: How to use timer??? on: May 08, 2014, 12:07:02 am
this may help: http://www.gammon.com.au/forum/?id=11504
5  Using Arduino / Programming Questions / Interrupt numbering mismatch: MEGA 2560 on: May 07, 2014, 05:30:31 pm
I am working with "Another Frequency Counter" program in Nick Gammon's excellent notes on Timers and Counters  (http://www.gammon.com.au/forum/?id=11504). This is the example that works by counting the interval between rising edges. I tested on my UNO first and it worked just fine. But in trying to convert it to run on a MEGA 2560 I came across what appears to me to be an Interrupt numbering mismatch between those used in the Arduino AttachInterrupt / DetachInterrupt commands and the ATMEL numbering for the MEGA 2560.

According to the Arduino reference the Mega2560 mapping is:
int.0   pin 2
int.1   pin 3
int.2   pin 21
int.3   pin 20
int.4   pin 19
int.5   pin 18

So I decided to use int.5 on pin D18 but then I noticed that maps to pin 46 on the MEGA2560 chip ("PD3/TXD1/INT3")
This suggests that if I use AttachInterrupt(5,isr,rising) with the signal coming into D18 I am actually using MEGA interrupt 3 and Timer/Counter 3 !

Checking the MEGA2560 pin mapping http://arduino.cc/en/Hacking/PinMapping2560 further suggests the true mapping is:

Arduino               MEGA2560
int.0   pin 2       interrupt/counter 4
int.1   pin 3       interrupt/counter 5
int.2   pin 21     interrupt/counter 0
int.3   pin 20    interrupt/counter 1
int.4   pin 19     interrupt/counter 2
int.5   pin 18     interrupt/counter 3

Am I interpreting this correctly?

Interestingly when I convert Nick Gammons example from interrupt 0 to interrupt 5 with the signal on D18 it does read the frequency correct, but only on the first reading. I have yet to try using Attachinterrupt(5...) and timer/counter 3, but will do so if my understanding above proves correct

thanks

6  Using Arduino / Storage / Re: Sparkfun microSD OK on my Uno, why not on my MEGA 2560? on: March 15, 2014, 04:49:15 pm
that fixed it - thanks
7  Using Arduino / Storage / Re: Sparkfun microSD OK on my Uno, why not on my MEGA 2560? on: March 15, 2014, 08:05:07 am
correction, make that:

pin     - Uno to MEGA
================
SS       - 10 to 53
MOSI - 11 to 51
MISO - 12 to 50
SCK    - 13 to 52

right ?
8  Using Arduino / Storage / Re: Sparkfun microSD OK on my Uno, why not on my MEGA 2560? on: March 15, 2014, 07:59:31 am
aha ... so 50,51,52 instead of 11,12,13 ?
9  Using Arduino / Storage / Sparkfun microSD OK on my Uno, why not on my MEGA 2560? on: March 15, 2014, 04:32:41 am
I've been using microSD card successfully for many months but I'm stuggling to get my Sparkfun microSD to work on m MEGA 2560. I tested the card on a Uno using the Cardinfo example sketch, but with chipselect to pin 8 per Sparkfun directions, and it works just fine.
But when I try same on my MEGA, except with pin 53 set as the output for hardware SS, it never sees the card!
Any clues appreciated
TIA
10  Using Arduino / Programming Questions / Re: unusual syntax - what does it mean? on: July 21, 2012, 07:32:16 am
excellent, thanks all
11  Using Arduino / Programming Questions / unusual syntax - what does it mean? on: July 21, 2012, 05:56:32 am
well it's unusual to me anyway... from the Starlino IMU 6DOF code, here: http://www.starlino.com/imu_guide.html
 
              signRzGyro = (cos(Awz[0]*PI/180) >= 0 ) ? 1 : -1;

hoping someone can explain what this code does?

tks
12  Development / Other Software Development / Re: DCF77 library for Arduino - synchronize with atomic clock on: April 20, 2012, 04:51:13 pm
that's a very neat and clever testing technique!
I will steal your idea and give it a try on my GPS, but it will be a while before I get to it because I'm focused on getting code working for my new accelerometer code at present - too many toys to choose from  smiley but I'll let you know what I find
13  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: April 19, 2012, 03:19:02 pm
Would you mind pointing out the corrections that need to be made to help it run faster and cleaner ...

have a read through this thread where problems with String are discussed, and PaulS even provided an example of how to use sprintf() that may help you. it worked for me!

and here's a full explanation of sprintf() works:
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/
14  Development / Other Software Development / Re: DCF77 library for Arduino - synchronize with atomic clock on: April 19, 2012, 03:12:37 pm
thanks for explanation. I'm already up to speed on GPS, I use a LS20031 that gives me time just fine (using time library). However although I have been able to get setsyncprovider to work with a DS1307 RTC I can't get GPS to respond... hence my interest in your thread.
I ran a thread on it here: http://arduino.cc/forum/index.php/topic,81175.msg612786.html#msg612786
15  Development / Other Software Development / Re: DCF77 library for Arduino on: April 19, 2012, 05:32:20 am
excuse my cruiosity, but what does a dcf77 do and where do you buy them?
Pages: [1] 2 3 ... 10