Programming a small PLC/PLR in BASIC?


Thread Starter



I'm looking into an application that will need a small PLR/PLC (few inputs and outputs, very simple HMI) yet will need more advanced programming capability. I've looked at ladders and FBD's and don't think they can easily handle some complex functions. Structured Text might work, so this could be my fallback, but I'd prefer a more BASIC-like language (I am more familiar with programming languages than PLC programming). Can anyone give me any pointers to a PLR or PLC that is inexpensive but has this programming capability?

bob peterson

It depends entirely on what you mean by complex functions.

If you are mostly referring to the more common math functions, the AB SLC and compactlogix processors have a compute instruction in RLL that allows you to enter a fairly long mixed algebraic expression. The length allowed is far longer than you would probably want to use for real applications as it's handy to have intermediate results for testing.

I created this expression and compiled it as an example.

I have been looking for this for years now and have been kind of disappointed. Here’s the thing:

- You can get PLCs that run a programming language that is text, and usually they are a bit goofy on some things like data types, array handling, etc. One PLC I had used, for instance, had a Structured text language and we tried to use a variable name in a case statement and it would not compile. Very hoky.

- Most PLCs operate on the typical scan philosophy even though they may offer another language. This is to say that it is different if you program in C (or BASIC) using multithreaded OS vs PLC. In C if you wait for something to happen in a function call or while loop, etc that thread simply halts and the rest of the threads continue to run. On just about every PLC if you use their text language it compiles to native PLC instructions under the hood and just gets inserted into the scan. If you wait in a while loop for an input you will usually fault the watchdog timer in the PLC.

If I were to bet who might have the closest thing to what you are looking for I would bet on B&R out of Austria. They are an independent automation company that has been around for a while and looked to be the closest thing to what I was looking for last time I did a PLC evaluation. Back then (maybe 6-8 years ago) the US support was not as built up as it is now and that turned me off. I think that has changed dramatically. I think they have Basic or C language as a choice, but more importantly I think they have a RTOS at their core, so you might have more luck assigning each task to its own thread. You might have to grill the people to find this out and maybe even do your own tests on some loaner hardware. If you do please report back, I'd like to know! Their servo drives and IO seem to be nice also.

Another possible choice is Delta Tau Power PMAC. They package a linux computer with xenomai RTOS and you can essentially program in C and access their IO and servo system in your C code. Basically you are mostly paying for their motion expertise, IDE/CrossCompiler, monitoring tools, etc. They have provided for analog and digital IO and HMI so you kind of get everything in one unit. We have bought a couple of these (since most of our machines incorporate motion control) and are going to test them when they come in.

Having said all of that, you can do some things to make PLCs act higher level. They are still somewhat of a disappointment but there are a lot of tricks available.

Good luck.

Look for "single board computer" with Google and you will find lots of them. There is lots of choice and your problem will be deciding which one you want.

curt wuollet

And of course, you can add IO to an existing PC and write in whatever you want. If you have a PC in the plan.


Thanks everybody, I will look into your suggestions. You are right, I don't see an obvious answer, but you've given me a few good paths to investigate.
There is a Microcontroller (dfl28Ucb110) , which executes the basic language. and you can set break points and view the basic language's variables and array elements. You can download your object code to Microcontroller by RS232, (Of course, debug is using the rs232 too).

This Microncontroller supports GPS and CAN bus too.

Details is in the