washing machine

^^^ I agree best way to learn is on an actual job. although I am still getting familar with PLC this forum seems to be a great help. Thanks
 
Paul, I'm I being nit-picky...? Yes...

I'm wondering why you're using 16 bits for 15 (mutually exclusive) states. Don't you only need 4? Or are you doing something clever?

Go to a binary data table and pick out a block of 16 consecutive bits that will each represent up to 15 mutually exclusive states (I normally reserve bit 15 for a state change indicator).
 
Paul, I'm I being nit-picky...? Yes...

I'm wondering why you're using 16 bits for 15 (mutually exclusive) states. Don't you only need 4? Or are you doing something clever?
Yes, you are correct that you COULD do so with only 4 bits, but that adds a level of complexity that you really don't want when identifying what state you are in. Using consecutive bits makes that much easier.

Steve
 
How many bits is an INT or SHORT in a Micro? Suppose it's 8. Why not just use the value (number) to represent the state from 1-15 or 0-14? How's it easier to have a separate bit for each state?

Yes, you are correct that you COULD do so with only 4 bits, but that adds a level of complexity that you really don't want when identifying what state you are in. Using consecutive bits makes that much easier.
 
I was just thinking, checking if one bit is set is pretty easy, but so is using an EQU to check if the state variable is what you want... It's only marginally more difficult than using single XICs. The only part thwt would make dealing with that any more difficult is whether or not you understand how binary representation of decmial numbers works.
 
I like the way Paul does the sequencing, but I agree with Nathan that a value can be used instead, we have an OEM that does there programming that way and it is very clear in which state the machine is in. Both way are equally good in my opinion.
 
One advantage to individual bits as state holders is in comments. The bits can be commented for their states. The individual values of a register cannot be commented. So a rung of logic with a state bit would read naturally by looking at the contact comments.
 
The only part that would make dealing with that any more difficult is whether or not you understand how binary representation of decmial numbers works.
Yes ,Bubba(me) is going to have a problem with this one.
 
Last edited:
Well, I definitely understand the advantage of more comments, as well as being easier to understand for someone who doesn't know binary (though I would suggest that if you work on a PLc, and don't know binary, you should read up on that, it's not hard at all, and is a rather useful thing to understand at times).

But there are times where you may end up reaching the limits of memory and such on the PLC, so there are times where it's likely better to store the data as a value.
 
With the magic of indirect addressing, one can use an integer value representing the step number and use it as the indirect address of the bit in the bit word. Then we can have the best of both worlds...

N7:0 = step number
B3/[N7:0] = bit

A big disadvantage of using 4 bit binary to represent the 16 steps is that those bits are more difficult to keep straight when they are used to drive output rungs. It's pretty easy to use a 'step 4 bit' or 'step 5 bit' to turn on an output--there's only one bit on at a time. It's not so intuitive to have 'bits 0 and 2 only' (step 5) or 'bit 2 only' (step 4) to turn on an output. You have to check the states of all the bits to verify the current step.
 
With the magic of indirect addressing, one can use an integer value representing the step number and use it as the indirect address of the bit in the bit word. Then we can have the best of both worlds...

N7:0 = step number
B3/[N7:0] = bit

A big disadvantage of using 4 bit binary to represent the 16 steps is that those bits are more difficult to keep straight when they are used to drive output rungs. It's pretty easy to use a 'step 4 bit' or 'step 5 bit' to turn on an output--there's only one bit on at a time. It's not so intuitive to have 'bits 0 and 2 only' (step 5) or 'bit 2 only' (step 4) to turn on an output. You have to check the states of all the bits to verify the current step.

Well, in the case of the integer representing states, you'd ikely want to use an EQU to check the state. You don't actually need to know what the binary representation was unless you wanted to do something else. If you were controlling multiple output states that weren't mutually exclusive (so you could have state 1 and state 3 on at the time time) you could use one MOV command to set both those bits at once by MOVing the number 5 (0101 binary) into the memory. Of course, this can get hairy if you have a bunch of states that need to be able to run simultaneously (which also moves even farther away from the idea of controlling something using a collection of mutually exclusive states)

In any case, there are lots of ways of controlling things like this. Computer programmers do this sort of thing all the time. They call a variable whose various bits mean different things a flag variable, and each bit a flag. Lots of times they'll have variables called certain things that are defined as having 1 partcular bit set on (so one might be 0001, the next, 0010, etc. corrosponding with 1, 2, 4, 8, etc.) and use an or command to combine them when they set the variable. (since 0001 OR 0010 = 0011)

Anyway, I could probably go on for a long time on this sort of thing (being a hobbyist compuer programmer certainly helps with this sort of thing.)

All in all, I think I would suggest that anyone who is seriously interested in PLC programming should learn the basics of computer programming as well. It provides a different ways to look at things, and probably makes it easier to understand some clever tricks you can do on PLCs.
 
You can optimize the logic at the expense of ease of troubleshooting. Why do I clear the whole word and then set a bit? Why not just move the value I want? In this simple program it would not hurt, but I like to be able to use "find all" and see everything associated with a single state. If you did a find all on the whole word, you'll have to spend more time looking at only the states that apply to the one you're dealing with.

I only use half the bits in the word, but I always leave room for expansion. Suppose we wanted to add fault states for "fill timeout" or "drain timeout". Or suppose we added an automatic soap dispenser or bleach adder to the code. Those spare states are almost always useful in the real world of ever changing requirements.
 
I should add that this style is not my original concept by any means. I am pretty sure I have seen it used by more than one integrator and corporation over the years, I just picked the details to my liking and use it like a tool.
 

Similar Topics

Can someone please help me? I have a PLC program due very soon and I'm worried as I do not know how to do any of it.. I'm doing a washing machine...
Replies
10
Views
3,300
I have a final year project to make "intelligent washing machine PLC-based" so I need help in STL programming.
Replies
11
Views
3,997
Hi yall, I am very new at the PLC. I am working on a project that involves controlling a commercial front loading washing machine with a PLC(...
Replies
24
Views
16,868
hi i want to do a program for industrial washing machine programe ,it will have 20 step with 25 programs can u suggest me how to do the programe...
Replies
2
Views
2,908
i cant seem to make a parellel connection from the door NO. to the neutral side , like i cant put the timer in the middle of the branch parellel...
Replies
3
Views
2,220
Back
Top Bottom