delays for nano seconds?
Moderator: Benj
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
Re: delays for nano seconds?
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
-
- Posts: 258
- Joined: Wed Nov 29, 2006 6:32 pm
- Location: Finland
- Has thanked: 7 times
- Been thanked: 36 times
- Contact:
Re: delays for nano seconds?
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)...
- greentech
- Flowcode V4 User
- Posts: 158
- Joined: Mon Jan 31, 2011 2:11 pm
- Has thanked: 10 times
- Been thanked: 2 times
- Contact:
Re: delays for nano seconds?
i am trying to drive a chopper transformer for switching supply. what do u advice?
- 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: delays for nano seconds?
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?
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?
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
- greentech
- Flowcode V4 User
- Posts: 158
- Joined: Mon Jan 31, 2011 2:11 pm
- Has thanked: 10 times
- Been thanked: 2 times
- Contact:
Re: delays for nano seconds?
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.
i am confused about the frequency on which chopper works.
-
- Posts: 258
- Joined: Wed Nov 29, 2006 6:32 pm
- Location: Finland
- Has thanked: 7 times
- Been thanked: 36 times
- Contact:
Re: delays for nano seconds?
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
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
- greentech
- Flowcode V4 User
- Posts: 158
- Joined: Mon Jan 31, 2011 2:11 pm
- Has thanked: 10 times
- Been thanked: 2 times
- Contact:
Re: delays for nano seconds?
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.
when i put a delay for micro seconds, on scope it shows time for milliseconds....whats going wrong there?
regards.
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
Re: delays for nano seconds?
did you set up the clock frequency in (build,project options) the same as your osccon register c block (if applicable)
- 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: delays for nano seconds?
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.
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.
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
- greentech
- Flowcode V4 User
- Posts: 158
- Joined: Mon Jan 31, 2011 2:11 pm
- Has thanked: 10 times
- Been thanked: 2 times
- Contact:
Re: delays for nano seconds?
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?
-
- Posts: 258
- Joined: Wed Nov 29, 2006 6:32 pm
- Location: Finland
- Has thanked: 7 times
- Been thanked: 36 times
- Contact:
Re: delays for nano seconds?
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...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?
Mika
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: delays for nano seconds?
Hi greentech,greentech wrote:I am trying to get 2 pwms 180 degrees out of phase. how can i invert the pwm?
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
Martin