Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

1 sec pulse from 30 sec clock

Status
Not open for further replies.
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.

Mike thanks for that!! cant tell you haw much this appreciated.

yeh my wifes now watchinh cora!! keeps them quiet!!

Mike what about the asm can you help me?


Regards mark
 
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.


3V0

You are right and I suppose I should take the pic. route to do the task but none the less I don't mind learning other methods this can only help me along the road to good electronics.

Your method I can use in other ways,maybe to detect the pendulums swing to trigger a pulse for impulse to keep the pendulum swinging.I suppose many ways to do the same job.

So I thank you for your sugestion and I do think it wll be used if not now in the future.

Kind regards mark
 
Last edited:
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.

Code:
;*******************************************************************
;                           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.


Mike!! wow!!!
You have exceeded my expectations I cannot tell you how grateful I am for this effort.
As you are aware I am not 100% sure about asm code just yet but I will give it a go and see what happens.Please understand it may take me some time get get it up and running.When I have I will post a message and let you know how it's gone.

Kind regards Mark
 
Last edited:
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
 
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

Torban feel free to jump in

Thanks for this method.The pendulum in the clock I am using is a 1 sec pendulum.
I would welcome many methods to use in my clocks to show the seconds infact I am thinking of putting an whole string of methods together to show that many can work.
Ae you may be aware my electronic knowladge is limmited as my interest lies in clocks really.It's only when I got thinking of how to ctreate the seconds pulse that I started to get really interested in what coculd be used.Problem for a novice like me is know what componants do to create a circuit and how best to put the circuit together.

I have seen lazer beam break schematics about that are mainly 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.

if you can help with a schema this would help me put it all toghether.

King regards mark
 
Last edited:
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?

I'll try to remember to dig that schematic up tomorrow; the box it's on is downstairs in Windows at the moment so it's off the net for now.

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.

So the pendulum completes a full swing (right to left to right) in 1 second? Put the beam break detector at the end of the swing range. The pendulum will swing into the top of its path, breaking the light beam and keeping it broken until it starts falling back into its reverse swing. One full swing later it will return and retrigger.

The 555 monostable ignores new signals while the current one is still in effect--i.e. if someone scores on my foosball table, further scores on that side are ignored for 3 seconds (this prevents retriggering as the ball bounces around in the goal cup on hard shots). In the case of the pendulum, a 0.5 second output pulse would keep the thing from retriggering on the pendulum's backswing even if the pendulum swings a little over the mark and cuts the beam on the fore- and back-swings.

If the pendulum completes a full right-left-right swing in 1 second, just put the beam sensor in the centre of the swing path. The pendulum should break the beam every second.

The resistors and timing capacitor you use in the 555 circuit determine its output pulse time. The circuit snippet which I will try to remember to send tomorrow is set for ~3 seconds, and googling something like "555 monostable tutorial" should give you some pointers on how it's set up (and more importantly, why. Which I'm still working on myself. . .)



Torben
 
Torben,
Thanks for your input and knowledge on this subject.

Marks clock pendulum makes a full swing forth, back and forth in 2 seconds which is one full cycle.
That type of clock is said to have a one second beat, in clock language.

In his case the sensing point, either opto sensor or sensing coil has to be at the middle of the pendulum swing.
An laser/opto sensing circuit would not affect the accuracy of the pendulum at all.
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.

The other clock you mention does one full cycle has a 1/2 second beat.
The way to get a 1 second impulse from it you described is correct by offsetting the sensing point at the dead end of the pendulum swing.
 
Last edited:
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
 
Ray n Torben

Thank you both for your inputs to this subject.I am very pleased that others have an interest too.I wished I could help you both with electronic solutions and tried and tested methods,one day I may be able to return the kind help and I would be very happy to do so.

Ray
as you know I am in the process of teaching myself PIC. programming this as many advantages so when I get to a stage of sharing tried and tested clock experiments I will let you know.

Torben
you suggested using C well I wish I knew C. I am told that this is where I want to end up at.At the moment putting circuits together to get my head around how different components work together and then using Pic.'s to limit the amount of parts to be used is where I am.For a beginner ASM. is I'm told the best place to start.Could take sometime as usually people who move onto pics already have a electronic background.


Kind regards Mark
 
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..


Ray cheers for this.

Just so I understand your sugestion-

"A sensing coil" I would assume this would be a simple electro mag coil but acting in the opposit way in insetad of out???

" driving an opamp circuit" I would guess this is some sort of low voltage switch that able to detect the minimle power form the coil then switching a larger power supply?????

"flip flop" Timer output ???

We have discussed 4017 devide and and gates in other threds.

Could you please clear up any wrong doings I have made.

Kind regards Mark
 
Just off topic slightly and maybe this one is for my other thread but the suggestions above are the basis of a free pendulum, or are they??
https://www.electro-tech-online.com...sing-a-pendulum-for-a-clock.28921/#post234902

A free pendulum one that has no wheel train to drive and so no drive from it and like in Hipp n toggle must be able to determine when it's own impulse is required IE. when the pendulum begins to slow.

I don't think using an external timebase to keep the pendulum in sync with it is the way, I think that the free pendulum has to have a triggering system that detects when it is loosing momentum just like hipp/toggle does but without the aid of the hipp/toggle. this would keep the pendulum completely free from mechanical interference.

Something along the lines of-A flag coming out of the bottom of the pendulum that as to pass an opto sensor at far right when it reaches the sensor it will have worked out the duration of the swing and determine if a pulse is required if a pulse is required when it reaches the left side of the swing then a pulse is given.

Or- use two sensors at far right and the pendulum as to pass both if it does then no pulse required if not then at some point a pulse will be delivered.

Or- use the sensors at the bottom.

I think that the impulse is best delivered from centre bottom.

could you suggest any other sensing for this purpose??

I think this is quiet a lot harder than it sounds especially to someone with little electro knowledge but I would like to hear your thoughts and theories and how best this can be converted into a circuit.

Regards mark
 
Last edited:
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.


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
 
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

Torben

Been fishing around on the 555 and it's quite a little piece of kit.I did spend sometime in this web site-


And I did find some very useful circuits to follow.Circuits that could be used for the 1 sec pulse and even the free pendulum.

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

Thanks for that!!

Mark
 
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.

You can google a 555 monostable timing calculator so that you don't have to do it by trial and error, or you can use the formula T = 1.1 * R * C, where T is in seconds, R is in ohms, and C is in farads.

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

Neat idea. I think that would probably work.

With a sensor coil, I would expect there to be a (very) slight drag effect on the pendulum. It may be insignificant or not; I don't know anything about your clock so I wouldn't even guess. The beam break detector would have no such effect, even in theory.

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.

Then just get a cheapo laser pointer at a dollar store, carefully remove the laser diode. Mine run from +4.5VDC, so I put a diode (a simple 1N914 or other garden-variety diode should work) in series with 5V to power it.

The whole shebang runs on 5VDC.

Disclaimer: this is all off of my very first independent digital design ever, and I ain't claiming to be an electrical engineer or even in school to be one. I Just like this stuff and try to learn what I can between work and baby. :)


Torben
 
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.

Torban

Cheers for that.I have taken a look and I will try and re-draw the complete circuit.

When I have worked it all out I will post it and then if you could pull it to bits cos I'm sure I won't get it right first time.

Regards Mark
 
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


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.
 
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.


CHEERS!! 3v0

Seems a little brutal for the poor LED. but I will give it a go.


Regards Mark
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top