Ramp function - FT_RMP

Begonnen von drChiavo, 05. Februar 2016, 14:29:18

Vorheriges Thema - Nächstes Thema

0 Mitglieder und 2 Gäste betrachten dieses Thema.

drChiavo

Hello,

What I want to do is increment a value by 1 each second and I was trying to use the linear ramp "FT_RMP" but unfourtunately is not working.
This is what I wrote

rampFunction(rmp := TRUE, in := 1, KR := 1, KF := 1, out => , busy =>, UD => );

IF   rampFunction.UD THEN
   
   increasePressureValue := increasePressureValue+1;

END_IF


Does anyone could tell me if the code is wrong or why is not working ?

Thanks

shrimps

Hi,
i think ramp has nothing todo:
source(in) = 1, dest = 1, so what is todo ?

But i am not sure...

I would yose a simple ton for this:
fbTon(in:= not fbTon.q, PT := t#1s);

if fbTon.q then
# 1 second is over
end_if


hth
Shrimps

drChiavo

Hello Shrimps,

Thanks for your answer. I tried what you told me but after the second 3 starts to sum up random numbers. Here is the code.


WHILE increasePressureValue <= 600000 DO

myTimer(IN := NOT myTimer.Q, PT := T#1S);

IF myTimer.Q THEN

increasePressureValue := increasePressureValue + 10000;

END_IF

END_WHILE


Any idea about the error?
Thanks

shrimps

Hi,
first you made the worst case of wrong use of Systemtimers like ton, tof tp:
They have to be called cyclic and not on demand !

Please catch the mytime at first statement so it will be called every cycle !

Then your WHILE would do (i hope) better things...

Another idea:

myTimer(IN := NOT myTimer.Q, PT := T#1S);

if increasePressureValue <= 600000 and myTimer.Q then
   increasePressureValue := increasePressureValue + 10000;
end_if


One of many Solutions for your way  8)

Hope that helps
Regards
Shrimps

PS: It looks you are comming from PC-Programming ?

drChiavo

Hello Shrimps,

I have tried what you told me but still the same problem. After the second 3 , "increasePressureValue" gets randoms numbers... I don't know what the problem is :/ 

Yes, I´m a beginner with CoDeSys.  :P  I have started to program two weeks ago...

Regards,
drChiavo

shrimps

Hmm,
drives me crazy:
Which IDE do you use (please full qualified)
Show me the full source !

Heres my example which works fine:

PROGRAM MAIN
VAR
myTimer: TON;
increasePressureValue: DINT;
END_VAR

myTimer(IN := NOT myTimer.Q, PT := T#1s);

IF increasePressureValue <= 600000 AND myTimer.Q THEN
   increasePressureValue := increasePressureValue + 10000;
END_IF

END_PROGRAM


Regards
Shrimps

drChiavo

Hello Shrimps,

I don't know what I was doing wrong but now it is working!
Thanks a lot for your help  :D

Regards,
drChiavo

shrimps

Sounds very good...

So waiting for the next  :)