LaserPING 2m Rangefinder

Hi!
I have an automation project that requires a large number of sensors (up to 30). I pretend to use an S7-1200 CPU 1215C PLC and these distance sensors (https://www.parallax.com/product/28041). Is it possible to connect these sensors to the PLC? If so, where can I find more information about the serial communication protocol used? Could you recommend any modules to perform this connection?
And is it possible (or advantageous) to use the PWM output in this situation?
Also, since multiple sensors would be operating simultaneously and close to each other, is there any risk of occurring crosstalk? If so, how can I avoid interferences? Or how to compute the minimum distance at which I can place two sensors without having them interfering with each other?
Thank you in advance.

Comments

  • Maria,
    First of all welcome to the Forums. There is a PDF file available in the link to the Laser-Ping that gives all of the specifications for this product including the protocols for serial communications.
    The question regarding proximity has two answers. The first is the firing sequence of the sensors and second is the distance from the sensor to the measured object. I would recommend using the PWM output for this application as it gives you control over when the sensor fires in the serial mode you have no control over this. Two sensors that are triggered at the same time must be far enough apart that the field of view does not overlap. The data sheet says the FOV is 55 degrees. With the PWM mode of operation, you can fire two sensors simultaneously when one can not see the return from the other. In the serial mode, you would be forced to physically place all of the sensors far enough apart so the signal from one could not interfere with another. I can not offer you any help regarding you processor choice. I hope this rambling reply can offer you some assistance.
    Jim
  • Hi!
    I have an automation project that requires a large number of sensors (up to 30). I pretend to use an S7-1200 CPU 1215C PLC and these distance sensors (https://www.parallax.com/product/28041). Is it possible to connect these sensors to the PLC? If so, where can I find more information about the serial communication protocol used?

    All of the information for the laser ping is available on the page you posted a link to. Look at the bottom of the page.
    Could you recommend any modules to perform this connection?

    If this were my project I would use one of the Propeller boards to interface the ping sensors to the PLC. This way you can translate the PWM or serial output to the protocol the PLC requires and you have help from the members of this forum if you run into problems.
    And is it possible (or advantageous) to use the PWM output in this situation?

    It might be if the PLC can convert the pulse width to a numeric value.
    Also, since multiple sensors would be operating simultaneously and close to each other, is there any risk of occurring crosstalk? If so, how can I avoid interferences? Or how to compute the minimum distance at which I can place two sensors without having them interfering with each other?
    Thank you in advance.

    They probably would interfere with each other if they were all triggered at or close to the same time. Using PWM would allow you to trigger each sensor in sequence to avoid interference. Placement may help avoid interference, but the results would depend on the geometry of the sensors and sample/area being measured.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • Thank you very much for your replies!
    Sorry, I never heard about propeller boards. Could you please recommend a propeller board? Where can I find more information about it?
    I think I have two possible solutions. The first one consists of translating the PWM output to a voltage (0-10V) signal and then connect it to an analog I/O module. The second one (which I don't know if it's even possible) consists of having all sensors sharing the same serial bus and then using a serial communication board as an interface with the PLC.
    I think S7-1200 doesn't support PWM inputs. I would need some conversion module to translate it into a voltage/current signal.
    Thank you in advance!
  • Tracy AllenTracy Allen Posts: 6,405
    edited 2019-08-21 - 16:56:32
    The propeller FLIP module is a good option.
    https://www.parallax.com/product/32123

    It could excite and read each of the sensors in quick succession and transmit the readings to your PLC via one serial bus. Pretty easy. Help is here on the forum and from great Parallax education material.
  • Any one of the following boards would be able to do what you want. I use the Propeller Activity Board WX for prototyping and the Propeller Project Board USB as the final board for projects that do not need a lot of additional circuitry such as yours would be. Based on what you have posted I would think the only additional circuitry you would need is an RS232 transceiver IC and a 5V to 16V AC adapter.

    The Propeller board would then be programmed to convert the PWM inputs from the LaserPING modules to numeric values and send them over the serial link to the S7-1200 CPU 1215C PLC.

    https://www.parallax.com/product/40000 - P8X32A QuickStart
    https://www.parallax.com/product/32150 - Propeller Mini
    https://www.parallax.com/product/32214 - Propeller ASC+
    https://www.parallax.com/product/32810 - Propeller Project Board USB
    https://www.parallax.com/product/32912 - Propeller Activity Board WX
    https://www.parallax.com/product/32123 - Propeller FLiP microcontroller module
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.

  • Thank you very much for your replies!
    Is it possible to send the data via RS485 interface using the Modbus RTU protocol? Where can I find more information about the programming?
    I already read the datasheets and guides for some of the products you recommend. However, I wasn't able to find information on how to deal with PWM inputs and how to generate serial signals. Could you please recommend any documentation/ guides?
    Also, are propeller boards suitable for industrial applications (robustness is a critical requirement)?
    Thank you in advance!
  • Thank you very much for your replies!
    Is it possible to send the data via RS485 interface using the Modbus RTU protocol?
    Yes, it is possible. Hardware wise it only requires an RS422/RS485 driver IC instead of the RS232 IC I suggested earlier. On the software side you need to create data packets that conform to the Modbus RTU protocol and the PLC requirements.
    Where can I find more information about the programming?
    I already read the datasheets and guides for some of the products you recommend. However, I wasn't able to find information on how to deal with PWM inputs and how to generate serial signals. Could you please recommend any documentation/ guides?
    Everything you need for using the board (i'm assuming the Propeller Project Board USB) is available on the Parallax site. If you click on the "Store", then the "Shop" button, you will get a menu on the left. Select "Board", Propeller, and finally select the Propeller Project Board USB and you will end up on a page that has links to the Details, Downloads & Documentation, and Additional Resources you will need.

    There are software "Objects" in the OBEX for serial I/O and PWM that you can download and use, although you may have to make some modifications to them.
    Also, are propeller boards suitable for industrial applications (robustness is a critical requirement)?
    Thank you in advance!

    So far I have not had a single board failure of in the field, and the earliest one I installed was in January 2012, so I have no qualms about the robustness and reliability of the Propeller boards.

    PS - I will take a look in the OBEX for suitable PWM objects for your application later today and make suggestions in another post.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • Tracy AllenTracy Allen Posts: 6,405
    edited 2019-08-22 - 21:21:45
    It is not PWM in the traditional sense. The microcontroller generates a short (>~2µs) low-high-low output pulse on a Pin, and then makes that same pin an input, and waits for it to go high again, and then low. The high duration in microseconds is proportional to distance to the target. Search is for "PING" at obex.parallax.com.

    From the old PING))) Demo, the Spin code as follows. It uses the internal cnt (count) register to time the pulses to a resolution of 1µs. That's it. Your application would execute this code for laserPINGs on a succession of pins, then send the distance values to the PLC in the acceptable format. You will also find modbus specific code via a search on the OBEX. Here is a link to JohnnyMac's nice EIA-485 object.
    PUB Millimeters(Pin) : Distance                                                  
    ''Measure object distance in millimeters                                             
      Distance := Ticks(Pin) * 10_000 / 29034                                       ' Distance In Millimeters
    
    PUB Ticks(Pin) : Microseconds | cnt1, cnt2
    ''Return Ping)))'s one-way ultrasonic travel time in microseconds                                                                                 
      outa[Pin]~                                                                    ' Clear I/O Pin
      dira[Pin]~~                                                                   ' Make Pin Output
      outa[Pin]~~                                                                   ' Set I/O Pin
      outa[Pin]~                                                                    ' Clear I/O Pin (> 2 µs pulse)
      dira[Pin]~                                                                    ' Make I/O Pin Input
      waitpne(0, |< Pin, 0)                                                         ' Wait For Pin To Go HIGH
      cnt1 := cnt                                                                   ' Store Current Counter Value
      waitpeq(0, |< Pin, 0)                                                         ' Wait For Pin To Go LOW 
      cnt2 := cnt                                                                   ' Store New Counter Value
      Microseconds := (||(cnt1 - cnt2) / (clkfreq / 1_000_000)) >> 1                ' Return Time in µs
    
  • Thank you very much for your replies! They were really helpful!
    Could you please recommend an RS485 driver IC? And could you explain why I need one?
  • Hi!
    Do I need a propeller board per sensor? I thought about connecting multiple sensors to the same propeller board. However, I would need long cables (up to 5 m) and, for what I read, PWM signals don't support long distances.
    If I decide to use the RS485 interface, can I connect all propeller boards to the same bus? How can I set each propeller board address (to make sure they're different)?

    Thank you in advance!
  • Hi!
    Do I need a propeller board per sensor? I thought about connecting multiple sensors to the same propeller board. However, I would need long cables (up to 5 m) and, for what I read, PWM signals don't support long distances.

    A single Propeller board can handle multiple sensors, and it may be worth trying some of the line drivers used for digital data transmission. The critical part of the PWM signal processing is the timing of the signal. As long as the time between the leading edge and following edge of the PWM pulse is maintained it should maintain accuracy. Simpler and less costly to connect many sensors to one Prop board.
    If I decide to use the RS485 interface, can I connect all propeller boards to the same bus? How can I set each propeller board address (to make sure they're different)?

    Thank you in advance!

    Yes, that is generally how RS485 works. Typically the data is sent as serial data bytes of a standard format. If you use a Prop board for each sensor you will need to assign them individual ID's (an address).

    Do you plan to have the Props process the readings or is that going to be done on a PC?
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • Thank you very much for your reply!
    I understand what you're saying. So, I don't have to worry about cable length? (my sensors would be placed some meters apart from each other)
    I am planning on having a PLC (S7-1200) processing the data. To achieve that, I also need an RS485 communication module (that's why I wanted to transmit data via an RS485 bus).
  • Thank you very much for your reply!
    I understand what you're saying. So, I don't have to worry about cable length? (my sensors would be placed some meters apart from each other)
    I am planning on having a PLC (S7-1200) processing the data. To achieve that, I also need an RS485 communication module (that's why I wanted to transmit data via an RS485 bus).

    I would not go so far as to say you don't have to worry about cable length, but 5 meters should not be a problem. As long as the the cable is terminated properly and is not such a small diameter that it attenuates the signal too much. If this was my project I would first see if 20/22 gauge twisted pairs and RS485 drivers/receivers with 120 ohm resistors on the receiver end would work for sending the PWM signal from the laser ping to the Propeller pin. That reduces the the number of different parts required by 1
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • Thank you very much for your reply!
    For example, if I'm using the Propeller FLiP microcontroller, what is the maximum number of PWM sensors I could connect to a single microcontroller? Is there any expansion module to increase this number?
    Thank you in advance!




  • kwinnkwinn Posts: 8,392
    edited 2019-09-05 - 15:42:35
    Thank you very much for your reply!
    For example, if I'm using the Propeller FLiP microcontroller, what is the maximum number of PWM sensors I could connect to a single microcontroller? Is there any expansion module to increase this number?
    Thank you in advance!

    You will need at least one pin, and probably two for serial data (30, 31) as well as two for the eeprom (28, 29) that holds the code for the Propeller, which leaves 28 pins for PWM.

    As far as additional inputs go, since you activate the pings sequentially you could use standard logic chips to multiplex groups of LaserPings, however it would probably be simpler to add a Propeller (or Propellers) if you need more than 28 inputs. How many LaserPings do you think you might need?
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • Thank you very much for your reply!
    Probably, less than 28, so one propeller must be enough.
  • Pins 30 and 31 are used for uploading and debugging new firmware, so, I'd recommend using a different set of pins for the EIA485 connection to the PLC. At last during the development phase. That would reduce the number of pins available for laserPings to 25 or 26.

    On the Propeller, the EIA485 connection requires either 2 or 3 pins:
    -- rx and tx separately plus direction, 3 pins,
    or,
    -- rx/tx combined plus direction, 2 pins
    The second option is possible because half duplex comms don't receive and transmit at the same time. Most '485 chips can be set up to do either option, but the firmware is a bit different.

    In either case, the Propeller, and probably also the PLC, would be resting in receive mode. The master goes into transmit mode, sends an address and a command, whereupon the target propeller makes one or a number of measurements, and then goes into transmit mode long enough to send back the requested reading(s).

    One very nice thing about the Propeller is that it has multiple COGs, one of which can constantly scan the sensors and process the readings, while another handles communication with the PLC. Data always immediately available. Processing of readings may be desireable for filtering or for calibration of zero and scale factors.
Sign In or Register to comment.