+ Reply to Thread
Results 1 to 9 of 9

Thread: How cane I make 2 programms in one ?

  1. #1

    Question How cane I make 2 programms in one ?

    German Version

    Hallo ich brauche eure Hilfe

    Ich baue einen Laufroboter der mit einer Fernbedienung gerade aus und rückwärts laufen kann. Doch ich bekomme es nicht hin diese 2 Programme in eins zu bekommen. Das vorwärts und rückwärts Laufen sollte von 2 Infrarot Sensoren einzeln aktiviert werden. Also wenn man mit einer Fernbedienung auf diesen einen Sensor drückt soll er vorwärts laufen. Wenn man mit der Fernbedienung auf den anderen Sensor drückt soll er rückwärts Laufen.
    Kann mir einer schreiben wie ich aus diesen 2 Programmes eins mache?

    Code:
    ' -----[ Title ]-----------------------------------------------------------
    ' Toddler Program 2.1 - First Steps Forward.bs2
    ' Run Movement Patters M0 to M8 to take several steps
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' -----[ Declarations ]----------------------------------------------------
    TiltStep         CON 5    ' TiltServo step size
    StrideStep       CON 5    ' StrideServo step size
    MoveDelay        CON 25   ' in micrcoseconds
    
    
    RightTilt        CON 620  ' Tilt limits
    CenterTilt       CON 750
    LeftTilt         CON 880
    
    
    
    
    RightForward     CON 650  ' Rechts
    StrideCenter     CON 750
    LeftForward      CON 950  '
    
    
    
    
    
    
    StrideServo      CON 12   ' Stride servo on P12
    TiltServo        CON 13   ' Tilt servo on P13
    
    
    MoveLoop         VAR Nib  ' Repeat movements
    Pulses           VAR Word ' Pulse variable
    
    
    INPUT            0        ' Pin0 als Eingang
    
    
    GreenLED         PIN     1' green LED is connected TO PIN 1
    
    
    IsOn             CON     0' LED is active lowigh
    IsOff            CON     1
    
    
    
    
    
    
    ' -----[ Initialization ]----------------------------------------------------
    
    
    
    
    ' -----[ Main Routine ]------------------------------------------------------
    ' Take three full steps.
    Main_Program:
        GOSUB M0 ' center servos
    ' -----[ Abfrage sensor ]----------------------------------------------------
        GreenLED = IsOn
    Sensor:
        IF IN0 = 1 THEN Sensor' Abfrageschleife
        GreenLED = IsOff
        DEBUG "Ab die Post!",CR
        GOSUB M0 ' center servos
        GOSUB M1 ' tilt right
        GOSUB M2 ' step left
        FOR MoveLoop = 1 TO 2 ' Anzahl der Schritte
            GOSUB M3 ' tilt left
            GOSUB M4 ' step right
            DEBUG "Step R",CR
            'PAUSE 10000
            GOSUB M5 ' tilt right
            GOSUB M6 ' step left
            DEBUG "Step L",CR
            'PAUSE 10000
        NEXT
        GOSUB M3 ' tilt left
        GOSUB M7 ' center feet
        GOSUB M8 ' center servos
    GOTO Main_Program
    
    
    ' -----[ Subroutines ]-----------------------------------------------------
    M0:
        FOR Pulses = 1 TO 100 STEP StrideStep
            PULSOUT TiltServo, CenterTilt
            PULSOUT StrideServo, StrideCenter
            PAUSE MoveDelay
        NEXT
    RETURN
    
    
    M1:
        FOR Pulses = CenterTilt TO RightTilt STEP TiltStep
            PULSOUT TiltServo, Pulses
            PULSOUT StrideServo, StrideCenter
            PAUSE MoveDelay
        NEXT
    RETURN
    
    
    M2:
        FOR Pulses = StrideCenter TO LeftForward STEP StrideStep
            PULSOUT TiltServo, RightTilt
            PULSOUT StrideServo, Pulses
            PAUSE MoveDelay
        NEXT
    RETURN
    
    
    M3:
        FOR Pulses = RightTilt TO LeftTilt STEP TiltStep
            PULSOUT TiltServo,Pulses
            PULSOUT StrideServo, LeftForward
            PAUSE MoveDelay
        NEXT
    RETURN
    
    
    ' rechter Schritt
    M4:
        FOR Pulses = LeftForward TO RightForward STEP StrideStep
            PULSOUT TiltServo,LeftTilt
            PULSOUT StrideServo, Pulses
            PAUSE MoveDelay
        NEXT
    RETURN
    
    
    M5:
        FOR Pulses = LeftTilt TO RightTilt STEP TiltStep
            PULSOUT TiltServo,Pulses
            PULSOUT StrideServo, RightForward
            PAUSE MoveDelay
        NEXT
    RETURN
    
    
    ' linker Schritt
    M6:
         FOR Pulses = RightForward TO LeftForward STEP StrideStep
            PULSOUT TiltServo,RightTilt
            PULSOUT StrideServo, Pulses
            PAUSE MoveDelay
        NEXT
    RETURN
    
    
    M7:
        FOR Pulses = LeftForward TO StrideCenter STEP StrideStep
            PULSOUT TiltServo,LeftTilt
            PULSOUT StrideServo, Pulses
            PAUSE MoveDelay
        NEXT
    RETURN
    
    
    M8:
        FOR Pulses = LeftTilt TO CenterTilt STEP TiltStep
            PULSOUT TiltServo,Pulses
            PULSOUT StrideServo, StrideCenter
            PAUSE MoveDelay
        NEXT
    RETURN
    
    
    das ist das erste Programm wo er vorwärts Läuft. Das Programm wird mit einer Fernbedienung aktiviert.
    
      IF IN0 = 1 THEN Sensor    <.< das ist für den Infrarot Sensor. Damit kann der Roboter erkennen das er das Programm                        abspielen soll
    
    
    Rückwärtslaufen: 
    
    ' -----[ Title ]-----------------------------------------------------------
    ' Toddler Program 2.2 - Walking Backwards.bs2
    ' Run Movement Patters M9 to M13 to walk backwards
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' -----[ Declarations ]----------------------------------------------------
    TiltStep CON 5 ' TiltServo step size
    StrideStep CON 5 ' StrideServo step size
    MoveDelay CON 20 ' in micrcoseconds
    RightTilt CON 620 ' Tilt limits
    CenterTilt CON 750
    LeftTilt CON 880
    RightForward CON 650 ' Stride limits
    StrideCenter CON 750
    LeftForward CON 850
    StrideServo CON 12 ' Stride servo on P12
    TiltServo CON 13 ' Tilt servo on P13
    MoveLoop VAR Nib ' Repeat movements
    Pulses VAR Word ' Pulse variable
    ' -----[ Initialization ]--------------------------------------------------
    ' -----[ Main Routine ]----------------------------------------------------
    Main_Program:
    GOSUB M9 ' center servos
    GOSUB M10 ' tilt right
    GOSUB M12 ' step back
    FOR MoveLoop = 1 TO 3
    GOSUB M13 ' tilt left
    GOSUB M14 ' step left
    GOSUB M15 ' tilt right
    GOSUB M16 ' step right
    NEXT
    GOSUB M13 ' tilt left
    GOSUB M17 ' center feet
    GOSUB M14 ' center servos
    END
    ' -----[ Subroutines ]-----------------------------------------------------
    M9:
    FOR Pulses = 1 TO 100 STEP StrideStep
    PULSOUT TiltServo, CenterTilt
    PULSOUT StrideServo, StrideCenter
    PAUSE MoveDelay
    NEXT
    RETURN
    M10:
    FOR Pulses = CenterTilt TO RightTilt STEP TiltStep
    PULSOUT TiltServo, Pulses
    PULSOUT StrideServo, StrideCenter
    PAUSE MoveDelay
    NEXT
    RETURN
    M11:
    FOR Pulses = LeftTilt TO CenterTilt STEP TiltStep
    PULSOUT TiltServo,Pulses
    PULSOUT StrideServo, StrideCenter
    PAUSE MoveDelay
    NEXT
    RETURN
    M12:
    FOR Pulses = StrideCenter TO RightForward STEP StrideStep
    PULSOUT TiltServo, RightTilt
    PULSOUT StrideServo, Pulses
    PAUSE MoveDelay
    NEXT
    RETURN
    M13:
    FOR Pulses = RightTilt TO LeftTilt STEP TiltStep
    PULSOUT TiltServo,Pulses
    PULSOUT StrideServo, RightForward
    PAUSE MoveDelay
    NEXT
    RETURN
    M14:
    FOR Pulses = RightForward TO LeftForward STEP StrideStep
    PULSOUT TiltServo,LeftTilt
    PULSOUT StrideServo, Pulses
    PAUSE MoveDelay
    NEXT
    RETURN
    M15:
    FOR Pulses = LeftTilt TO RightTilt STEP TiltStep
    PULSOUT TiltServo,Pulses
    PULSOUT StrideServo, LeftForward
    PAUSE MoveDelay
    NEXT
    RETURN
    M16:
    FOR Pulses = LeftForward TO RightForward STEP StrideStep
    PULSOUT TiltServo,RightTilt
    PULSOUT StrideServo, Pulses
    PAUSE MoveDelay
    NEXT
    RETURN
    M17:
    FOR Pulses = RightForward TO StrideCenter STEP StrideStep
    PULSOUT TiltServo,LeftTilt
    PULSOUT StrideServo, Pulses
    PAUSE MoveDelay
    NEXT
    RETURN

    Bitte helft mir ich bin 15 Jahre alt und habe keine Ideen mehr



    English Version ( Google translater )

    Hello I need your help


    I build a walking robot with a remote control that can just out and backwards. But I'm not getting out these 2 programs to get into one. The running back and forth should be activated by 2 infrared sensors individually. So when you press a remote control sensor on this one, he should move forward. When you press the remote control sensor on the other he is running backwards.
    Can I write a program, one of these two do?


    IF IN0 = 1 THEN Sensor
    <.<This is for the infrared sensor. The robot can recognize that he is to play the program

    Walking backwards:

    Code:
    ' -----[ Title ]-----------------------------------------------------------
    ' Toddler Program 2.2 - Walking Backwards.bs2
    ' Run Movement Patters M9 to M13 to walk backwards
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' -----[ Declarations ]----------------------------------------------------
    TiltStep CON 5 ' TiltServo step size
    StrideStep CON 5 ' StrideServo step size
    MoveDelay CON 20 ' in micrcoseconds
    RightTilt CON 620 ' Tilt limits
    CenterTilt CON 750
    LeftTilt CON 880
    RightForward CON 650 ' Stride limits
    StrideCenter CON 750
    LeftForward CON 850
    StrideServo CON 12 ' Stride servo on P12
    TiltServo CON 13 ' Tilt servo on P13
    MoveLoop VAR Nib ' Repeat movements
    Pulses VAR Word ' Pulse variable
    ' -----[ Initialization ]--------------------------------------------------
    ' -----[ Main Routine ]----------------------------------------------------
    Main_Program:
    GOSUB M9 ' center servos
    GOSUB M10 ' tilt right
    GOSUB M12 ' step back
    FOR MoveLoop = 1 TO 3
    GOSUB M13 ' tilt left
    GOSUB M14 ' step left
    GOSUB M15 ' tilt right
    GOSUB M16 ' step right
    NEXT
    GOSUB M13 ' tilt left
    GOSUB M17 ' center feet
    GOSUB M14 ' center servos
    END
    ' -----[ Subroutines ]-----------------------------------------------------
    M9:
    FOR Pulses = 1 TO 100 STEP StrideStep
    PULSOUT TiltServo, CenterTilt
    PULSOUT StrideServo, StrideCenter
    PAUSE MoveDelay
    NEXT
    RETURN
    M10:
    FOR Pulses = CenterTilt TO RightTilt STEP TiltStep
    PULSOUT TiltServo, Pulses
    PULSOUT StrideServo, StrideCenter
    PAUSE MoveDelay
    NEXT
    RETURN
    M11:
    FOR Pulses = LeftTilt TO CenterTilt STEP TiltStep
    PULSOUT TiltServo,Pulses
    PULSOUT StrideServo, StrideCenter
    PAUSE MoveDelay
    NEXT
    RETURN
    M12:
    FOR Pulses = StrideCenter TO RightForward STEP StrideStep
    PULSOUT TiltServo, RightTilt
    PULSOUT StrideServo, Pulses
    PAUSE MoveDelay
    NEXT
    RETURN
    M13:
    FOR Pulses = RightTilt TO LeftTilt STEP TiltStep
    PULSOUT TiltServo,Pulses
    PULSOUT StrideServo, RightForward
    PAUSE MoveDelay
    NEXT
    RETURN
    M14:
    FOR Pulses = RightForward TO LeftForward STEP StrideStep
    PULSOUT TiltServo,LeftTilt
    PULSOUT StrideServo, Pulses
    PAUSE MoveDelay
    NEXT
    RETURN
    M15:
    FOR Pulses = LeftTilt TO RightTilt STEP TiltStep
    PULSOUT TiltServo,Pulses
    PULSOUT StrideServo, LeftForward
    PAUSE MoveDelay
    NEXT
    RETURN
    M16:
    FOR Pulses = LeftForward TO RightForward STEP StrideStep
    PULSOUT TiltServo,RightTilt
    PULSOUT StrideServo, Pulses
    PAUSE MoveDelay
    NEXT
    RETURN
    M17:
    FOR Pulses = RightForward TO StrideCenter STEP StrideStep
    PULSOUT TiltServo,LeftTilt
    PULSOUT StrideServo, Pulses
    PAUSE MoveDelay
    NEXT
    RETURN
    Please help me I am 15 years old and I have no more ideas: (
    Last edited by davejames; 03-01-2013 at 07:18 PM. Reason: ...added [code][/code] tags

  2. #2

    Default Re: How cane I make 2 programms in one ?

    Zu hilfe!

    Do you mean a tv remote control, using modulated 38 kHz IR? You will need a special 3 pin IR receiver, such as http://www.amazon.com/TSOP1838-IR-In.../dp/B003IVGE6M which is active low, BTW.

    You also need Parallax's "read IR" routine to know which key was pressed. Do you know that routine?
    "Give a man an inch, and right away he thinks he's a ruler." Maxwell Smart

  3. #3

    Default Re: How cane I make 2 programms in one ?

    One general method to combine your programs is like this:

    main:
    read IR remote signal X
    if X=1 then forward
    if X=2 then backward
    goto main

    forward:
    (your routine to take 2 steps forward)
    goto main

    backward:
    (your routine to take 2 steps backward)
    goto main

    And that read IR routine can be found at http://www.parallax.com/StoreSearchR...ch=ir+receiver

    more specifically, http://www.parallax.com/Portals/0/Do...ectAppnote.zip
    "Give a man an inch, and right away he thinks he's a ruler." Maxwell Smart

  4. #4

    Default Re: How cane I make 2 programms in one ?

    Click image for larger version

Name:	IMG_0282.JPG
Views:	35
Size:	262.5 KB
ID:	99636

    This is the remote control with which the robot is started.

    Click image for larger version

Name:	IMG_0281.JPG
Views:	36
Size:	235.4 KB
ID:	99637Click image for larger version

Name:	IMG_0279.JPG
Views:	34
Size:	262.8 KB
ID:	99638Click image for larger version

Name:	IMG_0280.JPG
Views:	32
Size:	248.9 KB
ID:	99639

    and so does the robot. I have everything I need there. I just do not know how I get shut hammer out the running forward and reverse running together. I can not imagine by your post looks like it is the query of individual sensors.

  5. #5

    Default Re: How cane I make 2 programms in one ?

    Hey, that's a real Parallax Toddler. Great robot. Rare. In Germany, huh?

    Your IR receivers on the robot look OK, but that Samsung remote will be a problem, you need a Sony remote. Can you get a different universal remote and set it up like a Sony television remote?

    Do you have this document, with lots of code? www.parallax.com/dl/docs/books/edu/toddler.pdf
    "Give a man an inch, and right away he thinks he's a ruler." Maxwell Smart

  6. #6

    Default Re: How cane I make 2 programms in one ?

    No, the remote is ok I do not want every single keyboard on the remote control code ^^ I did it just so before the start of the robot by any click of the remote.


    The infrared sensor will be designed for the forward running and the other for the reverse rotation that is my problem I have no idea how to program it ...

  7. #7

    Default Re: How cane I make 2 programms in one ?

    Sorry, I can only help if you use a Sony TV remote. If you must use that remote, then you have to program it by yourself.

    Viel gluck!
    "Give a man an inch, and right away he thinks he's a ruler." Maxwell Smart

  8. #8

    Default Re: How cane I make 2 programms in one ?

    other helper here ? ^^

  9. #9

    Default Re: How cane I make 2 programms in one ?

    Breuli: I've offered to help you in several PMs, suggesting that you get a different remote using the Sony SIRC protocol, but you insist on using that Samsung remote you already have. If you would have spent $2 and bought a universal remote, we would have been done last week. You keep saying that you don't need all those buttons, but that is not helping your progress. If you want a small remote, then buy this and set it up for Sony TV: http://www.ebay.com/itm/New-Mini-Uni...item27cad18818
    "Give a man an inch, and right away he thinks he's a ruler." Maxwell Smart

+ Reply to Thread

Similar Threads

  1. Can I make a boe bot that looks like R2-D2?
    By BattleToads in forum General Discussion
    Replies: 2
    Last Post: 02-11-2013, 08:02 AM
  2. What would it take to make this?
    By NWCCTV in forum General Discussion
    Replies: 1
    Last Post: 08-08-2012, 06:01 AM
  3. Make pdu
    By marcla in forum Propeller 1 Multicore Microcontroller
    Replies: 3
    Last Post: 03-15-2008, 10:09 PM
  4. How to make a PCB
    By Archiver in forum BASIC Stamps Archive
    Replies: 1
    Last Post: 10-04-2000, 04:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts