hello everybody welcome to this tutorial
how to turn a Respberry pi by to PLC
will show you a quick setup of what you
gonna be able to do at the very end of this video
if you have the same setup at
least you can control the Respbarry pi
with anything that has a
browser on it, as well as a laptop or
mobile phone. So this is to show you the set-up
real quick
first of all let's start with down on
codesys so you go to the website
then you can go to downloads
little down below you will find Download
Center you click on the arrow you done
now a new tab open and I can actually
download codeys you need to login
so you need to create an account as soon
as you've done that you will be able to
download codesys 3.5 if you've done that
you go to the store type in Raspberry or Rasp
whatever you'll find a recipe plugin you
need to download on as well but remember
guys for this you actually need a
purchase account as well so that's
something else in the account you made
in the first bitt
down below you will find some things
about the codesys plug in some manuals
 
you already start up codesys and see if it's already running
then we go to the Raspberry pi right
now
guys actually recommend installing
Rasbian on your Raspberry pi with Noobs if you haven't
done that, I'm gonna show you the way to
expand your files as well if you have
used Noobs you can actually skipped that
part because if you've done it by Noobs
it's already expanded the files but we
will come to that later on
show starting up the remote server
So this is my Raspberry pi
here you can see your IP adres 
on the Raspberry pi
now go to menu I got in Dutch
actually so do not know what it is in
English probably preferences and there you can fined configuration and then
you can find file expended at the top you can do
it like this or you can go to the
terminal and there you can type in: sudo resp-config
with this you
open up the configuration window of Raspbian here you see file exspent you can actually click on
if you still need to do that,  what you
can do as well, you can go to Advanced
Options you can actually go through she
what I to see connections serial
connection
yeah it's real nice, you can change hostname as
well, then we go back to codesys
it should be still up, or in my case
it's still up, go to package manager
there you see the Raspberry pi
package that you need to install
any pres on install and it will run it, I
already installed it so it's not necessary
anymore, and after that you go back to
tools again go to update Raspberry pi
now with this you need filling your IP
address
your password and hostname, and now we can
actually  made connection with the Raspberry pi
if you have done everything correctly you should she update
finished at the bottom, right now you can
go to new project be sure that the
standard project is selected
give it a name I just give it a random
name like I do all my projects and now
it starts to run a pop-up message but
that's because already made one with that name
here you can actually select on what device
you want to program on, so we chose
the Raspberry pi and my case down below
you will see certain programming languages
you can use Ladder and
you can use script language, function-blocks
whatever you comfort with
structural text is even possible
press on ok, now will load everything in
now it will load in the PLC-PRG
think you actually need that to run
this program it's like you're familiar
with Siemens it's your OB, allright I'm
going to program in this just put a
lamp on switch, this it's going to be a
button is just a boolean in a way you can
see below you can actually change it
into an integer away if you like click
on OK down below you saw description, you
can add description some description as well
this is going to be a lamp_stat so this is
going to be a set coil
With this i am going to set the boolean to one, high ore whatever you wanna call it
And now a lamp_off button, this is boolean as well
put a reset coil on it, if you klick next to it you can go
you can go to this window and select all your
variables, i select lamp_stat
that's a small program that will run, go to application add
object: visualization I always
activate symbols as well
starts to load now we have visualization
manager web browser as well, first of all
make a button, sorry it's a lamp
and down below you can actually
set it's color, normally it's on yellow, I'm turning it on green. Then go to variables
click on the right thing again, go to
application go to program, then select variables
in this case lamp_stat
so I'm gonna create buttons completely on
myself, that's more fun, you got more
stuff you can do, as you see you can juse two colors,
it will slightly bent into the other
color you can use one color as well, as you can see down below
press on ok again, give it a name, select 'use gradient color' box
handy something of this program you can
use ctrl-copy, ctrl-paste and copy it all
with all the settings that ar in. I'm gone name this one off and change its color
that was that, ow wait. We still have to put variables in
go in to inputconfiguration you
select tap not toggle
once thats done, you go to webvisualization.
Ad the top you see the visualization that you gone load
we just have one, so that's not a problem
and the bar down that is what its gonna be called
 
right now you go to your IO, GPIO you see them in the left bar, next to go to the parameter
here you set GPIO you going to use to input
or output, in our case a output
then you go to "GPIO mapping" you search for
the same GPIO, in my case BIT25, go down to
25 BIT 25 and I'm gonna set variable to
it and that's going to be the lamp_stat
now lamp_stat go's on which switch  GPIO 25 on. After that you go to Device in the top, then you search for
network it's in the top,  scan
for network and select your raspberry pi
then go to the top, to
'login', and then press yes, my case I had the
wrong device selected, select the right one and do a login again.
my cases there is already program in the Raspberry pi,
that's why had pop up screen
now it's putting the program into the
Raspberry pi. Now where gone see what's happening
its in STOP mode like a PLC, so klick on it and put it in RUN mode
Left klick on it you should have the  start option and now it's
running so now I should be able to approach it
you type in the IP address, then you type in ..
the port number normally it's 8080 and
then the name of the it
and now you can see the light in de back turning on, now I'm going to do that with
my phone as well just starting internet, you can make a smaller you can adapt it
now you see turn it on and turn it off
soon I'm about to make some more videos
quality of the video is going to be
better, until then have a nice programming and good luck
