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 9: | Line 9: | ||
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. | 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. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Image:ClockFace.png | Clock Face ]] | [[Image:ClockFace.png | Clock Face ]] | ||
Line 22: | Line 16: | ||
*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. | ||
+ | |||
=== What it Looks Like === | === What it Looks Like === | ||
Line 121: | Line 116: | ||
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 240: | Line 233: | ||
|-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. |
<!--------------------------------> | <!--------------------------------> | ||
Line 262: | Line 255: | ||
|CQ1, CQ2 = capicators for the crystal | |CQ1, CQ2 = capicators for the crystal | ||
|about 20 pf seems to work, see the PIC16F877A manual | |about 20 pf seems to work, see the PIC16F877A manual | ||
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
|xx | |xx | ||
Line 270: | Line 263: | ||
|xx | |xx | ||
| | | | ||
− | <!-------------------------------- | + | <!-------------------------------- |
|-valign="top" | |-valign="top" | ||
|Q = crystal | |Q = crystal | ||
Line 294: | Line 287: | ||
|RRA1 = Pull Up resistor | |RRA1 = Pull Up resistor | ||
|10K more or less | |10K more or less | ||
− | <!-------------------------------- | + | <!--------------------------------> |
|-valign="top" | |-valign="top" | ||
| | | | ||
| | | | ||
− | <!-------------------------------- | + | <!-------------------------------- |
|-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. | |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. | ||
<!--------------------------------> | <!--------------------------------> | ||
Line 310: | Line 303: | ||
|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" | ||
| = | | = | ||
Line 336: | Line 329: | ||
<!--------------------------------> | <!--------------------------------> | ||
|-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" | ||
Line 361: | Line 354: | ||
|-valign="top" | |-valign="top" | ||
|MOUNT_1...4 | |MOUNT_1...4 | ||
− | |Mounting holes | + | |Mounting holes |
<!-------------------------------- | <!-------------------------------- | ||
|-valign="top" | |-valign="top" | ||
Line 371: | Line 364: | ||
=== 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 369: | ||
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. My stepper motor has 200 full steps ( 400 half steps ) per revolution. You should be able to adjust the code for different steppers. | + | 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. My stepper motor has 200 full steps ( 400 half steps ) per revolution. You should be able to adjust the code for different steppers. |
+ | |||
For the serial interface code see [[Serial Communications Library -- BoostC and 16F877A]] | For the serial interface code see [[Serial Communications Library -- BoostC and 16F877A]] | ||
− | + | ==== Compiling ==== | |
+ | The zip file contains the entire source bootst project. Unzip into a directory and open in source boost. Set the target to 16F877A and change the linker options ( Settings -> options -> linker "-v -swcs 6 2" ) My compiler reports something like: | ||
− | + | Memory Usage Report | |
− | |||
− | + | *RAM available:368 bytes, used:154 bytes (41.9%), free:214 bytes (58.1%), | |
+ | *Heap size:214 bytes, Heap max single alloc:95 bytes | ||
+ | *ROM available:8192 words, used:4156 words (50.8%), free:4036 words (49.2%) | ||
=== Building the Clock === | === Building the Clock === | ||
Line 402: | Line 396: | ||
=== Running the Clock === | === Running the Clock === | ||
− | + | Before plugging it in set the hands to 12 oclock and and 0 minutes ( if the hands are accessable ). | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | 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 | |
− | |||
− | + | If you are using the serial interface: | |
− | + | Enter the serial mode by connecting a 9600 8n1 with a terminal emulator like ..... | |
− | |||
− | + | The clock should send debugging information about onec a minute. It will also inform you of the changing of modes with the mode switch. | |
− | + | Then send an ! the clock should respond with.... | |
− | |||
− | |||
− | + | Command table | |
− | |||
− | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 446: | Line 424: | ||
|-valign="top" | |-valign="top" | ||
|Hn<cr> | |Hn<cr> | ||
− | |set clock to hour n ( n is one or two digits ) and move the hands | + | |set clock to hour n ( n is one or two digits ) and move the hands |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
|Mn<cr> | |Mn<cr> | ||
− | |set clock to minute n ( n is one or two digits ) and move the hands | + | |set clock to minute n ( n is one or two digits ) and move the hands |
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
|R<cr> | |R<cr> | ||
|Report on clock status | |Report on clock status | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
Line 521: | Line 471: | ||
=== Download === | === 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. | ||
− | |||
− | |||
− |