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 3: | Line 3: | ||
*Name: PIC based Stepper Motor Analog Clock with Dancing Hands | *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 russ_hensel | + | *Status: This is a very early draft. Code works but still in refinement, code available, email russ_hensel |
*Technology: Stepper Motors, PIC 16F877A and BoostC | *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. | + | This is an analog clock, with real hands driven by stepper motors. 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. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Major Parts === | === Major Parts === | ||
Line 22: | Line 14: | ||
*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 ) | ||
*PIC16F877 processor -- Others can be used, but this guy has a lot of IO, quite a bit is used for the clock | *PIC16F877 processor -- Others can be used, but this guy has a lot of IO, quite a bit is used for the clock | ||
− | *Low | + | *Low sid Driver Chip -- but any transistors with reasonable beta and enough current handling capacity could be substuited. |
*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. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Features === | === Features === | ||
Line 51: | Line 35: | ||
|-valign="top" | |-valign="top" | ||
|Special effects -- Dancing | |Special effects -- Dancing | ||
− | |Hour and minute hands may "dance" at special times, see the video at: | + | |Hour and minute hands may "dance" at special times, see the video at: xxx |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
Line 61: | Line 45: | ||
|For debugging and demo of special effects | |For debugging and demo of special effects | ||
− | <!-------------------------------- | + | <!-------------------------------- |
|-valign="top" | |-valign="top" | ||
− | | | + | | |
− | | | + | | |
<!-------------------------------- | <!-------------------------------- | ||
|-valign="top" | |-valign="top" | ||
Line 113: | Line 97: | ||
|} | |} | ||
+ | |||
=== Circuit === | === Circuit === | ||
Line 121: | Line 106: | ||
For parts I used used my junk box, when it fails consider SparkFun and Futurlec. Or..... See: [[Supplier]]. | For parts I used used my junk box, when it fails consider SparkFun and Futurlec. Or..... See: [[Supplier]]. | ||
− | |||
− | |||
==== 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 | + | 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 DC but the motors load down a battery pretty badly and you would need a timing signal ( the original code has a subroutine for timing off the crystal ). |
===== Power Supply Schematic and Board ===== | ===== Power Supply Schematic and Board ===== | ||
Line 143: | Line 126: | ||
|Part | |Part | ||
|Details | |Details | ||
− | + | ||
|-valign="top" | |-valign="top" | ||
|Wall Wart | |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 | + | |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. |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
Line 156: | Line 139: | ||
|My junk box yeilded 4,700 mfd at 25 volts | |My junk box yeilded 4,700 mfd at 25 volts | ||
<!--------------------------------> | <!--------------------------------> | ||
+ | |||
|-valign="top" | |-valign="top" | ||
|C1A = High Frequency Bypass | |C1A = High Frequency Bypass | ||
Line 170: | Line 154: | ||
|-valign="top" | |-valign="top" | ||
|DC1, DC2 = Clipping Diodes | |DC1, DC2 = Clipping Diodes | ||
− | |Clip the AC for the time keeping to +5 and 0 volts. Protects the input of the PIC | + | |Clip the AC for the time keeping to +5 and 0 volts. Protects the input of the PIC. |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
Line 176: | Line 160: | ||
|10 k resistors, form voltage divider to the timing signal to PIC, limits current to DC1 and DC2. | |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" | |-valign="top" | ||
|D_REVERSE = reverse voltage protection diode | |D_REVERSE = reverse voltage protection diode | ||
Line 206: | Line 194: | ||
|-valign="top" | |-valign="top" | ||
|MOUNT_1...4 | |MOUNT_1...4 | ||
− | |Mounting holes | + | |Mounting holes |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
|Stepper | |Stepper | ||
|Badly regulated power for the stepper motors, to the common connection on the motors. | |Badly regulated power for the stepper motors, to the common connection on the motors. | ||
− | <!-------------------------------- | + | <!-------------------------------- |
|-valign="top" | |-valign="top" | ||
|xx | |xx | ||
Line 224: | Line 212: | ||
===== 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 ) | + | Single sided, for toner transfer, in Eagle ( semi-final, less ground plane, files may be more up to date ) |
[[Image:ProcessorBoardSch.png | Power Supply Schematic ]] | [[Image:ProcessorBoardSch.png | Power Supply Schematic ]] | ||
Line 240: | Line 228: | ||
|-valign="top" | |-valign="top" | ||
|Wall Wart | |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 | + | |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. |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
|PIC16F877A | |PIC16F877A | ||
− | | | + | | |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
Line 253: | Line 241: | ||
|-valign="top" | |-valign="top" | ||
|Single Pole double throw Momentry Switch | |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 | + | |( or could be 2 momentary push buttons ) one moves the hands up, the other down, in the set and adjust modes. |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
|Pull Up/Down Resistors | |Pull Up/Down Resistors | ||
− | | | + | | |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | |CQ1, CQ2 = | + | |CQ1, CQ2 = crystal resistors |
− | |about 20 pf seems to work, see the | + | |about 20 pf seems to work, see the 977a manual |
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
|xx | |xx | ||
| | | | ||
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
|xx | |xx | ||
Line 273: | Line 261: | ||
|-valign="top" | |-valign="top" | ||
|Q = crystal | |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 | + | |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. |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
|RA4, RA5 = Pull up resistors | |RA4, RA5 = Pull up resistors | ||
− | |10K | + | |10K |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | |RB1 ... RB6 | + | |RB1 ... RB6 |
− | | | + | | |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | |RRA2, RRA3 | + | |RRA2, RRA3 = |
− | | | + | | |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
Line 292: | Line 280: | ||
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | |RRA1 = | + | |RRA1 = |
− | | | + | | |
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
− | | | + | |CLOCK = |
| | | | ||
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | |DRIVER = | + | |DRIVER = |
− | |Driver chip for stepper. ULN2803 | + | |Driver chip for stepper. ULN2803 |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | |RMC = Pull up resistor for master clear | + | |RMC = Pull up resistor for master clear |
− | |10k | + | |10k |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
|PUSH_BUTTON_SWITCH = Reset | |PUSH_BUTTON_SWITCH = Reset | ||
|Push to reset the processor. Mine was from salvage. | |Push to reset the processor. Mine was from salvage. | ||
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
| = | | = | ||
| | | | ||
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
| = | | = | ||
| | | | ||
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
| = | | = | ||
| | | | ||
− | <!-------------------------------- | + | <!--------------------------------> |
+ | |||
|-valign="top" | |-valign="top" | ||
| = | | = | ||
| | | | ||
− | <!-------------------------------- | + | <!--------------------------------> |
+ | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
| = | | = | ||
Line 336: | Line 326: | ||
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | |VDD = | + | |VDD = |
− | | | + | | |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | |G1 = | + | |G1 = |
− | | | + | | |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
− | |SW_UP, SW_DOWN = | + | |SW_UP, SW_DOWN = |
− | | | + | | |
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
| = | | = | ||
| | | | ||
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
| = | | = | ||
Line 358: | Line 348: | ||
| = | | = | ||
| | | | ||
− | |||
− | |||
− | |||
− | |||
<!-------------------------------- | <!-------------------------------- | ||
|-valign="top" | |-valign="top" | ||
Line 371: | Line 357: | ||
=== Program === | === Program === | ||
− | |||
− | |||
Nothing very fancy here. The 60 Hz input is fed to the port x interrupt. This lets the PIC keep time. The hands are not moved during the interrupt instead flags requesting hand movement are set and the main loop moves the hands. | Nothing very fancy here. The 60 Hz input is fed to the port x interrupt. This lets the PIC keep time. The hands are not moved during the interrupt instead flags requesting hand movement are set and the main loop moves the hands. | ||
Line 378: | Line 362: | ||
Invalid states for the mode can easily happen with a rotory switch when the wiper is not fully in position. Because of this not all possible states on the mode input are used. | Invalid states for the mode can easily happen with a rotory switch when the wiper is not fully in position. Because of this not all possible states on the mode input are used. | ||
− | The stepper control is half step. The activation of the coils is determined by an array which hold the 8 different activations of the coils | + | The stepper control is half step. The activation of the coils is determined by an array which hold the 8 different activations of the coils. |
− | |||
− | |||
− | + | For the serial interface code see [[Serial Communications Library -- BoostC and 16F877A]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | [[ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Additional Ideas === | === Additional Ideas === | ||
Line 511: | Line 386: | ||
*For a related project see: [[Stepper Motor Tester]] | *For a related project see: [[Stepper Motor Tester]] | ||
− | + | === Download === | |
− | |||
− | |||
+ | Comming, email me until then see [[russ_hensel] | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Comment, Questions, Contributions? === | === Comment, Questions, Contributions? === | ||
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. | ||
− | |||
− | |||
− |