# PLC programming mathematical operations

### PLC programming and mathematical operations

Let’s talk about mathematical operations in the allen bradley plc. There are four main operations which you can use when doing calculations in your plc program. Here is a basic overview of these operations. We get the same operations as we would in conventional programming languages as you may have guessed. We have addition, subtraction, multiplication and division operations which we can use in our plc programs.

### What are the operations in plc programming?

MUL is one of the operations that can be used. It is important to note that constants are only allowed in one source value at a time. As it generally is quite pointless just multiplying two constant numeric values together over and over again. So be sure to make use of only one constant on your rung. MUL is the multiply operator and allows you to multiply two values together and store them in the Dest register.

DIV is the division operator and can be used for any division which you need to do. Depending on the dest type you could potentially have a rounded off value if it’s an integer or a value with decimal places if not.

ADD as you may have guessed is for addition in your plc programs. It too uses two source values and saves to a dest value.

SUB is subtraction and can be used to do subtraction calculations. Same as with add it uses two source values and yet again saves it to dest value.

We have put together a small example of what this might look like in your ladder diagram below. It should be quite simple to see how all this fits together if you look at the below diagram.

plc programming mathematical operations

Some other plc programming resources which you can look at

plc programming website – plc programming
plc programming in pretoria – plc programming in pretoria

# PLC Programming what language is used to program PLCs

### PLC Programming what is the language?

Unlike conventional programming language paradigms which make use of some type of if else conditional type constructs. PLCs make use of a logical circuit type methodology called ladder. Ladder consists of rungs and branches which is used to add instructions to your plc programs. These allow of certain inputs and outputs on your plcs to be turned on and off with basic logic. Ladder is a graphical language which can be drawn with some logical form in order to control your plc unit.

### What software do I need to program ladder?

Generally it is common to make use of some software which contains the ladder functions. Software such as rs logix is used to program ladder logic. Here is an example of ladder logic in rs logix.

Ladder example of a plc program

Some of the most basic instructions can build quite awesome programs. Just with XIC, XIO and OTE you can build so many circuits. XIC is examine if closed. XIO examine if open and OTE is output energized. Outputs sit on the right side of your rungs on your ladder program. On the left is your inputs of your program. The left gets evaluated then executes your outputs. XIO will be evaluated when the switch is open. The easiest way to learn to program in ladder is to create your own little project and build it in the rs logix platform.

### What do I need to learn next?

Start by learning a few ladder instructions there quite a few more such as ons,osf,osr, ton and more which will allow you to do more complex ladder programs later on and really improve your skills. Below are some more free plc programming resources which you can check out. The owner of the blog updates it with new tutorials all the time and gives a positive spin on the content.

plc programming

plc programming tutorial

# Getting ideas for your rpg development

### Introduction

So you have been wanting to develop and rpg now for a while, but haven’t actually sat down to think about what is required to build the rpg. You haven’t even really formulated a solid idea as of yet. In this tutorial we will share methods to bring your ideas to the surface.

### How to get some ideas for your new rpg development project?

It is always a good thing, to look to some of your favorite rpg games for some inspiration. We not saying copy those ideas, but rather write down what you like about each of your favorites.

This should give you some insight into what makes those games so compelling. Let’s look at for example one of the top favorite rpg’s out there. For example the Pokemon series was highly popular amongst all ages and nationalities. Let’s ask ourselves what made the game series so compelling. Was it the large following of the television series which made it so popular or was it the idea of being able to live inside the world of Pokemon.

### Let’s create a list from one of our favorite rpg games

Screenshot of home screen of our favorite rpg game

In our point of view here are some of the top things that made the Pokemon rpg game series great.

1. Vast amounts of Pokemon which you can catch and the drive for wanting to catch them all.
2. The large number of abilities which each Pokemon had, made the games interesting and allowed for a lot of variety.
3. Pokemon types created the effect that you needed actual knowledge of the Pokemon’s type to be successful in the game and beat various opponents. In order to counter various elements or abilities.
4. Monetary system, the games allowed you to earn money and by special items with the money you made creating an additional drive.
5. Badge collection, this enforced self worth and the impression that you have earned your stripes.
6. A rival the rival portion of the story line introduced competition in the game, which made you want to become an even better trainer.
7. Story, the story of a small town kid going on to become a great Pokemon trainer. Everyone loves a small town success story.

Take your favorite rpg and just write down a few things which you found awesome about it. It could be something like weapons like you have in The Legend of Zelda.

Screenshot of our favorite rpg game encountering the rival

### Decide on a theme for your rpg

Try and create a setting for your rpg, is it in a dark world infested by vampires and zombies. Is it playful with candy everywhere. Is it educational with learning objectives along the way. It’s always good to remember if you are going to try commercialize your game if your game will fit your target audience. However we always advise to build your game for the love of it first rather than going in with a commercial model from the beginning. Games with passion sell, not commercially copied and pasted together.

### How to get ideas for a story line

Look to your own experiences in life or that of family and close friends. Everyone has a story, maybe you have an uncle you see as a super hero. Why not explore this character as part of your game story. Perhaps a hero in your community. Every game needs a hero and every game needs a villain. Find yours and grow it from there. Write up a fictional history on your character. Fictional goals which you think your characters have and this will point you in the right direction in getting the story line of your actual characters as well in your game.

Here are some extremely useful resources for rpg game development tutorials:

rpg development tutorial

rpg development tutorial part 2

# Ever wanted to develop your own platformer game?

### Where to start development of your platformer game?

Generally game development has not been a lucrative business and is mostly for hobbyists which want to just develop something really fun and awesome. Which is why this article will point you in the right direction to start thinking about how to create your platformer game in such a way that it can be captivating for your player and make it fun. The technical details we will point you in the right direction as well so that you can actually start to build your game. Here is an awesome tutorial series on platformer game development. We highly recommend following this series to get more insight into the actual programming of the game. There is a video tutorial and many graphical illustrations of how it is done.

### What will help make my platformer game fun?

The biggest issues often faced in platformer games are the frustration that it can often bring to the player. Things such as :

1. Confusing environments often this happens with too much movement in the background. This can cause the player to loose focus of what actually needs to be achieved. Make it easier for them to understand your level in your platformer.
2. Hazard clearance distances, often there is a hazard which a player needs to avoid. Don’t make it close to impossible to avoid, this will not challenge your player but rather give them a feeling of failure and frustration.
3. Gravity often plays a role, make it a little fun by allowing your player to move in a direction while in the air after jumping. This just gives them some extra control and allows them to master new ways of completing tasks in the level.
4. Power ups and rewards, it’s good to reward your player for completing challenges. Even though this is advised do not grant your player special items too easily. This might make the game lose it’s challenge factor or ambitious factor. Keep your player greedy and ambitious to get the next thing which they need to level up or improve their player.
5. Create interaction and mystery elements to your game. For example killing an enemy gives your player the ability to use the enemy to throw something at another enemy.

### Platformer game development resources

In this platform game development tutorial you will learn to build something similar to this:

platformer game development tutorial

# Artificial intelligence in games

## What is artificial intelligence?

Artificial intelligence in the context of gaming is usually referred to the computer, game AI or enemy engine. Artificial intelligence techniques are employed to make games more challenging and more fun and compelling for the player to play. In this tutorial we will be discussing some artificial intelligence algorithms used in game development as a whole. With some examples of where each can be used in your games.

## Artificial intelligence algorithms

Some of the artificial intelligence algorithms you will encounter are the following:

1. Neural Networks
2. Mini Max Trees
3. Decision Trees
4. Genetic Algorithm
5. A* Path finding

### Neural Networks

Neural networks in the simplest form tries to simulate human brain biology by having a network of neurons which fire when a certain thresh hold is reached. If the outcome of the neuron firing does not produce the desired outcome back propagation is employed to correct the thresholds of the neurons to make them only fire under certain circumstances in order to produce the required result.

### Mini Max Trees

Often used in solving game AI problems such as chess, checkers, uno and other turn based games which have an X amount of combinations. Mini Max trees employ a scoring approach to decision making where a score is calculated for each possible move which the artificial intelligence algorithm can take and then chooses the best possible outcome and prunes down on the worst possible outcomes.

### Decision Tress

Similar to mini max trees. Decision trees allow for multiple decisions which a artificial intelligence player can make on a particular game.

### Genetic Algorithm

Genetic algorithms try to simulate biological evolution over time. Genetic algorithms generally can be used to find the most optimal way of AI completing a level in a game or killing the player or whatever the goal may be. Genetic algorithms or GA’s as they are known as do this through breeding a large population of outcomes together and pruning of the ones which have the least best outcome then re breading the higher performance individuals to produce even more optimised artificial intelligence.

### A* Path finding

This form of algorithm divides a level into zones or a smaller grids which can be used to calculate manuvers around obstacles in your games. An example of this is counter strike bots which can navigate terrain even though they have never been exposed to a particular map.

To find out more about artificial intelligence and specifically genetic algorithms. Check out this tutorial series : Artificial intelligence and genetic algorithms

# How to start making games

## What do I need to learn to make games?

Depending on your ability you can go quite a few routes. There are some tools which will allow you to make games without any real programming experience. Where it is purely drag and drop and configuring a game. However these platforms can have their restrictions and it is always advised to learn some type of programming in game development. There are quite a few options if you want to get into the programming route.

## What are the languages I need to learn?

For game development there are number of options. Some of the most popular languages to know is c#, c++ and java script. Some game engines such as unreal engine makes use of c++ as a coding language. Unity engine you can develop in c# or java script. We however prefer a game library called phaser. Mainly it allows you to leverage skills in HTML5 , CSS3 and Java script to build your games. Also games can quite easily be ported to mobile devices such as android and ios. One of the reasons we recommend Phaser is that it allows you to learn key concepts in game development. Also teaches you logic and allows you to get in depth exposure to building your own games with a real life programming language.

## Where do I start?

On this blog we have a number of tutorial series which we will be giving away for free. Also you can join our newsletter where we will be constantly be sending you newsletters on new tutorials we publish and updates in terms of latest trends in making games. We are in the process of writing a book on game development where we will teach you to build a full game. If you are interested in getting first picks when we release our book you can subscribe to our newsletter and you will be the first to know.

For now you can checkout some of these tutorials.

Phaser rpg tutorial