PDA

View Full Version : pulsout question



lerameur
- 24th May 2008, 03:32
HI,

I am using a 20mzh crystal. from the pbp manual, it is a 2us period, is it possible to configure the chip so I get 100 000 hz or even 200 000hz pulses ?
1/2us = 500000hz I guess, I am using pulsout portb.4, 40 and I am getting only 7.5 khz

loop:
pulsout portb.4 ,10
goto loop
end



ken

skimask
- 24th May 2008, 04:35
I am using a 20mzh crystal. from the pbp manual, it is a 2us period, is it possible to configure the chip so I get 100 000 hz or even 200 000hz pulses ?
1/2us = 500000hz I guess, I am using pulsout portb.4, 40 and I am getting only 7.5 khz
ken

40 cycles @ 2us per cycle = 80us. 1/80us = 12.5Khz
But then you have to add the extra few cycles that pulsout uses to set the TRIS register for the pin and set and reset the logic level for that pin. AND you have to add in the 2 cycles it takes to GOTO the beginning of the loop. Not to mention any WDT clearing instructions and/or any PBP 'ON INTERRUPT' handling instructions stuffed in there. Those extra instructions are probably slowing the loop down to 7.5Khz.

Add:
DEFINE NO_CLEARWDT 1
to the top of your program whether you are using the WDT or not (but turn it off in the CONFIGs just in case)
Also, add a
DISABLE
to take care of any PBP 'ON INTERRUPT' handling around that tight loop.

That should speed up the loop a bit.

But, IMO, using pulsout is just a bad way to get a train of pulses @ 100Khz because, for one thing, the duty cycle won't be constant, especially if you're doing anything else in the program.

You might want to try to use some of the 'Instant Interrupts' and TMR0 with a high reload value (don't know what that value would be off the top of my head, maybe 232 with 1:1 prescale), then each time the interrupt fires, toggle the state of the pin.

http://www.mister-e.org/pages/utilitiespag.html

lerameur
- 24th May 2008, 14:53
Hi,

I am still working on my lowpass filter, I obtained the max7480 chip low pass filter. So for a cut off frequency of 2khz, I need the chip to clock at 200khz. I thought that maybe I could make a pic chip clock that speed. I also got into problems of making the chip clock to 64khz, but when I add to the clock input of the chip, the clocking would decrease by 100 fold...
In the chip specification, it says we can add capacitors to the clock input, but that did not work for me. I made the schematic exactly as they say on their datasheet, but I am not getting the result.

k

Melanie
- 24th May 2008, 18:40
Since when does a 20MHz clock make a 2uS period?

If you're running at 20MHz... then why not try...

TRISB.4=0
Loop:
Toggle PortB.4
PauseUS 4
Goto Loop

PauseUS doesn't go down to 4uS at 4MHz but it just might work at 20MHz... at 4MHz you could try...

TRISB.4=0
Loop:
Toggle PortB.4
@ NOP
@ NOP
@ NOP
@ NOP
Goto Loop

Since each @ NOP will eat 1uS.

skimask
- 25th May 2008, 00:10
So for a cut off frequency of 2khz, I need the chip to clock at 200khz.
So all you really need is just a solid 200Khz square wave signal?




Since when does a 20MHz clock make a 2uS period?
Well I know that! But the PBP manual says the PULSOUT period is 2us when clocked at 20Mhz.

lerameur
- 25th May 2008, 01:39
hey , just following the manual,

I got myself the 4047 chip this afternoon, we'll see how that works...

skimask
- 25th May 2008, 05:38
I got myself the 4047 chip this afternoon, we'll see how that works...
Well, heck, a 555 could've done that for ya!

shirleyz
- 1st June 2008, 07:47
so can i know how to send the pulse continously?...when i try using for loop, the motor just move a seconds....

skimask
- 1st June 2008, 08:47
so can i know how to send the pulse continously?...when i try using for loop, the motor just move a seconds....

What pulse?
What loop?
What motor?
What code?