Problem coverting code that works for S7-200 CPU 215 and above to work on a CPU 214

I

Thread Starter

Iain Davidson

I need to get an Attach interrupt that works on on CPU 215's and above, to work on a CPU 214. With the original code it is possible to use EVENT 21 (Timer T32 CT=PT interrupt), however this EVENT cannot be used with a CPU 214
This is the original code.

//Tachometer Example
//

BEGIN
NETWORK 1 //Tacho timer
//
//Free running 5 second timer.
//Used to count pulses from speed sensors.

LDN T32
TON T32 +5000

END_ORGANIZATION_BLOCK


SUBROUTINE_BLOCK Initialise:SBR0
//INITIALISE SUBROUTINE
//

BEGIN
NETWORK 1 //Initialise HSC
//
//This network Initialises the High Speed Counter HSC0

LD SM0.0
MOVB 16#F8 SMB37
MOVD +0 SMD38
MOVD +0 SMD42
HDEF 0 0
ENI
HSC 0

NETWORK 2 //Attach Interrupt
//
//This network attaches INT0 to the event of Timer T32 reaching its preset time.

LD SM0.0
ATCH COUNT:INT0 21
ENI

END_SUBROUTINE_BLOCK


INTERRUPT_BLOCK COUNT:INT0
//COUNT INTERRUPT ROUTINE
//

BEGIN
NETWORK 1 //Transfer the count of HSC0
//
//This network transfers the count of HSC0 to the variable VD100
//
//

LD SM0.0
MOVD HC0 VD100

NETWORK 2 //Clear the HSC0
//
//now clear the HSC0 ready for the next counting period.
LD SM0.0
MOVB 16#C0 SMB37
MOVD +0 SMD38
HSC 0

***********************************************
// Above at 'ATCH COUNT:INT0 21 is where I have the problem. In need to get something else that can interrupt the program at the 5 second gate time and then continue on to put the count at address VD100 etc etc and continue working.

I tried using the EVENT No. 12, however, this stops the PLC from seeing the pulse input at I0.0, so the HSC doesn't count anything.

Is it possible to use timed interrupts for this application??? If so how's the best way I have had no luck with then inregating with the program. Or do I need to start again and rewrite the program.

Any help would be greatly appriciated,
Thank you

Iain Davidson
Queensland
Australia
 
M

marc sinclair

Iain

This bit of code is one of my children (ahhh!!). As you rightly say the 214 has not got the ability to run an interrupt on the time up of T32. The easiest way to get this functionality is to use a timer to call an ordinary subroutine.

NOW - the 214 may cause problems if you are using the high resolution timer T32, It is possible to miss the timer ON, between scans. to avoid this
Set the timer T32 to +5000ms with an always on,
Call the subroutine with the T32 ON bit
In the called Subroutine, move the accumulated count and zero the counter AND reset T32

This way you guarantee that the subroutine is called at maximum 5000ms + a scan time (depends on your program)

If you need more help, please contact me on or offline

Marc Sinclair
http://www.germainesystems.co.uk/contact.html
 
Top