Scripts in WinCC flexible??!!

Tarek_Ashraf

Member
Join Date
Mar 2009
Location
cairo
Posts
16
hi,
i want to ask a question in WinCC flexible....now im reading values from a sinusoidal voltage supply through a plc....and i want to ask how to generate a script to let me know if im reading the values in the falling edge or the rising edge of the voltage sine wave....so that if V instantaneous new > V instantaneous old so im in the rising edge....but i cant write this script...could anyone please help me with this problem?? thanks in advance
 
My first thought is to agree with Jesper and say do it in the PLC.

My second thought is, what frequency is your sine wave going to be? If you try and do this in WinCC Flex, you'll be lucky to get two readings a second. So if your sine wave is, for example, 50 Hz mains frequency you'll be getting a reading not on the rising or falling slope of the same cycle but of a cycle 20 or 30 cycles later - and that's disregarding any filter effects in the input hardware!

If you want to get a more useful answer, you'll need to give us a lot more information, including what exactly you want to do and why.
 
well, now we have V=Vmax. sin(wt) and for current I=Imax. sin(wt-phi) so i want to get (wt) and (wt-phi) using arcsin function then subtract the two angles to get the phase shift....the problem here that arcsin function always gives me the angles in the first quadrant even if the reading is in the falling slope for example if the reading is taken at angle of 135....the output will be 45 as sin(45)=sin(135)...and that will make a difference in calculating the phase shift and makes it sometimes negative and thats impossible for the current to lead voltage in an induction motor....so i want to make an if condition to put the phase shift =(180-phase shift) if im on the falling edge..... hope its clear now to you and thanks....
 
ohh sorry...the frequency of the wave is 50 Hz...Im using a S7200 plc 222 cpu....with analogue to digital module EM231
Order Number: 6ES7 231--0HC22--0XA0
 
Hmmm... I am not an expert in measuring AC. It is many years when that was on my curriculum. So I am guessing.

I don't understand this part:
"well, now we have V=Vmax. sin(wt) and for current I=Imax. sin(wt-phi) so i want to get (wt) and (wt-phi) using arcsin function then subtract the two angles to get the phase shift"

I would guess that in order to extract RMS and phase angle of a sinusoidial value, you need to log 3-4 values for each half-period, and then apply curvefitting algorithm (fast fourier transformation ?) on the logged values. It will NOT be enough to just log the values and pick the max value to get Imax or Vmax.

And in order to get an accurate reading, the number of half-periods measured should be 10-20 or so.
So, you need to log values every 2.5ms. And it will require 50-100 REAL memory values per channel.

That analog input has 250us conversion time per channel. That is pretty fast. So if you use one channel for voltage and another for current, then you could theoretically read values every 500us. But does the S7-200 update its i/o at that rate ? Can the S7-200 calculate anything and still be fast enough ? Does S7-200 even have cyclical interrupts that can work down below 10 msec ? (I don't know S7-200 enough to answer these questions).
 
your point of view is really considered Jesper....but simply i have this equation Vinst.=Vmax.*sin(wt) and i have connections for Vinst. and Vmax. from the PLC....then sin(wt)=(Vinst./Vmax.)...
to get wt.... wt=sin^-1(Vinst./Vmax.)...and sin^-1...is got from atn function in the script which is arctan which is in other words tan^-1....anyway i know its a little complicated...but you know life goes on this way :D
 
Do you mean that there is a separate device that supplies sample values of Vmax and Vinst to the S7-200 ? Or does the S7-200 measure the raw analog values ?
 
yeah the s7200 reads the voltage of an induction motor which is a sine wave (AC)...and computes the maximum voltage of this sine wave and send both instantaneous voltage read and computed maximum voltage to the wincc...
 
I see several problems with that approach.

A typical analog input card doesnt sample all channels instantanously. They sample the analog value for one channel and convert to discrete, then go on to the next channel. That is why they state 250us per channel. And that is probably just a best guess. There will be minute differences for each sampling. So you would have to take the 250us difference between channels into account, and still there would be some errors with the timing.

Also, voltage and current measurement will be highly sensitive to a non-perfect sinusoidal vawe-form. That is why I think a FFT as necessary to deduce the phase.

I think what you need is something like this:
http://www.datasheet-gavazzi.com/pdf/UK/WM296.pdf
You can have a large number of values out: kW, kVAr, PF, kWh, kVArh, A, VL-L avg,VL1-N, VL2-N, VL3-N.
And I think you can connect WinCC Flex directly to it via Modbus RTU.
edit: Probably costs less than an S7-200 plus analog module.

nabeel, it is very annoying that you jump in and hijack a thread. Delete your post and start a new thread !
 
Last edited:
i think that power analyzer is what i need and for the modbus RTU.....is it simple in connections? as it would be my first time to work on remote connections...
 
This one I suggested is just an example. There are many other similar suppliers. I am not sure that it is easy, because the WM296 uses a method of "requesting data" and the WM296 then responds. In other words, you cannot just define tags in WinCC Flexible.

You haven't actually described what you really have to measure, and why, so maybe there is another way.
If you merely have to measure phase angle, then there is also dedicated meters for that, like this one: http://www.laurels.com/phase.htm
 

Similar Topics

Hey guys, I am trying to write a vb script in wincc 2007 flexible. Basically I need to have a button which is on my overview on every screen...
Replies
1
Views
1,607
Hello, I am using WinCC Flexible and want to test a script with the runtime simulator. Does anyone know if the scripts will run in the...
Replies
10
Views
8,730
Hi, I hope someone can help me with this. I have managed, using scripts, to export data in a .csv file. The problem I have is that when I open...
Replies
4
Views
2,459
hello, i need these files down here, DBExt-DLL (realizes database connections of WinCC-Skripting) MessageStatistic-DLL (status message...
Replies
0
Views
1,016
Hi Everyone, One of the projects we have has a very large number of scripts that require translating. It would be great if we could export the...
Replies
3
Views
1,852
Back
Top Bottom