-Menü

Beiträge anzeigen

Dieser Abschnitt erlaubt es Ihnen, alle Beiträge anzusehen, die von diesem Mitglied geschrieben wurden. Beachten Sie, dass Sie nur Beiträge sehen können, die in Teilen des Forums geschrieben wurden, auf die Sie aktuell Zugriff haben.

Beiträge anzeigen-Menü

Beiträge - dawrut

#1
Zitat von: mattsches in 22. April 2021, 17:33:55
I found some issues with BLIND_NIGHT when I started using it...

I come to the same conclusion. I thought that I initially fix the problems but I would need to rewrite the code. So I took your version and I'm testing it right now  :)
The problem I was facing with my version was that:

  • the blinds didn't move up in the morning
  • in the morning I'm using BLIND_INPUT, I'm providing my value to the PI input and I'm assigning rising edge pulse to IN - this is moving blinds to a certain position. But the blinds which were previously closed by BLIND_NIGHT doesn't move to my position. Others work fine.
#2
Zitat von: NightWatcher in 02. März 2015, 10:14:24
So, für alle die Interesse an einem erweiterten Baustein hat, der einen Trigger am Ausgang hat, sobald die Rollläden hochgehen, habe ich diesen in den Anhang gepackt.

Beschaltet habe ich den Trigger mit dem IN vom Blind_Input. PI habe ich auf 255 gesetzt.

So wird der Rollladen morgens auch hochgefahren, wenn ich in der Nacht Manuell eingegriffen habe.

@NightWatcher Do you still have the updated BLIND_NIGHT block? Can you share it again?
#3
I started to do small POC, I almost finish coding and what I have is:

  • I'm storing the output POS of the BLIND_CONTROL in the PERSISTENT memory area of the PLC
  • In the first PLC cycle after power failure I'm putting that value to the PI input variable of the BLIND_CONTROL - this will cause that during the calibration the blinds will go up and then come back to the previous position. Almost done but still, blinds will unnecessary goes up as I know the position!
  • In order to stop the physicals move of the blinds I'm using TON which will allow to set up PLC outputs (which triggers relays) after 90s so when the calibration is done by BLIND_CONTROL - so I've no blinds movement.

The code looks like this (without sunset and sunrise calculation code):


FUNCTION_BLOCK Blind
VAR_INPUT
    xBlindDown: BOOL;
    xBlindUp: BOOL;
    xAutoSunset: BOOL := FALSE;
    xAutoSunrise: BOOL := FALSE;
    tMaxRuntime: TIME := T#32S;
    tTimeUp: TIME := T#30S;
    tTimeDown: TIME := T#30S;


END_VAR
VAR_OUTPUT
    xBlindControlUp: BOOL;
    xBlindControlDown: BOOL;
END_VAR
VAR_IN_OUT
    PersistentData: BlindData; //this data is stored in VAR RETAIN PERSISTENT in the PLC_PRG
END_VAR
VAR
    _oBlindInput: OSCAT_BUILDING.BLIND_INPUT := (MAX_RUNTIME := tMaxRuntime, MANUAL_TIMEOUT := T#2M);
    _oBlindNight: OSCAT_BUILDING.BLIND_NIGHT;
    _oBlindSecurity: OSCAT_BUILDING.BLIND_SECURITY;
    _oBlindControl: OSCAT_BUILDING.BLIND_CONTROL_S;   
    _xInitPosition: BOOL := FALSE;
    _byBlindControlPosition: BYTE;
    _calibrationBlocker: TON;
    _xMasterMode: BOOL := FALSE;       
END_VAR



_calibrationBlocker(IN := TRUE, PT := T#90S);


_oBlindInput(
    POS:= PersistentData.byCurrentPosition,
    S1:= xBlindUp,
    S2:= xBlindDown,
    MASTER_MODE := _xMasterMode
);


_oBlindNight(
    UP := _oBlindInput.QU,
    DN := _oBlindInput.QD,
    S_IN := _oBlindInput.STATUS,
    PI := _oBlindInput.PO,
    DTIN := _dtCurrentDateTimeUTC,
    SUNRISE := _oSunTime.SUN_RISE,
    SUNSET := _oSunTime.SUN_SET,
    E_NIGHT := xAutoSunset,
    E_DAY := xAutoSunrise
);


_oBlindSecurity(
    UP := _oBlindNight.QU,
    DN := _oBlindNight.QD,
    S_IN := _oBlindNight.STATUS,
    PI := _oBlindNight.PO,
);


IF (NOT _xInitPosition) THEN
    // in the first cycle lets read last position saved before the power failure and set it to _oBlindControl PI input
    // this will casue the _oBlindControl to move to last position after calibration
    // we are reading the position only onece - in the first cycle after the power is back
    _byBlindControlPosition := PersistentData.byCurrentPosition;
END_IF


IF (_calibrationBlocker.Q) THEN
    // then, after calibration, just read the position from previous block (standard behaviour)
    _byBlindControlPosition := _oBlindSecurity.PO;
   
    // switch master mode back to true, initially it is false because we need to transfer PersistentData.byCurrentPosition change to all
    // the block (when the _oBlindControl is calibrating)   
    _xMasterMode := TRUE;
END_IF


_xInitPosition := TRUE;


_oBlindControl(
    T_UP := tTimeUp,
    T_DN := tTimeDown,
    UP := _oBlindSecurity.QU,
    DN := _oBlindSecurity.QD,
    S_IN := _oBlindSecurity.STATUS,
    PI := _byBlindControlPosition,
    POS => PersistentData.byCurrentPosition
);


// set outputs after the calibration (when _calibrationBlocker.Q is TRUE after 90 seconds)
// we don't need real calibration as we are saving last know position (before the power failure/full download) in PersistentData.byCurrentPosition
xBlindControlDown := _oBlindControl.MD AND _calibrationBlocker.Q;
xBlindControlUp := _oBlindControl.MU AND _calibrationBlocker.Q;


What I have is:

  • BLIND_CONTROL is doing calibration without physical movement of the blinds movement is not needed because I remember the position
  • BLIND_CONTROL after doing this "virtual" calibration will move gets back to the previously remembered position which I push to the PI input

I Will be doing some real testing today but so far it looks good in the simulation model.

Is the MASTER_MODE := TRUE actually needed in the BLIND_INPUT? What it actually does?


Any other ideas? Other approaches?
#4
How are you saving the position of the blind in case of a power failure?

Function BLIND_CONTROL_S has built-in automatic calibration which is needed to know the position of the blind in case of power failure or PLC restart. In such a case, the blind goes up. Is there a way to store the current position so that after the power failure the blind won't go up?
I was trying to add the whole BLIND_CONTROL_S  function block to the VAR RETAIN PERSISTENT memory area but this didn't help. I was also trying to store the POS output of the BLIND_CONTROL_S (which is the input for the POS of the BLIND_INPUT) but this also doesn't stop blinds to go up in case of power failure.

Any ideas?
#5
Zitat von: mattsches in 22. April 2021, 17:33:55
I found some issues with BLIND_NIGHT when I started using it and more or less rewrote its code. Don't remember if your issue was among my findings (more than seven years ago), but if you want, you can try if my version fixes your problem.

Thanks for sharing the code! I think I was able to fix the initial issue by a different combination of IN parameter of the Blind_Input function block. There are so many parameters that you can get lost...  :D

The problem which right now I'm trying to solve is how to turn off the automatic calibration of the BLIND_CONTROL_S block. I put it into the VAR RETAIN PERSISTENT area but still when I upload a full version of the code to the PLC all the blinds go up. This makes me crazy!
#6
SPS-Programmierung / Re: BLIND_NIGHT and offsets
12. April 2021, 20:52:14
Zitat von: Jensen in 07. Mai 2016, 07:18:26
Ok, auch dieses Problem fand eine Lösung.
MASTER_MODE := TRUE am BLIND_INPUT hat gefehlt.

@Jasen can you please take a look at my problem related to BLIND_NIGHT function block? Maybe you will help me  :)
http://www.oscat.de/community/index.php/topic,5828.0.html
#7
I can share my code with you, later on, I'm not in front of my PC at the moment.


But are you able to get BLIND_NIGHT even to work? For some reason, even if the sunset and sunrise values are set up correctly the BLIND_NIGHT function block simply don't start blinds.
#8
Is there anyone who can share his code with the working BLIND_NIGHT function block?
I'm out of ideas what might be wrong?


Sorry but I don't speak German at all...
#9
SPS-Programmierung / BLIND_NIGHT doesn't work
08. April 2021, 07:37:45
I've problems with BLIND_NIGHT. This function block seems not to be working in my case. I've been connected to the PLC when the sunset comes and nothing happened
My code looks like this:

FUNCTION_BLOCK Blind
VAR_INPUT
   xBlindDown: BOOL;
   xBlindUp: BOOL;
   xAutoSunset: BOOL := FALSE;
   xAutoSunrise: BOOL := FALSE;
   tSunsetOffset: TIME;
   tSunriseOffset: TIME;
END_VAR
VAR_OUTPUT
   xBlindControlUp: BOOL;
   xBlindControlDown: BOOL;
END_VAR
VAR
   BlindInput: OSCAT_BUILDING.BLIND_INPUT := (SINGLE_SWITCH := FALSE, MAX_RUNTIME := T#25S, MANUAL_TIMEOUT := T#60M, MASTER_MODE := TRUE, IN := TRUE);
   BlindControl: OSCAT_BUILDING.BLIND_CONTROL_S := (T_UP:=T#20S, T_DN:=T#18S);
   BlindNight: OSCAT_BUILDING.BLIND_NIGHT;
   BlindSecurity: OSCAT_BUILDING.BLIND_SECURITY;
   
   SunTime: OSCAT_BASIC.SUN_TIME := (LATITUDE := rLatitude, LONGITUDE := rLongitude);
   CurrentDateTimeUTC: DATE_AND_TIME;
   CurrentDateUTC: DATE;   
END_VAR


And here is the code:

CurrentDateTimeUTC := FuGetDateAndTime();
CurrentDateUTC := TO_DATE(CurrentDateTimeUTC);

SunTime(UTC := CurrentDateUTC);

BlindInput(
   POS:= BlindControl.POS,
   S1:= xBlindUp,
   S2:= xBlindDown,
);

//GVL.xInit is a global variable which is set to true after first PLC cycle
//this switch of IN state is required to stop moving of blinds after a power failure of PLC update
IF (GVL.xInit = TRUE) THEN
   BlindInput.IN := FALSE;
END_IF

BlindNight(
   UP := BlindInput.QU,
   DN := BlindInput.QD,
   S_IN := BlindInput.STATUS,
   PI := BlindInput.PO,
   DTIN := CurrentDateTimeUTC,
   SUNRISE := SunTime.SUN_RISE,
   SUNRISE_OFFSET := tSunriseOffset,
   SUNSET := SunTime.SUN_SET,
   SUNSET_OFFSET := tSunsetOffset,
   E_NIGHT := xAutoSunset,
   E_DAY := xAutoSunrise
);

BlindSecurity(
   UP := BlindNight.QU,
   DN := BlindNight.QD,
   S_IN := BlindNight.STATUS,
   PI := BlindNight.PO
);

// in order to stop moving blinds after a power failure or PLC update we need to check if PLC has been initialized
BlindControl(
   UP := BlindSecurity.QU AND GVL.xInit,
   DN := BlindSecurity.QD AND GVL.xInit,
   S_IN := BlindSecurity.STATUS,
   PI := BlindSecurity.PO
);

xBlindControlDown := BlindControl.MD;
xBlindControlUp := BlindControl.MU;


I also had a problem with the fact that after the power failure the blinds are going automatically up - I didn't want that is why I introduced the xInit global variable which is false by default and is set to true after the first PLC cycle. Thanks to this restart of the PLC is not moving the blinds up.
I was testing the whole code with IN := FALSE for BLIND_INPUT but it also didn't help, the BLIND_NIGHT was not working.

Do you see any obvious problems here?
#10
I'm using OSCAT library to control blinds. My PLC is PFC200 from Wago and I'm using e!Cockpit. Everything works fine but I would like to get rid of automatic calibration after power failure built in the BLIND_CONTROL_S function block.

As it is written in the last sentence the "The automatic calibration however can be prevented if both inputs UP and DN are FALSE". And it actually stops the blinds to be calibrated (basically moving up and then down) but afterwards I can't control the blinds any more - UP and DOWN buttons are not working.

I was trying almost everything with no luck. With such an approach buttons works fine:

BlindControl(
    UP := BlindSecurity.QU,
    DN := BlindSecurity.QD,
    S_IN := BlindSecurity.STATUS,
    PI := BlindSecurity.PO
);


But in this case, there is an automatic calibration which I don't like. All blinds are going up and then down. I'm going to move into a new house within a week, I will be modifying my program a lot a the beginning, I don't want the blinds to move with each download.

Witch such approach the calibration is turned off (as suggested in the last sentence of the documentation):

BlindControl(
    UP := FALSE,
    DN := FALSE,
    S_IN := BlindSecurity.STATUS,
    PI := BlindSecurity.PO
);

BlindControl.UP := BlindSecurity.QU;
BlindControl.DN := BlindSecurity.QD;


But then buttons don't work any more.

Maybe I'm using outdated libraries. Where I could find the latest OSCAT Basic and OSCAT Building libraries for Wago e!Cockpit? Were there any updates in the last few years?

I don't speak German at all...