HI Guys.
Need a bit help again.
I am in the process of building some test equipment utilizing PWM, how ever I need to be able to adjust the frequency, as well as the duty cycle.
I have a test rig set up at the moment however when testing I need to supply different frequency to ensure the equipment being tested works at all levels.
At the moment I have to take the chip out and adjust and reprogram each time i need to change the frequency, and this very time consuming.
If i change to a bigger chip like a 16F877a
Is there a simply way of adding ADC or two buttons (freq up/down) to my software, to change the frequency form 100Hz to about 4Khz.
Attached is a the code, I am using at the moment for you to take a look at, or if some one has some thing i can look at to give me a idea.
very much appreciated.
Thanks Guys
adjustable Frequency Help
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: adjustable Frequency Help
Hello,
You may need to disable the PWM before you can alter the clock source though i'm not 100% about this.
You can do this directly from Flowcode by calling the ChangePeriod PWM function.
You will need to pass the value 255 for the period value if this is the period you wish to use and then use 1, 4 or 16 for the prescaler value.
You may need to disable the PWM before you can alter the clock source though i'm not 100% about this.
You can do this directly from Flowcode by calling the ChangePeriod PWM function.
You will need to pass the value 255 for the period value if this is the period you wish to use and then use 1, 4 or 16 for the prescaler value.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode V4 User
- Posts: 40
- Joined: Sat Mar 06, 2010 5:25 am
- Location: Chicago USA, & Oxford & Northampton UK
- Has thanked: 6 times
- Contact:
Re: adjustable Frequency Help
Hi, Ben.
Thanks for Getting back to me.
Is there any other way to do this to that i can get more values.
this will work for some of the things i have to do but it will only give me 3 settings. I was looking to try and get a few more.
thanks
Trisb
Thanks for Getting back to me.
Is there any other way to do this to that i can get more values.
this will work for some of the things i have to do but it will only give me 3 settings. I was looking to try and get a few more.
thanks
Trisb
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: adjustable Frequency Help
Hello Trisb,
By varying the prescaler and the maximum period you can have much more control then 3 settings. However if you are reducing the maximum period then you will get less resolution when varying the period setting.
Full period value range
Max period = 255
Period = 0 <> 255
Reduced period value range
Max period = 254
Period = 0 <> 254
..
Max period = 1
Period = 0 <> 1
By varying the prescaler and the maximum period you can have much more control then 3 settings. However if you are reducing the maximum period then you will get less resolution when varying the period setting.
Full period value range
Max period = 255
Period = 0 <> 255
Reduced period value range
Max period = 254
Period = 0 <> 254
..
Max period = 1
Period = 0 <> 1
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Dan81
- Valued Contributor
- Posts: 268
- Joined: Sun Jan 15, 2006 4:07 pm
- Location: Albi France
- Been thanked: 60 times
- Contact:
Re: adjustable Frequency Help
Hello Trisb
Take a look at this file.
I've made some modifications.
That seems OK within Flowcode and Proteus.
The lowest frequency you can get is 240Hz (with a 4MHZ Quartz).
Instead of using PowerUP and PowerDown Button , you can use a potentiometer but you should change to a 16F886 (24pins).
Or remove quartz, move buttons to RA6 or RA7 and put potentiometer to RA5 (AN4)
Daniel
Take a look at this file.
I've made some modifications.
That seems OK within Flowcode and Proteus.
The lowest frequency you can get is 240Hz (with a 4MHZ Quartz).
Instead of using PowerUP and PowerDown Button , you can use a potentiometer but you should change to a 16F886 (24pins).
Or remove quartz, move buttons to RA6 or RA7 and put potentiometer to RA5 (AN4)
Daniel
- Attachments
-
- PWM test Unit-mod.fcf
- not hard tested
- (31.32 KiB) Downloaded 352 times
-
- Flowcode V4 User
- Posts: 40
- Joined: Sat Mar 06, 2010 5:25 am
- Location: Chicago USA, & Oxford & Northampton UK
- Has thanked: 6 times
- Contact:
Re: adjustable Frequency Help
Hi, Dan,
This looks great Thanks for looking at this for me..
I will give this a try on the Hardware and let you know how it goes.
Thanks
Tristan.
This looks great Thanks for looking at this for me..
I will give this a try on the Hardware and let you know how it goes.
Thanks
Tristan.