Author Topic: PLC - reading 640Hz with 1ms time base - Ideas?  (Read 1390 times)

0 Members and 1 Guest are viewing this topic.

Offline brabus

  • Frequent Contributor
  • **
  • Posts: 292
  • Country: it
PLC - reading 640Hz with 1ms time base - Ideas?
« on: February 27, 2021, 10:26:25 pm »
Good morning everyone.

I have an interesting question for you:

We need to read the speed of a diesel engine, the idea is to use the W signal coming from the alternator. The measurement shows about 640 Hz at 2000 rpm, 50% Duty.
The PLC we are using can perform tasks with different, but predictable, time bases: 1 ms, 5 ms, 10 ms or more.

At the beginning we wanted to make a gated counter: we leave it running @1ms for e.g. 10 seconds, counting how many pulses we see in the 10 seconds, and then calculating the frequency and thus the engine speed. But 640Hz is really fast, with just 1,56 ms period we are past the Shannon limit.

I am trying to make up my mind around a clever way to measure the frequency, maybe multiplying the square waves and numerarically, filtering, or trying a rudimentary FFT...

What would you do?

I will be glad to hear your ideas. Thanks for your help!
 

Offline fourfathom

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: us
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #1 on: February 27, 2021, 10:44:19 pm »
If you sample at the 1ms rate will you lose 640 Hz alternator events, or will you (I hope) get a series of true or false readings? (with a 750 Hz signal you would get "1,1,1,0,1,1,1,0..." with 500 Hz signal "1,0,1,0...", with 250 Hz "1,0,0,0,1,0,0,0..." and so on).

In that case, use the readings to increment a counter and read/clear (say) once per second.  This will give you a freq resolution of 1 Hz.  Or feed these 1/0 events into an IIR filter, scaled to essentially convert a duty-cycle into a frequency.  It doesn't have to be IIR, but that's easy.
 

Online MIS42N

  • Frequent Contributor
  • **
  • Posts: 260
  • Country: au
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #2 on: February 27, 2021, 11:06:25 pm »
Can you use a Divide by 16 Counter e.g 74LS93 or similar. Then you are dealing with 40Hz. If sampling at 1mS intervals you'll get 12 or 13 high, followed by 12 or 13 low. Count the transitions, multiply by 8, multiply by 1000 (mS in a second) divide by number of mS = original 640Hz. If the measurement period starts at a transition (time = 0, count=0) and ends at the next transition after a long period (say 1 second) you will get quite an accurate read. But the count must start at a transition and end at a transition to get the accuracy.
 

Offline fourfathom

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: us
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #3 on: February 28, 2021, 02:14:19 am »
If you sample at the 1ms rate will you lose 640 Hz alternator events, or will you (I hope) get a series of true or false readings? (with a 750 Hz signal you would get "1,1,1,0,1,1,1,0..." with 500 Hz signal "1,0,1,0...", with 250 Hz "1,0,0,0,1,0,0,0..." and so on).

In that case, use the readings to increment a counter and read/clear (say) once per second.  This will give you a freq resolution of 1 Hz.  Or feed these 1/0 events into an IIR filter, scaled to essentially convert a duty-cycle into a frequency.  It doesn't have to be IIR, but that's easy.

Or if you are just sampling a 0 - 640 Hz squarewave at a 1 ms rate, then yes, Nyquist is a problem.  If you simply divide the input by four, and sample *that* at 1 ms, you can detect the transitions in software and use any of our suggestions.  I still like the IIR low-pass filter, but integrate and dump is also a good technique.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 4223
  • Country: fi
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #4 on: February 28, 2021, 08:18:07 am »
If it always runs around 640Hz - more specifically, always significantly over 500Hz and below 1000Hz - you can just let it alias and detect the aliased frequency, for example 640Hz would show as 140Hz. Then add 500Hz to the number.

This gives false indication whenever the actual speed is below 500Hz or over 1000Hz, though.

A sidenote; I have hard time understanding why some people talk about the conductivity in milli-Siemens when they mean milliseconds. I mean, it looks very awkward, and it requires extra work to press the shift key. The correct unit for time is easier to produce: s.
« Last Edit: February 28, 2021, 08:20:39 am by Siwastaja »
 

Online MIS42N

  • Frequent Contributor
  • **
  • Posts: 260
  • Country: au
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #5 on: February 28, 2021, 11:56:32 am »
A sidenote; I have hard time understanding why some people talk about the conductivity in milli-Siemens when they mean milliseconds. I mean, it looks very awkward, and it requires extra work to press the shift key. The correct unit for time is easier to produce: s.
Every time I type ms I think about the abbreviation for women ms Nancy, ms Smith. So I write mS then go "oh, that's wrong" but the internet is full of wrongness and people understand anyhow so I don't change it. It isn't a good excuse, but maybe it makes it easier for you to understand. I know the rules - lower case except for people and liter, lower case for less than a million - but not good at following all of them. my bad.
 
The following users thanked this post: vk6zgo

Online AlfBaz

  • Super Contributor
  • ***
  • Posts: 2133
  • Country: au
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #6 on: February 28, 2021, 12:35:12 pm »
We need to read the speed of a diesel engine, the idea is to use the W signal coming from the alternator. The measurement shows about 640 Hz at 2000 rpm, 50% Duty.
Quote
What would you do?
I'd double check my frequency measurement, unless of course there's some exotic info missing  about the alternator.
\$P=\frac{120f}{N_{s}} \$


With the figures given above you alternator has 38.4 poles :o
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 4223
  • Country: fi
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #7 on: February 28, 2021, 01:20:21 pm »
I'd double check my frequency measurement, unless of course there's some exotic info missing  about the alternator.
\$P=\frac{120f}{N_{s}} \$


With the figures given above you alternator has 38.4 poles :o

My guess: there's a belt; not very exotic. Most alternators on most engines run on belts. Any non-integral ratio is possible.
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 7420
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #8 on: February 28, 2021, 01:52:12 pm »
What inputs does the PLC have? I'd imagine something designed to measure speed would be a very common feature. (My first thought: use a quadrature encoder input with a RC circuit to provide the phase shift to make a single frequency into a unidirectional quadrature signal.)
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline snarkysparky

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #9 on: February 28, 2021, 05:15:58 pm »
You will need hardware assistance to do it.

I think a common feature of many PLC is a counter input.  This will increment a counter in hardware without any software intervention which you can read periodically.

Failing that a simple binary divider circuit taking as input the W signal and output say    W/64 in frequency which you can easily read with 1 ms .

Its a very simple circuit.  If no one gives you a better idea post the details of the W signal and the PLC input and I will design you a circuit.
 

Online AlfBaz

  • Super Contributor
  • ***
  • Posts: 2133
  • Country: au
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #10 on: March 02, 2021, 06:07:20 am »
I'd double check my frequency measurement, unless of course there's some exotic info missing  about the alternator.
\$P=\frac{120f}{N_{s}} \$


With the figures given above you alternator has 38.4 poles :o

My guess: there's a belt; not very exotic. Most alternators on most engines run on belts. Any non-integral ratio is possible.
My industrial background saw diesel engine and alternator and thought diesel powered alternator. Reading back it may well be what you say, an alternator hanging off the side such as in automobiles.
Having said that 640Hz still seems unrealistic. Even if it was some ridiculous number of poles like 24 for example you are still looking at 3200RPM which would require the rotating parts to be very well balanced. Mechanically this would almost certainly rule out belt driven.

You will need hardware assistance to do it.
Yes, they're call frequency to voltage/current converters. They are relatively cheap and far easier to fault find than some overly convoluted PLC code
 

Online bdunham7

  • Super Contributor
  • ***
  • Posts: 3263
  • Country: us
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #11 on: March 02, 2021, 06:37:43 am »
Even if it was some ridiculous number of poles like 24 for example you are still looking at 3200RPM which would require the rotating parts to be very well balanced. Mechanically this would almost certainly rule out belt driven.

Automotive alternators routinely go 20,000+ RPM.  In this case, try a typical pulley ratio of 3.2 so that the alternator is doing 6400 RPM and you get 12 poles, which might be right for a big alternator on a diesel.
A 3.5 digit 4.5 digit 5 digit 5.5 digit 6.5 digit 7.5 digit DMM is good enough for most people.
 

Offline fourfathom

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: us
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #12 on: March 02, 2021, 06:46:45 am »
My industrial background saw diesel engine and alternator and thought diesel powered alternator. Reading back it may well be what you say, an alternator hanging off the side such as in automobiles.
Having said that 640Hz still seems unrealistic. Even if it was some ridiculous number of poles like 24 for example you are still looking at 3200RPM which would require the rotating parts to be very well balanced. Mechanically this would almost certainly rule out belt driven.

For what it's worth, the alternator on my sailboat (with a 45HP diesel) needs to spin between 3000 and 6000 RPM in order to deliver close to the rated output.  It's rated to 1200 12,000 RPM, and I think has 12 poles.  I don't know my pully ratios, but since my diesel tops out at around 3500 RPM, I would guess the ratio is about 1.5 : 1.

12 poles at 6000 RPM gives a 1200Hz waveform, doesn't it?  If so, the OP's 640 Hz seems quite reasonable.

[edit: Alternator is rated to 12,000 RPM, not 1200 (typo on my part).  Here's a link to a spec sheet: https://mk0balmaromwtjt14hae.kinstacdn.com/wp-content/uploads/2017/11/PDS-621-120-DV.pdf]
« Last Edit: March 02, 2021, 04:07:09 pm by fourfathom »
 

Online AlfBaz

  • Super Contributor
  • ***
  • Posts: 2133
  • Country: au
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #13 on: March 02, 2021, 09:57:30 am »
Interesting.

I'll have to look into this as I'm finding it hard to believe some of these figures, especially the "routinely 20,000+" bit.

Maybe I'm conflating precision balancing at speeds greater than 2500RPM on smaller machines with larger kW rated machines
 

Online MIS42N

  • Frequent Contributor
  • **
  • Posts: 260
  • Country: au
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #14 on: March 02, 2021, 10:54:46 am »
I found this "Typically, alternators have their full output rated at 6000 RPM but can continue to spin up to 12,000 RPM or more without any additional increase in output." from a research paper. It also says a typical rpm ratio for a passenger car is 3:1, so if the engine reaches 5000 rpm the alternator is doing 15000. This is not a lot, a turbocharger can spin over 100,000 rpm. Where my father worked in the 1950s there was a compressor with a 3/4 ton rotor that ran at 12,000 rpm. And belt driven superchargers are well over 20,000 rpm. So the figures look reasonable - 6000 rpm = 100 revs /sec and with multiple poles 640Hz looks OK.

 

Online bdunham7

  • Super Contributor
  • ***
  • Posts: 3263
  • Country: us
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #15 on: March 02, 2021, 03:34:51 pm »
I'll have to look into this as I'm finding it hard to believe some of these figures, especially the "routinely 20,000+" bit.

Open the hood of a car and measure the crankshaft and alternator pulley diameters.  Divide the former by the latter to get the drive ratio.  Determine the maximum speed of the engine and multiply that by the drive ratio and you have the maximum speed of the alternator.  I think you'd be hard pressed to find a modern automobile where that maximum doesn't hit at least 15000 RPM.   

I know of one case of an alternator failing due to overspeed.  A guy I knew was coming off the interstate with his old Mercedes SL and downshifted into the wrong gear, ended up way past redline and the old Motorola alternator just exploded.  Other than that, the high speeds don't seem to be an issue.  And yes, they are carefully balanced at manufacture, just like turbochargers.
A 3.5 digit 4.5 digit 5 digit 5.5 digit 6.5 digit 7.5 digit DMM is good enough for most people.
 

Online AlfBaz

  • Super Contributor
  • ***
  • Posts: 2133
  • Country: au
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #16 on: March 04, 2021, 10:29:42 pm »
I finally got around to looking up some of this stuff and everything I doubted is typical when it comes to automobile alternators.

I'm a little embarrassed by my lack of knowledge in this field considering I spent years maintaining, installing and repairing 3 phase industrial alternators and load sharing systems, not to mention doubting the generally wise contributions made in this forum.

My apologies to the OP for derailing your thread :-[
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 1715
  • Country: nl
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #17 on: March 05, 2021, 12:37:44 pm »
It seems your PLC is too slow to do it by itself.
And once you start adding hardware, a small microcontroller is usually the first to go to these days.
Any simply microcontroller can easily measure events with 100ns accuracy or better, which means you can get an accurate RPM reading between any 2 (rising) flanks of your alternator signal.

It does of course need some signal conditioning, overvoltage protection etc, but you need that with any added electronics.

And when you start thinking microcontrollers, you may also think of ditching the PLC and do everything in the microcontroller.
 

Offline brabus

  • Frequent Contributor
  • **
  • Posts: 292
  • Country: it
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #18 on: March 05, 2021, 03:04:07 pm »
I finally got around to looking up some of this stuff and everything I doubted is typical when it comes to automobile alternators.

I'm a little embarrassed by my lack of knowledge in this field considering I spent years maintaining, installing and repairing 3 phase industrial alternators and load sharing systems, not to mention doubting the generally wise contributions made in this forum.

My apologies to the OP for derailing your thread :-[

Absolutely no problem, it was a good occasion to read some interesting insights on the topic.

Thanks everyone for your interesting comments and for your knowledge; I tried to play a bit with the numbers on the PLC but the measurement is erratic. We can reliably read frequencies up to ~200Hz with a 1 ms time base and a windows of 1 s. No improvement with longer windows, such as 5 s or 10 s.
At the end of the day, there is very little we can do against Mr. Shannon.

I would gladly use some glue logic or a microcontroller, the problem is that the system needs to satisfy very stringent regulations and I am forced to buy off-the-shelf certified modules. We ended up identifying a counter module for the PLC, but the budget wasn't very happy with that.


Together with the customer we found a solution which meets the engineering target and the management cost projection: an off-the-shelf module which converts the frequency from the alternator into a proportional voltage signal. This signal will be then fed to the PLC and properly scaled to obtain an RPM value. Not the most fascinating solution, but it does what we need and everyone is happy.

Thank you again! :-+
« Last Edit: March 05, 2021, 03:07:12 pm by brabus »
 

Offline TomS_

  • Frequent Contributor
  • **
  • Posts: 624
  • Country: gb
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #19 on: March 16, 2021, 07:28:54 am »
Every time I type ms I think about the abbreviation for women ms Nancy, ms Smith. So I write mS
If it's of any help, I believe that "Miss" as in the woman's title is written as Ms.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 1715
  • Country: nl
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #20 on: April 01, 2021, 08:41:45 pm »
milli-Siemens does not have much to do with time.

https://en.wikipedia.org/wiki/Siemens_(unit)

It is amazing how often people think that inventing their own unit names is a clarification instead of an obfuscation of normal & decent SI units.
 

Online MIS42N

  • Frequent Contributor
  • **
  • Posts: 260
  • Country: au
Re: PLC - reading 640Hz with 1ms time base - Ideas?
« Reply #21 on: April 01, 2021, 09:45:35 pm »
milli-Siemens does not have much to do with time.

https://en.wikipedia.org/wiki/Siemens_(unit)

It is amazing how often people think that inventing their own unit names is a clarification instead of an obfuscation of normal & decent SI units.
Siwastaja pointed this out on February 28. There has been no transgressions since then. You are preaching to the converted.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf