Shop OBEX P1 Docs P2 Docs Learn Events
New to PBASIC — Parallax Forums

New to PBASIC

JimmioJimmio Posts: 43
edited 2005-05-19 14:15 in Robotics
How can I make the Boe-Bot say(in debug terminal)
DEBUG "Hi, I'm Boe. What's your name?"
Then be able to type in your name, and have it say
"Hello ----"

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-18 19:11
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    ReadName VAR Byte(10) ' Allocate 10 bytes for 'string'
    I9600 CON 84 + 16384 ' 9600 baud is 84, Inverted is 16384

    Main:
    SEROUT 16, I9600, [noparse][[/noparse]"Hi, I'm BOE. What's your name?", CR]
    SERIN 16, I9600, [noparse][[/noparse]STR ReadName\10\13] ' Read 10 bytes, or to CR
    SEROUT 16, I9600, [noparse][[/noparse]"Hello ", STR ReadName]
    GOTO MAIN

    -- or --

    Main2:
    · DEBUG "Hi, I'm BOE.· What's your name?", CR
    · DEBUGIN STR ReadName\10\13· ' Read 10 bytes, or to CR
    · DEBUG "Hello ", STR ReadName
    · GOTO MAIN2

    Post Edited (allanlane5) : 4/18/2005 7:15:25 PM GMT
  • JimmioJimmio Posts: 43
    edited 2005-04-18 19:13
    THANKS A MILLON! If I only knew that...
  • JimmioJimmio Posts: 43
    edited 2005-04-18 19:16
    I tried it, but it does not use the DEBUG TERMINAL?
  • JimmioJimmio Posts: 43
    edited 2005-04-18 19:20
    Then it repeats itself, over, and over, and over, and over...
    HOW DO I MAKE IT STOP?!?!?!?!?!?
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-18 19:23
    Funny, it should stop in the "SERIN" command until you enter another string.

    Suggestion 1: Read the manual.

    Suggestion 2:
    Main2:
    DEBUG "Hi, I'm BOE. What's your name?", CR
    DEBUGIN STR ReadName\10\13 ' Read 10 bytes, or to CR
    DEBUG "Hello ", STR ReadName
    STOP

    Note you are using a micro-processor, now. Usually you WANT a 'main' infinite loop to continue processing.
  • JimmioJimmio Posts: 43
    edited 2005-04-18 19:29
    where you say
    DEBUGIN STR
    ReadName does not work
    "Expected a byte variable"
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-18 19:29
    Read the manual?· C'mon, Allan, have you lost your mind?! tongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • JimmioJimmio Posts: 43
    edited 2005-04-18 19:53
    What does C1 and C2 mean?
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-18 19:58
    Well, if you left out the:

    ReadName VAR Byte(10)

    line, I guess it would complain. Sorry, I should have mentioned I was only replacing the 'MAIN: ... GOTO MAIN' part, with the MAIN2: ... GOTO MAIN2 part -- you still needed the variable declarations as given above.

    And Jon: yes, usually I refrain from the "have you read the manual on this?" comment, because sometimes people HAVE read the manual, they just didn't 'get it'. Even then, I'll try to give a helpful answer after that. Sigh.
  • JimmioJimmio Posts: 43
    edited 2005-04-18 20:02
    i mean to connect a speaker to pin 0, in index,DTMFOUT
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-18 20:45
    The schematic says C1 and C2 should be "10 uF Both".

    The goal here is to capacitively couple the AC signal to the speaker, while filtering any DC component. That's what the capacitors do for you.
  • dandreaedandreae Posts: 1,375
    edited 2005-04-19 19:25
    Jimmio said...
    What does C1 and C2 mean?
    Jimmio,

    C1 and C2 are labels in a schematic.· C usually stands capacitor and R usually stands for resistor.· Sometimes you'll see:

    C1 = 5pf
    C2 = 3300uf
    R1 = 10K
    R2 = 220ohm

    It's important to be able to read a schematic when putting together a project correctly.· There are of course other labels that I have not listed.· You definitely·want to read up on some basic electronics to give yourself a better understanding of electronics.· It is always a good practice to ask questions before damaging your circuit, it will save you money and head aches in the long run.

    Dave·


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Tech Support
    dandreae@parallax.com
    www.parallax.com

    ·
  • Tom WalkerTom Walker Posts: 509
    edited 2005-04-20 16:19
    All,
    From reading this and another similar thread from Jimmio, it sounds as though he is expecting the Stamp to "say" the string...unfortunately without the benefit of any help.

    Jimmio,
    Producing sound with a microcontroller is generally not a difficult thing, but speech is a whole different ball of wax. Typically, a speech "outputter" consists of some kind of tone generator...if you've ever seen someone who has had throat surgery and has to use a "voicebox" against their throat to speak, then you get the idea...it's nothing more than a device to produce a hum somewhere in the "normal" range of speech frequencies. This tone then goes through a "voicebox simulator" that shapes the tone into the various allophones that we use in speech, sometimes by simple manipulation of the frequency and sometimes by adding "noise" (for the sibilants, fricatives, and all of those other funny-sounding words) and sometimes by magic <g>. In the case of the afore-mentioned surgery recipient, their own throat and head perform this function on the tone from the handheld unit.
    On top of this, there is also a piece that converts the ASCII text (what you see in the DEBUG window) into a string of allophones for the processor to enunciate..this is a science that is "interesting" (and not always entirely successful) to say the least.
    With the above in mind, you should be getting the message that the Stamp, with its limited speed and memory space, is not capable of performing these tasks without some outside help. I would recommend the EMIC module that Parallax sells.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • JimmioJimmio Posts: 43
    edited 2005-05-19 04:13
    I have this code. How can I make it so it will follow commands?
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    ReadName VAR Byte(10) ' Allocate 10 bytes for 'string'
    I9600 CON 84 + 16384 ' 9600 baud is 84, Inverted is 16384
    ReadAction VAR Byte(10)
    Main2:
    DEBUG "Hi, I'm BOE. What's your name?", CR
    DEBUGIN STR ReadName\10\13 ' Read 10 bytes, or to CR
    Main3:
    DEBUG "Hello ", STR ReadName ,CR
    DEBUG "What would you like me to do?", CR
    DEBUGIN STR ReadAction\10\13
    DEBUG "So you want me to: ", STR ReadAction ,CR
    DEBUG "I'm starting your request",CR
    DEBUG "PLEASE WAIT",CR
    PAUSE 5000

    DEBUG "ERROR: incorrect wording of command",CR
    DEBUG "Starting over...",CR
    GOTO Main3
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-19 14:15
    Now you're pushing too far ... you will not be able to do text processing as your code suggests.· What you could do is accept single-character commands: F (forward), R (reverse), L (left), R (right), etc.·

    Here's a snippet of code that will handle upper- and lowercase letters:

    Get_Cmd:
    · DEBUGIN cmd
    · LOOKDOWN cmd, [noparse][[/noparse]"fFrRlLrR"], cmd
    · IF·(cmd > 7) THEN Get_Cmd
    · cmd = cmd / 2
    · ON cmd GOSUB Go_Fwd, Go_Rev, Go_Left, Go_Right
    · GOTO Get_Cmd

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.