how to write tachometer (rpm) program

A

Thread Starter

Anonymous

How to write a ladder program that calculates rpm of the motor? RPM Measurement will be made by inductive sensor from motor shaft. Ladder program can be either in OMRON or in Siemens S7-200.
 
M

Marc Sinclair

It depends on accuracy and the input frequency, I use the s7-200 almost exclusively, mainly because there isn't much it can't do :) So, using an S7-200 I would use one of the High-Speed Counter (HSC) inputs, for example i0.0 and configure HSC 0 for mode 0 (using the instruction wizard) Create an interrupt routine and within it read the HSC, transfer the value to a variable and then clear it. Call the interrupt from either the timed interrupt routine (I usually use 250ms) or T37 set to one second. You can then forget about it and just read and scale the count.

Marc Sinclair

http://www.germainesystems.co.uk
 
M

Miguel Salazar

Easy; Omron During 2 seconds, you have X counts.
If X > 0 then X * 30 = RPM
Just need a timer, counter and div
if you need the ladder In can help you later
 
T

Thomas Hergenhahn

I cannot give you a ready to run program here.

In principle, you have the choice to count frequency (pulses in a fixed time) or count period time between pulses. The precision of the further increases with frequency, because one pulse more or less will fall into your given time and one pulse contributes less to a high number than to a low one.

Vice versa, period timing is more exact for low frequencies, because a higher amount of units of resolution of your timebase fall into one period.

To combine the advantages of both methods, follow this way:
Memorize start time of some pulse (rising or falling edge).
At the next same edge, comparte time to a limit, e.g. a second.
If time is not yet elapsed, increment number of pulses.
If time is elapsed, subtract memorized start time from actual time.
Now, devide time difference by number of pulses in this time.
This will automatically adapt itself to varying frequencies.

With S7-200, make use of the high speed counters provided by this device. It also can provide a high resolution pulse length at some output, so it maybe useful to feed back a signal from such output back to counter start input. With Omron, I do not know.
 
I know of a model from Keyence KV-700 which can display the RPM from the CPU screen without the need to hook up with laptop or display unit.
It uses the high speed counter method. Don't need to have extra module - just need CPU. They always have sample program for all this functions. their website - www.keyence.com
 
M

Marc Sinclair

<p>Sorry, I thought that you would enjoy working out the details, it is the best way to learn. Here is listing of a demo program. you should cut this text and save as demo.awl then import into your STEP7-Micro. otherwise there is a ladder pdf version at http://www.germainesystems.co.uk/tacho_demo.pdf

<p>Once you've got it working, read the very fine manuals and try to understand how it works, there are many useful configurations for the High Speed Counters.

<p>_have fun :) <br>
Marc Sinclair
<pre>
----Start Cutting below this line -----

ORGANIZATION_BLOCK MAIN:OB1
TITLE=
//Tachometer Example
//Marc Sinclair http://www.germainesystems.co.uk
//

BEGIN
NETWORK 1 //Tachometer timing
//
//Free running one second timer.
//Used to count pulses from speed sensors.
LDN T32
TON T32 +1000

END_ORGANIZATION_BLOCK

SUBROUTINE_BLOCK Initialise:SBR0
TITLE=
//INITIALISE SUBROUTINE
//Marc Sinclair http://www.germainesystems.co.uk
//

BEGIN
NETWORK 1 //Initialise HSC
//
//This network Initialises the High Speed Counter HSC0
//by transferring 16#F8 to SMB37
//Clears it, by transferring zero to SMB38 nad SMD42
//The HDEF instruction Configures the HSC0 at Mode 0,
//which means a single input, count up on input i0.0
//We also enable the interrupts with the ENI
//and finally enable the HSC with the HCS instruction
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 T37 reaching its
preset time.
LD SM0.0
ATCH Speed 21
ENI

END_SUBROUTINE_BLOCK

INTERRUPT_BLOCK Speed:INT0
TITLE=
//SPEED INTERRUPT ROUTINE
//Marc Sinclair http://www.germainesystems.co.uk
//

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
//
//We now clear the HSC0 ready for the next counting period.
LD SM0.0
MOVB 16#C0 SMB37
MOVD +0 SMD38
HSC 0


--------Stop Cutting Above this Line--------
</pre>
 
Top