Author Topic: MPU Input  (Read 18175 times)

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
MPU Input
« on: March 22, 2012, 01:07:59 PM »
Hello all,

I would like to measure a magnetic pick up (MPU) using one of the high speed counters converting the MPU signal into RPM.

The MPU Signal is AC 35 - 55V so will need conditioning prior to being attached to the PLC and I expect to see about 4575 pulses per second so have some questions.

Has anyone done this before and does anyone know if there is an IC or widget that I can use?

Can the PLC actually count the inputs that quickly?

Cheers





 

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:MPU Input
« Reply #1 on: March 22, 2012, 01:10:47 PM »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:MPU Input
« Reply #2 on: March 22, 2012, 03:38:16 PM »
If the signal conditioner outputs a pulse train that has clearly defined edges the PLC should be able to read them at 4500+ pulses per second.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:MPU Input
« Reply #3 on: March 31, 2012, 11:51:50 AM »
Hi,

I have ordered the widget and I will report back when I have tested it.

I want to position a stepper motor based on the RPM signal.  I guess I need a lookup table but I'm struggling to get off the ground with this....

The RPM signal is fine, the stepper motor control is fine but i cannot make an association between a RPM value and a position, eg.

RPM        Stepper pos
0        =      0
5        =      3
10      =      6
....................
1550    =     1000

I need to cross reference the RPM and stepper position and put the required stepper position into a DM

The only way I can do this is with a whole load of IF statements........

Any ideas anyone??  all help appreciated.  

Cheers

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:MPU Input
« Reply #4 on: March 31, 2012, 12:43:02 PM »
Look up table can be implemented easily if the interval of your RPM is consistent. i.e. increment of 5 in your case.

Assuming:

R = PULSEFREQUENCY(1)/60    ' the speed in RPM
I = R/5            '

Now the variable I can be used to load the steps from a lookup table. If the look up table is constructed in DM[500]... onwards then the steps you want to send to the step motor is therefore found at DM[500+I]

steps = DM[500+I]
STEPMOVE 1, steps, n

or more directly:   STEPMOVE 1, DM[500+I], n

where "steps" is the #define name of any variable you want to use

You can also store the lookup table in the EEPROM (use i-TRiLOGI EEPROM manager). E.g. at address

steps = LOAD_EEP(1000+I)
STEPMOVE 1, steps, n

 

Email: support@triplc.com
Tel: 1-877-TRI-PLCS

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:MPU Input
« Reply #5 on: April 01, 2012, 03:25:40 AM »
Thanks,

I'll try that and come back to you.

Cheers

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:MPU Input
« Reply #6 on: April 01, 2012, 01:20:40 PM »
Marcus,

If you are still struggling I would be happy at taking a whack at algorithms.  

As was mentioned, if you have a linear relationship between RPM and your magic step number, then a lookup in DM[] is often a good solution.

But, the data you presented is linear.  The equation y= 1000/1550*x describes your problem.  Since TBASIC only work with integers you have to be a little careful with the order that you perform your arithmetic.

With X as your RPM value then you can solve for Y (step):

  Y = (X * 1000) / 1550

Simple, no tables.

Gary d

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:MPU Input
« Reply #7 on: April 02, 2012, 01:16:43 PM »
Thanks Gary,

The relationship may not be linear I just showed the position as an example.

In fact the position will need to be adjustable, so what I'm really looking for is a map or cross reference which is why I thought the lookup table would be a good idea.

What I want to do is look at the RPM signal after the raw input has been converted i.e DM[1] =356 RPM, now id like the code to look at the RPM range 355 - 340  and set position based on the x ref to X.  For this to work I guess I need the following:  

A RPM table made up from 10 sections I will also need a position table of 10 sections, so,

RPM  Position

0  -----  1
2  -----  1
4  -----  5
6  -----  5
8  -----  8
10  -----  9
12  -----  14
14  -----  14
16  -----  14
18  -----  30

This could be DM[10] to DM[20] for the RPM and DM[30] to DM[40] for the stepper position.

Now I need a function to look at the actual RPM (DM[1]) and complete the x ref and give me a position - simple!  

Maybe a nested For to loop will perform the required xref??  so far I have tried and failed.

What do you think?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:MPU Input
« Reply #8 on: April 02, 2012, 04:56:44 PM »
Then just store the value of the 10 "Position" in DM[10] to DM[19] and compute the index each RPM represent.

E.g. I = RPM/2

   RPM = 0 => I = 0
   RPM = 2 => I = 1
   RPM = 4 => I = 2

The position that corresponds to any RPM value can be obtained from DM[10+I]
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:MPU Input
« Reply #9 on: April 02, 2012, 06:36:01 PM »
Marcus,

If you make a table in DM with paired values. One of the pairs being the RPM and the other being the Step value you can do a linear search through the table.

I prefer to build a single table with paired values because it is easier to maintain then two separate tables.  The issue is that if you add a new entry to a table you must remember to do this in two places.

I use a "end of table value" to mark the end of the table.  This way your code does not have any idea how many entries are in the table.  If you add or subtract entries, the code that does the searching does not need to be changed. The end of table value must be larger than any possible RPM value.

The following custom functions builds the table in DM[].  In your production code you might want to save the table in EEPROM and just copy it into DM[] or you could access it in the EEPROM (as in one of the earlier suggestions).

For test purposes, I invoke this code with a 1st.Scan contact in the ladder logic.


' RPM / Step Look up table.
'
'  First entry in each pair is the RPM
'  Second entry is the step value for that RPM
'  The table is in ascending RPM values. There can not be any duplicate
'  RPM values.  Step values can be duplicates.
'
' The last RPM entry is used to mark the end of the table
' this way if you add entries to the table the algrithms will
' adjust automatically

'   ???RPM?????????????????????  Step
'
DM[TableBase + 0]  = 2??????: DM[TableBase + 1]  = 1
DM[TableBase + 2]  = 6??????: DM[TableBase + 3]  = 5
DM[TableBase + 4]  = 8??????: DM[TableBase + 5]  = 8
DM[TableBase + 6]  = 10??????: DM[TableBase + 7]  = 9
DM[TableBase + 8]  = 16??????: DM[TableBase + 9] = 14
DM[TableBase + 10] = 18??????: DM[TableBase + 11] = 30

' end of table marker is the largest positive intger that can
' be represented with 16 bits
'
DM[TableBase + 12] = &H7fff???: DM[TableBase + 13] = 100???
[/tt]

The following is the code to search though the lookup table in DM[]


' CalculateStep
'
' On entry R holds the RPM value
' On exit S  holds the Step value, I is changed.
'
' TableBase is the offset to the table in DM for the paired RPM/Step values
'    TableBase uses the #Define mechanism. This allows you to put the table
'    anywhere in DM without having to fix every usage in every custom function.

'
' The following is a brute force linear search through the RPM/Step lookup
' table.  

I = TableBase

WHILE R > DM??????
???I = I + 2 ??????' RPM in the table is measured RPM so...
                       ' try the next entry pair???
ENDWHILE

' RPM is just right, now return the step value for this RPM
'
S = DM[I+1]

[/tt]

Best of luck,

Gary D
« Last Edit: April 02, 2012, 08:53:42 PM by garysdickinson »

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:MPU Input
« Reply #10 on: April 08, 2012, 08:51:24 AM »
Thank You Gents

I will use your example Gary and come back to you.

Many thanks.