Does ceramic resonator works the same with crystal oscillator?

Thread Starter

Joanna Marie Pagtalunan

Joined Nov 11, 2018
7
Hi we are making this circuit called roulette game using pic 16f84a. We got the hex file and the ckt diagram from a youtube video (link below). When we did it in breadboard it doesnt work like the one in youtube. We have checked the connections many times. Im thinking if it is maybe because we used crystal osci instead of ceramic? Because crystal oscillators are the ones only available here in the nearby electronics store thats why we used it.

roulette_circuit.png 20181112_231814.jpg
 

jpanhalt

Joined Jan 18, 2008
11,087
Your crystal probably doesn't have built-in capacitors, the resonator likely did. You need to review this section of the datasheet:

upload_2018-11-12_10-51-44.png
 

Alec_t

Joined Sep 17, 2013
14,280
The PIC should have decoupling capacitors very close to its supply pins.
The LEDs should each have a series resistor to limit current (hence prevent PIC damage), unless current-limiting is inherent in the PIC.
 

jpanhalt

Joined Jan 18, 2008
11,087
I just took a short peek at her sources. The code is in C. The config. for 16F84A is XT (not HS), which should be OK for the crystal. As for individual resistors, the author explains his use of a single one since only one LED is on at a time.

I suggest removing the connection between resonator pin3 ("ground" and VCC) when using the crystal. I suspect one could tie the two capacitors used with a crystal to VCC, but I have never done that. They are usually shown connected to ground as in the schematic from the datasheet I posted.
 

Thread Starter

Joanna Marie Pagtalunan

Joined Nov 11, 2018
7
I just took a short peek at her sources. The code is in C. The config. for 16F84A is XT (not HS), which should be OK for the crystal. As for individual resistors, the author explains his use of a single one since only one LED is on at a time.

I suggest removing the connection between resonator pin3 ("ground" and VCC) when using the crystal. I suspect one could tie the two capacitors used with a crystal to VCC, but I have never done that. They are usually shown connected to ground as in the schematic from the datasheet I posted.
Just to clarify, you mean to say sir, that the crystal osci will be connected to pin 15 of pic and the to pin14 (vdd)?
 

FlyWizard

Joined Apr 27, 2016
6
As Alec_t mentioned, the decoupling capacitor from Vdd to Vss, C1, should be very close to the PIC. Right over the PIC from pin 5 to pin 14 would be best. I had a similar design on a breadboard that would not work until the processor was bypassed.
 

Thread Starter

Joanna Marie Pagtalunan

Joined Nov 11, 2018
7
As Alec_t mentioned, the decoupling capacitor from Vdd to Vss, C1, should be very close to the PIC. Right over the PIC from pin 5 to pin 14 would be best. I had a similar design on a breadboard that would not work until the processor was bypassed.
We tried doing it like this but it doesnt seem to work.
15420866513286383355929085723370.jpg
 

FlyWizard

Joined Apr 27, 2016
6
Things I would check:
1. Bypass every IC - you did this.
2. Check power at the IC power pins with a DVM. Is the voltage correct?
3. Check power anywhere it goes with the switch on. Everything getting power?
4. Make sure all LEDs are connected with correct polarity. They'll never turn on if they are backwards.
5. Are you sure the PIC is programmed properly?
6. Is the PIC bad? Do you have a second programmed PIC to swap in?
 

jpanhalt

Joined Jan 18, 2008
11,087
Just to clarify, you mean to say sir, that the crystal osci will be connected to pin 15 of pic and the to pin14 (vdd)?
No, that is not what I meant. Connect the crystal as shown in the datasheet between pins 15 and 16. Connect the capacitors to ground. There will be no connection to VDD.

The reason the ceramic resonator was connected to VDD was something to do with ease of wiring. As you know, the original work is in Japanese. I had to rely on the Google translation.

Now that you show the video, I am not convinced the PIC "isn't working." That phrase can mean anything from exploding to not doing what you expect to being stone dead and doing nothing. Originally, I thought you meant it was stone dead, but now I see that the LED's are flashing, and I take that as a sign that the PIC is working, but timings are off and too fast.

Two likely causes are changes/errors in the code or noise in the system that is causing frequent resets of the PIC. Decoupling capacitors , as others have mentioned, may help. The code itself can cause resets (for example, the watch dog timer). I do not do C; perhaps you do. Do the timing delays and sequence look okay?

As for the crystal, leave the capacitors attached to the crystal. They are needed. Do you know whether the crystal is parallel cut (see footnote #2 in that diagram). Although I have never connected the crystal capacitors to VDD instead of ground, you might try that. It should be harmless, and if that doesn't change anything, return to having those loading capacitors connected to ground.
 

jpanhalt

Joined Jan 18, 2008
11,087
Going back to your very first here, it just occurred to me that you may be planning to use the outputs on the LED pins to generate a pseudo-random number input to a 16F877A that will be displayed on an LCD.

Are you required to use that 16F84A and LED display in your project or can you just do the whole thing in the 16F877A and LCD? Generating those numbers requires only a short piece of code. That would also allow you to include all 38 numbers (6-bit), odd/even, red/black, and 0/00 (American wheel). With just the LCD, you wouldn't have the LED's seeming to spin, but you could imitate a spinning wheel on a 4-line numeric LCD pretty easily.

Just a thought that might be easier to do than troubleshooting hex code written a long time ago.

Edit: I concur with atferrari about your power pin. In your first picture of the board (post 1), it is connected correctly, but in your most recent post, that connection has been removed. Why? PIC's can sometimes get power from other pins ("back feed") but may act very oddly. RA2 and MCLR both have connections to VDD, but they are high impedance (at least 10K), which would not be enough to light the LED's. Is there another pin connected to VDD?
 
Last edited:
Top