Hi all developers! Today we will talk about Tc/BSD and virtualization. One of Beckhoff's biggest strengths is that it's possible to run your PLC code locally on your desktop in a virtual machine So this is perfect for many reasons. One reason is that it's possible to prototype locally on your machine so you don't have to buy expensive hardware if you just want to do some quick tests. For me learning is one of the biggest joys in life so being able to run virtually and locally on my desktop makes my learning process much easier I've previously been writing about the virtualization and TwinCAT on my blog AllTwinCAT.com, but that was more from a perspective of running it in a Windows virtual machine. Now we will take the next step and look how to run Tc/BSD in a virtual machine. Tc/BSD is Beckhoff's derivate of FreeBSD which is a unix-like operating system. Unlike Linux however which you probably heard about, Linux is just a kernel while FreeBSD is a full-blown operating system. So Beckhoff now offers this as an alternative for Windows though it's just for a few PLCs not all PLCs. But Istill think it's great that they're starting to to look into using an unix-like operating system for their runtime Unfortunately the usage of Tc/BSD seems to be quite limited so I can't find so much people actually using it. There is a little bit of documentation on the Beckhoff website which is good but I still think there's a little bit of information missing particularly about this subject, so that's why I thought I'd make this video. To show you how you can install Tc/BSD as a virtual machine and then we use this virtual machine to actually run some TwinCAT software on it I want to start by mentioning that everything that I will show you is not supported by Beckhoff As far as I know there is no documentation whatsoever available on the Beckhoff website regarding how to run Tc/BSD in a virtual environment so this is 100% unsupported Everything you do here is at your own risk! With that mentioned we can get started! There are a couple of things that you will need before we get started First of all you will need an USB memory stick, preferably with eight gigabyte or more storage on it. You will need a software called "Etcher". It's a tool that you use to write this installation file that we will download from Beckhoff into a USB stick. This software is completely free The third thing you need is a hypervisor to run your virtual machine. In this example I will use VmWare workstation pro. This unfortunately costs a little bit of money although there is a 30-day free trial that you can use. I tried to get it to work on a VirtualBox (free software), however I never got it to work, I had several issues. I had like problems with restarts. That the machine just restarted. It didn't want to start it crashed and...yeah just a lot of problems. If you managed to get this to work on VirtualBox then I would be really happy if you could write a comment or two in the comment field and explain how you managed to do it. The fourth thing that you will need is a PC with a host operating system. For this tutorial I will use a laptop with Windows 10 Pro Other operating systems might or might not work. For example if you can try it with mac, if you manage to get it to work with mac also please write a comment or two in the description below. The final thing is that you will need the TwinCAT XAE on your computer This is necessary because we will just write a simple application that we will run on this virtual machine. I will not show how you install Etcher or VmWare workstation pro This you can probably do yourself. However I will provide links in the description below to this software We're gonna do this together as a four stage rocket. First we will download Tc/BSD from the Beckhoff website. We will use Etcher to create a bootable USB stick with this downloaded file The third thing we will do is to create a virtual machine in VmWare workstation pro and install Tc/BSD from this USB stick. The fourth and the final thing that we'll do is to connect to this virtual machine using our development environment, write a tiny application compile it put it on the virtual machine and run it. To download Tc/BSD you have to go to the Beckhoff website and go to this address. I will provide it in the description below of this video You have to sign in which is free. You just register for a free account and you go here To software and tools...downloads. Download the Zip file. Start the download and then you wait for it to download. Once the file is downloaded you extract it. This is in swedish unfortunately My operating system is in Swedish but you probably get the idea. You unzip the zip file You'll get a couple of files which of the important one is this one. This holds the operating system and all the files. The next step is to start the software Etcher. This is the software that we'll use to actually take this ISO file and write it to our USB memory stick You select flash from file. You select the ISO file which we just extracted from the ZIP file As a target device you select the USB stick. Just make sure to actually select the USB stick and not something else, like for example your hard drive. Because if you select your hard drive then you're gonna have a really bad day. Make sure to select the USB stick and click on flash. Then we'll just wait while the software is making a bootable USB stick from this ISO file. When it's finished the writing it will start to validate, you can just skip it And then flash is complete so now you have a bootable USB stick that we will use to start the installation of the operating system Tc/BSD into our virtual machine. The next step is to start VmWare workstation. Make sure that it's started with administrator rights. That's very important. When you start the application just make sure it started with administrator rights Make sure to select "file", "new virtual machine". Select "typical". Make sure to select "I will install the operating system later" Make sure to select "guest operating system", "other" and then "FreeBSD 64-bit" Then you would need a name for your virtual machine here. Just come up with a good name. And this doesn't matter. Select "finish". Now we have our virtual machine here. So the thing we need to do now is that we will have to do some settings for us in order to use this virtual machine Click on "edit virtual machine settings" after selecting it Select this hard drive, remove it. Click "add". Select a new hard drive Select "SATA". Select "use of physical disk". So what
we're going to do now is that we're going to create a hard drive that is connected to the USB stick because we want the USB stick to... We need to do the installation of this operating system Next we need to select where this USB stick is. And here it's not very obvious. Physical drive zero or one? That doesn't say much. For this there's a trick. Just go to ... write diskmgmt.msc Which will start a disk manager of Windows. This is in swedish but you will probably...it will probably look similar in other languages as well. Here it's easy to see that the USB drive which is eight gigabytes is this guy, while the hard drive on this computer is this guy. So just then we know that this is number one and this is number two, so
this is the guy that we're going to use for the installation...that has the Tc/BSD install files. In this case it means it's this guy Select "use entire disk", click "finish". Now we also need to add another hard drive Now we need a second hard drive because this
is the hard drive where we're gonna actually install the operating system to. So select "hard disk", select "next" , select "SATA". Next select "create a new virtual disk". 20 gigabytes is fine and then just leave it like this I think 20 gigabytes is much more than necessary, and then select "finish" There's some other settings we need to do. First we can allocate a little bit more memory. I think 256 megabyte is probably enough. I mean Beckhoff are selling a PLC that's using Tc/BSD that has... I don't know...32 megabytes or something? So it should work with 256 megabytes But let's just increase it to 2 gigabytes because we have memory to spare here on this on this computer. The next thing we need to do is to select "options" and then go to "advanced" and make sure that firmware type here is "UEFI" This has to do with with the booting of the USB stick I'm not going to go into details here, I could talk about this probably, but you would just get very bored about it. Just select UEFI and I think that's everything. Now we can click "ok" Now we have all the settings we need on this virtual machine, so we can power it on Just select "yes" here Stuff happening. This looks good...so Beckhoff...yeah. Just wait, it's gonna do its magic. Tc/BSD That's really fancy, right? This is the installer for Tc/BSD. When I was running this the first time very recently then I thought it was a little exciting. I mean it is fun after all Now we have come to this window. Select "Tc/BSD install" And now...this is the 20 gigabyte hard drive that we created in the previous step when we configured this virtual machine so make sure this guy is selected. "Install Tc/BSD" , select "yes" Enter a password for the administrator account. We have to do what we usually do and just select a "1". I would of course encourage you to use a better password but just let's go with the classical one as password. Then it will start the installation Installation of Tc/BSD complete. That sounds good, right? Select "Ok" And just shut down. The reason I select "shutdown" is because we don't need this USB stick anymore. We don't need the hard drive with the USB stick Now that we have installed Tc/BSD from the USB stick into our virtual machine we don't need the hard drive with this USB stick. The hard drive with the USB stick we can remove. So not the one with 20 gigabytes but the other one. Remove it.
Select ok and start the virtual machine again It's "Beckhoff" there, it was a little cool. Now I knew this was gonna happen because I've been struggling with this for a little bit too long time. I'm trying to figure out why this happens So now you don't have to do it because I will explain to you what you're supposed to do so you don't have to waste the hours I had to spend to figure this out. Just press "Ok", select "edit virtual machine settings", the hard drive and check where the disk file for this hard drive is This is where the the file where your the operating system is installed that the virtual machine is using. Go to the folder where this file is. What you can do here... and delete this file that ends with "nvram". So this is the folder with your virtual machine just delete this particular file. Delete it, select "ok" and now we can power it on again "Beckhoff" there, it's a little cool And the "Tc/BSD" logo, which I think is a little fancy I think. Good job Beckhoff! Wait for it to start And now it's started. It of course looks a little bit different than Windows, than what you're used to. For anyone that has been using any Unix derivate or Linux (distribution) this is not any big surprise You login with administrator and the password that you selected in this case "1" Now we have started. This is a little interesting because here you can actually see which TwinCAT build that's integrated into this version of the operating system. It seems that Beckhoff are bundling it together with the whole operating system image which is similar to what they have done with the Windows CE images that I've been using. You get the AmsNetId of the of the PLC and the version of this operating system. So now we're ready to use it and this behaves just like any other shell that you're used to if you've been using Linux. So you can do all the stuff that that you're used to which is very convenient. I will not go too deep into this in this particular video because I'm planning to do more videos about Tc/BSD Here I will just make sure to...now I show you how to install it. Now we will also take the next step which is actually running some TwinCAT 3 software on this virtual machine. To do that we start our TwinCAT 3 development environment, in
this case I will just use the vanilla TcXaeShell Select "new TwinCAT project" Let's call it TcBsdTest *Waiting* This computer is insanely slow. Oh finally! "Add new item". Just create that PLC project While sitting and waiting here I have actually decided to build a new computer Finally, because this computer drives me crazy! Next we need to make sure to connect to our target. We have an ADS connection. Go to "router" Select "add". Do a broadcast search. It should detect it. Just select all the adapters. It should detect the virtual machine. There's no firewall stuff going on. Ah! Yeah and there we are! We can actually even see it here...Tc/BSD as OS version. Perfect. Select "add route". Password "1" or whatever password you selected. Now we have a connection to the TwinCAT PLC. To the Tc/BSD PLC Which means we have it here. So we select that as target. Not local desktop but this PLC, this virtual machine. Now let's just create a very simple program. A simple counter just a counter that increments. And activate the configuration Some required runtime license is missing Because this is a fresh virtual machine so we need some trial licenses on it to be able to run the software. Restart in run mode, yes. Login select "yes" And run. Magic! The software is running on our Tc/BSD virtual machine I want to finish by saying that I will most likely come back to the topic of Tc/BSD in future episode of this channel. So if you haven't subscribed yet please do so and press the like button if you like this video. If you really REALLY like the content that I'm doing here then please consider becoming either a YouTube member of this channel or a patreon member If you have any thoughts or any ideas or anything that you want to share then please write a comment or two. Until next time, see you!