Searching \ for '[PIC]: incrementing in steps' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'incrementing in steps'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: incrementing in steps'
2002\06\05@164028 by Gordon Varney

flavicon
face
I need a pin to clock out a square wave at 800Hz. Simple, just set pin high for 625us, set pin low for 625us, and
repeat.

Now I need to increment the clock frequency by 50Hz, do some work and increment by 50Hz again, continue incrementing
until complete. The step duration in a time period is not a constant. What is the best method to incrementing the
frequency by 50Hz.

(Note: I am using a combination of Assembly and the CCS compiler for this program.)

Gordon Varney
http://www.iamnee.com

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\06\05@172659 by Gordon Varney

flavicon
face
sorry for the bother, I got this one...:-)

    frequency=800;     //Starting value
    freq_dur=(1/frequency)/2;

Sometimes it is right in front of your nose and your can't see it.

Also, 4 hours of sleep last night can make things fuzzy.

Gordon Varney
http://www.iamnee.com


{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2002\06\05@173106 by Lawrence Lile

flavicon
face
Gordon,

I've sent you an excel spreadsheet under separate cover in oorder to not
post a big attachemtn to the list.

Here is the idea:  Teach Excel to do some of your work for you.  The
spreadsheet does the following:

1.  Calculates 1/F,  1/F / 2, and converts it to microseconds, which is the
same as machine cycles in a 4mHz PIC.

2. Formats this info into an array:    int16 freqlookup[] = { 625, 588, etc
etc };  << All this tedious symtax is generated inside Excel

3.  Now cut and paste the array into your C code

4. Place it in a constant table like this:

BYTE CONST freqlookup[] = { 625, 588, etc etc };
warning, this works in CCS C, may not in Hitech

5.  Use it in your code like this:

freqlookup[5];


6.  Stuff this number into a timer preset, say you are using timer2, preset
Timer2 with 65535 - freqlookup[x], where x is incremented each timer
interrupt.

This is all off the top of my head, YMMV.

--Lawrence

{Original Message removed}

2002\06\05@173527 by Lawrence Lile

flavicon
face
Oh well, I had a cool trick anyway.  Teaching Excel to format a big long
string of numbers and write code for your is a neat trick, keep it around.

--Lawrence

{Original Message removed}

2002\06\06@033204 by Vasile Surducan

flavicon
face
Use the PWM for frequency generation, change the pr2 (period) and t2con
values ( prescaler ) for 50Hz incrementation.

regards,
Vasile
http://www.geocities.com/vsurducan


On Wed, 5 Jun 2002, Gordon Varney wrote:

> I need a pin to clock out a square wave at 800Hz.
Simple, just set pin high for 625us, set pin low for 625us, and
> repeat.
>
> Now I need to increment the clock frequency by 50Hz,
do some work and increment by 50Hz again, continue incrementing
> until complete. The step duration in a time period is not a constant.
What is the best method to incrementing the
{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\06\06@081308 by Olin Lathrop

face picon face
> I need a pin to clock out a square wave at 800Hz. Simple, just set pin
high for 625us, set pin low for 625us, and
> repeat.
>
> Now I need to increment the clock frequency by 50Hz, do some work and
increment by 50Hz again, continue incrementing
> until complete. The step duration in a time period is not a constant. What
is the best method to incrementing the
> frequency by 50Hz.

It depends on the frequency resolution you need and the highest frequency of
interest.  800Hz is slow enough that this is easy to do with a timer
interrupt.  Timer 1 would be easiest because a CCP module can be used to
provide a 16 bit period value.  For higher frequencies, the PWM hardware
might be more suitable.  As the frequency gets higher, the resolution will
go down because all these methods devide the instruction clock by an
integer, and the integer values get small at high frequencies.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...