Editing PIC based Stepper Motor Dancing Analog Clock

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 114: Line 114:
 
|}
 
|}
  
=== Circuit ===
 
  
The circuit does not need much explanation beyond the schematic and parts list.  Here is just an overview.
 
 
To make it really easy to fabricate the printed circuit boards I seperated the power supply from the processor board.
 
 
For parts I used used my junk box, when it fails consider SparkFun and Futurlec.  Or.....  See: [[Supplier]].
 
 
To see the circuit and board in detail download the files and view in Eagle, the free version is fine.
 
 
==== Power Supply ====
 
 
This is a straight forward half wave rectifier with a linear regulator.  It is powered by a wall wart transformer rated at about 9 volts.  The unregulated voltage is over 9 volts ( 9 * ( 2 ^ 1/2 )) by simple theory.  This unregulated voltage is used directly by the steppers so choose you wall wart to match your stepper motors.  You should also size the filter caps based on the current that will be used by the motors.  A couple of volts of ripple is not a problem as long as you have enough overhead for the 5 volt regulator ( the PIC might run on less, let me know if you try it ).  An important part of the power supply is a 60 hz, roughly square wave.  It is clipped off from the AC input.  The 60 Hz power line tends to be very accurate over the long term, less so if you suffer power outages.  You could run the clock on batteries but the motors load down a battery pretty badly and you would need a different timing signal ( the original code has a subroutine for timing off the crystal ).
 
 
===== Power Supply Schematic and Board =====
 
 
Single sided, for toner transfer, in Eagle ( semi-final, less ground plane, files may be more up to date )
 
Note that I have included some parts for very conserative design, which I did not in fact use.
 
 
[[Image:PowerSupplyBoardSch.png  | Power Supply Schematic ]]
 
 
[[Image:PowerSupplyBoardBrd.png  | Power Supply Board ]]
 
 
Parts
 
 
{| class="wikitable"
 
|-valign="top"
 
|Part
 
|Details
 
<!-------------------------------->
 
|-valign="top"
 
|Wall Wart
 
|You need one with AC output to get the 60 Hz timing signal from the power line.  Mine is a 9 v 800 ma unit.  I found it somewhere.  The unregulated rectified voltage should be good for your motor, so check your motor against the wall wart.  The 9 volt unit does a good job of driving a 12 volt motor.  Motors do not need very well regulated power.
 
<!-------------------------------->
 
|-valign="top"
 
|D_RECT = Rectifier Diode
 
|Size for current needed by motors, then say double.  Let the reverse voltage be 4 x the input voltage.  Mine came from salvage.  Look on Instructables.com for similar power supplies.
 
<!-------------------------------->
 
|-valign="top"
 
|C1 = Filter Cap
 
|My junk box yeilded 4,700 mfd at 25 volts
 
<!-------------------------------->
 
|-valign="top"
 
|C1A = High Frequency Bypass
 
|.01 to 1 mfd cap with good high frequency response, mica is fine.  Electrolytic to be avoided.
 
<!-------------------------------->
 
|-valign="top"
 
|C2 = Filter Cap
 
|Probably can skip, I did.
 
<!-------------------------------->
 
|-valign="top"
 
|C2A = High Frequency Bypass
 
|.01 to 1 mfd cap with good high frequency response, mica is fine.  Electrolytic to be avoided.
 
<!-------------------------------->
 
|-valign="top"
 
|DC1, DC2 = Clipping Diodes
 
|Clip the AC for the time keeping to +5 and 0 volts.  Protects the input of the PIC.  I just used standard small signal diodes.
 
<!-------------------------------->
 
|-valign="top"
 
|R_CLIP1 R_CLIP2 = Clipping Resistors
 
|10 k resistors, form voltage divider to the timing signal to PIC, limits current to DC1 and DC2.
 
<!--------------------------------
 
|-valign="top"
 
|D_REVERSE = reverse voltage protection diode
 
|Use only if you worry about reverse voltage protection on the regulator.  Not real likely, I left it out.
 
<!-------------------------------->
 
|-valign="top"
 
|REG = 5 volt voltage regulator.
 
|100 ma seems to be pleanty, use a 1 amp unit if you want.  Current is only for the PIC, it is not much.  I think the 1 amp unit is the 7805.
 
<!-------------------------------->
 
|-valign="top"
 
|AC_IN
 
|AC input from wall wart.
 
<!-------------------------------->
 
|-valign="top"
 
|GND_IN
 
|Other input from wall wart.
 
<!-------------------------------->
 
|-valign="top"
 
|GND_OUT
 
|Ground out to Processor board.
 
<!-------------------------------->
 
|-valign="top"
 
|CLOCK_60
 
|60 Hz signal to Processor board.
 
<!-------------------------------->
 
|-valign="top"
 
|VDD
 
|5 volts to  Processor board.
 
<!-------------------------------->
 
|-valign="top"
 
|MOUNT_1...4
 
|Mounting holes.  No electrical connection.
 
<!-------------------------------->
 
|-valign="top"
 
|Stepper
 
|Badly regulated power for the stepper motors, to the common connection on the motors.
 
<!-------------------------------->
 
|-valign="top"
 
|xx
 
|
 
<!-------------------------------->
 
 
|}
 
 
==== Processor Board ====
 
 
 
===== Processor Schematic and Board =====
 
 
Single sided, for toner transfer, in Eagle ( semi-final, less ground plane, files may be more up to date )  To get a readable copy download the Eagle files and open in Eagle, see: [[Techniques#Software_design_tools | Techniques, Software Design Tools]]
 
 
[[Image:ProcessorBoardSch.png  | Power Supply Schematic ]]
 
 
[[Image:ProcessorBoardBrd.png  | Power Supply Board ]]
 
 
 
Parts
 
 
{| class="wikitable"
 
|-valign="top"
 
|Part
 
|Details
 
 
|-valign="top"
 
|Wall Wart
 
|You need one with AC output to get the 60 Hz timing signal from the power line.  Mine is a 9 v 800 ma unit.  I found it somewhere.  The output voltage, when rectified, needs to be enough to drive the motor, the PIC runs off a regulator so it does not care much about the input voltage.
 
<!-------------------------------->
 
 
|-valign="top"
 
|PIC16F877A
 
|My favorate 16 series part, relatively lots of memory and pins.  Bigger than you need, but only about 8 bucks.  Try with an 18 series part, should not be hard and will leave you more up to date.  Let me know.
 
<!-------------------------------->
 
|-valign="top"
 
|MODE_1...MODE_6 = Rotory Switch connections
 
|I used an old Radio Shack 12 position switch only 6 of them are used here.  You could use seperate pushbuttons, the advantage is that the position of the rotory switch indicates which mode you are in, else you may want an led for each one, perhaps using another bunch of ports.
 
<!-------------------------------->
 
|-valign="top"
 
|Single Pole double throw Momentry Switch
 
|( or could be 2 momentary push buttons ) one moves the hands up, the other down, in the set and adjust modes.  From my junk box.
 
<!-------------------------------->
 
|-valign="top"
 
|Pull Up/Down Resistors
 
|10k more or less
 
<!-------------------------------->
 
|-valign="top"
 
|CQ1, CQ2 = capicators for the crystal
 
|about 20 pf seems to work, see the PIC16F877A manual
 
<!--------------------------------
 
|-valign="top"
 
|xx
 
|
 
<!--------------------------------
 
|-valign="top"
 
|xx
 
|
 
<!-------------------------------->
 
|-valign="top"
 
|Q = crystal
 
|4 meg Hz is what I used.  May be quite a bit faster than needed, I have not looked into this.  The 4 meg crystal seems to work ok on a proto board.  Note that some of the code is dependent on this frequency, but could be fairly easily changed.
 
<!-------------------------------->
 
|-valign="top"
 
|RA4, RA5 = Pull up resistors
 
|10K more or less
 
<!-------------------------------->
 
|-valign="top"
 
|RB1 ... RB6 = Pull up resistors
 
|10K more or less
 
<!-------------------------------->
 
|-valign="top"
 
|RRA2, RRA3  = Pull up resistors
 
|10K more or less
 
<!-------------------------------->
 
|-valign="top"
 
|C_BP  = By Pass Cap.
 
|.01 to .1 mfd mica or other by pass cap, good at high frequency seems good.
 
<!-------------------------------->
 
|-valign="top"
 
|RRA1 = Pull Up resistor
 
|10K more or less
 
<!--------------------------------
 
|-valign="top"
 
|
 
|
 
<!-------------------------------->
 
|-valign="top"
 
|DRIVER  = Driver
 
|Driver chip for stepper.  ULN2803.  Good for up to .5 amp 35 volts I think.  Could use discrete transistors ( possibly darlingtons ) if you want higher current.  You should not need more current unless you make a really big clock.
 
<!-------------------------------->
 
|-valign="top"
 
|RMC  = Pull up resistor for master clear ( pull down with push button switch to reset ).
 
|10k more or less
 
<!-------------------------------->
 
|-valign="top"
 
|PUSH_BUTTON_SWITCH  = Reset
 
|Push to reset the processor.  Mine was from salvage.
 
<!--------------------------------
 
|-valign="top"
 
|  =
 
|
 
<!--------------------------------
 
|-valign="top"
 
|  =
 
|
 
<!--------------------------------
 
|-valign="top"
 
|  =
 
|
 
<!--------------------------------
 
|-valign="top"
 
|  =
 
|
 
<!--------------------------------
 
|-valign="top"
 
|  =
 
|
 
<!-------------------------------->
 
|-valign="top"
 
|CLOCK  = Clock input signal
 
|Connect to CLOCK_OUT on power supply.
 
<!-------------------------------->
 
|-valign="top"
 
|VDD = Positive Power
 
|5 volts from power supply.
 
<!-------------------------------->
 
|-valign="top"
 
|G1  = Ground Connection
 
|To the power supply.
 
<!-------------------------------->
 
|-valign="top"
 
|SW_UP, SW_DOWN = Setting switch
 
|I used a momentary double throw, single pole, you could use 2 momentary push buttons.
 
<!--------------------------------
 
|-valign="top"
 
|  =
 
|
 
<!--------------------------------
 
|-valign="top"
 
|  =
 
|
 
<!--------------------------------
 
|-valign="top"
 
|  =
 
|
 
<!-------------------------------->
 
|-valign="top"
 
|MOUNT_1...4
 
|Mounting holes.
 
<!--------------------------------
 
|-valign="top"
 
|  =
 
|
 
<!-------------------------------->
 
 
|}
 
  
 
=== Program ===
 
=== Program ===

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)