Making a PLC

A

Thread Starter

afshin

I want to know how to make a plc with an 8951 (a microcontroller from intel or atmel 8031 family). Can anyone help me?
 
I will be far less expensive (not to mention more reliable) to buy one than to make one. Unless your doing it for a school project, in
which case you should earn your own grade and do the work yourself.
 
H

Helge Slettvoll

Agree! But perhaps you just want to put a few PLC functions (logical functions) into the controller. The clue with PLC programs is that they are cyclical (ever repeating loop). I have once done this with a C-program. Much labour and little diagnostics. Unless this should be mass
produced, consider an ordinary PLC.
 
J

Johan Bengtsson

Well, were to start....

That does not sound like a small task, so the first question is of course: Do you really want to do that? why?

The "normal" use of a microcontroller like that is to directly write the control program in assembler or C, not to make a PLC with it. If you really want a PLC, get yourself a PLC. if you want to use those microcontrollers to do a specific task, skip the PLC part and program the microcontroller to that specific task.

Now, it is of course possible to make a PLC of a microcontroller, but it will not be a very good one.

You have to decide for an instruction set, make an interpreter for this instruction set and write communication routines to upload/download the program from the internal memory.

For simple logic you need:
instructions for input bit
instructions for output bit
instructions for logical operators
instructions for grouping these (ie paranteses or a stack)

One of the simplest instruction sets would be a completely stack oriented instruction set like:

LD (load input bit or memory location)
ST (store output bit or memory location)
INV (invert topmost stack contents)
AND (and the topmost two stack contents, push back to stack) OR (or the topmost two stack contents, push back to stack)

With these 5 instructions you can do all logic you want.... perhaps not the most effective instruction set but it would work.


You would like a ladder editor for your new PLC but that is of course not completely necesary....


/Johan Bengtsson

Do you need education in the area of automation?
----------------------------------------
P&L, Innovation in training
Box 252, S-281 23 H{ssleholm SWEDEN
Tel: +46 451 49 460, Fax: +46 451 89 833
E-mail: [email protected]
Internet: http://www.pol.se/
----------------------------------------
 
Johan Bengtsson:
> One of the simplest instruction sets would be a completely stack
> oriented instruction set like:

> LD (load input bit or memory location)
> ST (store output bit or memory location)
> INV (invert topmost stack contents)
> AND (and the topmost two stack contents, push back to stack) OR (or
> the topmost two stack contents, push back to stack)

> With these 5 instructions you can do all logic you want.... perhaps
> not the most effective instruction set but it would work.

Note that with only very slight modifications, you get the usual ladder
mnemonics:

LD (load input bit or memory location)
OUT (store output bit or memory location, but do not pop the stack) AND (and memory location/input/output into topmost stack contents) OR (or memory location/input/output into topmost stack contents) AND-BLOCK (and the topmost two stack contents, push back to stack) OR-BLOCK (or the topmost two stack contents, push back to stack)

Instead of INV, make LD-I, AND-I and OR-I variants; and fix the stack so that the bottommost element is discarded on overflow (not an error).

That's it.

Jiri, author of the MAT mnemonics compiler
--
Jiri Baum <[email protected]> http://www.csse.monash.edu.au/~jirib
MAT LinuxPLC project --- http://mat.sf.net --- Machine Automation Tools

 
J

Johan Bengtsson

Yes I know, the reason for this (perhaps not very clear) was that these would be the bare minimum to solve the problem and more instructions mean more programming of the interpreter inside the chip. There is also not anything preventing making an additional step before uploading the program translating those standard instructions to this basic set

LDI
becomes
LD
INV

AND
becomes
LD
AND

ORI
becomes
LD
INV
OR

But of course that isn't anything new, my thought was to make it as simple as possible to actually implement, in a chip like that it is probably the way I would have solved it anyway and put the rest of the responibility on the programming tool (in ladder <grin> instead)....


/Johan Bengtsson

----------------------------------------
P&L, Innovation in training
Box 252, S-281 23 H{ssleholm SWEDEN
Tel: +46 451 49 460, Fax: +46 451 89 833
E-mail: [email protected]
Internet: http://www.pol.se/
----------------------------------------
Do you need education in the area of automation?
 
Top