PDA

View Full Version : DEFINE OSC too limited



mytekcontrols
- 14th June 2005, 22:30
DEFINE OSC 4

This Define statement is suppose to synchronize most of PBP's time dependent functions (i.e.; pause and pauseus) to the oscillator feeding your PIC chip. Without the Define statement these functions assume you are running at 4 mhz. The problem is, that the choice of alternative oscillator speeds is limited to only 12 different speeds, which are: 3(3.58),4,8,10,12,16,20,24,25,32,33,40 mhz.

Now I don't know about you, but for me this is too limiting. Example: it wouldn't be uncommon for someone to want to run their PIC at 14.318 mhz (NTSC) or for that matter 17.734 (PAL) since these are 4fsc standards used in video applications. It would be nice to have the Pause function still work properly at this speed, but it wont, since their is no Define for either of these frequencies.

Not knowing what is going on underneath the cover of PBP, it would seem a relatively simple matter to allow for a much more flexible definition of oscillator speed that would accomodate a given users situation. Can the creators of PBP provide such a option?

Melanie
- 15th June 2005, 09:49
Of course the PAUSE works properly... you just need to make an adjustment with a little bit of math. So if you want to time 1 second with a DEFINE OSC of 16MHz and your 17.734MHz xtal, all you need is...

16/17.734*1000

Pause 902

Think outside the box. The limits of PBP are your imagination.

mytekcontrols
- 15th June 2005, 14:56
Hi Melanie,
Yes I understand that you can take the approach you just gave, but I tend to like things to mean what they say. If I have a statement that says "Pauseus 100" then I would like it to actually mean that I am taking a 100 microsecond pause. In this case we really aren't talking about "thinking outside of the box", but instead, about writing understandable code. Besides we aren't just talking about Pause routines here. There are 24 PBP functions that are all affected by incorrect oscillator selection.


COUNT, DEBUG, DEBUGIN,DTMFOUT,FREQOUT,HPWM,HSERIN,HSEROUT,
I2CREAD,I2CWRITE,LCDOUT,OWIN,OWOUT,PAUSE,PAUSEUS,
SERIN,SERIN2,SEROUT,SEROUT2,SHIFTIN,SHIFTOUT,
SOUND,XIN, and XOUT

I would hate to come back later, and try to debug even my own code, not say someone elses, if I used the method you suggested. Especially if a variety of the functions mentioned above were sprinkled throughout.

Don't get me wrong, I like PBP, and really appreciate the effort that had to be put into making it what it is today. However this is a "Wish List" and my wish is to see a better way to do the Oscillator Define, so that all functions utilizing timing in their makeup continue to do what they say, and to mean what they mean. Is this asking too much? Or am I developing a case of OCD?

crematory
- 29th July 2005, 16:19
Hello mytekcontrols

In deed, you are absolutely right.

breogan
- 21st November 2005, 11:00
Hi,
I'm trying to use 20MHz oscillator with PIC16C74A, for example, I have written this program to make blink a led for 1 second, but it doesn't work, the frequency is not 1Hz (it is more slow):

'********** Definitions **********
DEFINE OSC 20

'********** Main prog **********
Main:
high PORTA.0
pause 500
low PORTA.0
pause 500
goto Main

End

'***************************************

I'm using the David Tait programmer (home made) with the PIC74.EXE program (PIC16C74 Programmer Version 1.0b Copyright (C) 1996 Paul Vollebregt.) With the options "-hp8" (HS osc), also I have triyed with "-xp8" (XT osc).

Thanks !

Melanie
- 22nd November 2005, 07:08
Of course it'll be slower...

Lets assume that Pause 500 is a perfect 500mS (which is unlikely but probably close). Your HIGH and your LOW and your GOTO all take up time too which has to be taken into account. Finally, how accurate is your Oscillator? 20.00000MHz or is it a few percent high or low?

You want exactly 1Hz... go grab an oscillocope and trim it... now you have control in 1uS steps... but you add any other code or you nudge your room thermostat a little, and bang goes your timing!

Main:
high PORTA.0
pause 499
pauseus 1000
low PORTA.0
pause 499
pauseus 1000
goto Main

Ron Marcus
- 24th November 2005, 14:52
Is there some way to nudge the "DEFINE" value that PBP uses when compiling?

queenidog
- 19th May 2015, 15:21
Good answer Melanie, I agree 100% with what you say. Purists tend to focus too much on one parameter, not realizing that in the big picture, there are lots of things that affect your reading, like temperature! In engineering we typically ignore the bottom 10% and the top 90% and concentrate efforts in between, meaning we don't sweat the small stuff unless it is ABSOLUTELY necessary. A LED that doesn't blink at exactly 1.0000Hz? Who cares, unless your using to to time Longines watches.

Acetronics2
- 20th May 2015, 18:20
Good answer Melanie, I agree 100% with what you say. Purists tend to focus too much on one parameter, not realizing that in the big picture, there are lots of things that affect your reading, like temperature! In engineering we typically ignore the bottom 10% and the top 90% and concentrate efforts in between, meaning we don't sweat the small stuff unless it is ABSOLUTELY necessary. A LED that doesn't blink at exactly 1.0000Hz? Who cares, unless your using to to time Longines watches.

... I do not know if Mel will even see your post ...

did you notice it is a 10 years after dig out ( tadaaa, music ON ) ... add to that Mel has left this forum many years ago ... ( 2 or more ...)


Last Activity:- 22nd February 2012 01:20

Alain

queenidog
- 21st May 2015, 00:26
Yes I saw the date, but felt compelled to answer anyway, unaware of her status on this forum.

I had a friend who was doing some non-critical A/D conversions but was unsatisfied with the 10 bit (1:1024) resolution of his PIC and was going to employ an external A/D for the extra bits. I reminded him of the resolution and accuracy of his own DVM which was really no better. That and the fact that 10 bits over 5 volts is a resolution of about 5 mV.

Sometimes the forest can't be seen for the trees.

Aussie Barry
- 21st May 2015, 01:18
Does anyone know why Melanie left the forum?
She was a prolific poster and helped many along the way and then suddenly, nothing more.
I have always been curious about her departure.

I wonder if she is aware of the sad news about Darrel Taylor?

Cheers
Barry
VK2XBP

Heckler
- 21st May 2015, 01:54
Yeah I was thinking about that myself... we kind of almost get to know each other in an anonymous sort of way.

I would be nice to hear how/what she is doing now days.
I'm sure there are others who have left after making a real positive impact on the learning experience of microcontroller programming.

Really a great bunch here... I wish the Basic Language would experience a sort of comeback or revival!!

Art
- 21st May 2015, 06:53
I was going to point that out, but then thought why bother.. lol.
I have wondered the same and just assume people move on, same as I thought with Darrel for some time actually.

It is true that the imagination can move around some limiting facts. That is a positive and true message!

Acetronics2
- 22nd May 2015, 09:34
Does anyone know why Melanie left the forum?
She was a prolific poster and helped many along the way and then suddenly, nothing more.
I have always been curious about her departure.

I wonder if she is aware of the sad news about Darrel Taylor?

Cheers
Barry
VK2XBP

Hi, Barry

Mel left the forum for professionnal reasons, as she was to travel a lot with her new function.
as she wrote me she was to spend much much time flying around the world.

Moreover she has a new Hobby : flying light aircrafts ...

I did not have any news from her for at least two years ...

Alain

Aussie Barry
- 22nd May 2015, 11:43
Hi Alain,

Thank you for the quick reply.
If you still have her contact details, perhaps you could let her know about Darrel.

Cheers
Barry
VK2XBP

queenidog
- 22nd May 2015, 14:22
What about Darrel Taylor? Geez, he was another one who helped me a lot, not only through this forum but through the MELabs forum. He was the one that really got me started with this PIC/PBPro stuff, after I had a long hiatus from Motorola products. Great guy, smart as hell and helps every one. What is his story?

mackrackit
- 22nd May 2015, 16:07
http://support.melabs.com/threads/1035-The-passing-of-Darrel-Taylor?p=2591#post2591

longpole001
- 8th July 2015, 15:37
i have to aggree that the OSC define is very limiting and also makes for harder reading of code later on

i needed 1mhz setting , but there i no such setting , have to use 4mhz , which is fine , but it means all the code that has any pauses pauseus , are not correct and these routines have been used in other chips and now need to be changed just to suit this cpu setting.

not happy

it makes for servicing the software harder later down the road, and inconsitancies when the code is transported


not good

rmteo
- 28th July 2015, 02:32
... I wish the Basic Language would experience a sort of comeback or revival!!
Won't ever happen (outside of the hobby/education market) due to its many limitations/shortcomings.