Editing Arduino/Raspberry Pi based Dancing 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 1: Line 1:
 
This is a rework of an earlier PIC based project, see:  [[PIC based Stepper Motor Dancing Analog Clock]]
 
This is a rework of an earlier PIC based project, see:  [[PIC based Stepper Motor Dancing Analog Clock]]
  
This is an article started by Russ Hensel, see ["http://www.opencircuits.com/index.php?title=Russ_hensel#About My Articles" '''About My Articles'''] for a bit of info.  The page is just begun, the project is 90% complete, it is the last 10% that kills you.
+
This is an article started by Russ Hensel, see "http://www.opencircuits.com/index.php?title=Russ_hensel#About My Articles" '''About My Articles''' for a bit of info.  The page is just begun, the project is 90% complete, it is the last 10% that kills you.
  
 
= next all copied from earlier article,  in process editing it =
 
= next all copied from earlier article,  in process editing it =
 
=== Summary  ===
 
=== Summary  ===
  
*Name: Arduino/Raspberry Pi based Dancing Clock
+
*Name: PIC based Stepper Motor Analog Clock with Dancing Hands
 
*Purpose: An amusing analog clock, see below.
 
*Purpose: An amusing analog clock, see below.
*Status: This is a draft. Code works but still in refinement, code available, email the user russ_hensel. Also still refining the project.
+
*Status: This is a draft. Code works but still in refinement, code available, email russ_hensel Also still refining the project.
*Technology: Stepper Motors, Arduino, Raspberry Pi C++ and Python
+
*Technology: Stepper Motors, PIC 16F877A and BoostC
 
*Author: [[russ_hensel]] ( where you can find an email address to reach me )  
 
*Author: [[russ_hensel]] ( where you can find an email address to reach me )  
 
*License: Open source and object code.  
 
*License: Open source and object code.  
  
This is an analog clock, with real hands driven by stepper motors.  A clock for the confused dyslexics among us, for more information on Dyslexia see DAM ( Mothers Against  Dyslexia ). Because stepper motors are quite powerful the clock could be made quite large, 3 feet in diameter is probably within reach still using inexpensive ( salvage ) stepper motors.  The project description both the hardware and the software.
+
This is an analog clock, with real hands driven by stepper motors.  A clock for the confused dyslexics amoung us, for more informatinon on Dyslexia see DAM ( Mothers Against  Dyslexia ). Because stepper motors are quite powerful the clock could be made quite large, 3 feet in diameter is probably within reach still using inexpensive ( salvage ) stepper motors.  The project description includes eagle files for the circuits and a BoostC project with source code for the PIC.
  
  
 
News:
 
News:
* None yet,  
+
* May '09  C code was missing from archive, this has been fixed.
 +
 
 +
* Comming Soon:  I have a second physical version of the clock that looks much nicer, including real clock hands.  Code has been improved a lot as well.  ( code updated in new download below )
  
 
[[Image:ClockFace.png  | Clock Face ]]
 
[[Image:ClockFace.png  | Clock Face ]]
Line 24: Line 26:
  
 
*2 Stepper Motors -- probably can be salvaged from printers or 5 1/4 disk drives ( where I got mine )
 
*2 Stepper Motors -- probably can be salvaged from printers or 5 1/4 disk drives ( where I got mine )
* Arduino -- mine is a nano, but pretty much anything with 8 io pins should do
+
*PIC16F877 processor -- Others can be used, but this guy has a lot of IO, quite a bit is used for the clock
*Low side Driver Chip -- but any transistors with reasonable beta and enough current handling capacity could be substituted.
+
*Low side Driver Chip -- but any transistors with reasonable beta and enough current handling capacity could be substuited.
* Raspberry Pi -- I think any model will do, or use any PC that can run Python.
 
 
*Case -- With a bit more work than I have done you could have a really nice case.  I am working on an oak one now
 
*Case -- With a bit more work than I have done you could have a really nice case.  I am working on an oak one now
 
*Clock Face --  Some good artwork here could make a really good looking clock, anyone willing to send me an high quality graphics file?
 
*Clock Face --  Some good artwork here could make a really good looking clock, anyone willing to send me an high quality graphics file?
 
*Circuit Board --  Right now mine is built mostly on a proto board, but I have designed but not tested printed circuit boards suitable for single sided, toner transfer, fabrication.
 
*Circuit Board --  Right now mine is built mostly on a proto board, but I have designed but not tested printed circuit boards suitable for single sided, toner transfer, fabrication.
* Python 3.6, could be adapted to 2.7 where it was originally developed, but I have finally moved on
 
* Wire, usb cables, misc boards, including if you wish prototyping boards ( how sloppy ).
 
  
 
=== What it Looks Like ===  
 
=== What it Looks Like ===  
Line 132: Line 131:
 
==== Power Supply ====
 
==== Power Supply ====
  
===== 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 ]]
  
12 volt 1 amp ( better 2 amp ) wall wart and an additional regulator module to go from 12 v to 5 v
+
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 Board ====
Line 140: Line 228:
  
 
===== Processor Schematic and 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 ===
Line 156: Line 390:
  
 
==== Compiling ====
 
==== Compiling ====
 +
The zip file contains the entire source bootst project.  Unzip into a directory and open in source boost.  There are some additional notes at the top of the main source file.  Follow the instructions there, they will tell you about any compiler and/or linker options, and report on memory usage from a recent compile of mine.  The compile should run without error. 
 +
 +
If you do not wish to compile you can use the precompiled hex version also included in the zip archive.
  
 
=== Building the Clock ===
 
=== Building the Clock ===
Line 171: Line 408:
  
 
==== Without the Serial Interface ====
 
==== Without the Serial Interface ====
 +
 +
*Before plugging it in set the hands to 12 oclock and and 0 minutes ( if the hands are accessable, else skip this ).
 +
 +
*Plug in.  The hands should spin a bit and then stop. 
 +
 +
*The clock will be set to 12:00 and will immediately start running.  But the hands may not be initialized or adjusted to the correct zero positions.  To adjust them change the mode switch to Adj Hour Hand  and manipulate the up down switch untill the hour hand moves to 12:00 ( this does not change the internal time of the clock ), switch to Adj Minute Hand and adjust it to 0 minutes.
 +
 +
*Switch the clock back to run, the hands may move a bit, the time is very near 12:00 ( unless it took you a long time to adjust the hands ).
 +
 +
*Switch to set hour to set the correct hour.
 +
 +
*Switch to set minute to set the correct minute.
 +
 +
*Switch to run and enjoy.
  
 
==== With the Serial Interface ====
 
==== With the Serial Interface ====
Line 275: Line 526:
  
 
=== Download ===
 
=== Download ===
Will be at GitHub soon?
+
Note there may be a serious error in the schematic for the clock board.  You can jumper around it if you have already made the board, else wait for version X. ( may be fixed in version 2 below, but I need to check. )
 +
Download includes the boostc project ( .c, .h, and ._c files ) some of the graphics, movie, and eagle files [http://home.comcast.net/~russ_hensel/OC/DDClock/DDClock_v2.zip Download Version 2] Questions? email me until then see [[russ_hensel]]
  
 
=== Comment, Questions, Contributions? ===
 
=== Comment, Questions, Contributions? ===
Line 281: Line 533:
 
Email me [[russ_hensel]], or use the talk page for this topic.  All feedback is welcome.
 
Email me [[russ_hensel]], or use the talk page for this topic.  All feedback is welcome.
  
[[category:projects]][[category:Serial Communications]][[category:Microcontroller]] [[Category:Arduino/RaspberryPi]]  
+
[[category:projects]][[category:Serial Communications]][[category:Microcontroller]][[category:PIC]]
 
[[category: clock]]
 
[[category: clock]]

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)