Author Topic: rpm counter  (Read 15233 times)

csims

  • Newbie
  • *
  • Posts: 6
  • I'm a llama!
    • View Profile
rpm counter
« on: August 08, 2008, 11:59:45 AM »
I have no idea how to write this custom function..any help please

I want to limit X amount of rpm's over X amount of time
 (rpm's = 12 volt pulses)
If rpm's increase more than X from current read rpm's over X amount of time, turn on output 1. Then reset and restart function.

This function will allow me to detect engine rpm abnormal increses and retard ignition timing momentarily to stop wheel spin

Thanks for any help

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:rpm counter
« Reply #1 on: August 08, 2008, 12:10:23 PM »
Are you using the T100MD+ PLC? If so, you can wire it to input #3 or #4 and measure up to two channels of incoming pulse frequency using the PMON and PULSEFREQUENCY function. Then it is a matter of IF THEN ELSE statement to compare the current rpm with previous rpm.

E.g.  PMON 1 in an init function.
        M = ???   ' the normal frequency (RPM*60)

Use a clock pulse (e.g. 1.0 second) to read the frequency of incoming pulses from input #3 (Pulse monitor channel 1):

X = PULSEFREQUENCY(1)

IF (X-M) > ???  THEN
   SETIO xxx  '  xxx is the label name of output 1.
    ...
ELSE
    ...
ENDIF

' IF the current frequency (pulse per second) is an acceptable value then

M = X    ' store the normal M value.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

csims

  • Newbie
  • *
  • Posts: 6
  • I'm a llama!
    • View Profile
Re:rpm counter
« Reply #2 on: August 08, 2008, 12:18:20 PM »
there is not a normal rpm it will vary from 1000 to 9000.
I want to detect a e.g. 500rpm increase if they occur faster than e.g. 1ms

csims

  • Newbie
  • *
  • Posts: 6
  • I'm a llama!
    • View Profile
Re:rpm counter
« Reply #3 on: August 08, 2008, 12:19:20 PM »
yes t100md but would like to convert to small plc you sell.

csims

  • Newbie
  • *
  • Posts: 6
  • I'm a llama!
    • View Profile
Re:rpm counter
« Reply #4 on: August 08, 2008, 12:33:35 PM »
actually the time base should be .1 seconds

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:rpm counter
« Reply #5 on: August 09, 2008, 02:43:50 PM »
M as constant is just an illustration. You can will need to assign the correct value of M.

What you can do is to detect if the measured RPM (which is frequency *60 if you receive 1 pulse per revolution), so what you need to do is to check:

X = PULSEFREQUENCY(1)*60 - M  ' M is the RPM

IF X >500  THEN
   ....
ELSE
   ....
ENDIF

T100MD+ PLCs or T100MX+ would be the only PLC models we have that are able to execute these codes.

You can read the pulsefrequency evey 0.1s if you wish.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

csims

  • Newbie
  • *
  • Posts: 6
  • I'm a llama!
    • View Profile
Re:rpm counter
« Reply #6 on: August 10, 2008, 08:54:11 AM »
NICE!!!!
still a little fuzzy on (M) value...i.e. CORRECT value of M

What this should do is on a race car as the engine accelerates (from 1000 to 9000 rpm) is to check if the engine rpm increases more than 500 rpm in .1 seconds . I want to ignore decelerations

Would PULSEFREQUENCY(1) = (.1) for my circuit?
What is the shortest time base I could assign....  (.01)?

I do in fact receive one 12volt pulse per engine revolution

This is an amazing little box..I have used it for SO many applications.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:rpm counter
« Reply #7 on: August 10, 2008, 02:03:22 PM »
PULSEFREQUENCY(1) means getting the frequency of the incoming pulses on  channel 1. On the T100M+ PLC, this channel is mapped to digital  input #3. This has nothing to do with the sampling time.

Since the engine produces a pulse every revolution, that means if you measure incoming pulses to be 150Hz, that means the engine is running at 60*150 = 9000 rpm.

So you can add the last measured value of X to M:

M = M+X

So the next time you run the custom function again you will be checking if the new X is greater than the new M

X = PULSEFREQUENCY(1)*60 - M  ' M is the RPM
IF X >500  THEN
  ....
   M = M+X  ' update the new M value.
ELSE
   RETURN   ' do nothing
ENDIF

Your sampling time is determined by how often the ladder rung is run. E.g. if you run it with a 0.1s clock pulse then every 0.1s the following function would be executed.

   CLK:0.1s                     Fn_#1
|---||-----------------------{dCusF}

Of course the timing is only accurate if the whole program (ladder logic +BASIC) scan time does not exceed 0.1s.
« Last Edit: August 10, 2008, 02:04:52 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

csims

  • Newbie
  • *
  • Posts: 6
  • I'm a llama!
    • View Profile
Re:rpm counter
« Reply #8 on: August 11, 2008, 11:32:21 AM »
thanks for the ALL the help

I'll let ya know how it turns out
Charlie