Autor Thema: Ramp function - FT_RMP  (Gelesen 14249 mal)

0 Mitglieder und 1 Gast betrachten dieses Thema.

Offline drChiavo

  • Newbie
  • *
  • Beiträge: 6
    • Profil anzeigen
    • E-Mail
Ramp function - FT_RMP
« am: 05. Februar 2016, 14:29:18 »
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

Offline shrimps

  • Jr. Member
  • **
  • Beiträge: 75
    • Profil anzeigen
    • E-Mail
Re: Ramp function - FT_RMP
« Antwort #1 am: 05. Februar 2016, 19:57:30 »
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

Offline drChiavo

  • Newbie
  • *
  • Beiträge: 6
    • Profil anzeigen
    • E-Mail
Re: Ramp function - FT_RMP
« Antwort #2 am: 07. Februar 2016, 23:18:50 »
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

Offline shrimps

  • Jr. Member
  • **
  • Beiträge: 75
    • Profil anzeigen
    • E-Mail
Re: Ramp function - FT_RMP
« Antwort #3 am: 08. Februar 2016, 01:29:12 »
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 ?

Offline drChiavo

  • Newbie
  • *
  • Beiträge: 6
    • Profil anzeigen
    • E-Mail
Re: Ramp function - FT_RMP
« Antwort #4 am: 08. Februar 2016, 11:33:49 »
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

Offline shrimps

  • Jr. Member
  • **
  • Beiträge: 75
    • Profil anzeigen
    • E-Mail
Re: Ramp function - FT_RMP
« Antwort #5 am: 08. Februar 2016, 19:38:38 »
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

Offline drChiavo

  • Newbie
  • *
  • Beiträge: 6
    • Profil anzeigen
    • E-Mail
Re: Ramp function - FT_RMP
« Antwort #6 am: 08. Februar 2016, 21:12:08 »
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

Offline shrimps

  • Jr. Member
  • **
  • Beiträge: 75
    • Profil anzeigen
    • E-Mail
Re: Ramp function - FT_RMP
« Antwort #7 am: 08. Februar 2016, 21:46:20 »
Sounds very good...

So waiting for the next  :)