Page 1 of 1
delays for nano seconds?
Posted: Sat Feb 11, 2012 11:38 pm
by greentech
how can i generate delay for nano seconds in flowcode?
Re: delays for nano seconds?
Posted: Sun Feb 12, 2012 12:50 am
by brandonb
other members please correct me if im wrong, i dont think you can because of the clock speed limitations, at 32 Mhz clock it takes 1 microsecond to turn a output on and off, at 4Mhz it takes 8 microseconds thats straight time without any delays
Re: delays for nano seconds?
Posted: Sun Feb 12, 2012 6:22 am
by Mikat
brandonb wrote:other members please correct me if im wrong, i dont think you can because of the clock speed limitations, at 32 Mhz clock it takes 1 microsecond to turn a output on and off, at 4Mhz it takes 8 microseconds thats straight time without any delays
Yep, Brandon are right, but you can have 1 instruction cycle delay with asm nop command (thats 100ns@40MHz chip clock)...
Re: delays for nano seconds?
Posted: Sun Feb 12, 2012 4:42 pm
by greentech
i am trying to drive a chopper transformer for switching supply. what do u advice?
Re: delays for nano seconds?
Posted: Mon Feb 13, 2012 2:27 pm
by Benj
Hello,
the dsPIC 33 family can run up to 40MIPs so one 16-bit instruction every 25 nano seconds.
What kind of resolution are you looking for?
Re: delays for nano seconds?
Posted: Mon Feb 13, 2012 9:19 pm
by greentech
benj all i want is to drive a soft ferrite transformer, or u can say 12vto48v dc-dc converter for charging batteries from solar energy.
i am confused about the frequency on which chopper works.
Re: delays for nano seconds?
Posted: Tue Feb 14, 2012 9:52 am
by Mikat
Hi.
Isn't that easier done at hardware pwm?
At dsPic30f you can get 300KHz pwm at 1% resolution ( I am not an expert, but is there any reason to use very high switching frequency, it just rises the switching loss)...
Mika
Re: delays for nano seconds?
Posted: Tue Feb 14, 2012 11:37 pm
by greentech
i guess i need only 2 - 20 khz switching. how can i do that by pic16 devices?
when i put a delay for micro seconds, on scope it shows time for milliseconds....whats going wrong there?
regards.
Re: delays for nano seconds?
Posted: Wed Feb 15, 2012 5:50 am
by brandonb
did you set up the clock frequency in (build,project options) the same as your osccon register c block (if applicable)
Re: delays for nano seconds?
Posted: Wed Feb 15, 2012 3:36 pm
by Benj
Hello Greentech,
Use the 1 second flasher test to confirm you have everything setup correctly.
eg
while(1)
{
output 1 to LED pin
delay 1s
output 0 to LED pin
delay 1s
}
When the delays on the hardware match 1 second you have the Flowcode clock speed and configuration settings setup correctly for your hardware.
Re: delays for nano seconds?
Posted: Wed Feb 15, 2012 10:47 pm
by greentech
Checked it benj, all woking fine except for the pulse delay is in milliseconds when i hook it to scope. I am trying to get 2 pwms 180 degrees out of phase. how can i invert the pwm?
Re: delays for nano seconds?
Posted: Thu Feb 16, 2012 6:43 am
by Mikat
greentech wrote:Checked it benj, all woking fine except for the pulse delay is in milliseconds when i hook it to scope. I am trying to get 2 pwms 180 degrees out of phase. how can i invert the pwm?
In hardware pwm you need eccp module and set the register via c-code, if you want full or half bridge configuration, some 16f chips have the eccp module, then you can set two pwm:s at the 180 degrees phase shift (or actually one pwm, which drives two pins), and the dead band delay is adjustable too, but at least at version 4 flowcode doesn't support that.. But it's the "sure" way, that way there is hw logic to prevent switches opening at the same time...
Mika
Re: delays for nano seconds?
Posted: Thu Feb 16, 2012 8:03 am
by medelec35
greentech wrote:I am trying to get 2 pwms 180 degrees out of phase. how can i invert the pwm?
Hi greentech,
Same question was asked on a different thread so I posted a solution here:
http://www.matrixmultimedia.com/mmforum ... 701#p26295
The only issue will be a slight delay at the higher speed end.
Mika coved Other options which I totally agree with.
Although Flowcode does not support half bridge using ECCP, I would guess this could be achievable using C code and would be the best method if not using external components.
Another method to consider, is connect the PWM output to a spare interrupt on change input pin, then within IOC macro an output pin can be = NOT IOC input.
Martin