Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: IDE input error: can't input quotation marks on: January 10, 2011, 12:53:10 pm
I suffer the same problem since upgrading from version 18 to version 21 on Ubuntu 64 bits.

Dead keys don't work in version 21.
2  Forum 2005-2010 (read only) / Development / Re: Time Library added to Playground on: November 01, 2010, 12:24:25 pm
Wow, that is a quick bugfix! smiley

It's working just fine now.
3  Forum 2005-2010 (read only) / Development / Re: Time Library added to Playground on: November 01, 2010, 06:06:05 am
That indeed solves the problem. So if I understand it right, to get a precise sync, for the moment, you need to call now() just before setTime() ?

Quote
\0x07Waiting for sync message

\0x07
now() time before syncing = 3
pctime, time that was synced with
= 1288477507
timeStatus() after syncing = 2
now() time after syncing = 1288477507


now() time before syncing = 1288477549
pctime, time that was synce
d with = 1288477507
timeStatus() after syncing = 2
now() time after syncing = 1288477507


now() time before syncing = 1288477534
pctime, time that was sy
nced with = 1288477507
timeStatus() after syncing = 2
now() time after syncing = 1288477507

Code:
/*
 * TimeSerial.pde
 * example code illustrating Time library set through serial port messages.
 *
 * Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970)
 * you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2010
 T1262347200  
 *
 * A Processing example sketch to automatically send the messages is inclided in the download
 */

#include <Time.h>  

#define TIME_MSG_LEN  11   // time sync to PC is HEADER followed by unix time_t as ten ascii digits
#define TIME_HEADER  'T'   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message
unsigned long timeStorage = 0;

void setup()  {
  Serial.begin(9600);
  setSyncProvider( requestSync);  //set function to call when sync required
  Serial.println("Waiting for sync message");
}

void loop(){    
  if(Serial.available() )
  {
    processSyncMessage();
  }
  if(timeStatus()!= timeNotSet)  
  {
    digitalWrite(13,timeStatus() == timeSet); // on if synced, off if needs refresh  
    digitalClockDisplay();  
  }
  delay(1000);
}

void digitalClockDisplay(){
  /* // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println(); */
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void processSyncMessage() {
  // if time sync available from serial port, update time and return true
  while(Serial.available() >=  TIME_MSG_LEN ){  // time message consists of a header and ten ascii digits
    char c = Serial.read() ;
    if( c == TIME_HEADER ) {      
      time_t pctime = 0;
      for(int i=0; i < TIME_MSG_LEN -1; i++){  
        c = Serial.read();          
        if( c >= '0' && c <= '9'){  
          pctime = (10 * pctime) + (c - '0') ; // convert digits to a number    
        }
      }  
      timeStorage = now();
      Serial.println();
      Serial.print("now() time before syncing = ");
      Serial.println(timeStorage);
      setTime(pctime);   // Sync Arduino clock to the time received on the serial port
      timeStorage = now();
      Serial.print("pctime, time that was synced with = ");
      Serial.println(pctime);
      Serial.print("timeStatus() after syncing = ");
      Serial.println(timeStatus());
      Serial.print("now() time after syncing = ");
      Serial.println(timeStorage);
    }  
  }
}

time_t requestSync()
{
  Serial.print(TIME_REQUEST,BYTE);  
  return 0; // the time will be sent later in response to serial mesg
}

4  Forum 2005-2010 (read only) / Development / Re: Time Library added to Playground on: November 01, 2010, 04:05:04 am
I've tried that, no difference, still quite large discrepancies in the synced time (now()) with the original time send via serial (pctime). The older DateTime library doesn't have this behaviour in the same situation.

The example below is what happens when the time T1288477507 was send 4 times to sync via serial.
Quote
\0x07Waiting for sync message

TtimeStatus() = 2, pctime = 1288477507 and now() = 1288477512


TtimeStatus() = 2, pctime = 1288477507 and now() = 1288477513


TtimeStatus() = 2, pctime = 1288477507 and now() = 1288477516


TtimeStatus() = 2, pctime = 1288477507 and now() = 1288477515

Code:
/*
 * TimeSerial.pde
 * example code illustrating Time library set through serial port messages.
 *
 * Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970)
 * you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2010
 T1262347200  
 *
 * A Processing example sketch to automatically send the messages is inclided in the download
 */

#include <Time.h>  

#define TIME_MSG_LEN  11   // time sync to PC is HEADER followed by unix time_t as ten ascii digits
#define TIME_HEADER  'T'   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message
unsigned long timeStorage = 0;

void setup()  {
  Serial.begin(9600);
  setSyncProvider( requestSync);  //set function to call when sync required
  Serial.println("Waiting for sync message");
}

void loop(){    
  if(Serial.available() )
  {
    processSyncMessage();
  }
  if(timeStatus()!= timeNotSet)  
  {
    digitalWrite(13,timeStatus() == timeSet); // on if synced, off if needs refresh  
    digitalClockDisplay();  
  }
  delay(1000);
}

void digitalClockDisplay(){
  /* // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println(); */
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void processSyncMessage() {
  // if time sync available from serial port, update time and return true
  while(Serial.available() >=  TIME_MSG_LEN ){  // time message consists of a header and ten ascii digits
    char c = Serial.read() ;
    Serial.print(c);  
    if( c == TIME_HEADER ) {      
      time_t pctime = 0;
      for(int i=0; i < TIME_MSG_LEN -1; i++){  
        c = Serial.read();          
        if( c >= '0' && c <= '9'){  
          pctime = (10 * pctime) + (c - '0') ; // convert digits to a number    
        }
      }  
      setTime(pctime);   // Sync Arduino clock to the time received on the serial port
      timeStorage = now();
      Serial.print("timeStatus() = ");
      Serial.print(timeStatus());
      Serial.print(", pctime = ");
      Serial.print(pctime);
      Serial.print(" and now() = ");
      Serial.println(timeStorage);
    }  
  }
}

time_t requestSync()
{
  Serial.print(TIME_REQUEST,BYTE);  
  return 0; // the time will be sent later in response to serial mesg
}

5  Forum 2005-2010 (read only) / Development / Re: Time Library added to Playground on: October 31, 2010, 04:40:53 pm
Just send T1262347200 a couple of times via serial, and see the result...

Code:
/*
 * TimeSerial.pde
 * example code illustrating Time library set through serial port messages.
 *
 * Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970)
 * you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2010
 T1262347200  
 *
 * A Processing example sketch to automatically send the messages is inclided in the download
 */
 
#include <Time.h>  

#define TIME_MSG_LEN  11   // time sync to PC is HEADER followed by unix time_t as ten ascii digits
#define TIME_HEADER  'T'   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message

void setup()  {
  Serial.begin(9600);
  setSyncProvider( requestSync);  //set function to call when sync required
  Serial.println("Waiting for sync message");
}

void loop(){    
  if(Serial.available() )
  {
    processSyncMessage();
  }
  if(timeStatus()!= timeNotSet)  
  {
    digitalWrite(13,timeStatus() == timeSet); // on if synced, off if needs refresh  
    digitalClockDisplay();  
  }
  delay(1000);
}

void digitalClockDisplay(){
  /* // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println(); */
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void processSyncMessage() {
  // if time sync available from serial port, update time and return true
  while(Serial.available() >=  TIME_MSG_LEN ){  // time message consists of a header and ten ascii digits
    char c = Serial.read() ;
    Serial.print(c);  
    if( c == TIME_HEADER ) {      
      time_t pctime = 0;
      for(int i=0; i < TIME_MSG_LEN -1; i++){  
        c = Serial.read();          
        if( c >= '0' && c <= '9'){  
          pctime = (10 * pctime) + (c - '0') ; // convert digits to a number    
        }
      }  
      setTime(pctime);   // Sync Arduino clock to the time received on the serial port
      Serial.print("timeStatus() = ");
      Serial.print(timeStatus());
      Serial.print(", pctime = ");
      Serial.print(pctime);
      Serial.print(" and now() = ");
      Serial.println(now());
    }  
  }
}

time_t requestSync()
{
  Serial.print(TIME_REQUEST,BYTE);  
  return 0; // the time will be sent later in response to serial mesg
}

6  Forum 2005-2010 (read only) / Development / Re: Time Library added to Playground on: October 30, 2010, 06:22:16 pm
Syncing time is not precise. I am using the timeserial example with a little addition. Just after the  setTime(pctime); command I've added two commands to print both the pctime (that was just set) and the now() internal time. I suppose they should be the same, but they never are.

The output is like this:

1288477507
1288477511


1288477507
1288477510


1288477507
1288477610


1288477507
1288477516

I think this is the same problem Breezetrees is referring to. Any idea how to sync the time with more precision?
7  Forum 2005-2010 (read only) / Interfacing / Re: RFID reader with card availble signal? on: January 22, 2011, 05:23:17 am
That's one I have here at home. smiley

The problem is that this LED signal takes a long time, more than the time needed to send the serial info. I need fast response times. But last night I managed to find the solution. Take the LED signa from the id-12l, and when this is high give a reset signal to the id-12. This way it behaves just like the other type of reader I mentioned above. The difference off course is that an extra pin is needed, but that is no problem.
8  Forum 2005-2010 (read only) / Interfacing / RFID reader with card availble signal? on: January 20, 2011, 10:58:53 pm
I would like to find a RFID reader with a card available signal so I can easilly hook up multiple readers with NewSoftSerial with a minimal chance of loosing reads. I've found a reader that gives a card available signal. When a card is detected this pin is high. After 6ms, TX outputs data.  Then it becomes low after TX output finished:
http://www.emartee.com/product/41968/125Khz-RFID-Mini-Module-Kits#
I've tested a setup with four readers, and it works just fine. The problem is that these don't give a strong enough field to activate small glass tags, which I need for my project.

Anybody knows of a better reader with a card available signal?
Pages: [1]