# PLC practice



## thegoldenboy (Aug 15, 2010)

Two proximity sensors that have to be in agreement with each other within 5 seconds, or it throws a fault. 

Just something I see on a daily basis. I don't write program though, interested in picking it up.


----------



## dronai (Apr 11, 2011)

Because you might want to control more than that one motor with that relay


----------



## dronai (Apr 11, 2011)

Check out this schematic, we were just talking about this in this topic
http://www.electriciantalk.com/f2/120v-ac-relay-chattering-55756/


----------



## dronai (Apr 11, 2011)

thegoldenboy said:


> Two proximity sensors that have to be in agreement with each other within 5 seconds, or it throws a fault.
> 
> Just something I see on a daily basis. I don't write program though, interested in picking it up.


 

This is not correct yet, still working on this one.


----------



## thegoldenboy (Aug 15, 2010)

dronai said:


> This is not correct yet, still working on this one.


I've got it drawn out in our shop, I'll take a look at it tomorrow. I'll throw it together in MSpaint when I have the chance and post it back here.


----------



## LATTC (Feb 12, 2012)

thegoldenboy said:


> Two proximity sensors that have to be in agreement with each other within 5 seconds, or it throws a fault.
> 
> Just something I see on a daily basis. I don't write program though, interested in picking it up.


Little long because I added a reset button


----------



## dronai (Apr 11, 2011)

That's much longer than I thought it would be !

here's my attempt, but I can't get the done bit to stop the ride yet.


----------



## LATTC (Feb 12, 2012)

dronai said:


> That's much longer than I thought it would be !


Sorry, I added couple of safety features to the program.


----------



## LATTC (Feb 12, 2012)

*Multiple Stop Start Station*

Control one motor with multiple stop start stations.
Stops are in series
Starts are in parallel


----------



## dronai (Apr 11, 2011)

Why did you use an error state, and a fault light ? I'm loading yours now to test
And what is the clear on rung 1 ? Never used that


----------



## LATTC (Feb 12, 2012)

*Forward Reverse*

Forward/Reverse the motor using contact interlock.











The concept of interlocking can be applied to many applications.


----------



## LATTC (Feb 12, 2012)

dronai said:


> Why did you use an error state, and a fault light ? I'm loading yours now to test
> And what is the clear on rung 1 ? Never used that


It clears the memory.

Its good programming practice to use a binary bit instead of going directly to output.

You wanted the fault light to come on if the 2nd prox sensor did not detect an object within 5 secs.


----------



## LATTC (Feb 12, 2012)

*Run Jog Selector Switch*

Run and Jog Control

We use a selector switch to set run or jog mode.
Run mode will set the seal in bit 1:1/4 to 1 (on)
Jog mode will set the seal in bit 1:1/4 to 0 (off)


----------



## dronai (Apr 11, 2011)

LATTC said:


> It clears the memory.
> 
> Its good programming practice to use a binary bit instead of going directly to output.
> 
> You wanted the fault light to come on if the 2nd prox sensor did not detect an object within 5 secs.


Your reset button does the same job as the clear memory doesn't it ?


----------



## LATTC (Feb 12, 2012)

dronai said:


> Your reset button does the same job as the clear memory doesn't it ?


Just clears the fault light. You don't want that light on all day long.


----------



## dronai (Apr 11, 2011)

LATTC said:


> Just clears the fault light. You don't want that light on all day long.


 

Regarding the Clear instruction:
I see that, I just couldn't find any logic that would stay in the memory after the seal in circuits are dropped out by the NC contacts.


----------



## LATTC (Feb 12, 2012)

dronai said:


> Regarding the Clear instruction:
> I see that, I just couldn't find any logic that would stay in the memory after the seal in circuits are dropped out by the NC contacts.


s:1/15 the rung will only run once when the program first starts. It is called a initializing bit.

clear == MOV 0000H --> B3:0

so for example:
my B3:0 has some random data 1001 0001 1111 1000
the clear instruction will do this 0000 0000 0000 0000


----------



## 04-20ma (Aug 21, 2011)

You guys are thinking like electricians. U gotta think like a programmer. Just cause its ladder logic doesnt mean relay logic. 
Put the two prox switches in seris with xic`s with a tof instruction. then use the dn bit to trigget the alarm.


----------



## LATTC (Feb 12, 2012)

04-20ma said:


> You guys are thinking like electricians. U gotta think like a programmer. Just cause its ladder logic doesnt mean relay logic.
> Put the two prox switches in seris with xic`s with a tof instruction. then use the dn bit to trigget the alarm.


Can I see some code.


----------



## 04-20ma (Aug 21, 2011)

| p1. P2 |
|----] [----] [----------|tof|----|
| |
|----] [-----------------( )------|
dn. Flt


----------



## 04-20ma (Aug 21, 2011)

That didn't look like that when I sent it but ya get the giff?


----------



## LATTC (Feb 12, 2012)

How's that going to work?

Requirements
conveyor belt with 2 prox sensor down the line.

1. Prox sensor 1 detects object

Prox 2 is located down the line.
2a. Prox sensor 2 detects object within 5 secs.
or
2b. Fault light goes on.

your program:
both prox 1 and prox 2 has to detect before timer goes on to 5 sec and fault light goes on.


----------



## 04-20ma (Aug 21, 2011)

Ok I misunderstood what u wanted.


----------



## LATTC (Feb 12, 2012)

04-20ma said:


> You guys are thinking like electricians. U gotta think like a programmer. Just cause its ladder logic doesnt mean relay logic.
> Put the two prox switches in seris with xic`s with a tof instruction. then use the dn bit to trigget the alarm.


I remember back in school. I wrote a really sweet little program using sequencer. The instructor looked at my code and said, "Nice! You know one of your fellow classmates will be maintaining that code?"

Needless to say, I rewrote the program.:laughing:


----------



## starter (Oct 24, 2010)

Great pratice keep at it.


----------



## 04-20ma (Aug 21, 2011)

There ya go.


----------



## LATTC (Feb 12, 2012)

That only works if the product is stuck on the first prox switch. What if the product is stuck in between the sensors.


----------



## LATTC (Feb 12, 2012)

*Sequence control #1*

A basic sequence start where the first motor runs for 5 seconds before the 2nd motor starts.


----------



## LATTC (Feb 12, 2012)

*Sequence Control #2*

Operator pushes start button
1. 1st motor starts
2. 2nd motor starts after 5 seconds.

Operator pushes stop button
1. 2nd motor stops
2. 1st Motor stops after 5 seconds.

We really should use a on-delay instead of the off-delay. I'll leave the conversion to you guys.


----------



## LATTC (Feb 12, 2012)

*Solving Logixpro door simulation*


----------



## LATTC (Feb 12, 2012)

*Solving LogixPro Silo Simulation*


----------



## denny3992 (Jul 12, 2010)

This is were i got stuck, as i dont have any formal plc training....


----------



## LATTC (Feb 12, 2012)

denny3992 said:


> This is were i got stuck, as i dont have any formal plc training....


which part?


----------



## denny3992 (Jul 12, 2010)

LATTC said:


> which part?


The batch feed conveyor line.... I like the graphics and sound when u overflow.... Hilarious


----------



## dronai (Apr 11, 2011)

1. What are you using to capture the image ? 


2. Can you give a demonstration of a MOV and a way to emulate an encoder for my elevator tracking by using it ?


----------



## ScooterMcGavin (Jan 24, 2011)

If you have windows Vista or above, there is a great little program in the accessories folder called the Snipping tool. It lets you capture a window, rectangle, whole screen, or even a free form screen capture. I am not sure if you can get it for XP.


----------



## dronai (Apr 11, 2011)

scameron81 said:


> If you have windows Vista or above, there is a great little program in the accessories folder called the Snipping tool. It lets you capture a window, rectangle, whole screen, or even a free form screen capture. I am not sure if you can get it for XP.


 
Hey thanks !!! I've never used that tool. Lets see if it worked
Mustard Jar filling machine program


----------



## dronai (Apr 11, 2011)

Works for short programs, but if the program is long I can't get the whole thing in one shot like the other guy is doing.


----------



## LATTC (Feb 12, 2012)

dronai said:


> 1. What are you using to capture the image ?
> 
> Print screen and MS Paint program
> 2. Can you give a demonstration of a MOV and a way to emulate an encoder for my elevator tracking by using it ?


I need to see the program or you want a generic encoder solution.


----------



## dronai (Apr 11, 2011)

LATTC said:


> I need to see the program or you want a generic encoder solution.


 
Generic encoder. My Micro Logix doesn't have this, so I have to make something to simulate.


----------



## ScooterMcGavin (Jan 24, 2011)

Logixpro has a "save rungs as picture" option in the file menu. That's the best way to save a copy of the program as a picture especially a long one. I suspect he did that and then spliced it with a screenshot of the process in MS paint. If I recall you can choose which rungs to save as well.


----------



## dronai (Apr 11, 2011)

scameron81 said:


> Logixpro has a "save rungs as picture" option in the file menu. That's the best way to save a copy of the program as a picture especially a long one. I suspect he did that and then spliced it with a screenshot of the process in MS paint. If I recall you can choose which rungs to save as well.


 
Just figured out how to do as you described by splicing in MS Paint


----------



## LATTC (Feb 12, 2012)

dronai said:


> Generic encoder. My Micro Logix doesn't have this, so I have to make something to simulate.


Decoders do this through some combination circuit (not, and, nand gates)
*n => 2^n*

Encoders do this through some combination circuit (not, and, or gates)
*2^n => n*

Your TOD and FRD are encoder/decoder instructions.


----------



## LATTC (Feb 12, 2012)

dronai said:


> Just figured out how to do as you described by splicing in MS Paint


I really cannot see the program. Either, I am getting too old or screen resolution is low.


----------



## dronai (Apr 11, 2011)

LATTC said:


> I really cannot see the program. Either, I am getting too old or screen resolution is low.


 
It's not my work. I took it from my answer book to the lab assignments.
It's an elevator 3 floors but using limit switches instead of an encoder to track the location of the car.

I'm getting ahead of myself, and my skills are not solid enough with some of the fundamental practice.


----------



## dronai (Apr 11, 2011)

Lift Gate please check my work


----------



## dronai (Apr 11, 2011)

Check Work Please 
Ʊ


----------



## LATTC (Feb 12, 2012)

dronai said:


> It's not my work. I took it from my answer book to the lab assignments.
> It's an elevator 3 floors but using limit switches instead of an encoder to track the location of the car.
> 
> I'm getting ahead of myself, and my skills are not solid enough with some of the fundamental practice.


Hang in there. 

Most people will try to complicate it, but in reality PLC programming is very simple.

PLC in a nutshell,

```
While (true) //this is your plc loop
{
     if (input condition is this) //think of this as examine on
     {
           handle some process
     }
     else (input condition is this) //think of this as examine off
     {
           handle some other process
     }


}
```


----------



## ScooterMcGavin (Jan 24, 2011)

Your code has a couple of flaws. The way it is now if the operator were to hold the up and down button simultaneously both windings would energize. The same also applies to the upper and lower limior while at top or bottom stop. A little rearrangment of your code can fix that though. One thing I always tell people that I am training is a good programmer must anticipate reasonable faults and misuse of the system. I can gurantee operators won't always use the system exactly the way you intended. One of the coolest jobs I ever had was trying to "break" the code. I would do whatever I could to poke holes in the other guys program and break the system.


----------



## dronai (Apr 11, 2011)

scameron81 said:


> Your code has a couple of flaws. The way it is now if the operator were to hold the up and down button simultaneously both windings would energize. The same also applies to the upper and lower limior while at top or bottom stop. A little rearrangment of your code can fix that though. One thing I always tell people that I am training is a good programmer must anticipate reasonable faults and misuse of the system. I can gurantee operators won't always use the system exactly the way you intended. One of the coolest jobs I ever had was trying to "break" the code. I would do whatever I could to poke holes in the other guys program and break the system.


Yeah, I noticed that while testing my output lights :laughing: More work. 

I was working on a one shot for a single push button, and found a good example to work from. These are mind tweakers :blink:


----------



## thegoldenboy (Aug 15, 2010)

scameron81 said:


> Your code has a couple of flaws. The way it is now if the operator were to hold the up and down button simultaneously both windings would energize. The same also applies to the upper and lower limior while at top or bottom stop. A little rearrangment of your code can fix that though. One thing I always tell people that I am training is a good programmer must anticipate reasonable faults and misuse of the system.  I can gurantee operators won't always use the system exactly the way you intended. One of the coolest jobs I ever had was trying to "break" the code. I would do whatever I could to poke holes in the other guys program and break the system.


We just recently did this to a programmer. He wrote it, and they tested it in their shop on the actual equipment. Once it was installed in our location, we fault tested the snots out of it and found some holes. The program was rewritten.


----------



## industrial951 (Jan 29, 2011)

Try the compressor project yet? For some reason I had a tough time with that one, im actually going to be having to do a similar setup at work.


----------



## ScooterMcGavin (Jan 24, 2011)

Which part of it are you getting stuck on? If you post what you've got already I can work with you on getting setup.


----------



## industrial951 (Jan 29, 2011)

Hmm I think I was having trouble getting the compressors to kick in and out properly based on the load, been awhile since I messed with logixpro ill see if I can find the ladder logic file. When setting something like this up in real life would it be better to use an analog pressure transmitter over a pressure switch and how many?


----------



## LATTC (Feb 12, 2012)

*Batch Mixer Simulation*

Logixpro has limited instruction.


----------



## LATTC (Feb 12, 2012)

*Compressor Simulation*


----------



## LATTC (Feb 12, 2012)

*Bottle Line Simulation*

There is a bug in the Logixpro. You need to reduce the speed just a bit for this simulation to work. Other wise you can adjust the speed from really slow to fast.
The broken bottle part I have not coded because this simulation took me 1 hr to finish.


----------



## ScooterMcGavin (Jan 24, 2011)

industrial951 said:


> Hmm I think I was having trouble getting the compressors to kick in and out properly based on the load, been awhile since I messed with logixpro ill see if I can find the ladder logic file. When setting something like this up in real life would it be better to use an analog pressure transmitter over a pressure switch and how many?


I would go with the pressure transmitter because it affords you more flexibility. You really only need one transmitter at the receiver tank, so that you're seeing the actual plant air pressure. Were going through this right now, but the compressors we bought have built in controls and can talk to each other. They sequence themselves, standby start, fail over etc all automatically. They just need an air pressure input and a signal wire between the two compressors. We also have a hard wired pressure switch which trips the plant if the air pressure falls below a certain value. If you do go with a transmitter you just want to make sure that you have open loop/transmitter failure detection so that the PLC knows to shutdown and not overpressurize the system.


----------

