Hi!
I am trying to create a osc. generator with an output with 50 Hz.
First I try with a Xtal 196608 Mhz with HS in the config. The time on and out out is not correct, least twice as long as set. My experience, it start work correct when I use Xtal from 4 Mhz and down.
If I use Internal Osc. OSCCON = 0x60; 4 Mhz Ok. And OSCCON = 0x70; 8Mhz Ok.
By out on and off with delay on 10mS should give 50Hz. work perfect from 4Mhz and down.
Am I doing something wrong in the config when using Xtal? Please advice.
Thanks in advance
Jorgen
Pic12f683 Osc. problem!
Moderator: Benj
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Pic12f683 Osc. problem!
Hi Jorgen,
Take a look at this post.
You can use that method to produce an accurate 50Hz osc.
Give it a try and if you get stuck, I can assist you further.
Just let me know if using internal or external clock and at what frequency?
Take a look at this post.
You can use that method to produce an accurate 50Hz osc.
Give it a try and if you get stuck, I can assist you further.
Just let me know if using internal or external clock and at what frequency?
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Pic12f683 Osc. problem!
Hi Martin!
Thank`s for reply. It is actually also the intention I will use your model with the timer calculation and your exambles, to get an accurate frequency, good tool, but during development I discovered there are problems when using Xtal With frequency over 4Mhz when using the Pic12f683. So therefor I create this simple testprogram, and I measure the timelength with an oscilloscope. But if I use an internal oscillator, which can reach a maximum of 8Mhz, it works fine and delay timing fits. But not with extern Xtal. The delay timelength is laest twice as long as it should be. Maybe a bug, But before it write in bugs report I Will be sure I do it correct.So my question is, do I do something wrong in config when I use higher frequencies with Xtal?
Maybe you could have a look in the config and change it for 19Mhz Xtal and I could test, please.
Thank’s in advance.
Jorgen
Thank`s for reply. It is actually also the intention I will use your model with the timer calculation and your exambles, to get an accurate frequency, good tool, but during development I discovered there are problems when using Xtal With frequency over 4Mhz when using the Pic12f683. So therefor I create this simple testprogram, and I measure the timelength with an oscilloscope. But if I use an internal oscillator, which can reach a maximum of 8Mhz, it works fine and delay timing fits. But not with extern Xtal. The delay timelength is laest twice as long as it should be. Maybe a bug, But before it write in bugs report I Will be sure I do it correct.So my question is, do I do something wrong in config when I use higher frequencies with Xtal?
Maybe you could have a look in the config and change it for 19Mhz Xtal and I could test, please.
Thank’s in advance.
Jorgen
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Pic12f683 Osc. problem!
There is nothing wrong with config settings.
Seem like could be hardware.
Could it be your crystal is not running at the expected speed?
Can you use scope to measure frequency directly on the crystal pin?
What value caps have you connected between OSC1 & GND, OSC2 & GND?
Seem like could be hardware.
Could it be your crystal is not running at the expected speed?
Can you use scope to measure frequency directly on the crystal pin?
What value caps have you connected between OSC1 & GND, OSC2 & GND?
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Pic12f683 Osc. problem!
Hi Martin!
Thank´s for your help. Capasitors, oh I forgot these. After mounting 2x15 pF. it work.
I want to use your calculator and try to get some calculation I can´t find the calculation for 50 Hz which fit. I don´t have the posibilities in the timer2 for the pic12683.
Do you have any idea? please.
Br jorgen
Thank´s for your help. Capasitors, oh I forgot these. After mounting 2x15 pF. it work.
I want to use your calculator and try to get some calculation I can´t find the calculation for 50 Hz which fit. I don´t have the posibilities in the timer2 for the pic12683.
Do you have any idea? please.
Br jorgen
- Attachments
-
- Calc.PNG (29.59 KiB) Viewed 2760 times
-
- Ur værksted.fcfx
- (8.43 KiB) Downloaded 124 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Pic12f683 Osc. problem!
Glad its working now for you.
Don't forget from the post linked, it sates you will need the interrupt at double the required frequency.
Therefore you have to enter 100Hz and not 50Hz
Your Clock speed is 19660800, Not 4000000 as shown in the image of spread sheet you posted.
There is a correct setting you can use on your target device for 100Hz with a clock of 19660800 as I have seen it.
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Pic12f683 Osc. problem!
Hi Martin!
Again thank´s. Yes I know I have changed the frequency, the test is from two different pc, sorry
With the Xtal 19660800Mhz, I see your spreadsheet come with different suggestion, but it is not possible to use them in the timer2 config for the Pic16f683. Or maybe I do something wrong, if so I apologize.
But Martin I solve problem.
Prescaler Rate 1:16
Postscaler Rate 1:12
Rollover Value 256, give exactly 50Hz out.
Anyway, your spreadsheet for timer 2 is a good tool, and maybe better for bigger devices, certanly, I will use it.
Thanks again.
Jorgen.
Again thank´s. Yes I know I have changed the frequency, the test is from two different pc, sorry
With the Xtal 19660800Mhz, I see your spreadsheet come with different suggestion, but it is not possible to use them in the timer2 config for the Pic16f683. Or maybe I do something wrong, if so I apologize.
But Martin I solve problem.
Prescaler Rate 1:16
Postscaler Rate 1:12
Rollover Value 256, give exactly 50Hz out.
Anyway, your spreadsheet for timer 2 is a good tool, and maybe better for bigger devices, certanly, I will use it.
Thanks again.
Jorgen.
- Attachments
-
- Config 12f6831.jpg (78.54 KiB) Viewed 2718 times
-
- Sheet1.jpg (64.13 KiB) Viewed 2718 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Pic12f683 Osc. problem!
That's not quiet true.
If you look at the image you posted you will see 16, 16, 192
So does work for Pic16f683.
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Pic12f683 Osc. problem!
Hej Martin!
Sorry, sorry, and yes you are rigth, I did not know it was possible to write own values in this field, though they was fixed.
I learn some new today
I can tell you,I see a very accurate frequency on 50 Hz on the output measured during long time with timer 2
Thank´s again.
Br jorgen.
Sorry, sorry, and yes you are rigth, I did not know it was possible to write own values in this field, though they was fixed.
I learn some new today
I can tell you,I see a very accurate frequency on 50 Hz on the output measured during long time with timer 2
Thank´s again.
Br jorgen.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Pic12f683 Osc. problem!
Hi Jorgen,
Not a problem, Glad I have helped.
Yes, this method is far more accurate then software generated delays.
Martin