Search talk: to byte

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

das Bit im Byte CODESYS Forge talk (Thread)
das Bit im Byte
Last updated: 2010-02-17

Assign a 12 Byte Hex CODESYS Forge talk (Thread)
Assign a 12 Byte Hex
Last updated: 2021-09-09

Ist string[16] 16 Byte lang ??? CODESYS Forge talk (Thread)
Ist string[16] 16 Byte lang ???
Last updated: 2005-08-23

Control Win V3 change byte order CODESYS Forge talk (Thread)
Control Win V3 change byte order
Last updated: 2020-04-08

1 Byte in einzelne Bits auflösen CODESYS Forge talk (Thread)
1 Byte in einzelne Bits auflösen
Last updated: 2014-09-04

Byte oder Word als Bit benutzen CODESYS Forge talk (Thread)
Byte oder Word als Bit benutzen
Last updated: 2010-10-23

Modbus / RS485 custom byte level message CODESYS Forge talk (Thread)
Modbus / RS485 custom byte level message
Last updated: 2022-08-26

Read File more than 65535 byte CODESYS Forge talk (Thread)
Read File more than 65535 byte
Last updated: 2023-07-25

Byte input and output 1734-OE2V CODESYS Forge talk (Thread)
Byte input and output 1734-OE2V
Last updated: 2017-03-22

Einzelne Werte aus ARRAY OF BYTE CODESYS Forge talk (Thread)
Einzelne Werte aus ARRAY OF BYTE
Last updated: 2005-11-14

Writing 16 byte SDO over Ethercat CODESYS Forge talk (Thread)
Writing 16 byte SDO over Ethercat
Last updated: 2019-04-22

Byte an Ausgänge von EC4P CODESYS Forge talk (Thread)
Byte an Ausgänge von EC4P
Last updated: 2007-04-27

Zahlenwert <256 in 1 Byte wandeln CODESYS Forge talk (Thread)
Zahlenwert <256 in 1 Byte wandeln
Last updated: 2007-02-06

byte count with NBS UDP receive CODESYS Forge talk (Thread)
byte count with NBS UDP receive
Last updated: 2021-06-01

Assigning array of byte CODESYS Forge talk (Thread)
Assigning array of byte
Last updated: 2015-11-26

Is it possible for a byte to have a negative sign? CODESYS Forge talk (Thread)
Is it possible for a byte to have a negative sign?
Last updated: 2019-10-31

About byte swap and convert into 16 bits CODESYS Forge talk (Thread)
About byte swap and convert into 16 bits
Last updated: 2023-12-04

Assign Initial Value of Array of Byte CODESYS Forge talk (Thread)
Assign Initial Value of Array of Byte
Last updated: 2019-03-08

CANopen - mehr als 4 Byte aus dem Objektverzeichnis lesen CODESYS Forge talk (Thread)
CANopen - mehr als 4 Byte aus dem Objektverzeichnis lesen
Last updated: 2007-06-15

Read byte from a file starting from a certain position CODESYS Forge talk (Thread)
Read byte from a file starting from a certain position
Last updated: 2018-06-14

Byte conversion between RFID and RS232 module CODESYS Forge talk (Thread)
Byte conversion between RFID and RS232 module
Last updated: 2008-07-09

Post by voffi on Converting UINT into bytes and converting 2Bytes into UINT CODESYS Forge talk (Post)
There are some ways. One is to use SHR and SHL and it depends on your byte order in the data array. For Motorola byte order: PROGRAM PLC_PRG VAR u : UINT; byte_array_in : ARRAY [1..8] OF BYTE := [16#11, 16#12, 16#13, 16#14, 16#15, 16#16, 16#17]; byte_array_out : ARRAY [1..8] OF BYTE; END_VAR u := SHL(TO_UINT(byte_array_in[2]), 8) + TO_UINT(byte_array_in[1]); byte_array_out[1] := TO_BYTE(u); byte_array_out[2] := TO_BYTE(SHR(u, 8)); If it's Intel byte order just change 1 and 2 in the array indexes.
Last updated: 2023-12-07

Post by ihatemaryfisher on Sorting array of any-sized structure CODESYS Forge talk (Post)
In my machine's operation, I need to display multiples tables containing arrays of structured variables. The arrays change during operation, and my supervisor has advised me to write a new bubble-sort for each array. I think I can make a function to sort an array of any data type. This was my own project, and I'm a relatively new coder. I want to know the weaknesses in my approach, and a better method, if one exists. As far as I can test, the function accepts an array of a structured variable of any size, and sort it by any VAR in that structure. But it relies heavily on pointers, which I've heard are bad practice? Function call: // SORT BY BYTE-SIZED VAR IF xDoIt[6] THEN FUNBubbleSortSansBuffer( IN_pbySourcePointer := ADR(astArray[1]), // address of first byte in first element of array IN_pbyComparePointer:= ADR(astArray[1].byCompByte), // points to first byte of the comparing variable (variable you sort by) IN_uiStructureSize := SIZEOF(TYPE_STRUCTURE), // size, in bytes, of the structured variable IN_uiCompareSize := SIZEOF(astArray[1].byCompByte), // size, in bytes, of the comparing variable (variable you sort by) diArrayElements := UPPER_BOUND(astArray,1), // number of elements in array IN_xSmallToLarge := xSortOrder // whether to sort by small2large or large2small ); END_IF Function: FUNCTION FUNBubbleSortSansBuffer : BOOL VAR_INPUT IN_pbySourcePointer : POINTER TO BYTE; // points to beginning of array (first byte of first element) IN_pbyComparePointer: POINTER TO BYTE; // points to first byte of the comparing variable (variable you sort by) IN_uiStructureSize : UINT; // size, in bytes, of the structured variable IN_uiCompareSize : UINT; // size, in bytes, of the comparing variable (variable you sort by) diArrayElements : DINT; // number of elements in array IN_xSmallToLarge : BOOL; // whether to sort by small2large or large2small END_VAR VAR j : DINT; // repeat iteration over array until array ends i : DINT; // iterarte over array, swapping when necesary k : DINT; // iterator from 1 to size of structure (stepping 'through' a single element in array) dwSize : DWORD; // internal var for use in MEMUtils.MemCpy(<size>) // FOR SORTING BY BYTE VAR pbySourcePointer : POINTER TO BYTE; pbySourcePointer2 : POINTER TO BYTE; pbyComparePointer : POINTER TO BYTE; pbyComparePointer2 : POINTER TO BYTE; pbyPointerToBuffer : POINTER TO BYTE; // pointer to single byte buffer byBufferByte : BYTE; // single byte buffer END_VAR dwSize := UINT_TO_DWORD(IN_uiStructureSize); // get structure size (number of bytes) pbyPointerToBuffer := ADR(byBufferByte); // assign pointer to address of buffer byte (because MEMUtils.MemCpy requires a pointer input) CASE IN_uiCompareSize OF // depending on the size of the VAR to sort by (current functionality for BYTE and WORD/INT 1: // BYTE (8 BIT) FOR j := 1 TO diArrayElements DO // for number of elements in array FOR i := 1 TO (diArrayElements-1) DO // same thing, but row[i+1] row is included in swap logic pbySourcePointer := IN_pbySourcePointer + dwSize*(i-1); // point at #1 byte in array element[i] pbySourcePointer2 := pbySourcePointer + dwSize; // point at #1 byte in array element[i+1] // NOTE: because of memory locations, each array element is offset from one another by a number of bytes equal to the size of the structure // We can "walk" from array[i] to array[i+1] via steps equal to the size of the structure // e.g., ADR(array[i+1]) == ADR(array[i]) + SIZEOF([array datatype]) pbyComparePointer := IN_pbyComparePointer + dwSize*(i-1); // point to sorting variable in array element[i] pbyComparePointer2 := pbyComparePointer + dwSize; // point to sorting variable in array element[i+1] // using sort order (small -> large/large -> small) IF SEL(IN_xSmallToLarge, (pbyComparePointer2^ > pbyComparePointer^),(pbyComparePointer2^ < pbyComparePointer^)) THEN // This is where it gets tricky. We've identified pointers for the starting bytes of aArray[i] and aArray[i+1] // and we know the size of aArray[i]. We are going to swap individual bytes, one at a time, from aArray[i] and aArray[i+1] // this allows us to use only a single byte var as a buffer or temporary data storage // e.g., consider a structure consisting of a word, a byte, and a string. it is stored like this // |------WORD-------| |--BYTE-| |STRING------...| // astArray[1] == 1000 0100 0010 0001 1100 0011 1010 1010.... etc // astArray[2] == 0001 0010 0100 1000 0011 1100 0101 0101.... etc // performing a single swap (copy into a buffer, etc.) of the first byte of each array element creates this // astArray[1] == 0001 0100 0010 0001 1100 0011 1010 1010.... etc // astArray[2] == 1000 0010 0100 1000 0011 1100 0101 0101.... etc // incrementing the pointer adresses for the swap by 1 and swapping again swaps the next byte in each array element // astArray[1] == 0001 0010 0010 0001 1100 0011 1010 1010.... etc // astArray[2] == 1000 0100 0100 1000 0011 1100 0101 0101.... etc // continuing this from k to SIZEOF(TYPE_STRUCTURE) results in a toally swapped row FOR k := 1 TO IN_uiStructureSize DO // copy single byte[k] of array element 1 to buffer MEMUtils.MemCpy(pbyDest := (pbyPointerToBuffer), pbySrc := (pbySourcePointer+k-1), dwSize := 1); // copy single byte[k] of array element 2 to 1 MEMUtils.MemCpy(pbyDest := pbySourcePointer+k-1, pbySrc := (pbySourcePointer2+k-1), dwSize := 1); // copy buffer to byte[k] array element 2 MEMUtils.MemCpy(pbyDest := (pbySourcePointer2+k-1), pbySrc := pbyPointerToBuffer, dwSize := 1); END_FOR END_IF END_FOR END_FOR
Last updated: 2023-08-17

Post by bjarne-pagaard on Codesys v3.5 Sint to byte CODESYS Forge talk (Post)
Hi A SINT is a short (signed) integer. It is already only 1 byte - so you should have no problem casting it to a byte like so: bMyByte := TO_BYTE(sintMyShortInt); If you have a regular INT you want to put in 2 bytes - there are a lot of ways you can do this. A Union is certainly one of them. You could have a union with 2 memebers: An array of 2 bytes as one member, and an integer value as another member. Another way would be to look at MEMCPY to put the value into your CAN-message. .. or create a function to take your input value as input, and giving you 2 individual bytes as output. This could be handy if you need to change the byte-order. Integer data types: https://help.codesys.com/webapp/_cds_datatype_integer;product=codesys;version=3.5.17.0 -Bjarne
Last updated: 2024-04-24

Zugriff auf BYTE in einem WORD / INT in einem DINT etc... CODESYS Forge talk (Thread)
Zugriff auf BYTE in einem WORD / INT in einem DINT etc...
Last updated: 2023-01-19

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

Showing results of 4263

Sort by relevance or date