adccommunitymod (AutomationDirect) asked a question.

Beginner question: Visual Basic programming of a PLC...?

Created Date: May 13,2010

Created By: spinjector

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

Hi all, I'm the broadcast engineer for a company with six radio stations, and I'm looking at unifying all of our facilities & equipment onto a single DAQ/Control network with PLC devices. In reply to a previous question I posted here in the forum, someone suggested I take a look at the DL205 series of controller. My reaction is "Well, I guess it kinda looks ok... "... Hey I'm a newbie... =-) To continue - I have a basic question that will guide my search further: Are there any PLC devices that use Visual Basic or similar event-driven programming commands? Everything I want to do is in my head right now and floating around in VB code. I don't really have the time or inclination to learn the ins & outs of a new language such as RLL or iBox or any of the others I 've seen mentioned. If there are VB-like languages, can the code be compiled and uploaded to a PLC so it can operate independently of a PC..? Thanks.


  • adccommunitymod (AutomationDirect)

    Created Date: May 13,2010

    Created by: Do-more PE

    There are a few Windows CE PLC's out there, but the majority of PLC's program via ladder logic or similar language.

  • adccommunitymod (AutomationDirect)

    Created Date: May 13,2010

    Created by: krak

    Just a note, All PLCs can and usually do operate independently of a PC. You will have a hard time finding a PLC that will run on VB, however there are some microcontrollers that have dumb down versions of VB like a PICAXE, or dumb down c language used by an Arduino. Both offer some good libraries and have hardware to add to make them useful, however I would not recommend putting either of these on anything other than a hobby project. They are just not robust enough to handle tough conditions.

    RLL plus, aka stage programming, can be setup to be an event driven program. This is why I use it so much. It is closer to computer programming than RLL. I, as well as many other people on this forum do RLL and RLL plus programming for a living. So you may want to consider asking for some help. Most people here will teach you along the way of the project so don’t have to learn a new language by jumping in with both feet at once.

    What were you planning on using the PLCs for? Other than data collection that is.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 14,2010

    Created by: AZRoger

    I'll 2nd using Stages and suggest SET & RST too

    spinjector,

    I too came from a background of Visual Basic programming.

    RLL "lines " just look like naked "IF "s with no "THEN "s and no "ELSE "s.

    Everything is like BoolVar = Input1 AND (Input2 OR Input3) where BoolVar is equivalent to an OUTput Coil.

    What helped me bridge the gap was using the SET and RST commands instead of the OUT coils used in most of the examples and using Stages to keep track of where I am in the process.

    So you code the logic as ANDs, ORs, Compares, ETC. and when the result of all the logic is TRUE, then SET or RST a "variable " (often a coil) or JMP to another stage to perform the desired action and reflect the change in state of the system.

    When the result of the logic is FALSE, nothing will happen. Using stardard RLL OUT coils, something always happens and it's a major mind shift for VB (or any procedural language) programmers to think of logic that way.

    Use Stages to keep track of the state of affairs (like outer layers of nested IFs) and the SET and RST boxes to record changes only under the conditions when you want to change things.

    It took me a couple years (which you don't have :)) to settle on this programming style. Hopefully, this will help you get up to speed sooner - or convince you to outsource or get formal training as suggested above. ;)

    Roger

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 14,2010

    Created by: franji1

    Stage is a way to do Sequential Function Charts, but its represented in a ladder (linear) type program. SFCs are a subset of Petrinets, where a stage can have 0 or 1 tokens, but not more than 1 token, but multiple stages can have a token at any one time.

    So Stage 1 could have a single transition to Stage 2, based off some event firing (e.g. a timer). Or it could be a switch-type branch such that Stage 1 will jump to Stage 2 if condition X is reached, or Stage 3 if condition Y is reached, or Stage 4 if condition Z is reached, where X, Y, and Z are all "disjoint " (e.g. if/else if/else if/else, or switch).

    You can also fire off multiple stages to run in parallel, e.g. Stage 1 could fire off Stage 2, Stage 3 and Stage 4 all when event X happens.

    Or, you can do any combinations of the above from within a single stage, so the entire stage flow diagram could have 100 stages, with 5 to 10 stages active at any one time.

    Note that Stage is NOT SFC syntactically, but if you can grasp the semantics of SFC, you can probably develop Stage programs. Here is a very brief overview of the syntax AND semantics of SFC (not Stage) http://www.ecgf.uakron.edu/grover/web/ee491/slides/SFC.pdf . When SFC uses the term "Step ", think "Stage ". Ignore all the "GOTO " stuff (goto's are bad). Also, ignore any references to "Structured Text " or "Instruction List ", but pay close attention to the RLL. I believe SFC's EOT (End of Transition?) Ladder instruction is similar to Stage's JMP instruction, except you specify the destination Stage in the JMP instruction (e.g. JMP S3 will "transition " from the "current " stage to Stage S3 whenever the input logic to the JMP instruction is TRUE).

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 17,2010

    Created by: spinjector

    What were you planning on using the PLCs for? Other than data collection that is.

    Well... To put it in a very large nutshell, we have our main offices/studios, and six remote transmitter sites out in the hills. Everything is linked by T1. We currently have what I feel is an outdated, inadequate, and staggeringly overpriced remote control system that is fixed at 16 analog inputs, 16 digital inputs, and 32 digital outputs. There is a pair of units for each transmitter, and each pair costs about $10,000 to get up & running with all the necessary options - like a voice dialout card that calls you and plays pre-recorded messages when an alarm condition arises.

    Every site has a variety of equipment with simple ground-referenced remote control inputs & outputs, which the digital I/O of any PLC will handle nicely. Some equipment has voltage-sample outputs, such as the transmitter output power, antenna power distribution system, and the 208V/3-phase voltage monitors for the building AC. These of course would be handled nicely by the analog inputs of any PLC.

    One can divide the transmitter sites down into a variety of subsystems such as transmitter1, transmitter2, RF power distribution, HVAC, security & access control, heat & fire, all the little gadgets that have "alarm " and "warning " lights on them, and then there are even complex devices that have RS232 interfaces with ASCII commands that an operator would enter in a terminal program like Procomm Plus.

    So... With all that said, I'm sort of envisioning the following:

    Each subsystem would have a small(ish) PLC. For instance, each transmitter, the generator, HVAC, security, etc. Each of those PLC would have the appropriate sensors and programming to respond to alarms, and receive remote control commands from me to switch to certain modes, etc.

    Then all these PLC sub-systems would talk to a "boss " PLC that would perform logging & process control and communicate back to the offices/studios. Then here at the studios would be another PLC or a full-PC system that would run process-control software with onscreen gauges, and graphs, and button controls, and provide web-server access, email/txt-messaging for alarms, and all the other kinds of bells & whistles that one can do with a PC if you know how to program with VB & API interfaces.

    My "endpoint goal " is to have complete control of all systems from any web browser anywhere in the world, from the PC on my desk at home, to the web browser on my HTC cell phone when I'm on top of my favorite skill hill at Mont Tremblant in central Quebec.

    So I figured I'd start small, with one PLC hooked up to one transmitter, and connect one wire at a time, designate its function, get it to talk to the system back at the main office, and then slowly build up from there.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 17,2010

    Created by: spinjector

    spinjector,

    I too came from a background of Visual Basic programming...

    Thanks, Roger.

    Your explanation made sense, but I'm sure I'll start getting it firsthand if I go through with this. I 've always found that once you 've learned your first programming language and all it's tricks (which I did with Atari-400 BASIC when I was 10 years old.. LOL), it's not much of a jump to learn the next (and more) languages. Logic is logic, all that changes is the way it's expressed. The difficult part is punctuation. =-)

    As for outsourcing? Heck no. I'm a selfish geek; I like to do it all myself. =-)

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 17,2010

    Created by: spinjector

    You can also fire off multiple stages to run in parallel, e.g. Stage 1 could fire off Stage 2, Stage 3 and Stage 4 all when event X happens.

    Ahh... Bingo! I was wondering about this topic, because one of the complex issue I'll have to deal with is our RF-contactors. These are big 220-volt solenoid activated relay-like devices that route the RF power depending if it's day or night, main/backup transmitter on the air, etc. There are about 20 of them and they all have to be in certain states in certain modes or fire & damage will result. =-)

    All the rest of what you said, I understand the words but not the meaning - but I'm sure I will in time.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 17,2010

    Created by: milldrone

    solenoid activated relay-like devices that route the RF power depending if it's day or night ,

    Make sure you choose a model with a "real timeclock " (RTC).

  • adccommunitymod (AutomationDirect)

    Created Date: May 18,2010

    Created by: krak

    Now this sounds like it will be a fun project. I would steer away from using too many PLCs as subsystems. The programming can be done on one 250 with option cards to keep it clean and organized. Add a Cmore to each site and you can have the remote monitoring and control you are looking for, as well data logging and alarming. I’m not sure it can be done with just a HTC cell phone, but if your cell phone can run VNC or Remote desktop then you should be able to set up one computer to have your cell phone have access to.

    I can completely agree with being a selfish geek, and doing it yourself. In that case you will want to get the trainer kit videos from Doug Bell. AD also has a good knowledge base on its Learn site. Find a few small up projects to use a plc on. The project you are describing is not exactly beginner level work. You understand logic, so I bet you will pick the programming quickly.

    To start on your project, you will likely want to start with a flow a chart. List all the inputs and outputs. Work through the chart for all your actions, alarms, reactions, shut down, and safety concerns. Once you have done that, the programming is easy.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 13,2010

    Created by: spinjector

    Hi all,

    I'm the broadcast engineer for a company with six radio stations, and I'm looking at unifying all of our facilities & equipment onto a single DAQ/Control network with PLC devices.

    In reply to a previous question I posted here in the forum, someone suggested I take a look at the DL205 series of controller. My reaction is "Well, I guess it kinda looks ok... "... Hey I'm a newbie... =-)

    To continue - I have a basic question that will guide my search further:

    Are there any PLC devices that use Visual Basic or similar event-driven programming commands? Everything I want to do is in my head right now and floating around in VB code. I don't really have the time or inclination to learn the ins & outs of a new language such as RLL or iBox or any of the others I 've seen mentioned.

    If there are VB-like languages, can the code be compiled and uploaded to a PLC so it can operate independently of a PC..?

    Thanks.

    Expand Post