Shop OBEX P1 Docs P2 Docs Learn Events
BASIC Stamp Tutorial? — Parallax Forums

BASIC Stamp Tutorial?

ice-egozice-egoz Posts: 55
edited 2004-08-05 01:45 in BASIC Stamp
Hi, what does 13 mean?
are all numbers in ASCII code?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I need all ya guidance Masters. [noparse]:)[/noparse]

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-04 03:36
    Can you be more specific?

    If you see 13 in a DEBUG or SEROUT statement, it is the same as a carriage return. The BASIC Stamp has a built-in constant, CR, that has the value 13.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ice-egozice-egoz Posts: 55
    edited 2004-08-04 03:43
    'Bring the DTR high so the camera will know that it is about to recieve input
    high 13
    so this is CR? how does that get the DTR to be High?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I need all ya guidance Masters. [noparse]:)[/noparse]
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-04 03:45
    No, no, no -- this makes P13 an output and sets its level to five volts (digital 1).· The syntax for HIGH is:

    · HIGH pin

    Where pin can have a value of 0 to 15 (P0 to P15).

    When in doubt, you can hilight (double-click)·a keyword in your code, then press the [noparse][[/noparse]F1] key to open the help file to that keyword. There you'll get a full explanation and demo code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ice-egozice-egoz Posts: 55
    edited 2004-08-04 03:49
    '{$STAMP BS2}
    ' Bring the DTR high so the camera will know that it is about to recieve input
    high 13
    pause 970
    ' Use Yellow - data Pin 2
    ' Brown - ground Pin 5
    ' Orange - dtr Pin 8 (use CTS pin)

    Loop:
    BAUD_MODE CON 84
    ' Send out the command to take a picture
    serout 15, BAUD_MODE , [noparse][[/noparse]$7C,$00,$00,$00,$00,$00,$00,$1A]
    sleep 5

    goto Loop

    No idea. U might wanna look at this code. Maybe u can help me to understand..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I need all ya guidance Masters. [noparse]:)[/noparse]
  • AlWilliamsAWCAlWilliamsAWC Posts: 135
    edited 2004-08-04 13:33
    OK, let's go a line at a time:

    '{$STAMP BS2}· This tells the compiler what kind of Stamp we are using
    ' Bring...··········· This is a comment and the Stamp doesn't pay it any attention
    High 13············· Obviously, something is connected to the Stamp's P13 (DTR if you believe the comment above). This makes P13 an output and puts 5V on that output
    Pause 970········· This causes the program to pause 970mS. Because of overhead in the Stamp, this is probably giving a 1 second delay in real life
    ' More comments (omitted)

    Loop:··············· This is a label because it ends in a colon. Consider it a bookmark that some other piece of code will refer to
    BAUD_MODE CON 84··· This defines a constant for use later. This makes code more readable and easier to change later. This particular constant will set the baud rate of a SEROUT command, but you don't know that just by looking at this line (unless you are a good guesser)
    ' Send out the command to take a picture
    serout 15, BAUD_MODE , [noparse][[/noparse]$7C,$00,$00,$00,$00,$00,$00,$1A]·· This sends a string of bytes out of P15 (the serial port in this case). The baud rate will be 84 (the constant, which is 9600 baud on a BS2). The bytes are 7C, 00, ... 1A. These are raw bytes, not "7" "C", etc. So the $1A, for example, is a Control+Z.
    sleep 5············ This is another type of pause, but puts the Stamp in a low power mode Off hand I don't remember how long it will sleep, but the manual would tell you

    goto Loop········· Go to the Loop label (bookmark) and start over

    A few comments:
    1. The purpose of the code then is to turn DTR "on" (5V), wait a bit and then send 7C,00,00,00...,1A to the serial port. Wait a bit and then send it again (forever and ever).
    2. There is no reason for the CON statement to be inside the loop. It doesn't really matter, but conventionally this would be up near the top of the program. It doesn't execute (it is more like an instruction to the compiler than the Basic Stamp) so having it inside the loop is confusing.
    I might have written:
    '{$STAMP BS2}
    BAUD_MODE CON 84·· ' 9600 baud
    DTR CON 13············· ' Could use PIN with PBasic 2.5
    SOUT CON 15··········· ' ditto
    DTRDELAY CON 970··· ' pause time after asserting DTR
    PICDELAY CON 5······· ' Sleep delay between pictures

    ' Bring the DTR high so the camera will know that it is about to recieve input
    HIGH DTR
    pause DTRDELAY
    ' Use Yellow - data Pin 2
    ' Brown - ground Pin 5
    ' Orange - dtr Pin 8 (use CTS pin)

    CLoop:······················ ' Note Loop is probably reserved in PBasic 2.5
    ' Send out the command to take a picture
    serout SOUT, BAUD_MODE , [noparse][[/noparse]$7C,$00,$00,$00,$00,$00,$00,$1A]
    sleep PICDELAY
    goto CLoop

    This is the same code, but all the things someone might change is up at the top as constants. The flow is clearer with the baud rate constant lifted up also.

    Is this the Kodak code from sourceforge? I think they have a nice picture of one of our RS1 boards (http://www.awce.com/rs1.htm) connected to the camera. See http://camcontroller.sourceforge.net/dc3400.html·if you haven't already.

    Regards,

    Al Williams
    AWC
    Kits!
    http://www.awce.com/kits.htm
    ·
  • ice-egozice-egoz Posts: 55
    edited 2004-08-05 01:45
    Not too sure abt sourceforge but it is using RS-1, hehe [noparse]:)[/noparse] Thanks for making me understand BASIC language more. Thanks for taking the time, U made me smile thanks. But i have more qns in another topic. Thank You...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I need all ya guidance Masters. [noparse]:)[/noparse]
Sign In or Register to comment.