View previous topic :: View next topic |
Author |
Message |
daveh
Joined: 30 Aug 2013 Posts: 19
|
Acquire Date / Time from USB port |
Posted: Thu Mar 27, 2014 8:58 am |
|
|
I was wondering if anyone knows of a way to acquire the date / time from a USB port aside from creating a driver + program?
I'm not intending to use the USB for any other purpose than to update a Real Time Clock so the thought is that I would configure it as an HID or some other device that would have standard drivers pre-installed in windows (not requiring a program to be installed). I could plug the device into the USB port, it would get the date/time info from the computer and I could then disconnect the device.
I didn't know if any standard USB classes would have that capability? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Mar 27, 2014 9:29 am |
|
|
I don't think any do, without something being done at the PC end.
Obviously (for instance), if a drive is implemented, and then a file opened on this, it has a time stamp, but not easy to do. I don't think any of the standard classes would offer a simple way to get the time.
The standard USB interfaces with built in drivers, are at:
<http://msdn.microsoft.com/en-us/library/windows/hardware/ff538820%28v=vs.85%29.aspx>
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Thu Mar 27, 2014 10:39 am |
|
|
First problem is that the PC running Windows probably doesn't have the correct time ! Case in point, on this PC, running XP, with the 'clock' set to autoupdate using the web is 1 hour off, even if using NIST.com. What if the PC is off due to power failure? How do you verify the PC time really is correct??
Admittedly, it's not too hard to access the RTC of the PC, if you're using a Win98 machine as you have real comports with real interrupts. After 98, it got 'complicated'.
I would think a GPS module interfaced to your PIC might be a better choice to capture the 'real' time in order to update the local PIC connected RTC.
Perhaps a better option ?
Jay |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Thu Mar 27, 2014 10:53 am |
|
|
Sounds like he needs an "idiot proof" way of setting the time on his PIC project, and plugging it into a PC then unplugging it IS an attractive option (if that was indeed feasible).
I suspect that adding something like a GPS module is a rather unattractive option for him. |
|
|
daveh
Joined: 30 Aug 2013 Posts: 19
|
|
Posted: Thu Mar 27, 2014 11:11 am |
|
|
I'm building a little programmer to program the EEPROM on a fuel gauge and wanted to be able to put the date it's programmed. So I was looking for an easy way to do it w/o adding a bunch of buttons and implementing a user interface to manually set it.
The GPS isn't a bad idea but seemed like a bit of overkill. You'd still have to adjust that for time zone and DST right?
I'd like to just give this device to a tech and if he sees the time is off then plug it in and it will auto update to the computer time (which may or may not be correct). |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Thu Mar 27, 2014 11:59 am |
|
|
Yes, I know GPS is 'overkill' but might be a cheap solution. Have you considered the RTC accuracy of your product? If an RTC 'chip', they need crystals and unless you buy expensive crystals, use great PCB design, the RTC will lose time. Even a 1/4 second a day adds up. If a battery powered PIC with RTC internal, you need big batteries to keep it happy.
The configuring of the GPS should be a one time deal, or a simple 'power up function' that adjusts for time zone/DST options.
hth
jay |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Mar 27, 2014 10:53 pm |
|
|
I might be missing alot of details here but cant you use the:
_TIME_
_DATE_
...Options that come with CCS?
As i uderstand this information updates every time you program your chip.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Fri Mar 28, 2014 1:18 am |
|
|
I don't think he is just programming a PIC, but writing his own device to setup/program something else.
Best Wishes |
|
|
|