PDA

View Full Version : Low frequency generator



lerameur
- 25th May 2013, 21:16
Hi,

I am trying to make a low frequency generator at 50% duty cycle.
Low meaning from 10hz to 250hz.
After 245Hz, I can use the command HPWM
(and why dont they make the command HPWM go down to 1- Hz ?!! .. )

I have tried Pulsout, PWM, High Low commands...
Found Darrel link at : http://www.darreltaylor.com/DT_INTS-14/SPWM.html ( http://www.darreltaylor.com/DT_INTS-14/SPWM.html)
I'm not an expert programmer, just looking for a simple solution.

thanks
Ken

lerameur
- 26th May 2013, 15:46
Mainly I need a frequency output from 10Hz to 1200Hz approximately.
I decrease the internal oscillator down to 1Mhz and I'm getting down to 62Hz with HPWM, but the max frequency is then barely 400Hz !.
I programmed PWM myself , but with same result as HPWM.
Thought I found it with this program: http://melabs.com/samples/PBP-mixed/hardpwm.htm (http://melabs.com/samples/PBP-mixed/hardpwm.htm)
Unfortunately not, played around with PR2 and other parameters, still nt getting the result I want...

K

HenrikOlsson
- 26th May 2013, 16:10
Which chip are you currently using? Can you switch to another if a more suitable solution exists?

/Henrik.

lerameur
- 26th May 2013, 17:00
I am using 16F88, at this point I am able to view all options...

ken

lerameur
- 26th May 2013, 17:08
some people mentioned by other post to play around with capture mode CCP OSC, But the bandwidth is very small, Altering with parameters changes another.. ending up where I started !!
K

HenrikOlsson
- 26th May 2013, 18:01
Hi,
If you run the PIC at 1MHz and set the TMR2 prescaler to 1:16 then the lowest possible frequency, ie with PR2=255, would (if my calcs are correct) be around 24Hz, 1/(256*4*2.5us*16). If you run that thru an external flip-flop you'll get a divide by 2 ratio so you're down to 12Hz AND you'll get your 50% dutycycle for free - without having to change the dutycycle registers when you change frequency. You should be able to reach 1200Hz with this setup, ie PR2=1 the PWM frequency would be 3125Hz which, after the external 1:2 divider would give you 1562.5Hz. However, the granularity or resolution at the top end will be far from great.

What else, except generating this frequency, is the chip going to do?

/Henrik.

Demon
- 26th May 2013, 18:32
With no experience in PWM, could DT-INT clock be used for this?

Robert

Acetronics2
- 26th May 2013, 20:47
Why not easily generate 1000 - 25000 Hz ( straight with PBP ...) and use a , say, CD 4518 or 74LS390 as a 100 divider on the output ...

as duty cycle is supposed to always be 50% ... no problem then !

Alain

mark_s
- 26th May 2013, 21:07
If you can't make your pic16f88 work. The pic18f2431 with a 4mhz clock can output a pwm about 2hz using the power control pwm module. I know you said simple, but simple isn't always easy.

lerameur
- 26th May 2013, 22:02
I need to control frequency and Duty cycle (I mentioned earlier 50% Dutycycle cause I can easily get any Dutycycle the problem is frequency, but variable dutycycle is better) . I also want to output the frequency and dutycycle on a LCD.I had this thin g going out high and low pins.... but obviously LCDout played a destructive role in the timing. ...
I will check out all the possibilities and the power control pwm module with the F2431

Demon
- 27th May 2013, 02:34
Going out on a limb with this.

PIC 1 outputs signal on a pin, PIC 2 reads signal and displays on LCD, interrupt on 4 input pins on PIC 1 adjust duty and frequency. This way the LCDOUT doesn't interfere with the pwm.

Can we even read PWM signals with PICs (never even got close to doing this)?

Robert

lerameur
- 27th May 2013, 23:40
HUmm.. two pics.. well
I thought about going to a waveform chip like the ICL8038.. but I wanted a more 'modern' solution going with a single Pic,
I am going try tonight what Henrik mentioned above.

K

lerameur
- 28th May 2013, 00:20
I tried different value of PR2, (had tried it before..)
Still am getting 60Hz at PR2 255 and at 200 I get 77hz at 100 I get a steady 5v out...
Here is the link of the program I use for mytest: http://www.warburtech.com/products/compilers/picbasic.pro.compiler/sample.code/hardpwm.pbp/ (http://www.warburtech.com/products/compilers/picbasic.pro.compiler/sample.code/hardpwm.pbp/)

lerameur
- 28th May 2013, 00:57
I was playing around with internal frequency, just to let you know that it do not work. Decreasing the int freq to 500Khz decreases the min freq to 30Hz but also the max freq at 130Hz !!

K

rmteo
- 28th May 2013, 02:42
I tried different value of PR2, (had tried it before..)
Still am getting 60Hz at PR2 255 and at 200 I get 77hz at 100 I get a steady 5v out...
Here is the link of the program I use for mytest: http://www.warburtech.com/products/compilers/picbasic.pro.compiler/sample.code/hardpwm.pbp/ (http://www.warburtech.com/products/compilers/picbasic.pro.compiler/sample.code/hardpwm.pbp/)
That is not your only issue. Because you are dealing with reciprocal values, granularity (resolution) is going to be very poor throughout. At high PR2 values, you will see very little change in frequency - eg. reducing PR2 from 255 to 254 you may not be able to detect any change in frequency. However, at the other end of scale, incrementing PR2 will result in a huge change in frequency.

Antorbd04
- 20th September 2013, 12:25
How make 2 PWM output at 50Hz fixed frequency in PIC16F72 with feedback in picbasic pro?

pksinha
- 29th September 2013, 16:45
Better to use software pwm with time sliced method using timer0.

Archangel
- 29th September 2013, 21:53
Hi Ken,
We can use a computer when a sledgehammer will do? Way back before dirt was invented people used 555 & 556 timer chips $0.15 to $0.25 US to do this. alternatively you could use the PIC to swing the duty cycle from an adjustable analog oscillator.