Need a bit of help with a PLC program

Jozir

Member
Join Date
May 2018
Location
Vlaams-Brabant
Posts
55
Hey everyone, I'm currently in my last year of high school and I have to automate a scorebord for a foosball table using 4 optical sensors (sender + receiver), 4 reflectors, a PLC and a HMI. I use 8 digital inputs for the sensors (4 interrupt 4 normal)

PLC used: s7-1200 AE30 v2
HMI used: KTP700 7inches

I already wrote the ladder program to measure the speed of the ball, show the winner, players and goals on the HMI.

What am I having trouble with?
1.Direction detection of the ball. I set a timer when one of the field sensors receive a signal and I reset the timer when the corresponding goalsensor aquires a signal or the opposing fieldsensor aquires a signal. Now as far as the direction goes: I have to reset the timer with the same input (fieldsensor) that sets the timer

2. Starting and stopping a timer using an interrupt so I have 1speed measurement with and one without the usage of an interrupt. I keep having a problem with the elapsed time not being moved. I get a signal on my hardware interrupt, it jumps to the interrupt, the time starts but nothing happens with the ET time ( I move the time and execute the calculations from s to ms and from m/s to km/u).

Thanks in advance!
 
Last edited:
I’m not a Siemen’s programmer so I can’t help however I can give you some advice.
First, I don’t really see any questions. It looks more like you are simply asking people to step in and come up with a solution for you and especially given that you are in school that’s not very likely to happen here. Most of the people here are happy to help someone who is learning the craft but what they won’t do is solve the problem for you. You need to learn how to solve the problems yourself, so we/they will guide you rather than do it for you. With that you need to ask very specific questions, not generalized ones.
You will probably be asked to show what you’ve got so far and to explain what you’ve tried so far (some which you’ve done). Try to be as detailed as possible and it’s more than acceptable to take screen shots of your computer and post them.
Good luck. It sounds like an interesting project, I hope it goes well.
 
Hi Jozir,


Welcome to the forum.


1. You use one-shot detection. For example, timer running AND one-shot detection equals reset. Timer NOT running AND one-shot detection equals start timer (P_Trig or N_Trig in TIA.
2. Not sure what you are trying to do, but the interrupt is only called once per occurrence. So you should set a bit in that OB and use that bit elsewhere in the program.


I thought he asked a very specific question, after getting most things to work...


Hope that helps! Good luck!
 
Last edited:
Thank you boneless.
1) What do you mean with P_trig and N_trig? Positive and negative edge?

2) do you mean like set a bit eg. Time_running using the intput from a fieldsensor and then in OB1(main) set that timer with that bit?
 
2. Starting and stopping a timer using an interrupt so I have 1speed measurement with and one without the usage of an interrupt. I keep having a problem with the elapsed time not being moved. I get a signal on my hardware interrupt, it jumps to the interrupt, the time starts but nothing happens with the ET time ( I move the time and execute the calculations from s to ms and from m/s to km/u).


Are you calling the timer block in your interrupt routine? Timers need to be called all the time so putting one inside a timed interrupt is not recommended.


You could log the times in the interrupt and then subtract the two times to calculate the time between interrupts.
 
Sounds like a fun project!

For the second question: Your suggestion would work, but then you lose the value of the interrupt, vs just doing a regular input.

I think what you could do is actually call the timer once in the interrupt to start it RIGHT NOW, and then let MAIN keep timing from there, using the bit you created. You would end up calling the timer in two different OBs, with the same instance data block. I've never tried this specifically with timers and interrupts, but it might work.
 
Are you calling the timer block in your interrupt routine? Timers need to be called all the time so putting one inside a timed interrupt is not recommended.


You could log the times in the interrupt and then subtract the two times to calculate the time between interrupts.

I work with milliseconds I don't think that is an option. Yes I thought about calling the timer block in my interrupt but once I tested it I saw that the elapsed time wasn't being moved ( i call that move block in my main) because the interrupt is only executed one cycle.
 
So I currently have this:
I set a bit M_Field1 and reset a bit M_Goal1 with a signal on my I0.1 then I do the same for the other player

I move the time and start the timer in Main. ( I don't know if this speed measurement is gonna be different from the normal one)

https://ibb.co/hASnSd
 
How are you using the interrupts to measure speed - do you have 1 interrupt input to start the timing and a second timed interrupt to stop it?


posted before I read your previous post
 
Last edited:
How ae you using the interrupts to measure speed - do you have 1 interrupt input to start the timing and a second timed interrupt to stop it?

Yes I use one interrupt on my fieldsensor to start the sensor and one interrupt on the goalsensor to stop the timer. Then I was planning on using a negative edge of the goalsensor following with a DIV block ( from ms to s) and a MUL block ( from m/s to km/h).
 
I've simulated this using a 1500plc and timed interrupts but the principle should be the same using hardware interrupts in your S7-1200

startT.jpg
 
Last edited:
I've simulated this using a 1500plc and timed interrupts but the principle should be the same in your S7-1200

I use a hardware interrupt, does it work the same way as a cyclic interrupt?
EDIT: didn't read the text you wrote above the screenshot, my bad ... :D
 
Last edited:

Similar Topics

I'm trying to display a 32 bit word from my PLC (ProWorx32), which I have used a double precision add block to achieve. The problem is, even...
Replies
4
Views
2,434
I need help converting from a floating register to two integer words. I'm using a SLC 5/05 and need to be able to write 32 bit data to a servo...
Replies
2
Views
4,676
Can anyone explain to me how does the address scheme for a bit data file works? For example, B3:400 and B3/47 I am using the PLC 3rd edition by...
Replies
1
Views
3,504
I have this SLC 5/03 file attached. I don't own RS Logix software myself, but I'd like to be able to check out a few things in the program. I'm...
Replies
6
Views
2,637
Question- Say I have 8 digital INPUTS to my PLC, any of which may be asserted HIGH for a few seconds, all these inputs "OR'd", currently, to...
Replies
16
Views
3,512
Back
Top Bottom