Search talk: int

 
<< < 1 2 3 4 > >> (Page 2 of 4)

Post by timvh on Configuring a 2's compliment CODESYS Forge talk (Post)
You could create a DUT of the Type Union and add an array of 2 bytes + an Int. Then write the byte values in the array of the Union and read the Int. Or VAR iInt : INT; byHigh : BYTE := 2#1111_1111; byLow : BYTE := 2#1111_1111; END_VAR iInt := TO_INT(byHigh*16#100 + byLow);
Last updated: 2024-09-28

Post by tvm on multiply gives negatives CODESYS Forge talk (Post)
It's probably because you have an INT in the input to the MUL function, which will then try to output an INT as well. INT variables can only handle values of -32768 to 32767. Your value of 523000 won't fit in an INT, so it turns into an invalid number. Use a DINT. This is usually better for working with time values anyway, because time values are all 32 bit. Or if you can't, use INT_TO_DINT(gvlp.detectie_nalooptijd_s) in the input to the MUL function.
Last updated: 2024-01-04

Post by damian177 on Persistence variables PFC200 CODESYS Forge talk (Post)
Hi, I using persistence variables like below: VAR_GLOBAL PERSISTENT RETAIN id_worker1: ARRAY [0..3] OF INT := [231,234,176,222]; id_worker2: ARRAY [0..3] OF INT := [211,129,125,221]; Initial values can cause some problems?
Last updated: 2023-12-08

Post by domoticom on multiply gives negatives CODESYS Forge talk (Post)
Hi, Attached net gives sometimes negatives, what am I doing wrong ? PS: detectie_nalooptijd_s = INT
Last updated: 2024-01-04

Post by aris-k on Pack TWO INT variable to one DINT variable CODESYS Forge talk (Post)
You can try this setup: DINTVar := SHL(INT_TO_DINT (Low_Word_INT_Var),16) + INT_TO_DINT(High_Word_INT_Var);
Last updated: 2024-05-07

Post by timvh on Alarm Configuration Notification Action CODESYS Forge talk (Post)
If it is a BOOL, then use: ...Error_Active := ALARM BOOL: ALARM INT: STATE
Last updated: 2024-05-14

Post by ph0010421 on How to manage variable types larger than 64 bits - Ethernet/IP CODESYS Forge talk (Post)
My guess is that's a STRING, not an INT type. And it's 128 bytes, not bits
Last updated: 2024-09-23

Post by tvm on Cannot pass array of constant size to a function as a reference CODESYS Forge talk (Post)
maybe this would be a better approach, then you don't have to pass the constant at all. FUNCTION fun : INT VAR_IN_OUT arr: ARRAY[*] OF INT; END_VAR VAR lower: DINT; upper: DINT; END_VAR lower:= LOWER_BOUND(arr, 1); upper:= UPPER_BOUND(arr, 1); see here as well https://help.codesys.com/api-content/2/codesys/3.5.12.0/en/_cds_datatype_array/
Last updated: 2024-01-08

Post by mondinmr on Jitter problems on imx8 CODESYS Forge talk (Post)
SOLVED!!! In this imx8 max_cstate=1 in kernel boot parameters is not working! We found a workaround: #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <stdint.h> int main(void) { int fd; uint32_t value = 0; fd = open("/dev/cpu_dma_latency", O_WRONLY); if (fd < 0) { perror("Error opening /dev/cpu_dma_latency"); return 1; } if (write(fd, &value, sizeof(value)) != sizeof(value)) { perror("Error writing to /dev/cpu_dma_latency"); close(fd); return 1; } while (1) { pause(); } } This simple code launched before CODESYS do the same work! Now jitter is identical as measured by cyclictest!
Last updated: 2023-10-19

Post by wiresplus on INT_TO_WORD function not working CODESYS Forge talk (Post)
Hello, I need to take an INT input, and convert it to a WORD value. VAR DRV2Speed : WORD; //IO card takes a WORD where 16000 = full 10V output (equivalent to 50Hz) PumpFillSpeed : INT; //Users enter a value between 0 and 50 END_VAR IF <conditions> THEN DRV2Speed :=INT_TO_WORD((PumpFillSpeed/50)*16000); END_IF </conditions> According to me this should work - but it stays at 0, no matter what. What am I doing wrong?
Last updated: 2024-01-26

Post by mxj262 on FB having single input but initialized with Array CODESYS Forge talk (Post)
I am adding elements of an ARRAY using pointer to access each element inside a FOR loop and the FOR loop does not stop! What is the right way to use pointers in such case?? I have another loop that is not using pointer and it stops but the loop using pointer keep on adding. METHOD FB_Init: BOOL VAR_INPUT bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold) bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change) END_VAR VAR_IN_OUT // basically REFERENCE TO window_buffer: ARRAY [*] OF INT; // array of any size END_VAR THIS^.windowPtr := ADR(window_buffer[0]); THIS^.windowSize := UPPER_BOUND(window_buffer, 1) - LOWER_BOUND(window_buffer, 1) + 1; FUNCTION_BLOCK FB500 VAR_INPUT END_VAR VAR_OUTPUT END_VAR VAR windowPtr: POINTER TO INT; windowSize: DINT; currentIndex: UINT; element1:INT; element2:INT; i:INT; j:INT; sum:DINT:=0; END_VAR element1:=windowPtr[0]; // read the first element of the Array dynamic memorry element2:=windowPtr[1]; FOR i:=0 TO (TO_INT(windowSize-1)) BY 1 DO // this loop does not stop Sum:=sum + windowPtr[i]; END_FOR FOR j:=0 TO 5 BY 1 DO // this loop stops j:=j+1; END_FOR https://ibb.co/k3DhkZT
Last updated: 2024-05-06

Post by squale on URL jumps between different visualizations behind a reverse proxy CODESYS Forge talk (Post)
Hi kevinrn, I have the same question as yours. On my side I try to make nginx work but it doesn't goes well. I think the sub_filter doesn't work int this case.
Last updated: 2024-07-26

Post by macros8 on Alarm Management - latched variable represented as Text list CODESYS Forge talk (Post)
Hi, I haven´t noticed you put the comment here. I thing it´s a bit different. What I want is to have detail errors of technology in data type e.g. INT. This variable I would latch to the corresponding error msg but I would like to get it convert to text from the text list and not keep it in INT form. Example. Main error Valve Error: SubErrors 1 - Both sensors 2 - Not retracted in time 3 - Not pulled out in time In HMI Main error + latch SubErrors => "Valve Error: Both sensors" The benefit is that text lists are part of translation and can be easily manipulated. I know I can create whole string msg in PLC but then, it lose advantage of Alarm management. Thanks. M.
Last updated: 2023-11-07

Post by fefefede on Get the numer of day CODESYS Forge talk (Post)
Hello i tro to create a program to turn on or off the air condition in relationship temperature and numer of day. I can't get the number of day. I try this after installing SysTime library but this not work and have this error on debug ------ Build started: Application: Device.Sim.Device.Application ------- Typify code... Generate code... [ERROR] giorno_accensione_aria: PLC_PRG Device: PLC Logic: Application: C0032: Cannot convert type 'Unknown type: 'SysTimeCore(TRUE)'' to type 'TIME' [ERROR] giorno_accensione_aria: PLC_PRG Device: PLC Logic: Application: C0035: Program name, function or function block instance expected instead of 'SysTimeCore' [ERROR] giorno_accensione_aria: PLC_PRG Device: PLC Logic: Application: C0032: Cannot convert type 'Unknown type: 'DayOfWeek(CurrentTime)'' to type 'INT' [ERROR] giorno_accensione_aria: PLC_PRG Device: PLC Logic: Application: C0035: Program name, function or function block instance expected instead of 'DayOfWeek' [INFORMATION] giorno_accensione_aria: PLC_PRG Device: PLC Logic: Application: C0181: Related position Build complete -- 4 errors, 0 warnings : No download possible PROGRAM PLC_PRG VAR Temperatura: UDINT; AriaCondizionata: BOOL := FALSE; CurrentDayOfWeek: INT; //Variabile Giorno CurrentTime: TIME; GiornoDellaSettimana: INT; DayOfWeek: INT; END_VAR CurrentTime := SysTimeCore(TRUE); // Ottieni l'ora corrente CurrentDayOfWeek := DayOfWeek(CurrentTime); CASE GiornoDellaSettimana OF 1: // Azioni per Lunedì 2: // Martedì se più 10° accend altrimenti spegni IF Temperatura >= 10 THEN AriaCondizionata := TRUE; ELSE AriaCondizionata := FALSE; END_IF 3: // Mercoledì se più di 50° accendi altrimenti spegni IF Temperatura >=50 THEN AriaCondizionata := TRUE; ELSE AriaCondizionata := FALSE; END_IF 4: // Giovedì se più di 40° accendi altrimenti spegni IF Temperatura >=40 THEN AriaCondizionata := TRUE; ELSE AriaCondizionata := FALSE; END_IF 5: // Venerdì se più di 50° accendi altrimenti spegni IF Temperatura >=50 THEN AriaCondizionata := TRUE; ELSE AriaCondizionata := FALSE; END_IF 6: // Sabato se più di 25° accendi altrimenti spegni IF Temperatura >=25 THEN AriaCondizionata := TRUE; ELSE AriaCondizionata := FALSE; END_IF 7: // Domenica sempre spenta AriaCondizionata := FALSE; END_CASE
Last updated: 2023-09-14

Post by rickj on Defining local variables that can be independent with several users. CODESYS Forge talk (Post)
You need to create an array with one element for each possible user. I usually define these arrays in the root screen. FrameIndex : Array [0..MaxUsers] OF INT; Then use the global CurrentClientId (defined by one of the VISU libraries) to index the array element used to select the frame. FrameIndex[CurrentClientId]
Last updated: 2023-10-21

Post by tvm on Cannot pass array of constant size to a function as a reference CODESYS Forge talk (Post)
It will be a reference, because it's a VAR_IN_OUT. it's a little weird debugging the array online. It just shows as a POINTER TO INT, and you can't actually see the array from the function side. But you can still work with it as a normal array, not a pointer.
Last updated: 2024-01-09

Post by corriibme on JSON Utilities and SetArray CODESYS Forge talk (Post)
Hello @florian, Could you please help with how to set an array value? I've been trying to use the with the setKeyWithArray method which creates the key with an empty array value. But I have been unable to set items in this array? objindex:= fb_JBuilder.SetKeyWithArray("Key6", diParentIndex := diRootIndex); objindex2:= fb_JBuilder.SetValue(value:= iValue2, diParentIndex:= objindexx); //iValue: array[0..n] of int; Best regards
Last updated: 2024-05-11

Post by talhaali on Active alarm access in ST CODESYS Forge talk (Post)
Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working: VAR iCountActiveAlarms : INT; parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm; itfAlarmManagerClientAll : IAlarmManagerClient; END_VAR AlarmManager.g_AlarmHandler.GetActiveAlarms( itfAlarmManagerClient :=itfAlarmManagerClientAll, iCountActiveAlarms => iCountActiveAlarms, parritfActiveAlarms => parritfActiveAlarms); The Value is always 0. Please help.
Last updated: 2024-06-06

Post by talhaali on Can't read Alarm Class from Alarm Storage CODESYS Forge talk (Post)
Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working: VAR iCountActiveAlarms : INT; parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm; itfAlarmManagerClientAll : IAlarmManagerClient; END_VAR AlarmManager.g_AlarmHandler.GetActiveAlarms( itfAlarmManagerClient :=itfAlarmManagerClientAll, iCountActiveAlarms => iCountActiveAlarms, parritfActiveAlarms => parritfActiveAlarms); The Value is always 0. Please help.
Last updated: 2024-06-06

Post by talhaali on Can't read Alarm Class from Alarm Storage CODESYS Forge talk (Post)
Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working: VAR iCountActiveAlarms : INT; parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm; itfAlarmManagerClientAll : IAlarmManagerClient; END_VAR AlarmManager.g_AlarmHandler.GetActiveAlarms( itfAlarmManagerClient :=itfAlarmManagerClientAll, iCountActiveAlarms => iCountActiveAlarms, parritfActiveAlarms => parritfActiveAlarms); The Value is always 0. Please help.
Last updated: 2024-06-06

Post by talhaali on Can't read Alarm Class from Alarm Storage CODESYS Forge talk (Post)
Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working: VAR iCountActiveAlarms : INT; parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm; itfAlarmManagerClientAll : IAlarmManagerClient; END_VAR AlarmManager.g_AlarmHandler.GetActiveAlarms( itfAlarmManagerClient :=itfAlarmManagerClientAll, iCountActiveAlarms => iCountActiveAlarms, parritfActiveAlarms => parritfActiveAlarms); The Value is always 0. Please help.
Last updated: 2024-06-06

Post by talhaali on Active alarm access in ST CODESYS Forge talk (Post)
Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working: VAR iCountActiveAlarms : INT; parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm; itfAlarmManagerClientAll : IAlarmManagerClient; END_VAR AlarmManager.g_AlarmHandler.GetActiveAlarms( itfAlarmManagerClient :=itfAlarmManagerClientAll, iCountActiveAlarms => iCountActiveAlarms, parritfActiveAlarms => parritfActiveAlarms); The Value is always 0. Please help.
Last updated: 2024-06-06

Post by talhaali on Alarm Manager: CODESYS Forge talk (Post)
Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working: VAR iCountActiveAlarms : INT; parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm; itfAlarmManagerClientAll : IAlarmManagerClient; END_VAR AlarmManager.g_AlarmHandler.GetActiveAlarms( itfAlarmManagerClient :=itfAlarmManagerClientAll, iCountActiveAlarms => iCountActiveAlarms, parritfActiveAlarms => parritfActiveAlarms); The Value is always 0. Please help.
Last updated: 2024-06-06

Post by talhaali on Alarm Table Issues CODESYS Forge talk (Post)
Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working: VAR iCountActiveAlarms : INT; parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm; itfAlarmManagerClientAll : IAlarmManagerClient; END_VAR AlarmManager.g_AlarmHandler.GetActiveAlarms( itfAlarmManagerClient :=itfAlarmManagerClientAll, iCountActiveAlarms => iCountActiveAlarms, parritfActiveAlarms => parritfActiveAlarms); The Value is always 0. Please help.
Last updated: 2024-06-06

Post by talhaali on Alarm status in logic CODESYS Forge talk (Post)
Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working: VAR iCountActiveAlarms : INT; parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm; itfAlarmManagerClientAll : IAlarmManagerClient; END_VAR AlarmManager.g_AlarmHandler.GetActiveAlarms( itfAlarmManagerClient :=itfAlarmManagerClientAll, iCountActiveAlarms => iCountActiveAlarms, parritfActiveAlarms => parritfActiveAlarms); The Value is always 0. Please help.
Last updated: 2024-06-06

<< < 1 2 3 4 > >> (Page 2 of 4)

Showing results of 82

Sort by relevance or date