Pommie said:It sounds like the best thing to do is to order the parts and build a prototype.
I suggest that you initially use the 12V supply from the master to power the H bridge (SN754410) and to feed the 78L05 for the pic supply.
Once the hardware is available it will be fairly easy to change the code to accommodate different timing requirements.
BTW, if you don't get an immediate reply it's probably because I'm in bed. Being 10 hours ahead of the UK makes communication difficult.
Mike.
Pommie said:Mark,
The H bridge serves two purposes, to convert from logic levels (5V) to solenoid levels (12/24V) and to enable higher currents to be supplied. The H bridge could in fact be replaced by a relay that was configured for changeover. You could drive a 1.5V clock direct from the pic as long as the current requirement is no greater than 20mA.
The watch crystal is to run the pic. The reason that clock crystals are either 32,768Hz or 4,194,304Hz is because these are nice round numbers in binary and so easy to divide down in hardware.
32768 = 1,000,000,000,000,000 binary = 2^15
4194304 = 10,000,000,000,000,000,000,000 binary = 2^22
Either would be suitable for your project. The reason I chose 32768 was because the internal timers in the pic are 16 bit which will accommodate 2^15 but not 2^22. Also, slower running circuits use less power and are more stable.
One reason I suggested changing to a 16F88 was because it has an internal clock that can run at 32768Hz (the 628 runs at 4MHz but could still be used.). Unfortunately, these internal clocks are only accurate to 1%. In ppm terms that’s 10,000ppm compared to a crystals 20ppm. However, because we have a signal that arrives every 30 seconds, we can use it to calculate the true speed of the internal clock and compensate in software. This would mean that the first 30 second period would have seconds that could vary by ± 10mS, but subsequent seconds would be accurate.
Where about in Aus is your Aunt moving to? I only moved here 4 years ago from Manchester. Needless to say, I’m not missing the weather. I'm also rather surprised at how bad Maplins has become! It now looks more like Tandy.
Mike.
markelectro said:Mike
My Aunt is going to Adelaide,Wish I were going with her too
Maplins is a big concern over here,they have big superstores that you can walk around I tend to try and go without the Wife as she gets very bored with it.
Fannell's have come up trumps with a good prompt delivery, I received the parts this morning.
What I did forget is Breadboards, I want to get it right on these then maybe just maybe I will try my hand at PCB. as got to get the circuit small.I will get these from Maplins.
Could I be so bold as to ask if you could include a complete schemaone with the 5v supply and the resistor and capacitor values included. Sorry for asking I just want to get it right.
Kind regards Mark
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.
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
RODALCO said:I always believe in the KISS principle ( Keep It Simple Stupid )
If you can avoid complicated programming with exotic IC's or dodgy software go the other way.
Use some discrete logic or electromechanical means, which is part of a clock building hobby anyway go that route.
I make some pics of the tacho I built from old Landis & Gyr clock parts and a transisitor push pull driver.
My system has been working for 2 years continuously now, with no faillures.
Also during a power cut the seconds will get synchronised back in step.
Regards
Raymond
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?