Sign in to follow this  
Followers 0
OutRuN

More of an instrumentation question actually...

7 posts in this topic

Hello everyone!

 

I have programmed a PLC to take certain actions depending on the pressure fluctuations in the system. It is pretty str8forward, however I am having problems when:

  1. The pressure changes suddenly (so fast) that the PLC (or the sensor???) cannot sense or detect that the threshold was passed and the counter I am using for my steps does not count up or down.
  2. If the pressure in the system is not stable around the threshold levels then it messes up with the steps of the process and if not the relay outputs of the plc open and close like crazy until the fluctuation is further from the threshold level. For example if my step changes at 5 bar and the sensor is giving me 4.95 to 5 for a few seconds the above statement is true until the sensor reads 4.90 to 4.95. Same goes for the upper level.

On the 1st issue I believe that since my analogue signal from the sensor is quite accurate as I have also measured it with a multimeter. My sensor is this one : https://www.festo.com/gb/en/a/8022825/?q=8022825~:festoSortOrderScored and my PLC is this one : https://www.festo.com/gb/en/a/8022825/?q=8022825~:festoSortOrderScored .

I hope what I wrote was not very confusing. Any help is much appreciated. :)

Share this post


Link to post
Share on other sites

Assuming it's an analog signal from the sensor to the PLC:
You may need to do some filtering on the analog signal. Depending on the PLC, you may be able to do that in the configuration of the analog input module. If not, a simple average of a certain number of samples taken at a certain interval will smooth out those spikes. Alternatively, you can try debounce logic such that it needs to be above the threshold for a certain amount of time before your PLC says it's above the threshold. And do the same thing on the way down. It must be below the threshold for a certain amount of time before the PLC says it's below. Either option will impose a time delay in your PLC's response, which you need to be aware of.

If the sensor sends a digital signal to the PLC and the sensor can't be configured to filter spikes, you can do a debounce on the digital signal inside the PLC. That will eliminate the flickering if your debounce time is long enough.

Share this post


Link to post
Share on other sites

1. How fast are you sampling?  That sensor responds in ~3ms, which is pretty good for pressure sensors, IMHO.  But the PLC has to sample the signal and run the logic often enough to catch pulses the sensor sees.

2.  Threshold logic should always use hysteresis when signals can be noisy.  Say, activate when above 5.1 bar, deactivate below 4.9 bar, hold last state in between.  The "in between" must be larger than the noise in the signal.

Share this post


Link to post
Share on other sites
1 hour ago, Joe E. said:

Assuming it's an analog signal from the sensor to the PLC:
You may need to do some filtering on the analog signal. Depending on the PLC, you may be able to do that in the configuration of the analog input module. If not, a simple average of a certain number of samples taken at a certain interval will smooth out those spikes. Alternatively, you can try debounce logic such that it needs to be above the threshold for a certain amount of time before your PLC says it's above the threshold. And do the same thing on the way down. It must be below the threshold for a certain amount of time before the PLC says it's below. Either option will impose a time delay in your PLC's response, which you need to be aware of.

If the sensor sends a digital signal to the PLC and the sensor can't be configured to filter spikes, you can do a debounce on the digital signal inside the PLC. That will eliminate the flickering if your debounce time is long enough.

From that sensor I am using both the analogue and digital signals with Window mode function because the in built hysteresis function is doing the same flickering around the threshold levels. As far as the delay in the PLC program, the cycle is not constant. For example the system might stay between the 3.8 and 4.2 bar region for quite a while before dropping below 3.8. The problem arises when the sensor starts to read 3.840 to 3.790 or smth (I can see these numbers on the HMI screen after processing the signal). In addition, I cannot know how long it will take for the system to drop from 3.84 to 3.79 etc.

 

1 hour ago, pturmel said:

1. How fast are you sampling?  That sensor responds in ~3ms, which is pretty good for pressure sensors, IMHO.  But the PLC has to sample the signal and run the logic often enough to catch pulses the sensor sees.

2.  Threshold logic should always use hysteresis when signals can be noisy.  Say, activate when above 5.1 bar, deactivate below 4.9 bar, hold last state in between.  The "in between" must be larger than the noise in the signal.

The sampling speed is quite fast actually. I've tried the hysteresis with no luck. Like I said before I had the Set point 1 at 3.80 and reset point 1 at 3.75 and I was expecting it to stay stable around that point and when the pressure was close to that value it started to flicker like crazy :'(

Cheers.

PS:I am very new to these so maybe I am missing something out.

Share this post


Link to post
Share on other sites
1 hour ago, OutRuN said:

Like I said before I had the Set point 1 at 3.80 and reset point 1 at 3.75 and I was expecting it to stay stable around that point and when the pressure was close to that value it started to flicker like crazy

That means your noise is significantly larger than 0.05.  Make your hysteresis wider until it doesn't flicker.  Consider generating a histogram of your actual sample values so you can see the distribution.  That will help guide further filtering/threshold decisions.

If the noise is very bad, some other things to look at:

  • Look for electrical interference.  Verify that you are maintaining balanced current in twisted pairs for both device power and signal.
  • Look for physical pressure fluctuations.  A sensor that fast will pick up vibration/pulsation in the fluid.  Up to ~200Hz or so, I would expect.
  • Consider a modified hysteresis algorithm that requires two or three samples in a row past a threshold to flip the state in that direction.
1 person likes this

Share this post


Link to post
Share on other sites

I ended up using delays to give the system time to move far from the threshold levels. The hysteresis is somewhat funny though. Yes it tries to provide a stable output for small fluctuations around the threshold levels but it can be flickering again.

For example, without hysteresis and TL at 5 bar it flickers for any point between 4.95 and 5.05. With hysteresis it does not flicker between 4.95 and 5.05 but it flickers between 4.90-4.95 and 5.05-5.10 :D

For that reason I gave up on the hysteresis and tried to do it manually from inside the program. If you ask me, non of these solutions is ideal and I believe that expensive instruments that provide HyperAccuracy can be used for higher precision. But that would require much higher budget.

Do you agree with me or I should have done things differently ???

Share this post


Link to post
Share on other sites

Sounds like your noise is about ±0.1. Make the hysteresis deadband larger until it doesn't flicker.  Like I suggested above.  That will tell you the peak-to-peak magnitude of your noise.

Then you can pursue mitigations.  I recommend starting with electrical and physical so you maintain maximum responsiveness.  Like I suggested above.  Only then would I move to software solutions.  You can add digital filtering to the algorithm options (which would permit a smaller deadband, but add latency).

If you don't feel confident writing histogram code, see if your PLC can do internal high speed recordings into a buffer.  Studying captured full-speed data can help (Fourier transformed, perhaps).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0