Author Topic: FX PLC Programming Help  (Read 6020 times)

mace123s

  • Newbie
  • *
  • Posts: 8
  • I'm a llama!
    • View Profile
FX PLC Programming Help
« 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

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:FX PLC Programming Help
« Reply #1 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.
  • Are you using some sort of optical sensors to detect the "pole"?
  • If yes, why are you using an optical sensor with an analog output?  
  • Can you use an optical sensor that has NPN ouptuts that are compatible with PLC INPUTs.  A example is this sensor from Automation Direct http://www.automationdirect.com/static/specs/pe18mmfalaser.pdf
  • How many seconds does the pole block the beam?
  • How accurate do you need the measurement to be?  +/- 1 second? +/- 0.1 second? +/- 0.001 second?

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

mace123s

  • Newbie
  • *
  • Posts: 8
  • I'm a llama!
    • View Profile
Re:FX PLC Programming Help
« Reply #2 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

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:FX PLC Programming Help
« Reply #3 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:

  • On the rising edge of the StartScan INPUT reset your minimum detector
  • On the rising edge of the EndScan INPUT display the minimum value
  • In between the StartScan and the EndScan events, periodically call a CF to measure the object and keep track of the minimum analog value

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
« Last Edit: January 26, 2016, 06:24:29 PM by garysdickinson »