Show Posts
Pages: 1 ... 66 67 [68] 69 70 ... 98
1006  Using Arduino / Project Guidance / problem with core tone library on: February 05, 2012, 03:53:28 am
I am trying to generate a series of  frequencies using the tone library, but I keep getting an error message

Code:
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
C:\arduino22\arduino-0022\hardware\arduino\cores\arduino/Tone.cpp:415: multiple definition of `timer1_toggle_count'
Tone\Tone.cpp.o:C:\arduino22\arduino-0022\libraries\Tone/Tone.cpp:102: first defined here

even if I just try to generate a single tone.

Code:
#include <Tone.h>
int drivePin = 8;
void setup () {
    pinMode (drivePin,OUTPUT );
  Serial.begin (9600);
  }
 void loop () {
tone(drivePin, 1000, 250);
}

Any ideas?   I am not using any delays ?
 
1007  Using Arduino / Project Guidance / Re: newsoftserial and Nordic modules on: January 07, 2012, 03:44:57 pm
Thanks Paul

 
1008  Using Arduino / Project Guidance / newsoftserial and Nordic modules on: January 07, 2012, 11:23:54 am
I have two of these modules, based on the Nordic905 chips 
http://www.rfdesign.co.za/Files/5645456/RFOEM%20manual1.5%20Montar%20LH%20pdf.pdf

and want to try them to start with as simplex TxRx links, and perhaps later progress to handshaking.

To avoid the RXD TXD of the normal serial programming, I am planning to use newsoftserial ( which I have working fine on my gps clocks)

I cant seem to find any basic description of the newsoftserial library, I need to try firstly to send some data from the Tx Arduino board to the Rx one.

I normally use virtualwire to a simple RF transmitter module, but these modules have a load of extra handshaking stuff in them, so I dont think it will work.

I have been trying all day , but I am missing something, can anyone point me to a simple sketch to try and establish just a one way link,  that I can build on?

I must confess to also being confused with RX and TX names on the chips and modules, you connect Rx to Tx, and vice verca , but then you are told to connect a 1k resistor in the RX line if the Vcc is different  -  which Rx ?   ( OK that can be worked out ) but in setup for newsoftserial  we define

 NewSoftSerial mySerial(15, 14);

Which is Rx and which is Tx ?  and to which end are we referring?   I worked it out but if you didn't have a 1k resistor in the right line you could blow the  GPS transceiver or whatever.




1009  Using Arduino / Project Guidance / newsoftserial and Nordic modules on: January 07, 2012, 08:52:09 am
I have two of these modules, based on the Nordic905 chips 
http://www.rfdesign.co.za/Files/5645456/RFOEM%20manual1.5%20Montar%20LH%20pdf.pdf

and want to try them to start with as simplex TxRx links, and perhaps later progress to handshaking.

To avoid the RXD TXD of the normal serial programming, I am planning to use newsoftserial ( which I have working fine on my gps clocks)

I cant seem to find any basic description of the newsoftserial library, I need to try firstly to send some data from the Tx Arduino board to the Rx one.

I normally use virtualwire to a simple RF transmitter module, but these modules have a load of extra handshaking stuff in them, so I dont think it will work.

I have been trying all day , but I am missing something, can anyone point me to a simple sketch to try and establish just a one way link,  that I can build on?

I must confess to also being confused with RX and TX names on the chips and modules, you connect Rx to Tx, and vice verca , but then you are told to connect a 1k resistor in the RX line if the Vcc is different  -  which Rx ?   ( OK that can be worked out ) but in setup for newsoftserial  we define

 NewSoftSerial mySerial(15, 14);

Which is Rx and which is Tx ?  and to which end are we referring?   I worked it out but if you didn't have a 1k resistor in the right line you could blow the  GPS transceiver or whatever.




1010  Using Arduino / Project Guidance / Re: Cricket Scoreboard on: December 29, 2011, 05:58:08 am
Thanks Bob, I did send him a pm.

One of the problems here in South Africa, ( and op is in Australia ) is the temperature ( cricket is a summer sport )

The electro-mechanical ones with the turning vanes just jam up in the sun , it gets over 50C in the case.

I have replaced several of these with LED types.

One massive advantage Manamarkus,  if its a new board, try and locate it with its back facing  North, which saves all the hassles of keeping the sun off of the LEDs, and you can use half the number of LEDs per segment, for the same contrast.

What you will save in LEDs  will make a length of power cable worth it !
1011  Using Arduino / Project Guidance / Re: Accurate timing thoughts on: December 11, 2011, 05:02:15 am


or get a UP501D GPS receiver like this one, and using TinyGPS library, you can get accurate timing ( as well as position, height, speed, direction etc etc )

They are about the same price as buying a RTC chip, xtal, battery, holder, and PCboard.

Incidentally I was shocked at how sensative they are, see http://arduino.cc/forum/index.php/topic,82537.0.html

I have no interest in Fastrax who make the module, I am sure other makes with the same specs would be the same ,  I am just very impressed with my first play with GPS.
1012  Using Arduino / Networking, Protocols, and Devices / Re: indoor gps no problem :-) on: December 11, 2011, 04:59:16 am
I had a croc-clip wire from the shield to the usb socket on the arduino, which didn't make a lot of difference, but putting a foil plate over the whole lot makes it drop out.

The amazing thing to me is that the thing is upside down, with the antenna pointing down ....

BTW macegr, thanks for the average smoothing suggestion on the Adafruit forum, it was so much quicker , and slicker than my MacGuivered attempt!
1013  Using Arduino / Project Guidance / Re: simple averaging troubles on: December 11, 2011, 04:38:58 am
Hmm   The interval ends up at 60009 which doesnt make sense, so when I finally managed to get the GPS module to lose the signal ( by turning it upside down with the antenna pointing down, and the whole thing wrapped in foil, with an aluminium plate covering the lot ! ( see http://arduino.cc/forum/index.php/topic,82537.0.html )  the free running timing was way too slow.

By ignoring the calibration part of the sketch, and presetting the interval to 59851 it ran through the night with only a few seconds error.

I think the problem is to do with the variation of the timing I measure from the GPS minute changes.

As the GPS signal is so reliable, I am going to ditch the idea for now of calibrating the millis to the GPS, and let the GPS reset the time and clockmillis each minute.

When I get a chance I might revisit and try counting millis between hour changes from the GPS, which will reduce any latency problems I am getting n recording the minute change time.
1014  Using Arduino / Networking, Protocols, and Devices / Re: indoor gps no problem :-) on: December 10, 2011, 03:02:18 pm
Drats !    Foiled again ....
1015  Using Arduino / Networking, Protocols, and Devices / Re: indoor gps no problem :-) on: December 10, 2011, 11:29:24 am
Wow this is strange,  turming the module upside down only makes it skip the odd reaading while I am moving it around, then it settles down and locks on solid.
I need it to drop out 100%
So then I tried wrapping the whole Arduino and GPS module in plastic and cooking foil, with the GPS receiver upside down ( antenna looking down into the foil )  i.e.

it only takes a minute to lock on and give solid data.

If I then completely wrap the upside down receiver and Ardunio in foil,



it stays locked on, giving perfect time, but sometimes give garbled position data .
If I power down and reboot it, it doesnt lock on ( I tried it for 5 minutes )

It does lock on with it half wrapped upside down.
1016  Using Arduino / Networking, Protocols, and Devices / indoor gps no problem :-) on: December 10, 2011, 09:59:21 am
I made up a small board to attach a UP501D GPS receiver to an Arduino board to test my GPS clock project.

I have been testing the project indoors, and had no problem with the Rx locking on to the satellites.

Then I wanted to check that the clock would keep time with the GPS receiving no signals, so I put a metal plate ( the sidepanel  of my PC - dont ask ) right over the GPS receiver/antenna. and it still happily receives the signals !



I put it in the drawer under the PC and it works.

The only way I can make it lose signal is to turn the thing upside down !

I am very impressed and surprised......
1017  Using Arduino / Project Guidance / Re: simple averaging troubles on: December 09, 2011, 09:49:38 am
Thanks GoForSmoke -   I completely forgot to comment out all the zillion SerialPrints again !
I will try it with just printing the interval and see how it looks .

I will never get old , only in numbers , kid at heart :-)

1018  Using Arduino / Project Guidance / Re: simple averaging troubles on: December 09, 2011, 06:21:49 am


That averaging works very well,   I have incorporated a MacGuyvered rounding up or down the decimal places to keep the interval of the freerunning timer within 1 millisecond , which ( ideally  ,  if the temperature of the xtal didnt change too much )would equate to 43 seconds error a month !
Hopefully the GPS will not drop out for anything like that !

But the reading from the GPS between minute changes varies quite a few milliseconds, I suppose it depends on where the loop my sketch was when the next data packet is ready.
An interrupt would sort that out, but doesn't it mess up the millis count?

I am not really concerned as any delay in reading the minute change would be cancelled out the next minute anyway.

I am using the 5% averaging swaps, which I think relates to averaging over 20 samples ( although the history is never erased, just slowly modified )  but as I am smoothing a very steady level, I could take it down to 1% perhaps , I have days to let it settle.

it looks like my freerunning clock would have been 6 milliseconds fast every minute without this calibration.  If the GPS drops out it will carry on with the corrected interval.


Heres the code and below it the readings as it averages with 5% swaps


Code:
/*
   GPS clock by John Smith aka Boffin1  based on  http://tronixstuff.com/tutorials > Chapter 19
 and code by Aaron Weiss of SparkFun Electronics;  http://bit.ly/99YnI6
 and code and libaries by arduiniana.org. and the patirnt people of the Arduino forum !
 Thank you :)
 */

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


long error;
long clockmillis = 0;
long rxmillis = 0;
long interval = 60000;
int x =0;
unsigned long since;
unsigned long times [10];
const byte digitTable [10] = {                     //   patterns for 7 segment displays
  B11111110, B10110000, B11101101, B11111001, B10110011,  //  first bit for switching on display
  B11011011, B11011111, B11110000, B11111111, B11111011};

float average = 60000;
int clockmins;
int clockhours;

#define RXPIN 14 //   
#define TXPIN 15 //
#define GPSBAUD 9600 // baud rate of our UP501D GPS module. Change for your GPS module if different

// Create an instance of the TinyGPS object
TinyGPS gps;
// Initialize the NewSoftSerial library to the pins you defined above
NewSoftSerial uart_gps(RXPIN, TXPIN);

// This is where you declare prototypes for the functions that will be
// using the TinyGPS library.
void getgps(TinyGPS &gps);

int hourtens;
int hourunits;
int mintens;
int minunits;
int rxhours;
int rxmins;

void setup()
{
  uart_gps.begin(GPSBAUD); // setup sketch for data output speed of GPS module
  Serial.begin(115200);
  interval = 60000;
}
//  ========================================================================


void getgps(TinyGPS &gps)    // The getgps function will get the values we want.
{
  int year,a,t;
  byte month, day, hour, minute, second, hundredths;
  gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
  hour=hour+2; // my zone is GMT +2
  if (hour>23) {
    hour=hour-24;
  }

  rxhours = ( int ) hour;
  rxmins = (int) minute;

  if ( rxmins != clockmins ) {                    // ===================MINUTES HAVE CHANGED THIS SECOND ==================
    unsigned long  present = millis ();          //  set actual millis time of minute change for all subsequent calcs and timings
    since = (present - rxmillis) ;              // the millis count since the last minute change ( GPS accuracy on average )
    rxmillis = present;                        //  millis count at update
    Serial.print("rxmin has just changed,");  //  update clock, at secs = zero
    clockmins = rxmins; 
    clockhours = rxhours;     
    clockmillis = present ;                    // reset freerun clock counter millis
    Serial.print("  time = ");   
    Serial.print(clockhours);
    Serial.print(":");   
    Serial.print(clockmins);
    if ( (since > 59000 ) && ( since < 61000 )) {  //  only calibrate the freerun timer if consecutive GPS minutes
      Serial.print(" since = ");  Serial.print(since);
      average = average * 0.95 + since * 0.05;  // deduct 5% of the average, and add 5% of the new reading
      Serial.print("  averaged since = ");   
      Serial.print(average);
      if ( (average < 61000 ) && ( average > 59000)) //  if its already locked on
     
      { float error = (average - ( long ) average);
        Serial.print(" error = "); Serial.println(error);
        if ( error >= .5 ) { average ++ ; }
        if (error <= -.5 ) { average --;  }
               interval = (long ) average ;
      } //  end of if locked on
      Serial.print(" interval rounded for free running timer = "); Serial.println(interval);
    }   

    showtime ();       
    // =====================================================================================================       
  }

}

//********************************************************************************************

void loop()
{
  while(uart_gps.available())     // While there is data on the RX pin...
  {
    int c = uart_gps.read();    // load the data into a variable...

    if(gps.encode(c))      // if there is a new valid sentence...
    {
      getgps(gps);         // then grab the data,
    }
  }

  //Serial.println("running clock    ");
  unsigned long currentMillis = millis();
  if(currentMillis - clockmillis > interval) {
    clockmillis = currentMillis;
    clockmins ++;
    if ( clockmins >59 ) {
      clockmins = 0;
      clockhours ++;
      if (clockhours >59 ) {
        clockhours = 0 ;
      }
    }// end of if mins>59
    Serial.print("  interval= ");
    Serial.print(interval);
    Serial.print("clock time   == ");
    Serial.print(clockhours);
    Serial.println(clockmins);
    showtime ();

  }//  end of if current - clock > interval

  // Serial.print("clock time   == "); Serial.print(clockhours); Serial.println(clockmins);
}  // end of loop


and heres some of the data being averaged ,


 interval rounded for free running timer = 60000
rxmin has just changed,  time = 12:49 since = 60008  averaged since = 60000.54 error = 0.54
 interval rounded for free running timer = 60001
rxmin has just changed,  time = 12:50 since = 59980  averaged since = 60000.46 error = 0.46
 interval rounded for free running timer = 60000
rxmin has just changed,  time = 12:51 since = 60013  averaged since = 60001.08 error = 0.09
 interval rounded for free running timer = 60001
rxmin has just changed,  time = 12:52 since = 60013  averaged since = 60001.68 error = 0.68
 interval rounded for free running timer = 60002
rxmin has just changed,  time = 12:53 since = 60008  averaged since = 60002.94 error = 0.95
 interval rounded for free running timer = 60003
rxmin has just changed,  time = 12:54 since = 59980  averaged since = 60002.75 error = 0.75
 interval rounded for free running timer = 60003
rxmin has just changed,  time = 12:55 since = 59995  averaged since = 60003.31 error = 0.31
 interval rounded for free running timer = 60003
rxmin has just changed,  time = 12:56 since = 60011  averaged since = 60003.69 error = 0.69
 interval rounded for free running timer = 60004
rxmin has just changed,  time = 12:57 since = 59984  averaged since = 60003.66 error = 0.66
 interval rounded for free running timer = 60004
rxmin has just changed,  time = 12:58 since = 60014  averaged since = 60005.12 error = 0.12
 interval rounded for free running timer = 60005
rxmin has just changed,  time = 12:59 since = 60011  averaged since = 60005.41 error = 0.41
 interval rounded for free running timer = 60005
rxmin has just changed,  time = 13:0 since = 59995  averaged since = 60004.89 error = 0.89
 interval rounded for free running timer = 60005
rxmin has just changed,  time = 13:1 since = 60008  averaged since = 60006.00 error = 1.00
 interval rounded for free running timer = 60006
rxmin has just changed,  time = 13:2 since = 59991  averaged since = 60006.19 error = 0.20
 interval rounded for free running timer = 60006
rxmin has just changed,  time = 13:3 since = 60012  averaged since = 60006.49 error = 0.49
 interval rounded for free running timer = 60006
rxmin has just changed,  time = 13:4 since = 59981  averaged since = 60005.21 error = 0.21
 interval rounded for free running timer = 60005
rxmin has just changed,  time = 13:5 since = 60006  averaged since = 60005.25 error = 0.25
 interval rounded for free running timer = 60005
rxmin has just changed,  time = 13:6 since = 59992  averaged since = 60004.59 error = 0.59
 interval rounded for free running timer = 60005
rxmin has just changed,  time = 13:7 since = 60006  averaged since = 60005.61 error = 0.61
 interval rounded for free running timer = 60006
rxmin has just changed,  time = 13:8 since = 60000  averaged since = 60006.28 error = 0.28
 interval rounded for free running timer = 60006
rxmin has just changed,  time = 13:9 since = 59998  averaged since = 60005.86 error = 0.86
 interval rounded for free running timer = 60006
1019  Using Arduino / Project Guidance / Re: simple averaging troubles on: December 09, 2011, 12:48:04 am
I have just spotted a simple running averager by macegr on adafruits forum I might play with, it looks like it might be quite smooth :-

Code:
float adcResult = 0;
void setup()
{  Serial.begin(9600); }

void loop()
{
  adcResult = adcResult * 0.95 + analogRead(0) * 0.05;
  Serial.println(adcResult);
  delay(50);
}
1020  Using Arduino / Project Guidance / Re: simple averaging troubles on: December 09, 2011, 12:39:18 am
Thanks James,  you are spot on -  both counts :-)

If I had posted all of the sketch, you ( and 50,000 other Arduino heads ) would immediately have seen that when I had captured the time of receiving the minute change from the GPS module, I had called it    "int present = millis () "  instead of unsigned long !

( giving me 43 million as "since" .)

Its working well now, except I must tell it to ignore any " since" over 61000 so that it only averages counts  between subsequent minutes.

( I didn't post the whole sketch as it was 75%  commented out lines    smiley-sad-blue  )
Pages: 1 ... 66 67 [68] 69 70 ... 98