Mike Lee
Hello, I have mapped %QX0.0-%QX0.7 to remote digital output channels 0-7. However, %QB0 is not mapped to %QX0.0-%QX0.7. Therefore, the effect of SHR/SHL used by the PLC program on %QB0 will not be reflected in %QX0.0-%QX0.7. Is there any way to solve this problem?
Reply 0 0
thiagoralves
The address space is not overlapped, i. e. the bits in %QB are not mapped to %QX. Each address location is attached to a different memory region. You could create a function block that copies the bits you want to the specific QX variables
Reply 0 0
Mike Lee
Thanks! I noticed that modifying the macros __INIT_LOCATED, __SET_LOCATED, and __GET_LOCATED in accessor.h might allow mapping %QX0.0–%QX0.7 directly to %QB0.
I understand this isn’t the standard approach, but would adjusting these macros be a safe way to achieve bit-to-byte overlap, or is it likely to cause issues elsewhere?
Reply 0 0
thiagoralves
No, this won’t fix it. You will have to mess up with the glueVars.cpp, which is automatically generated by the compilation process based on the project that is being uploaded. That file is responsible for mapping the located variable pointers to the correct memory structures
Reply 0 0
fg71
You could use 16#01, 16#02, 16#04, 16#08, 16#10, 16#20, 16#40, 16#80 in Structured text to map bit to byte.
In the function block inputs is bit, and the output is byte.
 
You do not need to edit any .cpp or do any hack.
 
Use Structured text and make Function Block.  
Reply 0 0
thiagoralves
As @fg71 said, I believe the easiest approach for you is to build a BITS_TO_BYTE and a BYTE_TO_BITS function block. The code should be quite straightforward in Structured Text (you can build Function Blocks in any language by clicking on the + sign at the left panel and selecting "Function Block"). If you don't know Structured Text I'm pretty sure ChatGPT or some other AI might be able to help you get to the correct code. Once you have the blocks built, you can just connect your BYTE variable to the input of the BYTE_TO_BITS for example, and have it copy each bit of the input byte to the BOOL variables connected to the block outputs. Similarly you could do the opposite operation on the BITS_TO_BYTE block.
Reply 1 0
Mike Lee
Thanks everyone, it works fine now.
Reply 0 0
Reply