Help with Ladsim, a carpark and counters.

bobmcgod

Member
Join Date
Jan 2018
Location
Teesside
Posts
3
Hello

I'm studying engineering via a local universities distance learning program. I'm currently studying the PLC module and this means some practical stuff using ladsim, a program that from some breif browsing some of you are familiar with.

So the story is:

There is a carpark.
The carpark has 6 spaces.
The car park needs to show that it either has spaces or is full.

I've got the programme set up so that the counter C1 counts up only when the entry barrier changes from open to let the car through to closed and the same for the entry barrier except counting down.

If the car park is full the entry barrier doesn't open. This is so I don't have to mess around any further than I need to. The counter is set to count to 6. It won't count any higher if the car enters whilst the carpark is full but if it doesn't find a space and leaves it'll count down and not show the correct information. Ie it will display spaces when there are non.

The issue I'm having is that when I first wrote the program, it worked. Now with out modifying it, it doesn't. But the problem is sometime intermittent and obviously I can't submit something that won't work some of the time.

The car approaches the car park and activates a sensor. The sensor then opens the barrier and keeps it open using a timer. I have three rungs that track the barrier from open to closed by latching in the carrect order so that both trigger an output the tells the counter to count up or down (three rungs for the entry barrier and three seperate rungs for the closed).

With ladsim the rungs are black and then when true or 1 or active or whatever you want to call them they turn red. So when the car car enters the barrier the very first time the rung the counter is on is black then when it goes from open to closed it turns to red. It then stays red until another car enters and the barrier opens the rung turns to black and again the barrier shuts and it turns red.

From black to red the counter should count, either up or down. But it doesn't always do this.

Any ideas?

Thanks in advance,
 
There are lights for free spaces and full. And these work as they should when the counter works.

-| |-----------------C1/\


-| |-----------------C1\/


The counter lines them selves couldn't be more simple.

When the input goes from open to closed it counts up or down. But sometimes it doesn't.
 
I've not used ladsim, but here's a thought.

I'd be guessing that you've set your counter preset to 6, and when the counter is done, the carpark is full, yes?

Maybe the counter won't count any higher than its preset. I don't use a lot of counters, so I'm not sure if this is common for PLC counters, but it would make sense.

If that's the case, that would cause the results you've described. You have a couple of options:
1. Set the counter preset to a higher value (like 9999) and just a compare instruction to say something along the lines of "when the count is greater than or equal to 6, carpark is full". Have that compare instruction set a "carpark full" bit, and use that in your code instead of the "counter done" bit
2. Forget the counter and use simple add and subtract instructions. This is what I prefer to do most of the time. Have an integer to represent the number of cars in the carpark. Each time a car enters, add one. Each time a car leaves, subtract one. Use the same comparator as before to determine whether or not the carpark is full. The only thing you'll need to watch for is that a counter is in it's nature a one-shot operation - that is, when the rung conditions before it all go true, it will count once and only once. To count again, the rung conditions must go false and then true again. Whereas, an add or subtract instruction will execute every single scan while the rung conditions preceding them are true. So you'll need to either use a oneshot instruction or find some other means of making sure that your "count up" and "count down" rungs are only executed for one scan each time a vehicle enters or leaves.

Good luck!
 
Maybe the counter won't count any higher than its preset. I don't use a lot of counters, so I'm not sure if this is common for PLC counters, but it would make sense.

If that's the case, that would cause the results you've described. You have a couple of options:
1. Set the counter preset to a higher value (like 9999) and just a compare instruction to say something along the lines of "when the count is greater than or equal to 6, carpark is full". Have that compare instruction set a "carpark full" bit, and use that in your code instead of the "counter done" bit
2. Forget the counter and use simple add and subtract instructions. This is what I prefer to do most of the time. Have an integer to represent the number of cars in the carpark. Each time a car enters, add one. Each time a car leaves, subtract one. Use the same comparator as before to determine whether or not the carpark is full. The only thing you'll need to watch for is that a counter is in it's nature a one-shot operation - that is, when the rung conditions before it all go true, it will count once and only once. To count again, the rung conditions must go false and then true again. Whereas, an add or subtract instruction will execute every single scan while the rung conditions preceding them are true. So you'll need to either use a oneshot instruction or find some other means of making sure that your "count up" and "count down" rungs are only executed for one scan each time a vehicle enters or leaves.

Good luck!

Thank you for your reply. The counter wont go any higher than the preset. This is why I've got it set so that the barrier won't open if the car park is full.

The rung conditions for the counter are as you describe in that the conditions do go false and the true again. Ladsim even demonstrates this happening but doesn't seem to make the counter act on it! The purpose of this part of the practical is to show knowledge of counters so they sort of need to be in I guess.

Thanks

Adam
 

Similar Topics

Hi all, Firstly I am a complete novice with plc, just started a course so I know this problem is super basic for those with any experience. I...
Replies
8
Views
2,054
So basically im programming for my studys on the ICT3 via ladsim. I have everything sort of working but the method in which i have used for...
Replies
4
Views
2,342
I have been trying to complete a PLC program in Ladsim 3 for the Bytronic Industrial Control Trainer. I have managed to complete the first part...
Replies
1
Views
2,291
Hi all, hope you are having a great day, I am in need of your help to create a AOI or program that does this kind of job: I have a IO Link...
Replies
1
Views
82
please help me . I have to make this ladder diagram and I can’t figure it out :(
Replies
12
Views
340
Back
Top Bottom