Shop OBEX P1 Docs P2 Docs Learn Events
Ascii — Parallax Forums

Ascii

oldhippyoldhippy Posts: 36
edited 2014-10-21 19:34 in General Discussion
I am having trouble getting the BS2 to read and display ASCII code from a sensor. any Suggestions

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-10-05 18:43
    Sensor? What sensor?
    It send s ASCII code?
    How does the BS2 get the data? Via SERIN?
    If it's SERIN, have you looked at SERIN and DEBUG in PBASIC Help?
  • kwinnkwinn Posts: 8,697
    edited 2014-10-05 19:32
    oldhippy wrote: »
    I am having trouble getting the BS2 to read and display ASCII code from a sensor. any Suggestions

    Please post a data sheet, link to the data sheet, or part number of the sensor so we can help you. Almost all sensors I have come across with the exception of gps receivers send data in some form of binary.
  • oldhippyoldhippy Posts: 36
    edited 2014-10-06 06:15
    sensors have an RS232 data format (with 0V to Vcc levels) The output is an ASCII capital “R”, followed by four ASCII character digits representing the range in millimeters,
    followed by a carriage return (ASCII 13).
  • oldhippyoldhippy Posts: 36
    edited 2014-10-06 06:19
    THE SENSOR is a MaxBotix MB 7369 www.maxbotix.com
  • Mike GreenMike Green Posts: 23,101
    edited 2014-10-06 07:05
    SERIN <pin>,<Baud code>,[wait("R"),dec4 range]

    See the Stamp Manual for details, but the above will wait for the character "R", then take the next 4 bytes as a decimal integer and put the value in the variable called range. The carriage return will be ignored.
  • oldhippyoldhippy Posts: 36
    edited 2014-10-06 08:12
    thanks i'll give it a try
  • oldhippyoldhippy Posts: 36
    edited 2014-10-07 06:09
    that doesn't work
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-10-07 06:28
    oldhippy wrote: »
    that doesn't work

    Exactly what didn't work?
  • oldhippyoldhippy Posts: 36
    edited 2014-10-07 08:01
    Nothing worked. I looked at the out from the sensor with a scope and it seemed to be sending data however the stamp didn't show anything in the debug. Called MaxBotix and they will try to come up with some code.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-10-07 08:22
    oldhippy wrote: »
    Nothing worked....MaxBotix and they will try to come up with some code.

    Why won't you post what "code" you tried?
  • PublisonPublison Posts: 12,366
    edited 2014-10-07 10:26
    oldhippy wrote: »
    Nothing worked. I looked at the out from the sensor with a scope and it seemed to be sending data however the stamp didn't show anything in the debug. Called MaxBotix and they will try to come up with some code.

    Did you try the code from their site?
    [COLOR=#000000][FONT=Verdana]'Reads both the PW and serial outputs[/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana]' {$STAMP BS2} [/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana]' {$PBASIC 2.5} [/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana]' www.danderrick.com/[/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana]' permission for unlimited use granted to all [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Verdana]' First test of the MaxSonar®-EZ1™[/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana]' micro µ [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Verdana]' ------- P PINs ----------------------------- [/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana] [/FONT][/COLOR][B]pMaxRecv PIN 15 
     pMaxClock PIN 14
     pMaxPWM PIN 0[/B][COLOR=#000000][FONT=Verdana] [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Verdana]' --------------- X Variables ----------------- [/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana] [/FONT][/COLOR][B]xDist VAR Word 
     xPulse VAR Word 
     xX VAR Byte [/B]
    
    [COLOR=#000000][FONT=Verdana]' ============ Main loop ================ [/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana] [/FONT][/COLOR][B]DO GOSUB sPWM 
    GOSUB sSerial 
    DEBUG CR, CR 
    PAUSE 50 
     LOOP 
     END [/B][COLOR=#000000][FONT=Verdana]  ' never reached [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Verdana]' ------------- Subs ------------------------ [/FONT][/COLOR]
    
    [COLOR=#000000][FONT=Verdana] [/FONT][/COLOR][B]sPWM:[/B][COLOR=#000000][FONT=Verdana] 'Max sends 147 µs per inch [/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana]'BS2 reads for 2 µs [/FONT][/COLOR]
    [COLOR=#000000][FONT=Verdana]    [/FONT][/COLOR][B]FOR xX = 1 TO 5 
    HIGH pMaxClock 
    PULSIN pMaxPWM, 1, xPulse 
    LOW pMaxClock 
    DEBUG DEC5 xPulse, " " 
    PAUSE 50 
    NEXT 
    DEBUG CR 
    RETURN 
    
    sSerial: 
    FOR xX = 1 TO 5 
    SERIN pMaxRecv\pMaxClock, 16468, [WAIT ("R"), DEC xDist] 
    DEBUG DEC5 xDist, " " 
    PAUSE 50 
    NEXT 
    DEBUG CR 
    RETURN[/B][COLOR=#000000][FONT=Verdana] [/FONT][/COLOR]
    
  • PublisonPublison Posts: 12,366
    edited 2014-10-07 10:36
    Looks like they are using 8 BIT No-Parity Inverted in the sample code, (TTL mode).

    You can try Baudmode 84 which is 8 BIT No-Parity Non-Inverted. You have the RS-232 and the TTL would probably be inverted data.
  • oldhippyoldhippy Posts: 36
    edited 2014-10-10 11:11
    new to this trying to figure it out
  • oldhippyoldhippy Posts: 36
    edited 2014-10-10 11:12
    yes i tried this code but no luck. Am calling MaxBotix for more answers
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-10-10 11:45
    For some reason Maxbotix calls their inverted TTL "RS-232". It's really just inverted TTL.

    Do any of the above suggestions show how to receive inverted data with the BS? Can the BS receive inverted serial? If the BS can't receive inverted serial then oldhippy will need to use an inverter of some sort.

    You could also receive the data from the sensor by monitoring the pulse from one of the pins. I believe this behaves a lot like the Ping except you don't need to trigger the sensor.

    I suppose you could also use RCTIME and read the analog signal the sensor uses.

    Edit: I see Publison posted code to use both the serial data and the pulse data.
  • davejamesdavejames Posts: 4,047
    edited 2014-10-10 12:05
    oldhippy - what model of Basic Stamp are you using (BS2, BS2e, BS2pe, etc.)? This matters as the baudmode value used in the sample code (16468, 8-bit, no parity, inverted, 9600) is for a particular set of Stamps.
  • davejamesdavejames Posts: 4,047
    edited 2014-10-20 16:39
    oldhippy - any resolve to this?
  • GenetixGenetix Posts: 1,754
    edited 2014-10-21 16:28
    He said he's using a BS2.

    That code Publison posted also uses a Pin for Flow-Control which I am guessing is the Ranging Start/Stop Pin.

    Hippy, how do you have this thing wired and how are you powering it?
  • davejamesdavejames Posts: 4,047
    edited 2014-10-21 19:34
    Genetix wrote: »
    He said he's using a BS2.

    ...yup - I understand. Often times users will use "BS2" for any model, and I'm attempting to clarify that he's not using something other than a vanilla BS2.
Sign In or Register to comment.