1 phase inverter frequentie adjust?

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
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

1 phase inverter frequentie adjust?

Post by Jordy101091 »

Hi all,

I'm currently working on an application for driving a 1 phase FAN and if all goes well I'm going a step further and try to drive a 1 phase induction motor.
I have searched online how other people have done the same thing and did some research myself and with some help of a online calculator I have made a full sine wave look-up-table.
The lookup table contains 50 measurement point with an amplitude of 1023. This data is been stored in a data array within a calculation block.

(I dont know how to use a lookup-table in combination with the PWM module.)

This data is been givin to the PWM module via a simple while loop.
With the data of my lookup table and the following PWM module settings:

Period Register = 255
Clock Source = Clk / 1
uC clock = 19.6608 MHz

The output PWM signal looks like this.

Image


On the output of CCP1 (PWM1) I have build an RC-filter to filter the AC signal out so i'm able to see it.
After the RC filter the signal looks like this.

Image

As you can see my sinewave has a frequentie of 25.1Hz and a period time of 39.8 milli seconds. ( F = 1 / T or T = 1 / F)
My goal is to alter the frequentie from 25 Hz to about 150Hz. But I dont know how to do this. Maybe you can help me with this.

Also in my flowcode I needed to put an delay of 780 micro seconds to get a 25Hz signal.

I hope that you can help me change the frequentie between 25 and 150Hz with the use of a pot. meter.

Regards Jordy
Attachments
SIN LUT.xls
(100.5 KiB) Downloaded 303 times
Test drive PWM Puls Train.fcf
(10 KiB) Downloaded 365 times
the will to learn, should not be stopped by any price

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: 1 phase inverter frequentie adjust?

Post by Benj »

Hello,

I've done a bit of maths and this seems to be about correct.

If your delay for the 25.1hz output is 780us then your delay for outputting 150hz should be around 130us.

For a potentiometer reading you could do something like this to give you a range between 150hz and 17.5hz.

ByteVar = ADC ReadAsByte
IntVar = (ByteVar * 3) + 130

Then for your delay you will have to do something like this.

DelayVar = IntVar
While DelayVar > 255
{
delayus(255)
DelayVar = DelayVar - 255
}
delayus(DelayVar)

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 1 phase inverter frequentie adjust?

Post by Jordy101091 »

He,

Thanks for youre reply but I dont exactly know what you mean.
Maybe you can modify my flowcode so I can see what you mean.

Thanks,

Regards Jordy

PS. How did you calculate this.
the will to learn, should not be stopped by any price

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: 1 phase inverter frequentie adjust?

Post by Benj »

Hello,

Ok here is my version of your program with the delay control.

Here is the calculations I was using to work out what the delay periods need to be.

1 / 25.1 = 0.0398
0.0398 / 780E-6 = 51.07

1 / 150 = 6.66E-3
6.66E-3 / 51.07 = 130.53E-6
Attachments
Test drive PWM Puls Train.fcf
(10.5 KiB) Downloaded 352 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 1 phase inverter frequentie adjust?

Post by medelec35 »

Hi. This is how I worked out delay between PWM intervals. I don’t know if correct or not since not done this type of thing before, but here goes:

Time delay = 1/(Frequency X intervals).
Since 50 intervals then time delay for 25Hz = 1/(25x50)= 800us
For 150Hz = 1/(150*50) = 133uS
So the delay should be variable between 133us and 800us
So the formula I used is IntVar = (ByteVar *65)/25+133

I did notice that this formula would not have worked in the flowchart since IntVar was left as a byte not integer.

If flowchart does work then please give credit to Ben as I only changed formula slightly( which may not be correct :p) and a byte to an integer.

Martin
Attachments
Test drive PWM Puls Train2.fcf
(10.5 KiB) Downloaded 367 times
Martin

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 1 phase inverter frequentie adjust?

Post by Jordy101091 »

I noticed something when I was testing the modified flowcode programs.

The frequentie adjustment by delays is not reliable. My results are jumping all over the place.
from 25 Hz to 296 Hz back to 68,9 Hz. Its really crazy. So I was thinking How can i do this so precise as possible.


I need something where I can control the period time of one PWM signal.

By a clock speed of 19.6608 MHz and a period register of 255 and clock divided by 1 I get a
pwm frequentie of 19.2 KHz and a PWM period of 52 uS.

The frequentie of my output signal depends on the the 52 uS if decrease this value my frequentie goes up if increase this my frequentie goes down.

My question can I control this.
Ore do I need to generate PWM in software.
If so please explaine to my how I can do this.

Regards Jordy
the will to learn, should not be stopped by any price

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 1 phase inverter frequentie adjust?

Post by medelec35 »

Is voltage on pin 2 (AN0) stable?
Martin

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: 1 phase inverter frequentie adjust?

Post by Jordy101091 »

Yes voltage is stable up to 0.001 volt.
in combination with an RC filter 1k ,0.1uf
the will to learn, should not be stopped by any price

billduck
Posts: 159
Joined: Thu Jul 01, 2010 1:57 am
Has thanked: 23 times
Been thanked: 16 times
Contact:

Re: 1 phase inverter frequentie adjust?

Post by billduck »

This is a real interesting project. I just have a couple of questions. I understand the LUT. But why was the data biased to make it all positive. Also, I do not understand how to change the frequency. Lastly, were you going to drive some power transistors to provide some serious power to the motor.
Thanks in advance.

Post Reply