delays for nano seconds?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

delays for nano seconds?

Post by greentech »

how can i generate delay for nano seconds in flowcode?

brandonb
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?

Post 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

Mikat
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?

Post 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)...

User avatar
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?

Post by greentech »

i am trying to drive a chopper transformer for switching supply. what do u advice?

User avatar
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?

Post 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?

User avatar
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?

Post 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.

Mikat
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?

Post 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

User avatar
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?

Post 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.

brandonb
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?

Post by brandonb »

did you set up the clock frequency in (build,project options) the same as your osccon register c block (if applicable)

User avatar
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?

Post 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.

User avatar
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?

Post 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?

Mikat
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?

Post 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

medelec35
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?

Post 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
Martin

Post Reply