<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://calebneedscollege.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Vector_Clock</id>
	<title>Vector Clock - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://calebneedscollege.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Vector_Clock"/>
	<link rel="alternate" type="text/html" href="http://calebneedscollege.com/wiki/index.php?title=Vector_Clock&amp;action=history"/>
	<updated>2026-05-15T14:24:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.1</generator>
	<entry>
		<id>http://calebneedscollege.com/wiki/index.php?title=Vector_Clock&amp;diff=74&amp;oldid=prev</id>
		<title>Legg: Created page with &quot;==Synopsis== Use an oscilloscope in XY mode to display time.  Uses two MCP4725 and a DS1302. ==Notes== Known bug.  12 hour hand is missing.  Hour hand does not creep, but inst...&quot;</title>
		<link rel="alternate" type="text/html" href="http://calebneedscollege.com/wiki/index.php?title=Vector_Clock&amp;diff=74&amp;oldid=prev"/>
		<updated>2020-12-08T19:01:39Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Synopsis== Use an oscilloscope in XY mode to display time.  Uses two MCP4725 and a DS1302. ==Notes== Known bug.  12 hour hand is missing.  Hour hand does not creep, but inst...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Synopsis==&lt;br /&gt;
Use an oscilloscope in XY mode to display time.  Uses two MCP4725 and a DS1302.&lt;br /&gt;
==Notes==&lt;br /&gt;
Known bug.  12 hour hand is missing.  Hour hand does not creep, but instead moves in one hour notches.  Ideally, use the Sine function to determine precise positioning.&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C++&amp;quot; line='line'&amp;gt;&lt;br /&gt;
//Arduino UNO&lt;br /&gt;
//Pin 5  : DS1302 Chip Enable &lt;br /&gt;
//Pin 6  : DS1302 Data&lt;br /&gt;
//Pin 7  : DS1302 Data Clock&lt;br /&gt;
//Pin A4 : MCP4725 SDA pins&lt;br /&gt;
//Pin A5 : MCP4725 SCK pins&lt;br /&gt;
//&lt;br /&gt;
//5 Volt pin powers all external devices&lt;br /&gt;
//Please verify that your modules are also&lt;br /&gt;
//compatible with a 5 volt supply.&lt;br /&gt;
//&lt;br /&gt;
//On the MCP4725 devices, attach one A0&lt;br /&gt;
//pin to 5 volts and the other to ground&lt;br /&gt;
//to ensure these are on different addresses&lt;br /&gt;
//The SDA and SCK pins on these can be attached&lt;br /&gt;
//to each other.  The device ID of the&lt;br /&gt;
//MCP4725 had to be discovered experimentally&lt;br /&gt;
//and you may need to discover those values as&lt;br /&gt;
//well.&lt;br /&gt;
//&lt;br /&gt;
//On the MCP4725, choose the voltage out pins&lt;br /&gt;
//to be connected to the X and Y inputs of&lt;br /&gt;
//your oscilloscope such that the clock is suitably rotated.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;Wire.h&amp;gt;&lt;br /&gt;
#include &amp;lt;Adafruit_MCP4725.h&amp;gt;&lt;br /&gt;
#include &amp;lt;DS1302.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//Begin DS1302 Configuration&lt;br /&gt;
const int kCePin  = 5;  // Chip Enable&lt;br /&gt;
const int kIoPin   = 6;  // Input/Output&lt;br /&gt;
const int kSclkPin = 7;  // Serial Clock&lt;br /&gt;
DS1302 rtc(kCePin, kIoPin, kSclkPin);&lt;br /&gt;
//End DS1302 Configuration&lt;br /&gt;
&lt;br /&gt;
// Begin MCP4725 Configuration&lt;br /&gt;
Adafruit_MCP4725 dac_X;&lt;br /&gt;
Adafruit_MCP4725 dac_Y;&lt;br /&gt;
// End MCP4725 Configuration&lt;br /&gt;
&lt;br /&gt;
//timing and counnters&lt;br /&gt;
long us;&lt;br /&gt;
bool toggle;&lt;br /&gt;
byte t=0;&lt;br /&gt;
&lt;br /&gt;
const uint16_t DACLookup_FullSine_8Bit[256] =&lt;br /&gt;
{&lt;br /&gt;
  2048, 2098, 2148, 2198, 2248, 2298, 2348, 2398,&lt;br /&gt;
  2447, 2496, 2545, 2594, 2642, 2690, 2737, 2784,&lt;br /&gt;
  2831, 2877, 2923, 2968, 3013, 3057, 3100, 3143,&lt;br /&gt;
  3185, 3226, 3267, 3307, 3346, 3385, 3423, 3459,&lt;br /&gt;
  3495, 3530, 3565, 3598, 3630, 3662, 3692, 3722,&lt;br /&gt;
  3750, 3777, 3804, 3829, 3853, 3876, 3898, 3919,&lt;br /&gt;
  3939, 3958, 3975, 3992, 4007, 4021, 4034, 4045,&lt;br /&gt;
  4056, 4065, 4073, 4080, 4085, 4089, 4093, 4094,&lt;br /&gt;
  4095, 4094, 4093, 4089, 4085, 4080, 4073, 4065,&lt;br /&gt;
  4056, 4045, 4034, 4021, 4007, 3992, 3975, 3958,&lt;br /&gt;
  3939, 3919, 3898, 3876, 3853, 3829, 3804, 3777,&lt;br /&gt;
  3750, 3722, 3692, 3662, 3630, 3598, 3565, 3530,&lt;br /&gt;
  3495, 3459, 3423, 3385, 3346, 3307, 3267, 3226,&lt;br /&gt;
  3185, 3143, 3100, 3057, 3013, 2968, 2923, 2877,&lt;br /&gt;
  2831, 2784, 2737, 2690, 2642, 2594, 2545, 2496,&lt;br /&gt;
  2447, 2398, 2348, 2298, 2248, 2198, 2148, 2098,&lt;br /&gt;
  2048, 1997, 1947, 1897, 1847, 1797, 1747, 1697,&lt;br /&gt;
  1648, 1599, 1550, 1501, 1453, 1405, 1358, 1311,&lt;br /&gt;
  1264, 1218, 1172, 1127, 1082, 1038,  995,  952,&lt;br /&gt;
   910,  869,  828,  788,  749,  710,  672,  636,&lt;br /&gt;
   600,  565,  530,  497,  465,  433,  403,  373,&lt;br /&gt;
   345,  318,  291,  266,  242,  219,  197,  176,&lt;br /&gt;
   156,  137,  120,  103,   88,   74,   61,   50,&lt;br /&gt;
    39,   30,   22,   15,   10,    6,    2,    1,&lt;br /&gt;
     0,    1,    2,    6,   10,   15,   22,   30,&lt;br /&gt;
    39,   50,   61,   74,   88,  103,  120,  137,&lt;br /&gt;
   156,  176,  197,  219,  242,  266,  291,  318,&lt;br /&gt;
   345,  373,  403,  433,  465,  497,  530,  565,&lt;br /&gt;
   600,  636,  672,  710,  749,  788,  828,  869,&lt;br /&gt;
   910,  952,  995, 1038, 1082, 1127, 1172, 1218,&lt;br /&gt;
  1264, 1311, 1358, 1405, 1453, 1501, 1550, 1599,&lt;br /&gt;
  1648, 1697, 1747, 1797, 1847, 1897, 1947, 1997&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
const long HandsX[60] = &lt;br /&gt;
{&lt;br /&gt;
  2047, 2261, 2473, 2680, 2880, 3071, 3251, 3417,&lt;br /&gt;
  3569, 3704, 3820, 3918, 3994, 4050, 4083, 4095,&lt;br /&gt;
  4083, 4050, 3994, 3918, 3820, 3704, 3569, 3417,&lt;br /&gt;
  3251, 3071, 2880, 2680, 2473, 2261, 2048, 1834,&lt;br /&gt;
  1622, 1415, 1215, 1024,  844,  678,  526,  391,&lt;br /&gt;
   275,  177,  101,   45,   12,    1,   12,   45,&lt;br /&gt;
   101,  177,  275,  391,  526,  678,  844, 1024,&lt;br /&gt;
  1215, 1415, 1622, 1834&lt;br /&gt;
};&lt;br /&gt;
const long HandsY[60] =&lt;br /&gt;
{&lt;br /&gt;
  4095, 4083, 4050, 3994, 3918, 3820, 3704, 3569,&lt;br /&gt;
  3417, 3251, 3071, 2880, 2680, 2473, 2261, 2048,&lt;br /&gt;
  1834, 1622, 1415, 1215, 1024,  844,  678,  526,&lt;br /&gt;
   391,  275,  177,  101,   45,   12,    1,   12,&lt;br /&gt;
    45,  101,  177,  275,  391,  526,  678,  844,&lt;br /&gt;
  1024, 1215, 1415, 1622, 1834, 2047, 2261, 2473,&lt;br /&gt;
  2680, 2880, 3071, 3251, 3417, 3569, 3704, 3820,&lt;br /&gt;
  3918, 3994, 4050, 4083&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void Hand(byte v, byte len)&lt;br /&gt;
{&lt;br /&gt;
  long i,x,y;&lt;br /&gt;
  for(i=0;i&amp;lt;len;i++)&lt;br /&gt;
  //Draw from center&lt;br /&gt;
  {&lt;br /&gt;
    //2048,2048 is the center.&lt;br /&gt;
    x=2048+(HandsX[v]-2048)*i/100; &lt;br /&gt;
    y=2048+(HandsY[v]-2048)*i/100; &lt;br /&gt;
    dac_X.setVoltage(x   , false,400000);&lt;br /&gt;
    dac_Y.setVoltage(y   , false,400000);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Circle()&lt;br /&gt;
{&lt;br /&gt;
    uint16_t i;&lt;br /&gt;
    uint16_t j;&lt;br /&gt;
      for (i = 0; i &amp;lt; 256; i++)&lt;br /&gt;
      {&lt;br /&gt;
        dac_X.setVoltage(DACLookup_FullSine_8Bit[i], false);&lt;br /&gt;
&lt;br /&gt;
        j=i+193;&lt;br /&gt;
        j=j%256;&lt;br /&gt;
        dac_Y.setVoltage(DACLookup_FullSine_8Bit[j], false);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void setup(void) {&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  delay(1000);&lt;br /&gt;
  rtc.writeProtect(true);&lt;br /&gt;
  Serial.println(&amp;quot;This page intentionally left blank.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  dac_X.begin(0x63);&lt;br /&gt;
  dac_Y.begin(0x62);&lt;br /&gt;
  us = 500000 + micros();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop(void) &lt;br /&gt;
{&lt;br /&gt;
  byte hr;&lt;br /&gt;
  Time tm;&lt;br /&gt;
  tm = rtc.time();&lt;br /&gt;
  hr=tm.hr;&lt;br /&gt;
  while(hr&amp;gt;12) hr -= 12;&lt;br /&gt;
  &lt;br /&gt;
   if(t==0)&lt;br /&gt;
  {&lt;br /&gt;
    //Update time from rtc&lt;br /&gt;
&lt;br /&gt;
    t=1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if(micros()&amp;lt;us)&lt;br /&gt;
  {&lt;br /&gt;
    Circle();&lt;br /&gt;
    Hand(tm.min,70);  //Minutes&lt;br /&gt;
    Hand(hr*5,50); //Hours&lt;br /&gt;
    if(toggle){Hand(tm.sec,90);} //Seconds&lt;br /&gt;
  }&lt;br /&gt;
  else&lt;br /&gt;
  {&lt;br /&gt;
      us = 500000 + micros();&lt;br /&gt;
      if(toggle) toggle=LOW; else toggle=HIGH;&lt;br /&gt;
      &lt;br /&gt;
      t++;  &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Legg</name></author>
		
	</entry>
</feed>