<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.extremist.software/index.php?action=history&amp;feed=atom&amp;title=Hack_Notes_CVA_090617</id>
	<title>Hack Notes CVA 090617 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.extremist.software/index.php?action=history&amp;feed=atom&amp;title=Hack_Notes_CVA_090617"/>
	<link rel="alternate" type="text/html" href="https://wiki.extremist.software/index.php?title=Hack_Notes_CVA_090617&amp;action=history"/>
	<updated>2026-04-06T13:31:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.13</generator>
	<entry>
		<id>https://wiki.extremist.software/index.php?title=Hack_Notes_CVA_090617&amp;diff=5690&amp;oldid=prev</id>
		<title>Elgreengeeto: New page: =hacknotes 090617=  ==An idea== Messing around with trying to fit two 595 power shift registers onto the next board design and with moving up to an 18-pin socket for the motors the followi...</title>
		<link rel="alternate" type="text/html" href="https://wiki.extremist.software/index.php?title=Hack_Notes_CVA_090617&amp;diff=5690&amp;oldid=prev"/>
		<updated>2009-06-18T01:45:07Z</updated>

		<summary type="html">&lt;p&gt;New page: =hacknotes 090617=  ==An idea== Messing around with trying to fit two 595 power shift registers onto the next board design and with moving up to an 18-pin socket for the motors the followi...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=hacknotes 090617=&lt;br /&gt;
&lt;br /&gt;
==An idea==&lt;br /&gt;
Messing around with trying to fit two 595 power shift registers onto the next board design and with moving up to an 18-pin socket for the motors the following ocurred to me:&lt;br /&gt;
*Given that we only want to be able to turn on one motor at a time, having two 595&amp;#039;s is quite redundant.&lt;br /&gt;
*An 18-pin socket is hella big.&lt;br /&gt;
*If we used one 595 plus a switch controlling two separate power rails, we save money and board space and, best of all, control up to 16 motors with a 10-pin socket (assuming that we swap the always-ground pin with the second power rail).&lt;br /&gt;
*The drawbacks of this design would be:&lt;br /&gt;
**It further complicates the already complicated construction of the pager motor array when needing more than 8 motors&lt;br /&gt;
**Using any arbitrary combination of multiple motors could only theoretically be done by switching really quickly between each half really quickly. Doing this with LEDs one would likely see the flickering, doing it with motors however may not be as noticeable?&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
I bread-boarded up a circuit with one 595 and two 2N2222 transistors (I don&amp;#039;t know where to look for a single switch but I&amp;#039;m sure these exist). With the following code I was able to control 8 leds easily using only 4 sinks on the 595. I couldn&amp;#039;t quite work out getting arbitrary combinations by rapid switching to work right.&lt;br /&gt;
&lt;br /&gt;
==Circuit==&lt;br /&gt;
[[Image:IMG_7405.JPG]]&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// define the pins used to run the shift registers &lt;br /&gt;
int enable_low = 6;  //STR&lt;br /&gt;
int serial_in  = 2;&lt;br /&gt;
int ser_clear_low = 4;&lt;br /&gt;
int RCK  = 5;&lt;br /&gt;
int SRCK = 7;&lt;br /&gt;
&lt;br /&gt;
//define transistor pins&lt;br /&gt;
int T1 = 13;&lt;br /&gt;
int T2 = 9;&lt;br /&gt;
&lt;br /&gt;
int count;&lt;br /&gt;
int i;&lt;br /&gt;
unsigned long serialTimer = millis();&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  pinMode(enable_low, OUTPUT);  // set shift register pins as outputs&lt;br /&gt;
  pinMode(serial_in, OUTPUT);&lt;br /&gt;
  pinMode(ser_clear_low, OUTPUT);&lt;br /&gt;
  pinMode(RCK, OUTPUT);&lt;br /&gt;
  pinMode(SRCK, OUTPUT);&lt;br /&gt;
  &lt;br /&gt;
  // use some serial for debugging&lt;br /&gt;
  Serial.begin(115200);&lt;br /&gt;
  Serial.println(&amp;quot;Setting up board&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  // make sure we start out all off&lt;br /&gt;
  digitalWrite(enable_low, HIGH);&lt;br /&gt;
  // this should wipe out the serial buffer on the shift register&lt;br /&gt;
  digitalWrite(ser_clear_low, LOW);&lt;br /&gt;
  delay(100);   //delay in ms&lt;br /&gt;
  &lt;br /&gt;
  // work on a rising edge, so make sure they&amp;#039;re low to start.&lt;br /&gt;
  digitalWrite(RCK, LOW);&lt;br /&gt;
  digitalWrite(SRCK, LOW);&lt;br /&gt;
  &lt;br /&gt;
  digitalWrite(ser_clear_low, HIGH);   //we are now clear to write into the serial buffer&lt;br /&gt;
&lt;br /&gt;
  Serial.println(&amp;quot;Board is setup&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	Debug();&lt;br /&gt;
&lt;br /&gt;
//promising, but doesn&amp;#039;t quite work!&lt;br /&gt;
/*	for(i=0;i&amp;lt;10000;i++){&lt;br /&gt;
    	analogWrite(T2, 0);&lt;br /&gt;
    	analogWrite(T1, 255);&lt;br /&gt;
      	shiftOut(serial_in, SRCK, LSBFIRST, 00100000);&lt;br /&gt;
      	delayMicroseconds(100);&lt;br /&gt;
  		digitalWrite(RCK, HIGH);&lt;br /&gt;
  		delayMicroseconds(100);&lt;br /&gt;
  		digitalWrite(RCK, LOW);&lt;br /&gt;
    	analogWrite(T1, 0);&lt;br /&gt;
    	analogWrite(T2, 255);&lt;br /&gt;
      	shiftOut(serial_in, SRCK, LSBFIRST, 10000000);&lt;br /&gt;
      	delayMicroseconds(100);&lt;br /&gt;
  		digitalWrite(RCK, HIGH);&lt;br /&gt;
  		delayMicroseconds(100);&lt;br /&gt;
  		digitalWrite(RCK, LOW);&lt;br /&gt;
	}*/&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//// FUNCTIONS&lt;br /&gt;
&lt;br /&gt;
void Debug(){&lt;br /&gt;
  for(count=1;count&amp;lt;9;count++){&lt;br /&gt;
  	TurnOnMotor(count);&lt;br /&gt;
  	delay(500);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void TurnOnMotor(int which){&lt;br /&gt;
  // accept which from 1 to 8&lt;br /&gt;
  // send message to shift register as appropiate&lt;br /&gt;
  digitalWrite(enable_low, HIGH);&lt;br /&gt;
  delayMicroseconds(100);  //slow and steady&lt;br /&gt;
  Serial.print(&amp;quot;Motor  &amp;quot;);&lt;br /&gt;
  Serial.println(which); // print angle&lt;br /&gt;
  switch(which){&lt;br /&gt;
    case 1:&lt;br /&gt;
      analogWrite(T2, 0);&lt;br /&gt;
      analogWrite(T1, 255);&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 00010000);&lt;br /&gt;
      break;&lt;br /&gt;
    case 2:&lt;br /&gt;
      analogWrite(T2, 0);&lt;br /&gt;
      analogWrite(T1, 255);&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 00100000);&lt;br /&gt;
      break;&lt;br /&gt;
    case 3:&lt;br /&gt;
      analogWrite(T2, 0);&lt;br /&gt;
      analogWrite(T1, 255);&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 01000000);&lt;br /&gt;
      break;&lt;br /&gt;
      analogWrite(T2, 0);&lt;br /&gt;
      analogWrite(T1, 255);&lt;br /&gt;
    case 4:&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 10000000);&lt;br /&gt;
      break;&lt;br /&gt;
    case 5:&lt;br /&gt;
      analogWrite(T1, 0);&lt;br /&gt;
      analogWrite(T2, 255);&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 00010000);&lt;br /&gt;
      break;&lt;br /&gt;
    case 6:&lt;br /&gt;
      analogWrite(T1, 0);&lt;br /&gt;
      analogWrite(T2, 255);&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 00100000);&lt;br /&gt;
      break;&lt;br /&gt;
    case 7:&lt;br /&gt;
      analogWrite(T1, 0);&lt;br /&gt;
      analogWrite(T2, 255);&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 01000000);&lt;br /&gt;
      break;&lt;br /&gt;
    case 8:&lt;br /&gt;
      analogWrite(T1, 0);&lt;br /&gt;
      analogWrite(T2, 255);&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 10000000);&lt;br /&gt;
      break;&lt;br /&gt;
    case 0:&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 0);&lt;br /&gt;
      break;&lt;br /&gt;
    default:&lt;br /&gt;
      // turn them all off&lt;br /&gt;
      shiftOut(serial_in, SRCK, LSBFIRST, 0);&lt;br /&gt;
  } &lt;br /&gt;
  //in all cases, pulse RCK to pop that into the outputs&lt;br /&gt;
  delayMicroseconds(100);&lt;br /&gt;
  digitalWrite(RCK, HIGH);&lt;br /&gt;
  delayMicroseconds(100);&lt;br /&gt;
  digitalWrite(RCK, LOW);&lt;br /&gt;
  analogWrite(enable_low, 0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elgreengeeto</name></author>
	</entry>
</feed>