Ladder Logic 306b: More on Simulation
A couple of weeks ago I taught a class to interns at Automation NTH, a local engineering and integration company. I have held classes for both customers and employees of theirs before, and this particular class (NTH University 103b) has evolved into a simulation class. As I mentioned in my Ladder Logic 306a post, last year we programmed a simulated palletizer.
Most of the class last year was focused on simply getting the auto sequence to operate automatically. It was a much more complicated application than what we did this year, which was a simple loading conveyor and pick and place.
As with last year’s class, we started by writing a System Routine. Students have been through basic PLC programming courses (generally Siemens and/or Allen-Bradley) both at their university and through Automation NTHs internal programs, so they were familiar with editing and basic ladder logic. But as with most training, which is instruction-set based, they had not learned to actually write a working program.
The next step was to create simulated inputs and outputs rather than using the physical ones on the trainer. This is the most important aspect of running a simulation rather than hooking up to one of my small simulated factories; instead of I/O responding to physical actions, the inputs and outputs need to be controlled by a simulation routine in the program itself. This is done generally with timers as shown below:
Notice that the tagnames are mapped to generic inputs and outputs. These are not physical, in this case they are DINTs. A UDT or Siemens Data Block (DB) could just as easily be used, the important factor is that they are controlled by a Simulation routine.
Above is the layout of the controller. We used an Allen-Bradley CompactLogix PLC, a useful feature of this platform is that multiple people can edit the program online at the same time.
The class lasted one week, and in general I demonstrated how the different aspects of the simulation program worked, and then students would implement their own version. Since the Auto Sequence was much simpler than last year, we had more time to add features to the program, such as Part Tracking and Recipes.
The routine r98_Sim contained all of the code that provided feedback to make the simulated machine run. If there had been time I would like to have provided a graphical simulation of the machine. I could easily do this using Allen-Bradley FactoryTalk View, but I don’t own enough licenses for every student. I am still exploring options using Visual Basic, but it seems very time consuming so far. Perhaps one of my readers is interested in pursuing this?
A quick note on the current “situation”: as some of you read in my last post, my training facility was destroyed by a tornado on March 3 of this year. This was followed by the Coronavirus outbreak, which has affected everyone worldwide. My office was only a bit over a mile or 2km from my home, which was also damaged. I am now working out of my garage and an upstairs room and like everyone else, I don’t go out for anything but necessities.
I still plan to continue much of the same work I did before, but obviously I am not traveling and teaching classes anymore. I do plan on continuing my work with Fischertechnik and my Simulation Trainers, as well as my Trainer Kits. I also still do remote programming work for ABD, and am recording a training video for Automation NTH. So I still have plenty of work, but I am also available for remote training if anyone is interested. I am not sure exactly how it would work, I do have several computers and PLC trainers, but not a lot of space. Let me know if there is interest and we can talk about it.
For those who have been affected adversely by the pandemic, my thoughts and prayers are with you.