Shop OBEX P1 Docs P2 Docs Learn Events
REP command with BS2P — Parallax Forums

REP command with BS2P

FORDFORD Posts: 221
edited 2011-01-30 19:10 in BASIC Stamp
Hi All,
I read in one of Tracy Allens posts regarding use of a DS18B20 temperature device, a command "REP" within a debug command.
I have searched Parallax documentation and cant find anything realted to this command.

Can anyone provide a link, or an explanation of the REP command pleease.

Any help appreciated.

Cheers,
Chris,
Western Australia.

Comments

  • bsnutbsnut Posts: 521
    edited 2011-01-24 01:46
    I think the command you are talking about is DEC. I never seen what you are talking about and will have to look in to it later this morning when I get home from work.
  • FORDFORD Posts: 221
    edited 2011-01-24 01:52
    Thanks for the quick reply William,
    No its definately REP, and I have no idea of its purpose.
    Have searched manuals etc and can find nothing.

    See the code below written by Tracey Allen...

    DEBUG "degC=", REP "-"\signC, DEC ABS degC/10, ".", DEC1 ABS degC,TAB
  • Clive WakehamClive Wakeham Posts: 152
    edited 2011-01-24 02:09
    edit..... removed link.
  • bsnutbsnut Posts: 521
    edited 2011-01-24 05:32
    I found this in the Basic Stamp Editor Help file for REP.

    If you need to display the same ASCII character multiple times, the REP (repeat) formatter can help. REP takes the form: REP x\n ;where x is the character and n is the number of times to repeat it. For example:

    DEBUG REP "-"\10

    would display 10 hyphens on the screen, "
    ".

    I hope this helps you out, because I learned something too about this as well.
  • FORDFORD Posts: 221
    edited 2011-01-24 16:43
    William, thanks heaps mate.

    Thats expained it perfectly.

    Where did you find it in the help ?
  • davejamesdavejames Posts: 4,047
    edited 2011-01-24 19:42
    Ford,

    If you have the paper copy of the "Syntax and Reference" manual, version 2.2, REP is located on (or near) page 167 under the DEBUG section.

    If you have the Basic Stamp editor, version 2.4.2, open up the help and under the Index tab, enter "REP" and it will take you to the DEBUG section. Scroll down just shy of half way and you'll come across a table of Formatters. At the bottom of the table, REP resides.

    Thanks for asking this question - I had no idea the DEBUG (or SEROUT for that matter) supported this function.

    Later,

    DJ
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2011-01-25 00:02
    Hi Ford and others, I hope you'll find REP useful!

    The count can even be a zero. So
    REP "-"\signC
    either prints a minus sign or not depending on the sign bit of a number. The whole instruction line prints a temperature, either negative or positive. Note that the sign bit is given its own name as an alias for bit15 of the temperature Word variable.
    degC VAR Word
    signC VAR degC.bit15
    DEBUG "degC=", REP "-"\signC, DEC ABS degC/10, ".", DEC1 ABS degC,TAB
    

    A few other uses:

    -- Add a line feed conditionally to a line return, necessary for some displays but not others:
    LFb VAR BIT ' if this equals 1, print a LF after each CR
    DEBUG CR, REP LF\LFb

    -- Make an ascii graph on a screen, the position of the "X" depends on a variable line after line:
    ix VAR  BYTE
    FOR ix=0 TO 249
       DEBUG REP 32 \ (ix // 50), "X"    ' ix spaces followed by "X"
    NEXT
    

    -- Right justify text in a field of width W
    myString DATA 29, "What is going on at Parallax?" ' counted string, length in first byte
    n VAR BYTE
    char VAR BYTE
    w CON 40   ' 40 char width
    READ myString,n   ' length of string
    DEBUG REP 32\ (w-n)     ' leading spaces
    FOR n=1 TO w
       READ N + myString, char : DEBUG char
    NEXT
    
  • davejamesdavejames Posts: 4,047
    edited 2011-01-25 12:28
    Mr. Allen - thank you for the expansion on REP.

    I'll be copy/pasting this info into the file in which I keep tips & tricks.

    DJ
  • FORDFORD Posts: 221
    edited 2011-01-28 19:19
    Tracy,
    I am using your code to write 8 channels of temperature data to an Sd card at 1 minute intervals, using a bs2p.

    Thank you heaps for posting that code for the DS18B20, its a very neat bit of code.

    Hope alls well over your way,
    We are on Cyclone watch alert today, very rare for so far South here in Western Australia.

    Again, thank you.

    Cheers,
    Chris
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2011-01-29 10:57
    So much going on in Australia this month. We've seen the viral Toowoomba Flood video on U-tube, and last night's news showed fireballs above some petroleum storage facility near Sidney, but I trust Western Australia might be out of the flood and fire zone. Good luck with that cyclone! Here in the San Francisco it is our usual overcast or foggy mornings and sunny afternoons.

    I was curious which DS18B20 code you were using. One I had posted used the skipRom command to address one single device, or and another used the readROM to discover the unique address of a single device on the line, which could then be entered as fixed data to address multiple devices. But I don't think I posted one that did a full seach and enumeration with multiple unknown devices on the buss. I used to have that, but can't find it at the moment.
  • FORDFORD Posts: 221
    edited 2011-01-30 19:10
    Hi Tracy,
    Thanks again,

    I would like to see the code you used to enumerate the devices.
    I have done lots with ds1996 memory stuff, but have never tried enumeration with 1wire devices.
    I am using 8 i/o to read 8 devices, so enumeration would be a great help, as I want to ad some ralays later, so will need some spare i/o for that.

    Best regards,
    Chris.
Sign In or Register to comment.