Problems with FILTER

Begonnen von Mink, 07. Januar 2012, 19:37:33

Vorheriges Thema - Nächstes Thema

0 Mitglieder und 1 Gast betrachten dieses Thema.

Mink

Hi everybody

I am studying to be a marine engineer in Denmark. One of our classes is automation, where we use WAGO 750-841 PLCs.

In one of our projects we use a PID controller, to maintain a given temperature. To measure the temperature we use a 750-461 module, with a PT100 sensor. But when we used D i the controller, we got a lot of spikes i the output signal due to noise on the signal from the PT100 sensor.

In search of a filter we found the OSCAT_Basic_332 lib. At first we tried the FILTER_I on the raw INT signal from the PT100. We tried different time constants, but it didn't remove any noise. We also tried to filter the converted celsius signal, but that didn't help either.

We then got some help from some other students, who had made the project earlier. Then we used FILTER_DW in the way shown in the attachment (don't mind the danish). Here we multiply the celsius reading with 1000, filter it with FILTER_DW, and then divide it with 1000. This method remove practically all the noise.

In the first method with FILTER_I the numbers in the INT is from about 0-1000.

In the method with FILTER_DW the numbers in the DW is from about 0-100.000.

I find it strange that a 100 times greater number should make any difference in how a lowpass filter works.

Can anybody come with a good explanation to why the FILTER_I didn't work?
Or what could be done different, because I don't like the solution we ended up using with the FILTER_DW?

Hope to hear from you.
Regards
Christian Mink

[gelöscht durch Administrator]

hugo

whats strange on your project is the fact that you are using a real and then a dword filter.

a filter for real values would be  ft_pt1 !!!!
on the other hand i think i found your problems
in codesys you can see a strange number on the top right corner of any symbol used.
this number defines the execution sequence of the code in your case you multiply first and then you subtract which is obviously not meant to be and will lead to strange results.
you can change the execution sequency by right clicking on any signal and then change the sequence number (not 100% sure whats it called in the english version).

this the sequence problem is your problem with filter_I also

Mink

Hi Hugo

I know that the method we first used wasn't very good. But it did work as it was. And you are right, the sequence is wrong with the DIV and SUB of the PT100 signal.

We did try the FT_PT1 at first, but we couldn't make it work, I can't really remember what the problem was back then. We are not world champions in CoDeSys (yet) :-)

But I have made some modifications to the program now, and used the FT_PT1 filter on the REAL celsius reading. A time setting of 2 seconds, and multiplier of 1 seems to work quite well. I only have very small spikes on the output signal now.

I have attached the new program with the FT_PT1, and the correct sequence order.

Thank you very much for helping!
It turned out that the solution was right under my nose :-)

By the way, the OSCAT basic lib is a very great package. It has so many functions, and all Open Source :-)

[gelöscht durch Administrator]

hugo

#3
your simple program can be even made more efficient by using the multiplier K of FT_PT1 instead of your additional div in front of the ft_pt1 the factor K of ft_pt1 simply multiplies the input in your case this could be 0,101... of course the offset is still needed.

this saves one operation and very important it replaces a division by a multiplication (a division takes approx 3 times more clock cycles as a multiplication does)

Mink

You are absolutely right!

Have changed the program again, according to your advice :-) And now it is as simple as it gets (I think).

Didn't know about the difference in speed of DIV and MUL. But absolutely to be considered.

This is just a subprogram of the project. We have made a project that works like a heavy fuel oil seperator on a ship, but not using the real machine, just a little box as simulation, and regulating a electrical "heat gun" with the PID.
We also have KEP Server running as OPC, an Infilink as HMI.

But as you just showed me, there is a lot to be learned about code optimizing. I would think that you could find lots of little things which could have been done better, or smarter in our program.

I have attached the "final" program.

Thanks again for the help, will definetely come back to this forum in the future, you have helped me a lot :-)

[gelöscht durch Administrator]

hugo

if you are really interested in optimization:
consider the following:

1. why dont you subtrakt your offset before you convert to a real a floating point operation takes more ressources then a integer opertation the result is going to be the same

2. if you rename your ft_pt1 to Oil_temp you can reference your oil temperature by OIL_TEMP.Out in your project saving the continuous transfer of out to the final output

optimization is never done it can always be improved

Mink

Again you are right :-)

I can see I still have a lot to learn :-) And I think automation is exciting, so i hope that I will learn more in the future.

I am very glad you took the time helping me, I will return here if I have any questions in the future.

Regards Christian

hugo

is our english manual sufficient for you?

Mink

I think your english manual looks very good. I haven't read all of it, mostly just searching for the lowpass filter.
But I appreciate the work you have put in it! It must have taken a very long time.

But I can understand and speak german, my english is just a bit better :-)

But I will be using the OSCAT lib and manual in the future, there is so much more in there in it, than the standard CoDeSys libraries. Maybe I can use some of it, although I don't know how to use most of it yet :-)
I am still learning CoDeSys and automation.