Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 28, 2024, 09:19:31 09:19


Login with username, password and session length


Pages: [1]
Print
Author Topic: Propeller Clock & Magic Wand...  (Read 6086 times)
0 Members and 1 Guest are viewing this topic.
stam
Guest
« on: December 06, 2007, 11:54:55 23:54 »

Hello there!  Smiley

I was looking over the net and I found some great mini projects like propeller clock and magic wand.

One site that has everything is that:
http://www.luberth.com/analog.htm

My main problem is that as far I searched I didn't find nothing in C, everything is in asm...

For example I have understand the hole idea of magic wand but I can't figure out how much is the delay between each led light up...  Huh Sad

The asm code for the magic wand is that:

Code:
;*******************************************************************************************
;                           message.asm
;
; This code makes a message appear in mid air.The 5 leds are connected to portb. RB0 - RB4
; put new message in below. NOTE: messages too long are a problem, as the
; 'persistence of vision' doesn't work.
; LEDS connected to port RB0 - 4 tilt/accelerometer to RA0 to start text
;
; letters are in columns. i.e letter A
; 0110
; 1001
; 1001   the 1's make up the A.  1 = LED on. 0 = off
; 1111
; 1001
;
; By Barry Carter
;
;*******************************************************************************************

LIST    P=16C84;f=inhx8m

w       equ     0 ; register destination addresses.
f       equ     1
same equ 1

z       equ     2 ; status flags
zero equ 2
c equ 0
carry equ 0

count1  equ     0C      ; wait counter ls digit file register C
count2  equ 0D ; wait counter ms digit file register D

portb   equ     06      ; port b I/O register f6
porta equ 05 ; port a I/O register f5
status  equ     03      ; status register f3
time equ .15
;
;
;
org     0 ; origin
;
init   
movlw   0 ;initialise port settings
tris    portb
movwf   portb
movlw 1
tris porta
bcf porta,0

start
goto getbut

;* TYPE YOUR MESSAGE IN HERE *

letters call lh ;type in letters here.
call le
call ll
call ll
call lo
goto getbut ;goto get button input

;* FINISH MESSAGE SECTION *

getbut bcf status,1
movf porta,w ;gets input from start button on porta.0
movwf status ;read status register, to see value of porta
btfsc status,0
goto getbut ;if status = 1 then goto letter else goto getbut
goto letters


;*ROUTINES FOR OUTPUTING CHARACTERS TO LED'S ON PORTB*
;each letter is prefixed with l e.g la is a

la call wait ; wait for a bit
movlw B'00001111' ;output corresponding values out of portb
movwf portb
call wait
movlw B'00010010'
movwf portb
call wait
movlw B'00010010'
movwf portb
call wait
movlw B'00001111'
movwf portb
call space1
return

lb call wait ; wait for a bit
movlw B'00001111'
movwf portb
call wait ;
movlw B'00010101'
movwf portb
call wait
movlw B'00010101'
movwf portb
call wait
movlw B'00001010'
movwf portb
call space1
return

lc call wait ; wait for a bit
movlw B'00001110'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00010001'
movwf portb
call space1
return

ld call wait ; wait for a bit
movlw B'00011111'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00001110'
movwf portb
call space1
return


le call wait ; wait for a bit
movlw B'00011111'
movwf portb
call wait
movlw B'00010101'
movwf portb
call wait
movlw B'00010101'
movwf portb
call wait
movlw B'00010101'
movwf portb
call space1
return

lf call wait ; wait for a bit
movlw B'00011111'
movwf portb
call wait
movlw B'00010100'
movwf portb
call wait
movlw B'00010100'
movwf portb
call wait
movlw B'00010100'
movwf portb
call space1
return

lg call wait ; wait for a bit
movlw B'00001110'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00010011'
movwf portb
call wait
movlw B'00010011'
movwf portb
call space1
return

lh call wait ; wait for a bit
movlw B'00011111'
movwf portb
call wait
movlw B'00000100'
movwf portb
call wait
movlw B'00000100'
movwf portb
call wait
movlw B'00011111'
movwf portb
call space1
return

li call wait ; wait for a bit
movlw B'00010001'
movwf portb
call wait
movlw B'00001111'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00000000'
movwf portb
call space1
return

lj call wait ; wait for a bit
movlw B'00010010'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00011110'
movwf portb
call wait
movlw B'00010000'
movwf portb
call space1
return

lk call wait ; wait for a bit
movlw B'00011111'
movwf portb
call wait
movlw B'00000100'
movwf portb
call wait
movlw B'00001010'
movwf portb
call wait
movlw B'00010001'
movwf portb
call space1
return

ll call wait ; wait for a bit
movlw B'0001111'
movwf portb
call wait
movlw B'00000001'
movwf portb
call wait
movlw B'00000001'
movwf portb
call wait
movlw B'00000001'
movwf portb
call space1
return

lm call wait ; wait for a bit
movlw B'00001111'
movwf portb
call wait
movlw B'00011000'
movwf portb
call wait
movlw B'00011000'
movwf portb
call wait
movlw B'00001111'
movwf portb
call space1
return

ln call wait ; wait for a bit
movlw B'00011111'
movwf portb
call wait
movlw B'00001000'
movwf portb
call wait
movlw B'00000100'
movwf portb
call wait
movlw B'00011111'
movwf portb
call space1
return

lo call wait ; wait for a bit
movlw B'00001110'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00001110'
movwf portb
call space1
return

lp call wait ; wait for a bit
movlw B'00011111'
movwf portb
call wait
movlw B'00010100'
movwf portb
call wait
movlw B'00010100'
movwf portb
call wait
movlw B'00001000'
movwf portb
call space1
return

lq call wait ; wait for a bit
movlw B'00001110'
movwf portb
call wait
movlw B'00010001'
movwf portb
call wait
movlw B'00010011'
movwf portb
call wait
movlw B'00001111'
movwf portb
call space1
return

lr call wait ; wait for a bit
movlw B'00011111'
movwf portb
call wait
movlw B'00010100'
movwf portb
call wait
movlw B'00010110'
movwf portb
call wait
movlw B'00001001'
movwf portb
call space1
return

ls call wait ; wait for a bit
movlw B'00011101'
movwf portb
call wait
movlw B'00010101'
movwf portb
call wait
movlw B'00010101'
movwf portb
call wait
movlw B'00010111'
movwf portb
call space1
return

lt call wait ; wait for a bit
movlw B'00010000'
movwf portb
call wait
movlw B'00011111'
movwf portb
call wait
movlw B'00010000'
movwf portb
call wait
movlw B'00000000'
movwf portb
call space1
return

lu call wait ; wait for a bit
movlw B'00011111'
movwf portb
call wait
movlw B'00000001'
movwf portb
call wait
movlw B'00000001'
movwf portb
call wait
movlw B'00011111'
movwf portb
call space1
return

lv call wait ; wait for a bit
movlw B'00011110'
movwf portb
call wait
movlw B'00000001'
movwf portb
call wait
movlw B'00011110'
movwf portb
call wait
movlw B'00000000'
movwf portb
call space1
return

lw call wait ; wait for a bit
movlw B'00011110'
movwf portb
call wait
movlw B'00000011'
movwf portb
call wait
movlw B'00000011'
movwf portb
call wait
movlw B'00011110'
movwf portb
call space1
return

lx call wait ; wait for a bit
movlw B'00010010'
movwf portb
call wait
movlw B'00001100'
movwf portb
call wait
movlw B'00001100'
movwf portb
call wait
movlw B'00010011'
movwf portb
call space1
return

ly call wait ; wait for a bit
movlw B'00010001'
movwf portb
call wait
movlw B'00001110'
movwf portb
call wait
movlw B'00001000'
movwf portb
call wait
movlw B'00010000'
movwf portb
call space1
return

lz call wait ; wait for a bit
movlw B'00010001'
movwf portb
call wait ;
movlw B'00010011'
movwf portb
call wait
movlw B'00010101'
movwf portb
call wait
movlw B'00011001'
movwf portb
call space1
return

space1 movlw B'00000000' ;routine to put spaces between the letters
call wait
movlw B'00000000'
movwf portb
movlw B'00000000'
return

space2 nop ;loop forever
goto space2


;* wait subroutine *

wait   
movlw   time         ; load count1 with decimal time
movwf   count1
d1 movlw   time ; load count2 with decimal time
movwf   count2


d2 decfsz  count2,same ; decrement F,skip if zero
goto d2 ; if not zero
decfsz  count1 ; decrement count1 if count2 is zero
goto d1 ; do inside loop again if count2 nz
retlw 00
; ----------------------------       


END

Can anyone help me to figure that out the delay at the wait subroutine?

I am using a PIC16F628...

Thanks a lot Smiley

Logged
Parmin
Hero Member
*****
Offline Offline

Posts: 582

Thank You
-Given: 494
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #1 on: December 07, 2007, 03:09:55 03:09 »

Code:
;* wait subroutine *

wait   
movlw   time         ; load count1 with decimal time
movwf   count1
d1 movlw   time ; load count2 with decimal time
movwf   count2


d2 decfsz  count2,same ; decrement F,skip if zero
goto d2 ; if not zero
decfsz  count1 ; decrement count1 if count2 is zero
goto d1 ; do inside loop again if count2 nz
retlw 00
; ----------------------------     

If you look at the top, there is a
time equ .15    <-  decimal 15 or hex 0x0F

The total time of the wait is then about

(256 - 15) x (256 - 15) = 58081 clock steps plus a few more for the routine to work.

Assuming the oscillator is 4Mhz, that gives about 1us a clock so the delay is about 58ms.  Remember this is an approximation, DECFSZ uses 1 clock on not zero and 2 clocks on Zero, so you have to add this into the calculation.

The easiest way is to put the subs into MPLAB and run it with stopwatch.

The safest bet is to use about 60ms and try it out.  This is a very simple program with very simple effect.  Using C for this program would be way overkill and may not give you tight enough timing.


Logged

If I have said something that offends you, please let me know, so I can say it again later.
stam
Guest
« Reply #2 on: December 09, 2007, 11:57:43 11:57 »

Thanks Parmin for the reply!

I'll try later when I get back from job...

I hope I can do something with C Smiley

Posted on: December 07, 2007, 08:36:18 08:36 - Automerged

I give up, it's a very simple circuit & program and even with the asm code ready I can't figure it out... SadSad

Thanks Parmin for the help Smiley
Logged
Parmin
Hero Member
*****
Offline Offline

Posts: 582

Thank You
-Given: 494
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #3 on: December 09, 2007, 10:26:27 22:26 »

Which part do you have problem with?
Logged

If I have said something that offends you, please let me know, so I can say it again later.
stam
Guest
« Reply #4 on: December 09, 2007, 11:29:49 23:29 »

With the hardware part I think it's the problem...

I program the pic (PIC16F628) with the asm that i posted before, i make the circuit  (this: http://www.luberth.com/wand.gif) and when i power up the circuit and press the button nothing happen Sad

I was thinking to build one of these propeller clocks but if i can't make this little think work I will not have any hope on the clock...

Thank you very much for all the help! Smiley
Logged
Parmin
Hero Member
*****
Offline Offline

Posts: 582

Thank You
-Given: 494
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #5 on: December 10, 2007, 12:43:10 00:43 »

Ok, if nothing happened,

Did you disable analogue mode of the 628?
Code:
COMCON=7

What oscillator mode do you use? the 628 have internal oscillator, Luberth uses RC timer for oscillator, which is about the same.

Best thing to start in projects like this is to try to blink ONE led first. Make sure that you use a 200 ohm resistor in series with the LED while trying this - On the final design, no resistor is used because the LED are blinked very fast so it is ok to over load them.

Try something like below for a 1/4 seconds blink (2hz) using the same wait subs as before
Code:
blink
movlw B'00000001'
movwf portb     ; turn on B0
     gosub wait          ; using a few wait subs for longer delays
     gosub wait          ; each wait is about 60ms
     gosub wait          ;  4 x 60ms = about 1/4 second blink
     gosub wait          ; add more waits for even longer delays
     gosub wait
movlw B'00000000'
movwf portb     ; turn off B0
     gosub wait
     gosub wait
     gosub wait
     gosub wait
        goto blink    ; back to top
Logged

If I have said something that offends you, please let me know, so I can say it again later.
andybiker
Newbie
*
Offline Offline

Posts: 26

Thank You
-Given: 60
-Receive: 24


« Reply #6 on: December 11, 2007, 12:53:26 12:53 »

I built a prop-clock several years ago, had to use asm, it worked well until it threw itself apart!
balance it well!
the big problem is how to get power to the rotating electronics... I used a bearing.
Andy.
Logged
Parmin
Hero Member
*****
Offline Offline

Posts: 582

Thank You
-Given: 494
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #7 on: December 12, 2007, 02:41:42 02:41 »

the big problem is how to get power to the rotating electronics... I used a bearing.
Andy.
I would use a 3.5mm audio jack and socket at the end of the axle. they are cheap and easy to replace. Choose one with side wipe on the socket contact.
Logged

If I have said something that offends you, please let me know, so I can say it again later.
bugmike25
Junior Member
**
Offline Offline

Posts: 84

Thank You
-Given: 15
-Receive: 13


« Reply #8 on: December 12, 2007, 11:54:32 11:54 »

I suggest a brushless system.  Just wind two coils, one having a smaller diameter than the other. Keep one fixed with the base.  The other must fit inside the other coil but rotate with propeller arm. Experiment with coil turns. i suggest that you generate a voltage larger than the 5V needed for the arm (maybe evenmore than twice as much). Then use a 7805 voltage regulator.  This should ensure a stable voltage and sufficient current for the electronics to function.

I'm designing a more complex propellor clock for my thesis. Should be interesting.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC