Shop OBEX P1 Docs P2 Docs Learn Events
Using the Ping sensor with the Propeller ( Hi Speed counting ) — Parallax Forums

Using the Ping sensor with the Propeller ( Hi Speed counting )

markustermarkuster Posts: 184
edited 2013-12-30 22:43 in Accessories
Hi,

I need to count boxes on a conveyor belt.

The speed is about 2 boxes per second.

Do you know if the propeller and the Ping sensor have enough
speed to count the boxes?

You can see the picture attached here .

Thanks.


boxesparallax.jpg
1024 x 712 - 42K
«1

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-12-11 06:29
    The Propeller has plenty of speed. The Achilles heel will be the rate of which the PING sensor responds, and it will vary depending on how close or far away the object is. I just tested mine with the Propeller DEMO code and scoped the signal pin at about 16 samples per second, so there should be plenty of overhead to count boxes within your required time frame. It might help if there is a default backing for when a box is not present.
    Backing
    |
    |
    X
    X
    X        .....          >|
    X        'BOX'           |PING sensor 
    X        '''''          >|
    X
    X
    
    


    Reference:
    http://www.parallax.com/downloads/ping-ultrasonic-distance-sensor-propeller-code
  • markustermarkuster Posts: 184
    edited 2013-12-11 07:19
    Hi,

    It seems 16 per second is more than enough.

    The enviroment is industrial , there are some elecric motors runing near ( 4 feet) . And do you know how to prevent
    electronic noise ?.

    In other words , the Ping with the Propeller could work in industrial enviroment or just hobby ?

    Thanks again.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-12-11 08:43
    You can't really prevent electrical noise, but you can shield from it. Standard shielding practices and clean power supply techniques (<-standard industrial requirements) should be fine as far as keeping electrical noise down to a minimum.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-11 09:24
    I think you'd be much better off using an optosensor, like one of these:

    A factory environment with conveyors running is a very noisy place at ultrasonic frequencies. That noise can interfere with ultrasonic sensors, giving false readings. I say this from experience, having failed with ultrasonics to measure and count apples using the technology.

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2013-12-11 10:02
    I think you'd be much better off using an optosensor, like one of these:

    A factory environment with conveyors running is a very noisy place at ultrasonic frequencies. That noise can interfere with ultrasonic sensors, giving false readings. I say this from experience, having failed with ultrasonics to measure and count apples using the technology.

    -Phil

    Phil beat me to it. Much better to use an IR sensor, and one that uses a 40KHz carrier rather than a constant IR source is virtually fool proof.
  • markustermarkuster Posts: 184
    edited 2013-12-11 12:19
    Hi,

    I started with an infrared sensor :
    http://www.ebay.com/itm/Adjustable-IR-Infrared-Sensor-Switch-3-80cm-w-Fixed-Rings-/390670330880?pt=AU_B_I_Electrical_Test_Equipment&hash=item5af5c42c00

    But I had some problems with it. Sometimes the sensor start sensing even without boxes on the conveyor belt.

    For this reason I thought about the PING sensor alternative but Phil wrotte : "...conveyors running is a very noisy place at ultrasonic frequencies..."

    For this reason I will try to use infrared egain , but do you know how to protect it from the industrial noise too.
    Do you have some information about it ?

    Mark.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-12-11 12:37
    The iR sensor that you bought certainly looks good, but there is nothing to verify that it used a carrier frequency and was set up to only receive the reflections of that frequency.

    Even with IR, the world is a noisy place... so having a device that transmits and receives one frequency eliminates the majority if not all the false positives. Without a modulated IR, heat from lights can make a lot of problems.

    Phil seems to have chosen a very expensive industrial option. There are other IR sensors that are quite inexpensive that work with a modulated IR.

    Can you clarify what kind of budget you desire for this project? It would narrow down suggestions.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-11 13:24
    What Loopy said about carrier frequency (i.e. modulation). There's nothing in the eBay listing to suggest that the sensor is modulated, and that makes all the difference.

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2013-12-11 18:39
    The most reliable system I have assembled consists of an IR emitter in the center of a 6 inches square piece of black painted aluminum and a 40KHz IR receiver module in a black painted tube. The emitter and receiver and receiver were mounted on opposite sides of the conveyor.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-11 18:43
    I have to agree that a through-beam setup is the most reliable, especially as compared to a reflective setup. And kwinn's extra preparations are certainly worth the effort under adverse circumstances.

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2013-12-11 18:56
    If you are using a propeller for this you could probably do it with a simple led and phototransistor. Have the propeller pulse the led on and off at a fixed rate, and read the output from the phototransistor to determine if it is blocked by a box. A box is detected by receiving no pulses for a period of time.
  • markustermarkuster Posts: 184
    edited 2013-12-13 07:46
    Hi ,

    After reading your posts It seems carrier frequency or modulation is important.

    I have and old sensor a friend gave to me some years ago , I found it at the web yestarday , but how do you know
    if this BM200-DDT has carrier frequency or modulation ?

    I have just one BM200-DDT and I am testing it at home now , it works fine, but home is not a noisy place.

    http://products.autonicsonline.com/item/photoelectric-sensors/light-common-type-photoelectric-sensors-bm-series-/bm200-ddt?

    Mark
  • kwinnkwinn Posts: 8,697
    edited 2013-12-13 19:18
    Using a carrier frequency makes the system less susceptible to ambient IR and electrical noise, and industrial/manufacturing sites tend to be very noisy. A well designed power supply also goes a long way towards reducing electrical noise.

    BTW, using a reflective sensor may be the wrong choice for this application. Typically they only have a range of a few inches, and it may be that cardboard IR reflectivity is not sufficient for even that distance.
  • markustermarkuster Posts: 184
    edited 2013-12-17 07:59
    Yes,

    I need just 10 inches (or less) range.
    Do you know if BM200-DDT could work fine with the Parallax Propeller microcontroller ?

    here is the link:
    http://products.autonicsonline.com/i...es-/bm200-ddt?

    Thanks.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-17 08:30
    Your link doesn't go anywhere.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-17 14:21
    The sensing distance on that unit is 200 mm (8") max. I think a thru-beam sensor would be more reliable than a reflective one.

    As to interfacing to the Prop, it should be easy: the ouput is open-collector, so just pull it up to 3.3V with a 2.2K resistor.

    -Phil
  • markustermarkuster Posts: 184
    edited 2013-12-17 15:39
    Thanks Phil:


    But, how I can "pull it up to 3.3V with a 2.2K resistor"

    Do you have some information about this ?

    Is it like the attached picture , with R=2.2K ?

    Thanks,

    pinndice.jpg
    298 x 169 - 8K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-17 17:08
    Like this:

    attachment.php?attachmentid=105629&d=1387328882

    But, again, use a thru-beam sensor, not a reflective one. With a reflective sensor you risk two kinds of error: 1) missing a box entirely, and 2) counting the same box twice.

    For optimum reliability, you can use two thru-beam sensors spaced half a box width apart. The outputs will be in quadrature with each other, so if a box backs up slightly then resumes forward motion, it won't get counted twice. Also, if someone waves their arm through the beams, it won't get counted as a box.

    -Phil
    380 x 280 - 2K
  • markustermarkuster Posts: 184
    edited 2013-12-17 17:27
    Thanks,

    Is the resistor (at your last attachemt ) 2.2 K ?

    It seems I have to send a connetion to the +3.3volts of the voltaje regulator of the Propeller
    , and the +12 volts power suply and R Must be 2.2K resistor

    Is this correct ?

    Thanks again. I will test.

    PS: If I have problems I will try thru-beam sensor.
    PS2: I thought you will not post because it is late , I was waiting your post , thanks.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-17 18:16
    markuster wrote:
    Is the resistor (at your last attachemt ) 2.2 K ?
    Yes, although the exact value is not important. Anything between, say, 1K and 2.7K will work just fine.

    The open-collector output of the sensor only pulls down (to 0V). This gives you the luxury of selecting the high voltage by choosing which level to tie the pull-up to. By tying it to the Prop's Vdd level, you automatically get compatibiloity with the Prop's inputs.

    BTW, my very first industrial application was counting boxes in an apple-packing plant. It was not easy! Based upon that experience, I can only further advise this: keep the leads between the sensor and Propeller short!

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2013-12-17 23:02
    Both of Phil's suggestions are excellent, particularly the one to use two thru-beam sensors spaced half a box width apart. If mounting the sensor and IR source on opposite sides of the conveyor is a problem there are two alternate mounting methods. You can use an "L" shaped bracket to mount the sensor above and behind the conveyor, and place the IR emitter below and between the rollers. The second method would use a "C" shaped bracket to mount the sensor above the center of the conveyor, and the IR emitter between the rollers below it. Having the sensor pointing at the floor reduces the pickup of stray IR.
  • markustermarkuster Posts: 184
    edited 2013-12-18 13:03
    Hi,

    I tested the sensor and it works fine.

    The Propeller is near the sensor ( 3 feet) .

    But:
    I have to send the data to a PC. The problem I have is about the distance between the Propeller
    and the PC it is about 100 feet. I add the prop plug to the Propeller and I am converting the serial to the RJ45 I tested at home and it works fine
    but It has been impossible in the real work.

    Perhaps the noise , I don't know.

    I will continue working and I will tell you if I have succes , thanks.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-18 13:35
    For that much distance between the Prop and the PC -- especially in a noisy industrial environment -- I would definitely use RS422 comms with your twisted-pair cable.

    -Phil
  • markustermarkuster Posts: 184
    edited 2013-12-20 06:39
    Hi,

    I will do the job with RS422.

    But I don't understand about "RS422 comms with your twisted-pair".

    Is the standard cable used at offices ( 15 feet aprox. ) to join to the Net called twisted-pair, or twisted-pair cables are
    used for RS422.

    In other words:
    Is it important a twisted-pair cable or a non twisted-pair cable. Must be twisted to use with RS422 ?

    And how I can twist the cable , I have to twist at the end of the cable ? ( Do you have an schematics to understand it ? )

    Sorry , I am a little confused.

    thanks.
  • JLockeJLocke Posts: 354
    edited 2013-12-20 08:21
    The individual wire pairs are already twisted around each other inside the insulating jacket of the cable. See the article here: Twisted pair-Wikipedia
  • markustermarkuster Posts: 184
    edited 2013-12-20 13:49
    Ok,

    but do you know if the individual wire must be crossed like the pictures ?

    You can see at picture 1 of 7 , that the first position of connector 1 is joined with the third position of the connector 2.

    Then , picture 2 = 2 joined with 6
    Then , picture 3 = 3 joined with 1
    Then , picture 4 = 4 joined with 4
    Then , picture 5= 5 joined with 5
    Then , picture 6 = 8 joined with 8
    ....
    ...

    Is this ok ?

    Thanks.
    642 x 482 - 34K
    642 x 482 - 33K
    642 x 482 - 41K
    642 x 482 - 39K
    642 x 482 - 40K
    642 x 482 - 43K
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-12-20 14:07
    Generally the solid colored wire is twisted with the striped wire of the same color. These are a twisted pair inside the cable. The position on the connectors get switched around on crossover cables which is not the same as a twisted pair, though crossover cables have twisted pairs inside. I doubt you'll want to use a crossover cable in this application (I think crossover cables are used with ethernet equipment). A normal cat5 line should have four sets of twisted pairs to choose from.

    RS422 uses differential signals. By twisting the wires with the signals together, you insure any noise received by one wire is also received by the other. Since the noise will be on both wires of the differential pair, it can be cancelled out. (I think I got most of that right. I'm mostly just spouting back what I've read on the forum.)
  • markustermarkuster Posts: 184
    edited 2013-12-20 15:32
    Hi,

    It is alittle difficult to understand to me.

    So, I have to use a twisted cable and I have to crossover cables near the connectors like the pictures ?

    Do you have something to read or a a link to an schematic picture ?


    Thanks
  • kwinnkwinn Posts: 8,697
    edited 2013-12-20 19:15
    Duane Degn wrote: »
    .............................................
    RS422 uses differential signals. By twisting the wires with the signals together, you insure any noise received by one wire is also received by the other. Since the noise will be on both wires of the differential pair, it can be cancelled out. (I think I got most of that right. I'm mostly just spouting back what I've read on the forum.)

    Right on Duane.

    Markuster, both signals (+ and - , also shown as A - B and Y - Z need to use the two wires in a single pair as shown in the attached diagram. The problem with pre-made ethernet cables is that the pinouts of the connectors are not straight forward. That is why a lot of industrial and building automation equipment uses screw terminal strips. If you want to use off the shelf ethernet cables you need to take the wiring of the crossover cable into account when you connect the RS422 transmitters and receivers to the female RJ45 connectors. The attached diagram shows the typical wiring.

    PS Using off the shelf cables is a good idea and well worth the minor inconvenience of dealing with the crossover wiring.
    1024 x 333 - 39K
Sign In or Register to comment.