Pommie said:This is what I think you need as far as a circuit goes.
I would suggest a 32768Hz watch crystal as the code for PWM becomes fairly simple.
Anyone got a better suggestion for the input.
BTW, I'm currently playing here while my wife is watching soaps. Looks like it's the same the world over.
Mike.
3v0 said:If you want to learn ASM then I suggest you do not spend time on the optical. It would be fun to try but may be tricky to get working,
PIC ASM is not too hard to learn. You can get help here once you start coding. Nigel has a good set of intro PIC tutorials. There is also Newcomers, please read! (PIC regarded) Upd. 0xD post at the head of the microcontroller forum. It lists many additional tutorials.
You will need to install MicroChips free MPLAB to assemble the code then use your programmer and its software to program it.
;*******************************************************************
; 16F628 Timer Program
;*******************************************************************
;
list p=16f628A ; list directive to define processor
#include <p16F628A.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _LP_OSC
cblock 20h
Phase
endc
cblock 70h
int_work
int_status
int_pclath
int_fsr
endc
org 0h
goto start
nop
nop
nop
interupt movwf int_work
swapf STATUS,W
movwf int_status
bcf STATUS,RP0
bcf STATUS,RP1
movfw PCLATH
movwf int_pclath
clrf PCLATH
movfw FSR
movwf int_fsr
btfss INTCON,INTF ;has RB0 gone high
goto NotRB0 ; no
; yes, clear the timer and phase
bcf INTCON,INTF
clrf TMR1L
clrf TMR1H
clrf Phase
NotRB0 btfss PIR1,CCP1IF
goto NotCCP1
;time up so toggle port b outputs.
bcf PIR1,CCP1IF; reset special event trigger interupt
movlw b'00001100'; make rb1 low and rb2 high
btfss Phase,0
movlw b'00001010'; make rb1 high and rb2 low
movwf PORTB
incf Phase,F ; will toggle bit 0 of phase
NotCCP1
movfw int_pclath
movwf PCLATH
movfw int_fsr
movwf FSR
swapf int_status,W
movwf STATUS
swapf int_work,F; swap to file
swapf int_work,W; swap to work
retfie
start bsf STATUS,RP0
bcf STATUS,RP1
bcf STATUS,IRP
movlw b'01000000'; interrupt on rising edge
movwf OPTION_REG
movlw b'11111111'
movwf TRISA
movlw b'11110001'; make rb1,2,3 output
movwf TRISB
clrf PORTA
clrf PORTB
movlw b'00000111'; setup comparator
movwf CMCON
movlw B'00000001'
movwf T1CON; enable timer 1
movlw low(0x4000); 0x4000 = half of 32768 i.e. 0.5 seconds
movwf CCPR1L
movlw high(0x4000)
movwf CCPR1H
movlw B'00001011'; enable special event trigger on CCP1
movwf CCP1CON;
bsf STATUS,RP0
bsf PIE1,CCP1IE; enable CCP1 interupt
bcf STATUS,RP0
movlw (1<<GIE|1<<PEIE|0<<T0IE|1<<INTE|0<<RBIE|0<<T0IF|0<<INTF|0<<RBIF)
movwf INTCON; enable Peripheral and RB0 interrupts
Loop goto Loop
end
Pommie said:Here's a first go at an asm file. It uses timer1 and the ccp module to generate an interrupt every 0.5 seconds and the RB0 interrupt to reset the timer. It is untested as I don't have a 628 handy at the moment but I think it should work.
On the circuit diagram, I would add a 5k resistor from RB3 to ground.
This code assumes a crystal frequency of 32768Hz. If you can only get 38k crystals then change the 0x4000 to d'19000'.
Mike.
Torben said:Hi Mark,
Just jumping in here, but you mentioned using a reed switch on the pendulum. Is the pendulum period one second? Seems to me that you might be able to get away without the PIC; just put a beam-break detector across the pendulum's path (a laser diode from a $2 laser pointer aimed at a phototransistor, say), run that to a transistor with a resistor or two, and maybe a Schmitt trigger or 555 to "condition" the pulse. I did this with a foosball scoreboard circuit last year; the ball entering the goal breaks a laser beam which triggers a 555 wired monostable via a phototransistor. The 555 then takes that very brief pulse and stretches it out to 3 seconds to light up a score lamp (and to increment a counter).
Of course if you can't mount the sensors or the pendulum doesn't have the right period this won't work.
Oh yeah--do you know C? You should be able to get away with programming the PIC in C instead of asm, if you're more comfortable with that. I haven't used PICs, but I have used Atmel 8051s with C with good results (with the penalty of slightly larger executable code size).
Just some thoughts, anyway. Whatever you do, good luck!
Torben
markelectro said:I have seen lazer beam break schematics about that are mainky used for alarm purposes and I guess all they are is a switch so can be addapted to use for many functions.Can you provide a schema for this ciurcuit to include the 555 timer?
Where I would get confused is making the circuit only work in one direction.As the pendulum swings it only as to register a pulse in one direction to make sure we only get a pulse 1 in a second.
RODALCO said:A small magnet could be attached to the pendulum rod facing the back clock cabinet wall.
A sensing coil driving an opamp circuit could be used to create one second impulses. These can be counted via a flip flop or 4013 - 4017 to get a divided by two. By gating the 2 second pulse and the one second pulse a driving train can be made to provide alternating impulses to the one seconds slave clocks..
3v0 said:Everything you mentioned could be made to work.
The detector is made from a bit of fiber optic cable, an LED and a
phototransistor.
Torben said:Rodalco, you are absolutely right. I messed up my earlier message; in the second-to-last paragraph I should have said "If the pendulum completes a full right-left-right swing in 2 seconds, just put the beam sensor in the centre of the swing path. The pendulum should break the beam every second.".
My mistake.
Torben
markelectro said:Torben
for the 1 sec out put
Using the Photo transister for the input and play around with the resistors and the capacitors until we get a good output.
For the Free pendulum -
one circuit looks interesting-fig 10a missing pulse detector.
Basically this does as it says the circuit is always looking for a pulse , When It misses a pulse it triggers an alarm.
If the input to the 555 was either a phototransistor or a coil with a opamp circuit we could play around with it and if it did not recive a signal then we could turn the alarm into a pulse required to run the pendulum.
Correct me if I'm wrong
Torben said:Also, as to my schematic, I haven't had a chance to dig up a good one today, but I did manage to remember that it is explored in another thread of mine here:
https://www.electro-tech-online.com/threads/beam-break-dark-alarm-question.26780/
You could use the 555 circuit from the first schematic posted, and the phototransistor circuit from the last schematic. Read the posts 'cause the transistor section in the first schematic is hosed and the posts explain why.
RODALCO said:Hi,
I have made a short recording of my seconds T&N clock and put it on U tube, which shows the transfer between seconds and minutes.
https://www.youtube.com/watch?v=VRx5YEAE0kQ
Raymond
markelectro said:3V0 n all
Can a fibre optic cable be purchased to fit over a LED. I have some firbre optic cable that once was used for a star light effect for the house. How would this be best mounted to take the light from the Led.
Mark
3v0 said:You can buy commerical optical connectors and parts.
DIY method: According to Mims you drill a hole in the top of the LED, or use a hot wire to melt one in.
The important thing is how you cut the fibre optic strand. Use a hobby knife to score the fibre while rolling it. Then snap it off. If the score is true you should have a smooth flat surface on the end of the fibre.
Stick the fiber into the LED.
Do not have much time right now. Will recheck this info and post if I have more info or do not have it right.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?