Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Dynamic Images

zastrow
2022-07-26
2024-04-06
  • zastrow - 2022-07-26

    Hi,

    I have a project where we are attempting to have images change as we go through screens. We cannot have images local on the PLC as each PLC will hold different images. We are currently able to pull from a database a file path to the image or the image itself. The problem comes to actually getting this images to load in Codesys 3.5.16 SP6. Currently the only way we know how to load images is through the image pool. Is it possible to update the image in the image pool while the program is running? Or is there another way to load images? (Also willing to update Codesys if that would be helpful)

     
  • zastrow - 2022-07-27

    Hi all,

    Just checking to see if anyone has any ideas on this. I am really looking to store the file path to the image and than overwrite the file path in the image pool and then get the image to update in runtime.

     
  • zastrow - 2022-10-19

    Hi all,

    I solved my issue. If anyone is interested I can post my solution.

     
    πŸ‘
    1
  • rickj - 2022-11-06

    Hi zastortow, I would love t know how you did this. Can you give some insight here or post something. Thanks.

     
    • zastrow - 2022-11-07

      Hey rickj, so it depends if you need dynamic images to work with a webvisu or not. I personally needed it to work with a webvisu, so I will describe how I went about doing that. The first thing you will need to do is select 'Advanced' under visu properties (Step1.PNG). That will bring up the options 'Bitmap ID variable' and 'Dynamic bitmap'. Under 'Bitmap ID variable' you will see 'Bitmap ID', this will be a string that just says the file name for the image you are trying to access (it can also be a file path, but that will not work with web visu). Under 'Dynamic bitmap' you will see 'Bitmap version' this one is very important; it must be changed every time you change your image otherwise the image will not get redrawn. So how do you go about changing your image then? The way I found to get it to work with webvisus is to overwrite the image in the runtime file location and then update your 'Bitmap version' or at least thats the basic idea. The runtime location is usually not the most fun to find. Although it can be easily viewed through Codesys, just go to the Device, select Files, select Refresh (Step2.PNG). You will now see a bunch of files and folders; one should be called 'PlcLogic' this folder is your main runtime location (ie when you use file libraries this will be the root directory). Inside the 'PlcLogic' folder you will see the folder 'visu'. This folder will hold all images that are part of any imagepool and will also hold webvisu files. This is important to know because in order for any image to get dynamically changed on a webvisu you must replace or create a file in that folder. At this point I assume it still is not quite clear what you have to do. But I wanted to give you some background information on the layout of everything. So, now I will go over what I do in detail. First, I ftp the image onto the device, the file ends up under the PLClogic folder. Then when I want that image to load, I copy it from the PLClogic folder to the visu folder. Now you can either updated the 'Bitmap ID' string to match the name of the file or you can choose not to use the bitmap id and rather you can just overwrite the Static image. After this you update your bitmap version num and the image should have changed. Let me know if you need any additional help! (I do have a project that I could include but I need to clean it up) lmk if you need it.

       
      πŸ‘
      1
      • dandyk - 2024-04-06

        Hello, I have very similar problem, but it seems that your solution does not work for me.

        I am using TwinCAT XAE Shell v3.1.4024.55 and TwinCAT Runtime. Sorry for writing here on codesys forge, but since I found the only relevant topic here and since TwinCAT is almost the same with CODESYS in many applications, I chose to write here.

        I simply need to dynamically update image in visualization based on camera trigger (I am doing a machine vision application). Camera triggers an image, my program processes it (applies thresholding, draws contours etc...) and saves the processed image in the runtime location (the same one you were mentioning). This was done successfully.

        I need to make it work at runtime, while the program is executing and I need to refresh the image in the visualization each time camera triggers a new image and program processes it.

        When I create image element in the visualization and define the bitmap ID variable as STRING which contains the image ID defined in the image pool, then it displays the image in the image pool, but does not work at runtime, while the program is executing.

        I also used the Bitmap Version. I declared it in Global variable list as integer with initial value of 0 and wrote the variable in the bitmap version in the image element in visualization. Each time new image is saved to the runtime location, I wrote a program to increment Bitmap Version by 1. It increments and the image does not update in the visualization, unfortunately.

        I think that bitmap version is working correctly and deletes the cached image as it is supposed to, but the Image Pool does not update the image ID with the new image... the path to the image is always the same... only the actual image changes with the same file name. Image Pool is not dynamic and cannot refresh the image in the path to the actual one at runtime.

        How can I refresh the image ID in the image pool at runtime? Bitmap version only deletes cached image and reloads the image from the image ID, but the image ID has the same image, because image pool won't update at runtime.

        Do you know any solution to this problem?

         
  • rickj - 2022-11-14

    Thank you very much for your explanation. I think I have a pretty good understanding of what you have done. Thanks.

     
    • mandeepahujaifm - 2023-04-19

      Can we please get a copy of this project. I have the exact same requirement with FTP and showing images on both Target and Webvisu.

       

Log in to post a comment.