Shop OBEX P1 Docs P2 Docs Learn Events
Infrared Parallel Parking For SumoBot — Parallax Forums

Infrared Parallel Parking For SumoBot

SolEmoSolEmo Posts: 15
edited 2013-07-30 21:32 in Robotics
Coding For it. ( I wrote it):
' {$STAMP BS2}
' {$PBASIC 2.5}


DEBUG "PROGRAM RUNNING!!!"


'----[I/O]----


ServoLeft PIN 13
ServoRight PIN 12
IrLedLS PIN 2
IrSenseLS PIN 1
IrLedLF PIN 4
IrSenseLF PIN 11
IrLedRF PIN 15
IrSenseRF PIN 14
IrLedRS PIN 3
IrSenseRS PIN 0
LeDSpeaker PIN 5


'----[Constants]----


IrFreq CON 18000


'----[Variables]----


counter VAR Word
FREQOUT 4,2000,3000
irBits VAR Nib


irLS VAR Bit
irRS VAR Bit


'----[initialization]----


Start_Delay:
FOR counter= 1 TO 3
PAUSE 900
FREQOUT LedSpeaker,1000,3000


NEXT
'----[Main Routine]----
DO
FREQOUT 4,2000,3000


IF (irLS = 0) AND (irRS = 0) THEN
GOSUB Forward_Pulse
ELSEIF (irLS = 1) THEN
GOSUB AnotherParking
ENDIF
LOOP
Forward_Pulse:
FOR counter=1 TO 50
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20


NEXT
RETURN


AnotherParking:
FOR counter=1 TO 54
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20


NEXT


FOR counter=1 TO 15
PULSOUT 13,850
PULSOUT 12,850
PAUSE 20


NEXT
PAUSE 20
FOR counter=1 TO 73
PULSOUT 13,650
PULSOUT 12,850
PAUSE 20


NEXT


FOR counter=1 TO 14
PULSOUT 13,650
PULSOUT 12,650
PAUSE 20


NEXT


FOR counter=1 TO 4
PULSOUT 13,650
PULSOUT 12,850
PAUSE 20


NEXT
RETURN

I am using a 350-00003 (infrared LEDs) and 350-00014 (infrared receiver).
I don't know why it does not work as I wanted. It is first time using Infrared as my project. All the sensor are working perfectly.
Please help me to do some amend the coding if needed. PLEASE!!

Comments

  • ercoerco Posts: 20,256
    edited 2013-07-21 21:15
    SolEmo wrote: »
    I don't know why it does not work as I wanted.

    That makes it unanimous. None of us know either. We can't read your mind to know what you want, nor determine what it IS doing.

    Now seriously, what is it doing wrong, very specifically?
  • SolEmoSolEmo Posts: 15
    edited 2013-07-21 23:13
    It just move straight. Then the sensors couldn't detect the left side at all. I had checked the sensors and it is working perfectly alright. So I don't know is it my coding for the sensors are wrong.
  • FranklinFranklin Posts: 4,747
    edited 2013-07-22 08:39
    I had checked the sensors and it is working perfectly alright.
    How do you know the sensors are working in your final setup?
  • ercoerco Posts: 20,256
    edited 2013-07-22 08:58
    Looks like your code is copied/modified from Parallax or elsewhere for SumoBot, is that right? Did you test the stock unmodified code (which is likely perfect) on your bot?
  • SolEmoSolEmo Posts: 15
    edited 2013-07-22 17:44
    Yap. I did test the stock unmodified code on my bot.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-07-22 18:20
    You really should take the advice of others in your previous threads about this. It is never going to work "the way you expect" by just copying and pasting someone else's code, especially "sample" code. Sample code is just that, samples to get you started. You need to dig in and get your fingers dirty and modify the code to what you need. Noone here is going to do the work for you but we will ALWAYS help you out if we can and you put forward the effort.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-22 18:28
    By starting a new thread (this one makes three) about the same topic, readers can't see what help has already been offered.

    For example, someone might suggest using code tags in order to make your code more readable without realizing such action has already be suggested(and is still a good idea).
  • SolEmoSolEmo Posts: 15
    edited 2013-07-22 18:55
    Could you teach me how to use the infrared coding for it?? Cos I couldn't understand how to use the infrared coding at all.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-07-22 19:23
    Do you have a Piezo speaker connected? It looks to me like this command
    IrLedLF PIN 4
    would be incorrect if there is a Piezo on Pin 4. Can you post a pic of your setup?
  • SolEmoSolEmo Posts: 15
    edited 2013-07-22 19:30
    20130703_140619_6_bestshot.jpg

    This is my sumobot picture.
    1024 x 768 - 89K
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-07-22 19:49
    What Pin is IrLedLF PIN 4 attached to? You need to change the code to match where that IRLED is located. If it is on Pin4 and you have the Piezo speaker on Pin4 also it is not going to work correctly.
  • SolEmoSolEmo Posts: 15
    edited 2013-07-22 23:16
    If I wanted to detect just a few cm away, what freq should I use for the sensors??
  • ercoerco Posts: 20,256
    edited 2013-07-23 09:44
    You're asking a lot of those simple digital IR sensors, which are not particularly good at accurate distance measurements. You can try to calibrate using different IR frequencies, then when you accidentally bump and move your critically-maligned LEDs in those tubes and you lose all your calibration. It's an accident waiting to happen IMO.

    If it were me, I'd use either ultrasonic (PING or HC-SR04) or Sharp IR ranging sensors. Four sensors: front, rear, and two looking at the wall to tell if you were parallel.

    You've seen this? http://www.youtube.com/watch?v=LBCyhkz8S4E
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-07-28 22:21
    @erco, I am assuming you would recommend the Sharp IR sensors for a Wild Thumper also, correct? Do they work the same as the Parallax IR sensors? I need to get them ordered so there get to me when I return from Montana.
  • ercoerco Posts: 20,256
    edited 2013-07-30 20:45
    Parallax does sells one Sharp sensor, if that's what you're asking about: http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/776/Default.aspx?txtSearch=sharp+ir+sensor. They're probably no good outdoors in bright sunlight. And analog output means an ADC is required. BTW there are several variants with different ranges to choose from: http://www.junun.org/MarkIII/Store.jsp

    PINGs (or HC-SR04) are digital and much better outdoors.

    BTW, here's my Sharp IR demo as a digital sensor:
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-07-30 21:32
    Yea, I will most likely end up using Pings on my Wild Thumper. My parts are sitting at home waiting for my return and hopefully I can get the Thumper up and moving real soon.
Sign In or Register to comment.