Internet PLC Forum

General => Technical support => Topic started by: mace123s on January 25, 2016, 11:08:22 AM

Title: FX PLC Programming Help
Post by: mace123s on January 25, 2016, 11:08:22 AM
I need help writing a statement to capture the minimum analog input.
When the eye is blocked I need to start reading an analog input (0-5VDC) from a scanner
and when the eye is clear I need to log the minimum analog input during that period.
The scanner is reading the diameter of a pole.
Any help would be greatly appreciated.
                                                            Thanks
Title: Re:FX PLC Programming Help
Post by: garysdickinson on January 25, 2016, 12:42:28 PM
Measuring a time difference between events is not terribly difficult to do with the PLC.

I have a few questions that I'd like to ask you about your application.  With these answers I'd be happy to help you solve your problem.

If you could use an optical sensor that can be connected directly to the PLC, then you have a lot more options of how to make the measurement.

Gary D*ickinson





Now you just need to measure how long the INPUT is active.  Depending on
Title: Re:FX PLC Programming Help
Post by: mace123s on January 25, 2016, 06:10:00 PM
I'm using a Banner EZ-ARRAY Scanner. Im using the npn discrete output to signal the start and stop of the scanning cycle.
The analog output represents the pole diameter which varies per pole because the poles are tapered. The Diameters vary from 2" to 12". The poles are sold by the smallest diameter per pole. The poles scanned also vary in length from 6'6" to 20' long. I'm using encoder pulses to measure the length of the poles. The analog signal is proportional to the number of beams blocked on the scanner so the analog signal is proportional to the pole diameter. I just need a way to log the analog signals minimum value for the length of the scan cycle.
Thanks
Title: Re:FX PLC Programming Help
Post by: garysdickinson on January 25, 2016, 08:37:38 PM
Since you have an INPUT that indicates the start of the item that your are scannong and a second INPUT that goes active at the end of the item, the problem is pretty simple:


I've attached a the ladder logic to solve the problem.

There are 3 CF (custom functions) used. One to reset the minimum detector, one to sample the ADC(1) value and the last to display the minimum value.


' RstMinDetector - CF to reset the minimum detector
'
SetLCD 0,1, "\01"   ' clear LCD screen
MinValue = 4095      ' reset to the max ADC ouput value
[/font][/color]
*******************************************************

' Measure - CF to take an ADC measurement and keep track of the smallest value
'
CurrentValue = ADC(1)   ' take the measurement

SetLCD 1,1, "ADC(1): " + str$(CurrentValue) + "    "

' Minimum detector
'
if CurrentValue < MinValue
   MinValue = CurrentVAlue
endif
[/font][/color]
*******************************************************

' DispMin - CF called to display the minimum value on the LCD display
'
SetLCD 2,1, "Min: " + str$(MinValue)
[/font][/color]
*******************************************************

Oh I am a big fan of using the Define Variable names.

The variable "CurrentValue" is defined as DM32[1]
and the variable "MinValue is defined as DM32[2].

Best of luck

Gary D*ickinson