How accurate does your pulse need to be? You can get a reasonably accurate 1Hz pulse by using a 555 timer. The best part is that it is simple (no programming required), has few parts, and you could build it for pennies. Check out this link:
You can calculate the pulses using the formulas provided in the document.
t1= 0.693(R1+R2)C
t2= 0.693(R2)(C)
If your pulse is 1Hz, that means one cycle per second; therefore t1=t2= 0.5 seconds
Then just plug in the numbers and solve. Pick a value for R1 and solve simultaniously for R2 and C.
0.5=.693(R1+R2)C
0.5=.693(R2)(C)
Hope that helps.
Btw, for greater accuracy, use a trimmer for R2 and fine tune the circuit until it is exactly 1 Hz
I am breadboarding, so I programed my PIC and then set it up with the crystal. I tried using 22pF caps, because that was all I had got, and it didn't work.
The caps may be too low or it may be something else, can you put 2 caps in parallel on each leg of the crystal? Did you change the config to LP from XT? What are you using to program your chip? Are you sure it is being programmed?
I could put 2 caps on each leg of the crystal if i had them! I will have to get some new caps! I converted the assembler file to hex using MPASMWIN and then programmed the PIC with Progpic2.
When i had programmed the PIC, i saved a file of the readback data (see below!)
ORG 0x2000
DATA 0x0F
DATA 0x00
DATA 0x0F
DATA 0x00
ORG 0x2123
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
DATA 0x8C
The actual running part of the program is identical, but you have some strange rubbish higher up in data eeprom etc. none of which will affect the programs running.
The picture attached is a circuit diagram for how to connect the crystal to the PIC. Then all you need to do is to connect the power lines to the PIC and a cable out of RB0 for the pulse.
The picture attached is a circuit diagram for how to connect the crystal to the PIC. Then all you need to do is to connect the power lines to the PIC and a cable out of RB0 for the pulse.
With MCLR enabled in the configuration fuses, you need to connect pin 4 to Vdd with a resistor, 1 kohms should be ok. Or disable the external MCLR funtion by changing the config settings: _MCLR_OFF
When i try to connect the pulse to my 4510 BCD counter, then it does not count!!!
The spec sheet for the 4510 says that the minimum pulse width for the pulse at 5V is 150ns. It has no max. Shouldn't this mean that it will register the pulse?
Could you program the pic to make the pulse shorter?
A pic should be able to clock a cmos counter without any problem. Have you got all the other pins on the 4510 connected correctly. That is, carry in, Preset and reset grounded and U/D tied high.
It would be fairly easy to change the duty cycle of the pulses but it shouldn't be necessary.
Mike.
Edit, if you want to try a shorter pulse then change the code to,
Code:
main movfw TMR1H ;get timer high byte
andlw b'00011111' ;keep the lower 5 bits
btfss STATUS,Z ;if not zero (97% of the time)
bcf PORTB,0 ;clear portB bit 0
btfsc STATUS,Z ;if zero (3% of the time)
bsf PORTB,0 ;set bit 0 of port b
goto main ;do it all again
This will give a 30mS pulse. To make it double change the b'00011111' to b'00011110'. Making more bits zero (from the right) will double the time for each additional zero.
hi,
I think my problem with the counter is that I have not got big enough capacitors around the crystal. I only have two 22pF ones. It says that I should use 68 or 100pF ones.