Jump to content
OMRON Forums

Steven Beaumont

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by Steven Beaumont

  1. This code will get time since epoch with nanosecond resolution. You can convert to milliseconds and round first if you want.

     

    struct timespec start;
    clock_gettime( CLOCK_REALTIME, &start);
    return(start.tv_sec+start.tv_nsec/1000000000.0);

     

    It should be added to the NTP app note soon.

     

    Thanks used this code but it locked up system if it is run on every plc cycle

     

    struct timeval MyTimeVal;

    gettimeofday(&MyTimeVal, NULL);

     

    Which code would be best in your opinion.

     

    Regards

    Steven

  2. I have been working on capturing encoder positions and logging it relative to real world UTC time.

    I have the Linux operating system synced to a ptp time source but the only access to this time I have found is the C++ code "time()" which give time as an integer in seconds, is there a method to get sub second time from within C code, I am looking for at least millisecond resolution anything better would be a plus.

    I have already tried to use "ftime()" but found it crashed the system.

    any help here would be appreciated.

     

    Regards

    Steven

×
×
  • Create New...