SlideShare une entreprise Scribd logo
1  sur  12
The Propeller, a mechanically scanned LED clock by Bob Blick.

The clock is on a spinning piece of perfboard, but it must get power.
I thought of many ways to do this, including using two motors(motor
one has its shaft fixed to a base, and motor two spins the body of
motor one, generating electricity), making a rotary transformer, or
using slip rings.

I decided to do it another way, taking power from the spinning
armature of a plain DC motor. In order to run the wires out of the
motor, I removed the bearing from one end of the motor, leaving a
big hole.

There are three terminals inside most small DC motors, and it acts
a lot like three-phase alternating current, so it must be rectified
back to DC. A nice side effect of this is that the position of the
motor can be detected by taking one of the phases straight into the
microprocessor.

Step One: Mangle a Motor.

Find a VCR, perhaps a Sharp or a Samsung, with a flat reel motor.
The motor I have is marked JPA1B01, but Sharp knows it by the number
RMOTV1007GEZZ. Take it apart without mangling the brushes(there are
little holes to slip a paperclip into to move the brushes out of the
way), and notice that it has one ball bearing and one sleeve bearing.
Knock the sleeve bearing out of the case and glue or solder it to the
other end of the motor, as an extension of the ball bearing. The shaft
of the motor will have to be repositioned slightly to get the right
height, press it in a vise with a hollow spacer on one end. Take a
Berg connector with three wires and solder them to the three terminals
on the motor's armature. Glue a short threaded spacer to the shaft at
the end that will stick out the hole, and reassemble the motor(be
careful with the brushes). You can glue the motor to a VCR head as a
weighted base.

Step Two: Build the circuit.

I used perfboard(Vectorboard) and handwired the circuit together. Use
an 18-pin socket for the 16C84 because it needs to be programmed
before
putting it in the circuit. For the 7 current-limit resistors I used a
DIP resistor array, because it made it easy to experiment with LED
brightness. I settled on 120 ohms. You can use seven regular
resistors,
because 120 ohms works fine, though it puts the peak current right at
the limit for the 16C84. Think about balance while you build this
circuit, and reference my pictures, so you don't have to add a lot of
balancing weight later. Substitute for any part values you like. Note
that I used a 47000uf supercap, it is to keep the clock running after
turning it off, so you can set the time. The LEDs get power separate
from this. Don't substitute a ceramic resonator for the 4MHz crystal,
this is a clock and should be accurate.

Step Three: Program the 16C84.

You'll need a programmer that will program a PIC16C84. If you found
this file/web page, you can find plans to build a 16C84 programmer.
Program it using the hex file accompanying this document. I have
included the source code(.asm) just for your amusement. When
programming the chip, set the chip options to: watchdog timer(WDT)
OFF and oscillator to normal XT crystal.

Step Four: Throw it together and Keep Time.

Screw the circuit board to the motor, and plug the three wire
connector
in. Apply power to the motor. The preferred voltage is 6.2 volts, but
it will run from 5 volts to about 7.5 volts. Note that 5 volts gets to
the circuit when 6.2 volts is applied to the motor, because of diode
losses. The clock may be working at this point, displaying 12:00. If
it
isn't. there was probably some voltage on the supercap when you
plugged
in the chip. Turn off the power and momentarily short pins 5 and 4
together(ground and /mclr) to reset the chip. Now when you apply power
the clock should work, and you can set it by turning off the power and
pushing the buttons(hours, 10 minutes, minutes) the right number of
times. If the numbers appear backwards, reverse the polarity to the
motor to make it spin the other way. You might experiment with
balancing
the clock, and the use of foam under the base to reduce vibration.

Step Five: Modifications.

If you look closely at the source code, you'll see that the "dot rate"
is adjusted to the speed of the motor to make the display a consistent
width regardless of the motor's speed. The motor I used has brushes
set
90 degrees apart, and gives two indexes each revolution. The clock
displays on two sides, 180 degrees apart. If you use a motor with the
brushes 180 apart, the clock will only display on one side, and the
numbers will be too wide. You'll want to modify the program, in the
section marked D_lookup_3. The value in the W register when Delay gets
called effects the width of the digits. You might try sending half of
the period_calc value to Delay, perhaps by rotating period_calc right
into W(remember to clear the carry flag first). Like this:
bcf    STATUS,C
rrf    period_calc,w
call   Delay

January 25, 1997 Bob Blick
www.bobblick.com
copyright 1997 Bob Blick, all rights reserved
updated notes November 2, 2006
Note: PIC16C84 is now obsolete. You may use either a PIC16F84 or
PIC16F84A with no changes.
Note: Sharp VCR motor is now obsolete. Use any DC motor, preferably
meant for 12 volts so the speed will not be too great when operated
at approximately 6.2 volts.




The Propeller Clock Parts List
Capacitors:
C1, C2 - 33pf ceramic
C3, C6 - 0.1uf ceramic
C4 - 47uf electrolytic
C5 - 47,000uf supercap(memory cap)

Diodes:
D1-D7 - light emitting diodes
D8-16 - 1N4001 general purpose 1amp rectifiers

Resistors:
R1 - 120 ohm DIP array or seven 120 ohm resistors
R2-R6 - 10k ohm

Misc:
J1 - three terminal Berg connector
SW1-SW3 - normally open pushbutton switches
U1 - PIC16C84, PIC16F84 or PIC16F84A
XTAL1 - 4MHz crystal
MOTOR - Sharp RMOTV1007GEZZ

Note: U1 to be programmed with mclock hex file



                                     Code
;--------
; mclock8.asm
; "The Propeller" mechanically scanned LED clock
; some changes since last version -
; modified table etc for compatiblility with 8th LED
; watchdog timer used to ensure startup
; Bob Blick February 12, 1997
; Licensed under the terms of the GNU General Public License, www.gnu.org
; No warranties expredded or implied
; Bob Blick February 18, 2002
;--------
               list    p=16C84
               radix   hex
include "p16c84.inc"
;--------
; remember to set blast-time options: OSC=regular xtal, WDT=ON
; timings all based on 4 MHz crystal
;--------
; are these equates already in the include file? someday I'll look.
;--------
w              equ     0
f              equ     1
;--------
; Start of available RAM.
;--------
        cblock 0x0C
               safe_w          ;not really temp, used by interrupt svc
               safe_s          ;not really temp, used by interrupt svc
               period_count    ;incremented each interrupt
               period_dup      ;copy of period_count safe from interrupt
               period_calc     ;stable period after hysteresis calc.
               flags           ;b2=int b1=minute b4=edge
               dot_index       ;which column is being displayed
               digit_index     ;which digit is being displayed
               hours           ;in display format, not hex(01-12)
               minutes         ;00 to 59
               bigtick_dbl     ;incremented each interrupt
               bigtick_hi
               bigtick_lo
               keys            ;key value
               scratch         ;scratch value
               tick            ;used by delay
        endc
;--------
; Start of ROM
;--------
               org     0x00            ;Start of code space
               goto    Start
;--------
; INTERRUPT SERVICE ROUTINE
;--------
               org     0x04            ;interrupt vector
Intsvc         movwf   safe_w          ;save w
               swapf   STATUS,w        ;swap status, w
               movwf   safe_s          ;save status(nibble swap, remember)
;--------
; done saving, now start working
;--------
; clear watchdog timer to ensure startup
               clrwdt
;
; increment period count
               incf    period_count,f
               btfsc   STATUS,Z        ;zero set means overflow
               decf    period_count,f
; 234375 interrupts every minute. Increment the bigtick each time.
               incf    bigtick_lo,f
               btfsc   STATUS,Z
               incf    bigtick_hi,f
               btfsc   STATUS,Z
incfsz bigtick_dbl,f
               goto   Bigtick_out
;--------
; here? bigtick has rolled over to zero and one minute has passed.
; reload bigtick and set a flag for the main counter
;--------
               movlw   0xFC           ;234375 = 0x039387
               movwf   bigtick_dbl    ;0 - 0x039387 = 0xFC6C79
               movlw   0x6C
               movwf   bigtick_hi
               movlw   0x79
               movwf   bigtick_lo
               bsf     flags,1        ;notify Keep_time
Bigtick_out
;--------
; done working, start restoring
;--------
               swapf   safe_s,w       ;fetch status, reswap nibbles
               movwf   STATUS         ;restore status
               swapf   safe_w,f       ;swap nibbles in preparation
               swapf   safe_w,w       ;for the swap restoration of w
               bcf     INTCON,2       ;clear interrupt flag before return
               retfie                 ;return from interrupt
;--------
; CHARACTER LOOKUP TABLE
; ignore high bit. set=LED off, clear=LED on, bit0=bottom LED, bit6=top LED
;--------
Char_tbl
               addwf   PCL,f
               dt      0xC1,0xBE,0xBE,0xBE,0xC1       ;"O"
               dt      0xFF,0xDE,0x80,0xFE,0xFF       ;"1"
               dt      0xDE,0xBC,0xBA,0xB6,0xCE       ;"2"
               dt      0xBD,0xBE,0xAE,0x96,0xB9       ;"3"
               dt      0xF3,0xEB,0xDB,0x80,0xFB       ;"4"
               dt      0x8D,0xAE,0xAE,0xAE,0xB1       ;"5"
               dt      0xE1,0xD6,0xB6,0xB6,0xF9       ;"6"
               dt      0xBF,0xB8,0xB7,0xAF,0x9F       ;"7"
               dt      0xC9,0xB6,0xB6,0xB6,0xC9       ;"8"
               dt      0xCF,0xB6,0xB6,0xB5,0xC3       ;"9"
               dt      0xFF,0xC9,0xC9,0xFF,0xFF       ;":"
Char_tbl_end
;--------
; SUBROUTINES STARTING HERE
;--------
; clear important bits of ram
;--------
Ram_init       movlw   0x07
               movwf   keys
               movlw   0x12           ;why do clocks always start
               movwf   hours          ;at 12:00 ?
               clrf    minutes
               clrf    dot_index
               clrf    digit_index
               movlw   0xFC
               movwf   bigtick_dbl
               retlw   0
;--------
; unused pins I am setting to be outputs
;--------
Port_init       movlw  0x00            ;all output, b7=unused
                tris   PORTB           ;on port b attached to LEDs
                movlw  b'00010111'     ;port a has 5 pins. I need 4 inputs
                                       ;b0=minutes, b1=10mins, b2=hours
                                       ;b3=unused, b4=rotation index
                tris   PORTA           ;on port a
                retlw  0
;--------
; get timer-based interrupts going
;--------
Timer_init      bcf    INTCON,2        ;clear TMR0 int flag
                bsf    INTCON,7        ;enable global interrupts
                bsf    INTCON,5        ;enable TMR0 int
                clrf   TMR0            ;clear timer
                clrwdt                 ;why is this needed? just do it..
                movlw  b'11011000'     ;set up timer. prescaler(bit3)bypassed
                option                 ;send w to option. generate warning.
                clrf   TMR0            ;start timer
                retlw  0
;--------
; test for index in rotation and store period in period_dup
;--------
Check_index     movf   PORTA,w         ;get the state of port a
                xorwf  flags,w         ;compare with saved state
                andlw  b'00010000'     ;only interested in bit 4
                btfsc  STATUS,Z        ;test for edge
                retlw  0               ;not an edge, same as last
                xorwf  flags,f         ;save for next time
                btfsc  flags,4         ;test for falling edge
                retlw  0               ;must have been a rising edge
                movf   period_count,w ;make a working copy
                movwf  period_dup      ;called period dup
                clrf   period_count    ;a fresh start for next rotation
                clrf   digit_index     ;set to first digit
                clrf   dot_index       ;first column
; calculate a period that does not dither or jitter
; period will not be changed unless new period is really different
                movf   period_calc,w
                subwf  period_dup,w    ;find difference
                btfss  STATUS,C        ;carry flag set means no borrow
                goto   Calc_period_neg ;must be other way
                sublw  2               ;allowable deviation = 3
                btfss  STATUS,C        ;borrow won't skip
                incf   period_calc     ;new value much larger than calc
                retlw  0
Calc_period_neg addlw  2               ;allowable deviation = 3
                btfss  STATUS,C        ;carry will skip
                decf   period_calc     ;no carry means it must be changed
                retlw  0
;--------
; change LED pattern based on state of digit_index and dot_index
;--------
Display_now     movlw  0x05
                xorwf  dot_index,w     ;test for end of digit
                movlw  0xFF            ;pattern for blank column
btfsc   STATUS,Z
               goto    D_lookup_3      ;it needs a blank
               bcf     STATUS,C        ;clear carry before a rotate
               rlf     digit_index,w   ;double the index because each
               addwf   PCL,f           ;takes two instructions
D_10hr         swapf   hours,w
               goto    D_lookup        ;what a great rush of power
D_1hr          movf    hours,w         ;I feel when modifying
               goto    D_lookup        ;the program counter
D_colon        movlw   0x0A
               goto    D_lookup
D_10min        swapf   minutes,w
               goto    D_lookup
D_1min         movf    minutes,w
               goto    D_lookup
D_nothing      retlw   0
D_lookup       andlw   b'00001111'     ;strip off hi bits
               movwf   scratch         ;multiply this by 5 for lookup
               addwf   scratch,f       ;table base position
               addwf   scratch,f       ;is this cheating?
               addwf   scratch,f       ;I think not.
               addwf   scratch,f       ;I think it is conserving energy!
               btfss   STATUS,Z        ;test for zero
               goto    D_lookup_2      ;not a zero
               movf    digit_index,f   ;this is just to test/set flag
               movlw   0xFF            ;this makes a blank LED pattern
               btfsc   STATUS,Z        ;test if it is 10 hrs digit
               goto    D_lookup_3      ;it's a leading zero
D_lookup_2     movf    dot_index,w     ;get column
               addwf   scratch,w       ;add it to digit base
               call    Char_tbl        ;get the dot pattern for this column
D_lookup_3     movwf   PORTB           ;send it to the LEDs
               movlw   0x0C            ;overhead value sub from period
               subwf   period_calc,w   ;compensate for overhead and set
               call    Delay           ;width of digits with this delay
               incf    dot_index,f     ;increment to the next column
               movlw   0x06            ;6 columns is a digit plus space
               xorwf   dot_index,w     ;next digit test
               btfss   STATUS,Z
               retlw   0               ;not a new digit
               clrf    dot_index       ;new digit time
               incf    digit_index,f
               retlw   0              ;Display_now done.
;--------
; a short delay routine
;--------
Delay          movwf   tick
Delay_loop     decfsz tick,f
               goto    Delay_loop     ;w is not damaged, so Delay can
               return                 ;be recalled without reloading
;--------
; test for keypress and call time adjust if needed
;--------
Check_keys     movf    PORTA,w        ;get port "a"
               xorwf   keys,w         ;compare with previous
               andlw   b'00000111'    ;only care about button pins
               btfsc   STATUS,Z       ;zero set=no buttons
retlw    0             ;return
               xorwf    keys,f        ;store key value
               movlw    0x64          ;a fairly long delay will
               movwf    scratch       ;prevent key bounces
Key_delay      movlw    0xFF
               call     Delay
               decfsz   scratch
               goto     Key_delay
               btfss    keys,2        ;test "minutes" button
               goto     Inc_mins
               btfss    keys,1        ;test "tens" button
               goto     Inc_tens
               btfss    keys,0        ;test "hours" button
               goto     Inc_hours
               retlw    0             ;must be a glitch. yeah, right!
;--------
; increment ten minutes
;--------
Inc_tens       movlw   0x0A
               movwf   scratch        ;scratch has ten
Inc_tens_loop call     Inc_mins
               decfsz scratch
               goto    Inc_tens_loop ;another minute added
               retlw   0
;--------
; increment one hour
;--------
Inc_hours      movlw   0x12
               xorwf   hours,w
               btfsc   STATUS,Z
               goto    Inc_hours_12
               movlw   0x07           ;this part gets a little sloppy
               addwf   hours,w
               movlw   0x07
               btfss   STATUS,DC
               movlw   1
               addwf   hours,f
               retlw   0
Inc_hours_12   movlw   0x01
               movwf   hours
               retlw   0
;--------
; increment the time based on flags,1 as sent by interrupt routine
; Inc_mins loop also used by time-setting routine
;--------
Keep_time      btfss   flags,1        ;the minutes flag
               retlw   0              ;not this time
               bcf     flags,1        ;clear the minutes flag
Inc_mins       movlw   0x07           ;start incrementing time
               addwf   minutes,w      ;add 7 minutes into w
               btfsc   STATUS,DC      ;did adding 7 cause digit carry?
               goto    Sixty_mins     ;then test for an hour change
               incf    minutes        ;otherwise add 1 for real
               retlw   0              ;and go back
Sixty_mins     movwf   minutes        ;save the minutes
               movlw   0x60           ;test for 60
               xorwf   minutes,w      ;are minutes at 60?
btfss   STATUS,Z
               retlw   0              ;no? go back
               clrf    minutes        ;otherwise zero minutes
               goto    Inc_hours      ;and increment hours
;--------
; End of subroutines
; Program starts here
;--------
Start          call    Ram_init       ;set variables to nice values
               call    Port_init      ;set port directions
               call    Timer_init     ;start timer based interrupt
;--------
; Done initializing, start the endless loop.
;--------
;
Circle                                ;begin the big loop
;
;--------
; detect falling edge on PORTA,4 to determine rotary index
; calculate rotation period and store in period_dup
; compare with working period(period_calc) and adjust if way different
;--------
               call    Check_index
;--------
; check display state and change if needed
;--------
               call    Display_now
;--------
; check keyboard and adjust time
;--------
               call    Check_keys
;--------
; check minute flag and increment time if a minute has passed
;--------
               call    Keep_time
;--------
; gentlemen, that's a clock, keep it rolling
;--------
               goto    Circle         ;you heard the man, get going!
               end
;--------
; end of file
;--------




                                    Hex
:020000040000FA
:10000000F028FF3FFF3FFF3F8C00030E8D00640090
:100010008E0A03198E03980A0319970A0319960F7B
:100020001828FC3096006C309700793098009114B5
:100030000D0E83008C0E0C0E0B1109008207C134CB
:10004000BE34BE34BE34C134FF34DE348034FE34BA
:10005000FF34DE34BC34BA34B634CE34BD34BE34AE
:10006000AE349634B934F334EB34DB348034FB34BF
:100070008D34AE34AE34AE34B134E134D634B6342B
:10008000B634F934BF34B834B734AF349F34C934DC
:10009000B634B634B634C934CF34B634B634B534E5
:1000A000C334FF34C934C934FF34FF3407309900F6
:1000B00012309400950192019301FC3096000034B7
:1000C000003066001730650000340B118B178B165B
:1000D00081016400D83062008101003405081106F6
:1000E0001039031900349106111A00340E088F00DC
:1000F0008E019301920110080F02031C8328023C19
:10010000031C900A0034023E031C900300340530A7
:100110001206FF300319A9280310130D8207140ECD
:100120009A2814089A280A309A28150E9A28150831
:100130009A2800340F399A009A079A079A079A0763
:10014000031DA6289308FF300319A92812081A07CF
:100150001E2086000C301002B520920A06301206CE
:10016000031D00349201930A00349B009B0BB628B8
:100170000800050819060739031900349906643088
:100180009A00FF30B5209A0BC128191DE328991C4D
:10019000CC28191CD22800340A309A00E3209A0B8C
:1001A000CE280034123014060319DD280730140756
:1001B0000730831C01309407003401309400003470
:1001C000911C00349110073015078318E928950A0F
:1001D0000034950060301506031D00349501D228C7
:1001E0005620602065206E208720B920E020F3286B
:0201F000FF3FCF
:02400E00F53F7C
:00000001FF
The propeller
The propeller

Contenu connexe

Tendances

A Stealthy Stealers - Spyware Toolkit and What They Do
A Stealthy Stealers - Spyware Toolkit and What They DoA Stealthy Stealers - Spyware Toolkit and What They Do
A Stealthy Stealers - Spyware Toolkit and What They Dosanghwan ahn
 
ch6-pv2-device-drivers
ch6-pv2-device-driversch6-pv2-device-drivers
ch6-pv2-device-driversyushiang fu
 
General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareDaniel Blezek
 
Vhdl practical exam guide
Vhdl practical exam guideVhdl practical exam guide
Vhdl practical exam guideEslam Mohammed
 
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernelsMainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernelsDobrica Pavlinušić
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersConnor McDonald
 
OakTable World Sep14 clonedb
OakTable World Sep14 clonedb OakTable World Sep14 clonedb
OakTable World Sep14 clonedb Connor McDonald
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20DefconRussia
 
Exploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET ImplementationExploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET Implementationnkslides
 
Make ARM Shellcode Great Again
Make ARM Shellcode Great AgainMake ARM Shellcode Great Again
Make ARM Shellcode Great AgainSaumil Shah
 
DWARF Data Representation
DWARF Data RepresentationDWARF Data Representation
DWARF Data RepresentationWang Hsiangkai
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)Simen Li
 
224698998 moshell-commands
224698998 moshell-commands224698998 moshell-commands
224698998 moshell-commandsAchmad Salsabil
 
HackLU 2018 Make ARM Shellcode Great Again
HackLU 2018 Make ARM Shellcode Great AgainHackLU 2018 Make ARM Shellcode Great Again
HackLU 2018 Make ARM Shellcode Great AgainSaumil Shah
 
SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]Takuya ASADA
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureCyber Security Alliance
 

Tendances (20)

A Stealthy Stealers - Spyware Toolkit and What They Do
A Stealthy Stealers - Spyware Toolkit and What They DoA Stealthy Stealers - Spyware Toolkit and What They Do
A Stealthy Stealers - Spyware Toolkit and What They Do
 
ch6-pv2-device-drivers
ch6-pv2-device-driversch6-pv2-device-drivers
ch6-pv2-device-drivers
 
General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics Hardware
 
Vhdl practical exam guide
Vhdl practical exam guideVhdl practical exam guide
Vhdl practical exam guide
 
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernelsMainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
 
OakTable World Sep14 clonedb
OakTable World Sep14 clonedb OakTable World Sep14 clonedb
OakTable World Sep14 clonedb
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
 
Exploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET ImplementationExploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET Implementation
 
Make ARM Shellcode Great Again
Make ARM Shellcode Great AgainMake ARM Shellcode Great Again
Make ARM Shellcode Great Again
 
CARACTERES ASCII ENSAMBLADOR
CARACTERES ASCII ENSAMBLADORCARACTERES ASCII ENSAMBLADOR
CARACTERES ASCII ENSAMBLADOR
 
FPGA Tutorial - LCD Interface
FPGA Tutorial - LCD InterfaceFPGA Tutorial - LCD Interface
FPGA Tutorial - LCD Interface
 
DWARF Data Representation
DWARF Data RepresentationDWARF Data Representation
DWARF Data Representation
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
 
224698998 moshell-commands
224698998 moshell-commands224698998 moshell-commands
224698998 moshell-commands
 
HackLU 2018 Make ARM Shellcode Great Again
HackLU 2018 Make ARM Shellcode Great AgainHackLU 2018 Make ARM Shellcode Great Again
HackLU 2018 Make ARM Shellcode Great Again
 
Debugging TV Frame 0x09
Debugging TV Frame 0x09Debugging TV Frame 0x09
Debugging TV Frame 0x09
 
Redo internals ppt
Redo internals pptRedo internals ppt
Redo internals ppt
 
SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
 

Similaire à The propeller

Assembly language
Assembly languageAssembly language
Assembly languagebryle12
 
Hp dv6 7000 goya balen 11254-3
Hp dv6 7000 goya balen 11254-3Hp dv6 7000 goya balen 11254-3
Hp dv6 7000 goya balen 11254-3JosPinaya
 
At89 c2051 (3)
At89 c2051 (3)At89 c2051 (3)
At89 c2051 (3)angiey y
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
 
Kernel Recipes 2013 - Deciphering Oopsies
Kernel Recipes 2013 - Deciphering OopsiesKernel Recipes 2013 - Deciphering Oopsies
Kernel Recipes 2013 - Deciphering OopsiesAnne Nicolas
 
Windows kernel debugging workshop in florida
Windows kernel debugging   workshop in floridaWindows kernel debugging   workshop in florida
Windows kernel debugging workshop in floridaSisimon Soman
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhtsBéo Tú
 
Topviewsimulator
TopviewsimulatorTopviewsimulator
TopviewsimulatorRashmi
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051) vijaydeepakg
 
Syllabus 3 month pclr
Syllabus 3 month pclrSyllabus 3 month pclr
Syllabus 3 month pclrchiptroniks
 
Real Time Clock Interfacing with FPGA
Real Time Clock Interfacing with FPGAReal Time Clock Interfacing with FPGA
Real Time Clock Interfacing with FPGAMafaz Ahmed
 
MICROCONTROLLER 8051-BASED SOLAR CHARGE CONTROLLER.pptx
MICROCONTROLLER 8051-BASED SOLAR CHARGE CONTROLLER.pptxMICROCONTROLLER 8051-BASED SOLAR CHARGE CONTROLLER.pptx
MICROCONTROLLER 8051-BASED SOLAR CHARGE CONTROLLER.pptx37PaduriHrishitha
 

Similaire à The propeller (20)

Assembly language
Assembly languageAssembly language
Assembly language
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
chapter 4
chapter 4chapter 4
chapter 4
 
Hp dv6 7000 goya balen 11254-3
Hp dv6 7000 goya balen 11254-3Hp dv6 7000 goya balen 11254-3
Hp dv6 7000 goya balen 11254-3
 
At89 c2051 (3)
At89 c2051 (3)At89 c2051 (3)
At89 c2051 (3)
 
89 c2051
89 c205189 c2051
89 c2051
 
Experiment 16 x2 parallel lcd
Experiment   16 x2 parallel lcdExperiment   16 x2 parallel lcd
Experiment 16 x2 parallel lcd
 
At89c4051
At89c4051At89c4051
At89c4051
 
Pclr syllabus 1 month
Pclr syllabus  1 monthPclr syllabus  1 month
Pclr syllabus 1 month
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
Kernel Recipes 2013 - Deciphering Oopsies
Kernel Recipes 2013 - Deciphering OopsiesKernel Recipes 2013 - Deciphering Oopsies
Kernel Recipes 2013 - Deciphering Oopsies
 
Windows kernel debugging workshop in florida
Windows kernel debugging   workshop in floridaWindows kernel debugging   workshop in florida
Windows kernel debugging workshop in florida
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
 
Real Time Embedded System
Real Time Embedded SystemReal Time Embedded System
Real Time Embedded System
 
Topviewsimulator
TopviewsimulatorTopviewsimulator
Topviewsimulator
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
 
Syllabus 3 month pclr
Syllabus 3 month pclrSyllabus 3 month pclr
Syllabus 3 month pclr
 
Real Time Clock Interfacing with FPGA
Real Time Clock Interfacing with FPGAReal Time Clock Interfacing with FPGA
Real Time Clock Interfacing with FPGA
 
W10: Interrupts
W10: InterruptsW10: Interrupts
W10: Interrupts
 
MICROCONTROLLER 8051-BASED SOLAR CHARGE CONTROLLER.pptx
MICROCONTROLLER 8051-BASED SOLAR CHARGE CONTROLLER.pptxMICROCONTROLLER 8051-BASED SOLAR CHARGE CONTROLLER.pptx
MICROCONTROLLER 8051-BASED SOLAR CHARGE CONTROLLER.pptx
 

Dernier

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 

Dernier (20)

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 

The propeller

  • 1. The Propeller, a mechanically scanned LED clock by Bob Blick. The clock is on a spinning piece of perfboard, but it must get power. I thought of many ways to do this, including using two motors(motor one has its shaft fixed to a base, and motor two spins the body of motor one, generating electricity), making a rotary transformer, or using slip rings. I decided to do it another way, taking power from the spinning armature of a plain DC motor. In order to run the wires out of the motor, I removed the bearing from one end of the motor, leaving a big hole. There are three terminals inside most small DC motors, and it acts a lot like three-phase alternating current, so it must be rectified back to DC. A nice side effect of this is that the position of the motor can be detected by taking one of the phases straight into the microprocessor. Step One: Mangle a Motor. Find a VCR, perhaps a Sharp or a Samsung, with a flat reel motor. The motor I have is marked JPA1B01, but Sharp knows it by the number RMOTV1007GEZZ. Take it apart without mangling the brushes(there are little holes to slip a paperclip into to move the brushes out of the way), and notice that it has one ball bearing and one sleeve bearing. Knock the sleeve bearing out of the case and glue or solder it to the other end of the motor, as an extension of the ball bearing. The shaft of the motor will have to be repositioned slightly to get the right height, press it in a vise with a hollow spacer on one end. Take a Berg connector with three wires and solder them to the three terminals on the motor's armature. Glue a short threaded spacer to the shaft at the end that will stick out the hole, and reassemble the motor(be careful with the brushes). You can glue the motor to a VCR head as a weighted base. Step Two: Build the circuit. I used perfboard(Vectorboard) and handwired the circuit together. Use an 18-pin socket for the 16C84 because it needs to be programmed before putting it in the circuit. For the 7 current-limit resistors I used a DIP resistor array, because it made it easy to experiment with LED brightness. I settled on 120 ohms. You can use seven regular resistors, because 120 ohms works fine, though it puts the peak current right at the limit for the 16C84. Think about balance while you build this circuit, and reference my pictures, so you don't have to add a lot of balancing weight later. Substitute for any part values you like. Note that I used a 47000uf supercap, it is to keep the clock running after turning it off, so you can set the time. The LEDs get power separate from this. Don't substitute a ceramic resonator for the 4MHz crystal,
  • 2. this is a clock and should be accurate. Step Three: Program the 16C84. You'll need a programmer that will program a PIC16C84. If you found this file/web page, you can find plans to build a 16C84 programmer. Program it using the hex file accompanying this document. I have included the source code(.asm) just for your amusement. When programming the chip, set the chip options to: watchdog timer(WDT) OFF and oscillator to normal XT crystal. Step Four: Throw it together and Keep Time. Screw the circuit board to the motor, and plug the three wire connector in. Apply power to the motor. The preferred voltage is 6.2 volts, but it will run from 5 volts to about 7.5 volts. Note that 5 volts gets to the circuit when 6.2 volts is applied to the motor, because of diode losses. The clock may be working at this point, displaying 12:00. If it isn't. there was probably some voltage on the supercap when you plugged in the chip. Turn off the power and momentarily short pins 5 and 4 together(ground and /mclr) to reset the chip. Now when you apply power the clock should work, and you can set it by turning off the power and pushing the buttons(hours, 10 minutes, minutes) the right number of times. If the numbers appear backwards, reverse the polarity to the motor to make it spin the other way. You might experiment with balancing the clock, and the use of foam under the base to reduce vibration. Step Five: Modifications. If you look closely at the source code, you'll see that the "dot rate" is adjusted to the speed of the motor to make the display a consistent width regardless of the motor's speed. The motor I used has brushes set 90 degrees apart, and gives two indexes each revolution. The clock displays on two sides, 180 degrees apart. If you use a motor with the brushes 180 apart, the clock will only display on one side, and the numbers will be too wide. You'll want to modify the program, in the section marked D_lookup_3. The value in the W register when Delay gets called effects the width of the digits. You might try sending half of the period_calc value to Delay, perhaps by rotating period_calc right into W(remember to clear the carry flag first). Like this: bcf STATUS,C rrf period_calc,w call Delay January 25, 1997 Bob Blick www.bobblick.com copyright 1997 Bob Blick, all rights reserved
  • 3. updated notes November 2, 2006 Note: PIC16C84 is now obsolete. You may use either a PIC16F84 or PIC16F84A with no changes. Note: Sharp VCR motor is now obsolete. Use any DC motor, preferably meant for 12 volts so the speed will not be too great when operated at approximately 6.2 volts. The Propeller Clock Parts List Capacitors: C1, C2 - 33pf ceramic C3, C6 - 0.1uf ceramic C4 - 47uf electrolytic C5 - 47,000uf supercap(memory cap) Diodes: D1-D7 - light emitting diodes D8-16 - 1N4001 general purpose 1amp rectifiers Resistors: R1 - 120 ohm DIP array or seven 120 ohm resistors R2-R6 - 10k ohm Misc: J1 - three terminal Berg connector SW1-SW3 - normally open pushbutton switches U1 - PIC16C84, PIC16F84 or PIC16F84A XTAL1 - 4MHz crystal MOTOR - Sharp RMOTV1007GEZZ Note: U1 to be programmed with mclock hex file Code ;-------- ; mclock8.asm ; "The Propeller" mechanically scanned LED clock ; some changes since last version - ; modified table etc for compatiblility with 8th LED ; watchdog timer used to ensure startup ; Bob Blick February 12, 1997 ; Licensed under the terms of the GNU General Public License, www.gnu.org ; No warranties expredded or implied ; Bob Blick February 18, 2002 ;-------- list p=16C84 radix hex
  • 4. include "p16c84.inc" ;-------- ; remember to set blast-time options: OSC=regular xtal, WDT=ON ; timings all based on 4 MHz crystal ;-------- ; are these equates already in the include file? someday I'll look. ;-------- w equ 0 f equ 1 ;-------- ; Start of available RAM. ;-------- cblock 0x0C safe_w ;not really temp, used by interrupt svc safe_s ;not really temp, used by interrupt svc period_count ;incremented each interrupt period_dup ;copy of period_count safe from interrupt period_calc ;stable period after hysteresis calc. flags ;b2=int b1=minute b4=edge dot_index ;which column is being displayed digit_index ;which digit is being displayed hours ;in display format, not hex(01-12) minutes ;00 to 59 bigtick_dbl ;incremented each interrupt bigtick_hi bigtick_lo keys ;key value scratch ;scratch value tick ;used by delay endc ;-------- ; Start of ROM ;-------- org 0x00 ;Start of code space goto Start ;-------- ; INTERRUPT SERVICE ROUTINE ;-------- org 0x04 ;interrupt vector Intsvc movwf safe_w ;save w swapf STATUS,w ;swap status, w movwf safe_s ;save status(nibble swap, remember) ;-------- ; done saving, now start working ;-------- ; clear watchdog timer to ensure startup clrwdt ; ; increment period count incf period_count,f btfsc STATUS,Z ;zero set means overflow decf period_count,f ; 234375 interrupts every minute. Increment the bigtick each time. incf bigtick_lo,f btfsc STATUS,Z incf bigtick_hi,f btfsc STATUS,Z
  • 5. incfsz bigtick_dbl,f goto Bigtick_out ;-------- ; here? bigtick has rolled over to zero and one minute has passed. ; reload bigtick and set a flag for the main counter ;-------- movlw 0xFC ;234375 = 0x039387 movwf bigtick_dbl ;0 - 0x039387 = 0xFC6C79 movlw 0x6C movwf bigtick_hi movlw 0x79 movwf bigtick_lo bsf flags,1 ;notify Keep_time Bigtick_out ;-------- ; done working, start restoring ;-------- swapf safe_s,w ;fetch status, reswap nibbles movwf STATUS ;restore status swapf safe_w,f ;swap nibbles in preparation swapf safe_w,w ;for the swap restoration of w bcf INTCON,2 ;clear interrupt flag before return retfie ;return from interrupt ;-------- ; CHARACTER LOOKUP TABLE ; ignore high bit. set=LED off, clear=LED on, bit0=bottom LED, bit6=top LED ;-------- Char_tbl addwf PCL,f dt 0xC1,0xBE,0xBE,0xBE,0xC1 ;"O" dt 0xFF,0xDE,0x80,0xFE,0xFF ;"1" dt 0xDE,0xBC,0xBA,0xB6,0xCE ;"2" dt 0xBD,0xBE,0xAE,0x96,0xB9 ;"3" dt 0xF3,0xEB,0xDB,0x80,0xFB ;"4" dt 0x8D,0xAE,0xAE,0xAE,0xB1 ;"5" dt 0xE1,0xD6,0xB6,0xB6,0xF9 ;"6" dt 0xBF,0xB8,0xB7,0xAF,0x9F ;"7" dt 0xC9,0xB6,0xB6,0xB6,0xC9 ;"8" dt 0xCF,0xB6,0xB6,0xB5,0xC3 ;"9" dt 0xFF,0xC9,0xC9,0xFF,0xFF ;":" Char_tbl_end ;-------- ; SUBROUTINES STARTING HERE ;-------- ; clear important bits of ram ;-------- Ram_init movlw 0x07 movwf keys movlw 0x12 ;why do clocks always start movwf hours ;at 12:00 ? clrf minutes clrf dot_index clrf digit_index movlw 0xFC movwf bigtick_dbl retlw 0 ;--------
  • 6. ; unused pins I am setting to be outputs ;-------- Port_init movlw 0x00 ;all output, b7=unused tris PORTB ;on port b attached to LEDs movlw b'00010111' ;port a has 5 pins. I need 4 inputs ;b0=minutes, b1=10mins, b2=hours ;b3=unused, b4=rotation index tris PORTA ;on port a retlw 0 ;-------- ; get timer-based interrupts going ;-------- Timer_init bcf INTCON,2 ;clear TMR0 int flag bsf INTCON,7 ;enable global interrupts bsf INTCON,5 ;enable TMR0 int clrf TMR0 ;clear timer clrwdt ;why is this needed? just do it.. movlw b'11011000' ;set up timer. prescaler(bit3)bypassed option ;send w to option. generate warning. clrf TMR0 ;start timer retlw 0 ;-------- ; test for index in rotation and store period in period_dup ;-------- Check_index movf PORTA,w ;get the state of port a xorwf flags,w ;compare with saved state andlw b'00010000' ;only interested in bit 4 btfsc STATUS,Z ;test for edge retlw 0 ;not an edge, same as last xorwf flags,f ;save for next time btfsc flags,4 ;test for falling edge retlw 0 ;must have been a rising edge movf period_count,w ;make a working copy movwf period_dup ;called period dup clrf period_count ;a fresh start for next rotation clrf digit_index ;set to first digit clrf dot_index ;first column ; calculate a period that does not dither or jitter ; period will not be changed unless new period is really different movf period_calc,w subwf period_dup,w ;find difference btfss STATUS,C ;carry flag set means no borrow goto Calc_period_neg ;must be other way sublw 2 ;allowable deviation = 3 btfss STATUS,C ;borrow won't skip incf period_calc ;new value much larger than calc retlw 0 Calc_period_neg addlw 2 ;allowable deviation = 3 btfss STATUS,C ;carry will skip decf period_calc ;no carry means it must be changed retlw 0 ;-------- ; change LED pattern based on state of digit_index and dot_index ;-------- Display_now movlw 0x05 xorwf dot_index,w ;test for end of digit movlw 0xFF ;pattern for blank column
  • 7. btfsc STATUS,Z goto D_lookup_3 ;it needs a blank bcf STATUS,C ;clear carry before a rotate rlf digit_index,w ;double the index because each addwf PCL,f ;takes two instructions D_10hr swapf hours,w goto D_lookup ;what a great rush of power D_1hr movf hours,w ;I feel when modifying goto D_lookup ;the program counter D_colon movlw 0x0A goto D_lookup D_10min swapf minutes,w goto D_lookup D_1min movf minutes,w goto D_lookup D_nothing retlw 0 D_lookup andlw b'00001111' ;strip off hi bits movwf scratch ;multiply this by 5 for lookup addwf scratch,f ;table base position addwf scratch,f ;is this cheating? addwf scratch,f ;I think not. addwf scratch,f ;I think it is conserving energy! btfss STATUS,Z ;test for zero goto D_lookup_2 ;not a zero movf digit_index,f ;this is just to test/set flag movlw 0xFF ;this makes a blank LED pattern btfsc STATUS,Z ;test if it is 10 hrs digit goto D_lookup_3 ;it's a leading zero D_lookup_2 movf dot_index,w ;get column addwf scratch,w ;add it to digit base call Char_tbl ;get the dot pattern for this column D_lookup_3 movwf PORTB ;send it to the LEDs movlw 0x0C ;overhead value sub from period subwf period_calc,w ;compensate for overhead and set call Delay ;width of digits with this delay incf dot_index,f ;increment to the next column movlw 0x06 ;6 columns is a digit plus space xorwf dot_index,w ;next digit test btfss STATUS,Z retlw 0 ;not a new digit clrf dot_index ;new digit time incf digit_index,f retlw 0 ;Display_now done. ;-------- ; a short delay routine ;-------- Delay movwf tick Delay_loop decfsz tick,f goto Delay_loop ;w is not damaged, so Delay can return ;be recalled without reloading ;-------- ; test for keypress and call time adjust if needed ;-------- Check_keys movf PORTA,w ;get port "a" xorwf keys,w ;compare with previous andlw b'00000111' ;only care about button pins btfsc STATUS,Z ;zero set=no buttons
  • 8. retlw 0 ;return xorwf keys,f ;store key value movlw 0x64 ;a fairly long delay will movwf scratch ;prevent key bounces Key_delay movlw 0xFF call Delay decfsz scratch goto Key_delay btfss keys,2 ;test "minutes" button goto Inc_mins btfss keys,1 ;test "tens" button goto Inc_tens btfss keys,0 ;test "hours" button goto Inc_hours retlw 0 ;must be a glitch. yeah, right! ;-------- ; increment ten minutes ;-------- Inc_tens movlw 0x0A movwf scratch ;scratch has ten Inc_tens_loop call Inc_mins decfsz scratch goto Inc_tens_loop ;another minute added retlw 0 ;-------- ; increment one hour ;-------- Inc_hours movlw 0x12 xorwf hours,w btfsc STATUS,Z goto Inc_hours_12 movlw 0x07 ;this part gets a little sloppy addwf hours,w movlw 0x07 btfss STATUS,DC movlw 1 addwf hours,f retlw 0 Inc_hours_12 movlw 0x01 movwf hours retlw 0 ;-------- ; increment the time based on flags,1 as sent by interrupt routine ; Inc_mins loop also used by time-setting routine ;-------- Keep_time btfss flags,1 ;the minutes flag retlw 0 ;not this time bcf flags,1 ;clear the minutes flag Inc_mins movlw 0x07 ;start incrementing time addwf minutes,w ;add 7 minutes into w btfsc STATUS,DC ;did adding 7 cause digit carry? goto Sixty_mins ;then test for an hour change incf minutes ;otherwise add 1 for real retlw 0 ;and go back Sixty_mins movwf minutes ;save the minutes movlw 0x60 ;test for 60 xorwf minutes,w ;are minutes at 60?
  • 9. btfss STATUS,Z retlw 0 ;no? go back clrf minutes ;otherwise zero minutes goto Inc_hours ;and increment hours ;-------- ; End of subroutines ; Program starts here ;-------- Start call Ram_init ;set variables to nice values call Port_init ;set port directions call Timer_init ;start timer based interrupt ;-------- ; Done initializing, start the endless loop. ;-------- ; Circle ;begin the big loop ; ;-------- ; detect falling edge on PORTA,4 to determine rotary index ; calculate rotation period and store in period_dup ; compare with working period(period_calc) and adjust if way different ;-------- call Check_index ;-------- ; check display state and change if needed ;-------- call Display_now ;-------- ; check keyboard and adjust time ;-------- call Check_keys ;-------- ; check minute flag and increment time if a minute has passed ;-------- call Keep_time ;-------- ; gentlemen, that's a clock, keep it rolling ;-------- goto Circle ;you heard the man, get going! end ;-------- ; end of file ;-------- Hex :020000040000FA :10000000F028FF3FFF3FFF3F8C00030E8D00640090 :100010008E0A03198E03980A0319970A0319960F7B :100020001828FC3096006C309700793098009114B5 :100030000D0E83008C0E0C0E0B1109008207C134CB :10004000BE34BE34BE34C134FF34DE348034FE34BA :10005000FF34DE34BC34BA34B634CE34BD34BE34AE :10006000AE349634B934F334EB34DB348034FB34BF
  • 10. :100070008D34AE34AE34AE34B134E134D634B6342B :10008000B634F934BF34B834B734AF349F34C934DC :10009000B634B634B634C934CF34B634B634B534E5 :1000A000C334FF34C934C934FF34FF3407309900F6 :1000B00012309400950192019301FC3096000034B7 :1000C000003066001730650000340B118B178B165B :1000D00081016400D83062008101003405081106F6 :1000E0001039031900349106111A00340E088F00DC :1000F0008E019301920110080F02031C8328023C19 :10010000031C900A0034023E031C900300340530A7 :100110001206FF300319A9280310130D8207140ECD :100120009A2814089A280A309A28150E9A28150831 :100130009A2800340F399A009A079A079A079A0763 :10014000031DA6289308FF300319A92812081A07CF :100150001E2086000C301002B520920A06301206CE :10016000031D00349201930A00349B009B0BB628B8 :100170000800050819060739031900349906643088 :100180009A00FF30B5209A0BC128191DE328991C4D :10019000CC28191CD22800340A309A00E3209A0B8C :1001A000CE280034123014060319DD280730140756 :1001B0000730831C01309407003401309400003470 :1001C000911C00349110073015078318E928950A0F :1001D0000034950060301506031D00349501D228C7 :1001E0005620602065206E208720B920E020F3286B :0201F000FF3FCF :02400E00F53F7C :00000001FF