PLC IDE and OPTA -TCP MODBUS - Error A4152 - 16-bit variables must be aligned to a 16-bit boundary

Hello,

Since yesterday when I try to compile a program for my opta where I try to use it as a Master to read or send registers, I can create variables as shown in picture 1:

However, no matter whether I assign them as INT or WORD, when I try to use these variables for any operation on a Functional Block Diagram, I get this error when compiling. (see picture 2)

"Error A4152 - 16-bit variables must be aligned to a 16-bit boundary"

It doesnt matter that I use "to word" "to Int" or any other function.

In fact, The most frustrating thing is that I literally have a successful compiled and working program of this exact same thing. It feels as if my PLC IDE got corrupted. I tried to install it in another computer but it wouldnt install due to an error, and then I tried in a third computer, and it installed, but it got "an error -1" when performing the simplest compilation, so I havent been able to test it.

Please see the picture 3 and the modbus variables, which I made yesterday, and which compiles and works succesfully throught ethernet.

¿Is my software corrupt? If installing and unistalling does not solve it, (it does not) what else can I do?
Why did it work until yesterday but not anymore?

Thanks

I don't know this software but most likely the error is the address, 30001 doesn't seem right

Hello, thank you for your answer and for reading my post.

I believe I can choose adresses between 1 and 65000. In fact I have successfully used these addresses (read and written on them, with the OPTA as Master and my PC as Slave) on the working example (the config you see on the picture compiles and runs, no problem, but it was created yesterday before the appearance of this error for me) :

I have now tried to replicate these addresses that I know that have worked, in a function that I know that has worked (so, I am now trying to read holding register 20110 with modbust function 3. The program that I made yesterday works. The program I made today does not. (see picture of program of today)

"must be aligned to a 16-bit boundary" means, the address must be an even number (30000, 30002, etc). The error may be for another variable than the one shown in your last screenshot.

Hello, thank you again,

I didn't know about the even number thing, I will keep in mind, although 20110 does not work.

Here is why I think the error is from this variable. The program I created today does only one thing, a comparison. I have even deleted the ladder, it is just a FBD with this comparison:

As you can see on the picture above, readreg1 is a "WORD" in this example. I try to compile, i get the same error.

I now switch it for a new variable of word type "NEW WORD TEST":

It compiles and works. it is that variable that is created for modbus. If it make it "int" instead of word" is the same error.

Since I suspect my installation has become corrupted, and I have a fourth PC on my house, i am gonna try to install the PLC ide there and replicate it, to see if i run into the same issue or not

OK, I GOT IT TO WORK, HERE IS WHAT I DID

I have not switched computers, its the same example

In the manually created WORD global variable, I put it as a mapped address, instead of auto, and I gave it manually an address and configured as shown on the picture above

I then went into modbus function, addres 20110 as I wanted, and assigned this word variable configured like that to the modbus function.

It compiles, and works.

Thanks for your help.

Before marking this Issue as "solved" I will test it some more and extensively, I want to make sure that this solves this issue for good.

2 Likes

I am gonna consider it solved. Here Is what must be done:

-Create global variables that you want to read or write through modbus

  • manually Configure them as shown on the pictures above

-Compile

-Use them on your functions

-compile

-when you are done, manually asign them to modbus functions. Compile.

It seems to work.

If you dont compile after creation and before assigning to modbus, it seems to fail.

Anyway.

Thanks, best regards to everyone.

It looks like I spoke too fast. I am unable to replicate this success in a new project.

I am at a loss. I read somewhere on these forums some days ago that modbus ethernet was disabled on 1.06 PLC IDE as a server, I dont know if that is true.

I find this very frustrating, as I have dedicated many many hours to try to troubleshoot this and repeating the exact same steps yields me different results and errors each time. Now the problem is either "data block not found" or the same as before.

@opta_user_777 Hi, thanks for the info. Yes, it is a bit frustrating... me and my coworkers put a lot of time trying to develop something but, like you, facing various problems. Please @PMarquinez or other Arduino representative; try to give to who bought the hardware a new version of PLC IDE and support us. We see a lot of potential on the Opta. Thanks

1 Like

Hey @opta_user_777 what if you create the variable as auto instead of manually mapping it? Do you actually need to manually map it?