Shop OBEX P1 Docs P2 Docs Learn Events
Barcode Sensor for Scribbler 2 — Parallax Forums

Barcode Sensor for Scribbler 2

DashingDashing Posts: 3
edited 2011-11-25 17:03 in Accessories
I just started using the Scribbler 2 robot and I'm programming using the Scribbler Program Maker (S2 v1.3). While most of the conditions are self-explanatory, I don't really understand how to use the barcode sensor. There are three icons for the barcode sensor, can anyone explain the difference between them and how to use them? Also, would the barcode sensor conflict with the line following sensor?

1.
1.jpg


2.
2.jpg


3.
3.jpg
118 x 80 - 3K
115 x 82 - 3K
117 x 80 - 4K

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-11-24 20:38
    Dashing,

    Welcome to the Parallax forum! Per your labels above,

    Number 1 returns true if the S2 passes over the #1 barcode in the forward direction.
    Number 2 returns true if the S2 passes over the #1 barcode in the reverse direction.
    Number 3 returns true if the S2 passes over the #1 barcode in either direction.

    -Phil
  • DashingDashing Posts: 3
    edited 2011-11-25 12:26
    Thanks Phil for your welcome and the explanaton.

    I was trying to program the robot to follow a black line on a white surface and stop at then end where the robot would see barcode #1. While the line following code works fine when I didn't add in the first conditon for the barcode, the robot doesn't seem to be following the black line after I add in the first condition for the barcode sensor. I pasted my program on the two pictures below. Can anyone explain to me did I do something wrong?

    1.jpg
    2.jpg
    755 x 695 - 132K
    650 x 468 - 77K
    1.jpg 131.7K
    2.jpg 77.3K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-11-25 12:52
    Combining line following in that way with barcode sensing may not be possible. The reason is that the barcode sensor looks for the same thing as the line sensor. When both reflective sensors detect something dark, the barcode sensor thinks it's looking at the first wide bar in the barcode, waits until the right sensor sees light again, then tries to process the barcode. Unfortunately sitting on a dark line looks just the same as the first barcode bar, and there's no way to tell the difference until it's too late and the robot has veered from the line.

    What you could try is to add the barcode sensor to the end of the line sensor test, such that if both sensors see "light", pause for a short instant, then test again. If both sensors then see dark, process the barcode. In your layout, you will want a short light-colored gap between the line and the first bar of the barcode.

    -Phil
  • DashingDashing Posts: 3
    edited 2011-11-25 16:50
    Thanks again Phil. Now I understand why the robot stop following the line after I inserted the barcode sensor. I tried it again with the barcode sensor in the end of the line sensor test, but it still didn't work. I guess barcode sensor just doesn't work with line following sensor at the same time. Do you know any other way to program the robot so it knows that it is the end of the course without the use of object sensor since I want to program it to avoid the obstacles on course also? I tried it again with the attached program in desperate attempt, but it didn't work.

    1.jpg


    I was hoping that if the robot is following the straight black line without the need to adjust near the end, no flag would be raised so it'll bypass all the conditions and goes to the end, which would exit the loop. However, the robot simply spins in circle in the end until it finds the black line again.
    651 x 670 - 113K
    1.jpg 113.2K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-11-25 17:03
    Even with an abrupt end to the line, one sensor will almost always not see it before the other one misses it, too. In that case, in your code, one of the flags will always be raised, and either of those flags will prevent the loop from exiting.

    -Phil
Sign In or Register to comment.