Simple USB logger (ST)

Hi All,
I’m quite new to PLC and I would like to find an example and a simple project made in Structure Text for external USB logging.
My goal is to create two files: one every second and one every 60 seconds.
I tried the examples and tips given in the following post:

But unfortunately I couldn’t get it working.
I’m using a X20CP1584 model and any example with a Visu (VC4) page will be greatly appreciated.

there are two ways mentioned in previous topic you refer to.

official sample:
https://help.br-automation.com/#/en/4/libraries%2Fasusb%2Fsamples%2Fsamples_asusb.html

or user solution:

Which of them you have used and what troubles did you have? The explanation that you couldn’t get it working is not sufficient. :slight_smile: Try to provide us some more details :slight_smile:

Hi Jaroslav,

Thanks for the reply and sorry for not providing enough information.

The B&R online help examples show how to read data, except for one of them which sends data to a USB printer. And that’s not what I’m looking for.

The user solution gives me a lot of errors when I compile the solution, besides the fact that it’s made for Mapp View (I am and will use VC4). Still, I tried to add it to my project (probably incorrectly) and it didn’t work.

In the post I referenced, there is also another user example I tried: DataLoggintoUsb. Everything seems to be fine when I configure the project with my PLC model, but when I leave it running, it doesn’t log any data or create any files on the USB stick.

Well you are right, in AsUsb sample there is read functionality only. I think it is because writing is the same, you have to only use writing FUB instead of reading :slight_smile: So should be easy enough for someone who has experiences. Since you are new I think the easiest way is to use mpData. Refer to online help B&R Online Help. In getting started is shown how to log value of one variable, but you can of course log more…it is very easy to use, it is more configuration than programming.

Have you configured the target space to write to correctly?
I am using 4PPC70 HMIPLC combo, modified the AS provided example from Help (search for FileIO library).
My strDevice is ‘USER’, which saves to user partition and everything seems to be happy. It is the default in PLC config/File devices/File device 1
The example’s strDevice is ‘HARDDISK’, I have not checked whether that needs to be set as a File device pointing to a USB path, but would not be surprised at all. Quick search through help points at the need to first configure a device by using DevLink (search for that), where you will point to the device by IF3.ST1 (for me 4PPC70 has 2 USB ports, IF3 and IF4)

Digging a bit deeper, you will find this:
AsUSB - Integrating USB devices

Starting with AR 4.x, USB devices are integrated in Automation Runtime dynamically, so that they no longer need to be configured in Automation Studio. In order to use a USB device during runtime, its internal device name needs to be determined. This is needed to complete the device handle with the DevLink() FB. Then the USB device can be used normally. The internal device name is determined using the AsUSB library. For an example, see the AS Help documentation for the library AsUSB - Examples).

In order to use a USB device during runtime, its internal device name needs to be determined. This is needed to complete the device handle with the DevLink() FB

and if you need another example, this old one should still work:

GitHub - hilch/FindUsbStickOnBAndRPlc: B&R Automation Studio : Search USB Stick and use it as file device