Editing TideClock

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
 
[[Image:tideclock_boardassy_01.jpg]]
 
[[Image:tideclock_boardassy_01.jpg]]
 
Here are the two PCBs comprising the clock.  I haven't finished the wooden cabinet they will go into. Stay tuned...
 
  
 
== Description ==
 
== Description ==
Line 34: Line 32:
 
The prototypes (4 are in various stages of construction) have cost about $500 each for materials. Labour not included...
 
The prototypes (4 are in various stages of construction) have cost about $500 each for materials. Labour not included...
  
== Hardware files ==
+
== Hardware design files ==
 
Warning!!! Use this design at your own risk.
 
Warning!!! Use this design at your own risk.
 
Download the hardware files [http://svfreya.ca/tideclock/TideClock_revA.zip here].  This .ZIP file contains two subfolders: a '''Design Files''' folder with the Altium-format schematic and PCB layout files; and a '''Manufacturing Files''' folder with the Gerbers and PDFs of the Schematics and Assembly drawings.
 
 
During building of the first 4 TideClocks, I made a few changes and am calling it revision B. The changes are:
 
*decreased diameter of holes in pads for mounting Linuxstamp I
 
*placed Max input voltage on silkscreen near solar input pads
 
*included PCB and Assy part numbers
 
*corrected polarity of supercap on silkscreen
 
*changed C207 2u2 to 1uF for commonality of parts
 
*included 3D model of LinuxStamp I on 3D model of PCB.
 
The hardware files for revision B are [http://svfreya.ca/tideclock/TideClock_revB.zip here].
 
  
 
== Power ==
 
== Power ==
Line 66: Line 53:
  
 
== Busybox ==
 
== Busybox ==
I configured Busybox pretty much as described for the Linuxstamp.
 
  
 
== Building the Linux Kernel ==
 
== Building the Linux Kernel ==
Line 96: Line 82:
 
* turn off Network Device Support->"PPP support"
 
* turn off Network Device Support->"PPP support"
 
* turn on "I2C Core Debugging messages"
 
* turn on "I2C Core Debugging messages"
* turn on Device Drivers -> Real Time Clock->"Intersil ISL1208" (MUST if you want to use the external RTC)
+
* turn on Real Time Clock->"Intersil ISL1208" (MUST if you want to use the external RTC)
* turn on Device Drivers -> CONFIG_RTC_HCTOSYS (MUST if you want the kernel to set system time from the RTC)
 
* set Device Drivers -> Real Time Clock-> RTC_HCTOSYS_DEVICE='rtc1' (MUST indicate which RTC to pull the time from)
 
 
* turn on RAMDISK support, so we can put kernel+rfs into flash and run the whole thing out of RAM. During booting the kernel+flash image is uncompressed into RAM and the rfs image mounted as /
 
* turn on RAMDISK support, so we can put kernel+rfs into flash and run the whole thing out of RAM. During booting the kernel+flash image is uncompressed into RAM and the rfs image mounted as /
 
** in “Main menu”->“Device Drivers”->“Block devices” make sure “RAM disk support” is selected.  
 
** in “Main menu”->“Device Drivers”->“Block devices” make sure “RAM disk support” is selected.  
Line 211: Line 195:
  
 
Use Darrell's Bootloader on the Linuxstamp to upload the new kernel+rfs to dataflash. The Linuxstamp should now boot without an SD card and without an NFS server.  The u-Boot kernel arguments can still include an nfs server rfs - they will be ignored.
 
Use Darrell's Bootloader on the Linuxstamp to upload the new kernel+rfs to dataflash. The Linuxstamp should now boot without an SD card and without an NFS server.  The u-Boot kernel arguments can still include an nfs server rfs - they will be ignored.
 
== I2C and RTC ==
 
The TideClock includes a Real Time Clock (RTC) (Intersil ISL1208) to keep time when the rest of the device is off. The kernel reads the RTC during booting to update the system time, which allows the tidal predictions to be correct for the current time. The RTC is powered by a supercap for several weeks of timekeeping when no other power is available.
 
 
Since the Linuxstamp CPU includes its own CPU. it would have been possible to rewire that board to provide a separate backup supply to its crystal but I thought it easier to leave the Linuxstamp unmodified and just provide a separate RTC.  It turned out that using the Linuxstamp RTC was no more difficult that the way I chose, so for cost savings one could dispense with the separate RTC.
 
 
The ISL1208 communicates via I2C so I had to get that feature operating. As a start, read http://openhardware.wordpress.com/2008/10/13/i2c-fun-with-the-at91rm9200/
 
 
I tried
 
<pre>
 
patch -i addRTC.patch -o board-ecbat91.c
 
</pre>
 
but it failed to patch (not right version?) so I made the modifications by hand.  A patch file for my mods will be posted shortly...
 
 
I also patched the at91rm9200_devices.c file to move the SCK pin from PA26 to PA24, and to slow down the I2C clock from ~167kHz to ~67kHz. A patch file for my mods will be posted shortly...
 
 
Remember to also edit the kernel's .config (using <tt>make ARCH=arm menuconfig</tt> as described in the Kernel section above) to enable the RTC portions of the kernel. Note that rtc0 points to the Linuxstamp's CPU (AT91RM9100) internal RTC, while rtc1 points to the ISL1208.
 
 
When testing I2C functionality, you can cross-compile the I2C tools from http://www.lm-sensors.org/wiki/I2CTools and they will run on the Linuxstamp.
 
With the ISL1208 attached to pins 24 (I2C_SCK) and 25 (I2C_SDA), it appears on I2C bus 0 at address 0x6f (0b1101111x) and you can read back the minutes by:
 
<pre>
 
./i2cget 0 0x6f 0x01
 
</pre>
 
 
When an ISL1208 is powered up for the first time or following total power loss (i.e. no backup battery), its time registers will not begin updating until at least one of time registers has been written to.  To write to the registers the write-enable bit 4 of register 0x07 needs to be set to 1 first.  e.g. To set the time to 23 minutes after the hour, do:
 
<pre>
 
./i2cset 0 0x6f 0x07 0x10
 
./i2cset 0 0x6f 0x01 23
 
</pre>
 
 
The I2C tools won't access the clock when a kernel that has control of rtc1 is running. Use the <tt>busybox hwclock ...</tt> function instead. On the command line, set the system time/date and then write the system time to the ISL1208 by:
 
<pre>
 
date -s "2011-12-29 11:40"
 
busybox hwclock -w -f /dev/rtc1
 
</pre>
 
 
Reading the RTC is similar:
 
<pre>
 
busybox hwclock -f /dev/rtc1                                               
 
  rtc-isl1208 0-006f: read time OK                                               
 
  Thu Dec 29 11:25:34 2011  0.000000 seconds
 
</pre>
 
 
TODO:  the ISL1208 can be ''tuned'' (calibrated) to minimize inaccuracies.
 
 
See also the kernel's ./Documentation/rtc.txt, which includes a test program for messing with the RTC.  The sysfs interface under /sys/class/rtc/rtcN provides read-only access to various rtc attributes. Google for more info.
 
 
Note that the CPU's internal RTC (rtc0) is *not* updated automatically from either the ISL1208 or the system clock. If you plan on using it and want it synced with the rtc1/system time, the toss the following into <tt>/etc/init.d/rcS</tt>.
 
<pre>
 
busybox hwclock -w -f /dev/rtc0
 
</pre>
 
 
== Power-saving Suspend ==
 
I was able to get the CPU to suspend to RAM and cut its current consumption to about 12mA.  Before suspending, the internal RTC (rtc0) was set to wake the CPU after a set elapsed time (e.g. 15 minutes).  This is used to update the TideClock graph at intervals and sleep in between to cut power consumption.
 
 
Details to follow shortly.
 
 
  
 
== GPIO / Hardware Pin I/O ==
 
== GPIO / Hardware Pin I/O ==

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)