Shop OBEX P1 Docs P2 Docs Learn Events
Laser Range Finder Image Viewer V1.2 , can only grab an image at 9600 and 19200 baud? — Parallax Forums

Laser Range Finder Image Viewer V1.2 , can only grab an image at 9600 and 19200 baud?

zappmanzappman Posts: 418
edited 2015-01-09 19:35 in Accessories
I am using the Laser Range Finder Image Viewer V1.2 software, and I can grab an image at 9600 and 19200 baud, but not at 11520, 57600 or 38400 baud, when using my serial bridge program.

Link to page to download viewer software: http://www.parallax.com/downloads/laser-range-finder-image-viewer

Version Details from the above URL:
Version 1.2

Adjusted serial port RX timeout based on baud rate (to avoid a timeout during frame grabs at baud rates 38400 and lower).
Reduced baud rate selection to 9600, 19200, 38400, 57600, and 115200 (it's unrealistic to use the tool with lower baud rates).
Modified serial port routines to work regardless of the user's current Windows Regional and Language Options settings (force character set encoding to Windows-1252).
Disabled COM port/baud rate selection while device is connected.

1) Does the "Laser Range Finder Image Viewer V1.2 software" work at 11520, 57600 or 38400 baud (can or has someone tested it)?
Yes, the Laser Range Finder Image Viewer V1.2 software" work at 11520, 57600 or 38400 baud, tested with my PropPlug.

2) Where can I download the "Laser Range Finder Image Viewer V1.1 software", so I can try it at at 11520, 57600 and 38400 baud?
I guess I don't need V1.1 since V1.2 works with my PropPlug

3) Any other help resolving this problem, will be appreciated.
Still need to get my serial bridge program working.




Here is a screen shot of a good LRF Image Grab at 19200 baud.
attachment.php?attachmentid=112740&d=1420836273


Here is a screen shot of the "LRF Index outside the bounds of the array." error, I get when trying a LRF Image Grab at 384000, 57600 or 115200 baud
attachment.php?attachmentid=112741&d=1420836826

I am using a Propeller Activity Board Rev. B running the code below connect the "Laser Range Finder Image Viewer" to the "LRF"
{{ ParallaxLaserRangeFinderBridge-001.spin
  ____________________________________________
  Code written by Duane Degn for
  use with Say It Module
  ____________________________________________
  Modified for use with
  Parallax Laser Range Finder
  Product ID 28044
  by M.Sapp 2015_01_09 

  Image grab works at 19200 and 9600 baud
  using 28044-LRF-ImageViewer-1.2 software
  and Propeller Activity Board Rev B

  This program must be loaded into EEPROM
  on the Propeller Activity Board.
  Then, "power off then on", "both the LRF and
  the Propeller Activity Board".
  Then, run the  "LRF-ImageViewer" software.

  REMEMBER: LRF Power must be cycled for theLRF to
  set to a new baud rate.
  _____________________________________________
}}
    
CON

  _Clkmode = xtal1 + pll16x     ' 80MHz  Change these two settings to match
  _Xinfreq = 5_000_000          ' your setup.

  ' Pin Assignments
  ' _LrfLed = 26                ' Connected to Led on Say It  15
 
  _LrfTx = 6                    ' Connected to Rx (Sn on LRF)
  _LrfRx = 7                    ' Connected to Tx (Sout on LRF)
  _DebugTxPin = 30
  _DebugRxPin = 31
 
  _LrfBaud = 19200             '11520 57600 38400 19200 9600  
   
OBJ

  Com[2] : "FullDuplexSerial"                 ' uses two cog
  
PUB Main | localIndex, localAttmpts

  
  Com[0].start(_DebugRxPin, _DebugTxPin, 0, _LrfBaud)
  Com[1].start(_LrfRx, _LrfTx, 0, _LrfBaud)
  waitcnt(clkfreq / 4 + cnt)

  repeat
    result := Com[0].rxcheck
    if result <> -1 and result <> 0
      Com[1].tx(result)
    result := Com[1].rxcheck
    if result <> -1 and result <> 0
      Com[0].tx(result)

Attached zip file:
ParallaxLaserRangeFinderBridge-001 - Archive [Date 2015.01.09 Time 15.24].zip

This is what I get when send the "v" command to the LRF
Parallax Laser Range Finder
Designed by Grand Idea Studio [www.grandideastudio.com]
Manufactured and distributed by Parallax [support@parallax.com]

FW = 1.0
MFG = 7FA2
PID = 7691
SLOPE = +0.00142183 (3ABA5CB6)
INT = -0.02270363 (BCB9FCF8)
PFC_MIN = 38

Comments

  • PublisonPublison Posts: 12,366
    edited 2015-01-09 13:57
    Did you try Joe Grand's web site?

    I have not gone through all the files available.

    http://www.grandideastudio.com/portfolio/laser-range-finder/
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-09 14:05
    My guess is the bridge program is either not keeping up with the higher data rates or messing up the timing of the bytes so the program doesn't receive them when it would be normally expected (too much latency).

    Do you have a PropPlug or other USB to serial device? I'd think the program would have a better chance of success using a USB to serial device than with using a serial bridge written in Spin.

    If you don't have a USB to serial device, and need to use the Activity Board as a bridge, it might help to use serial drivers with larger buffers.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-09 14:12
    I was going to offer to look for my LRF but it was within arms reach.

    I see the LRF has a spot for a PropClip but not a PropPlug but this doesn't matter since you'll want to use the "SIN" and "SOUT" pins. Just connect the PropPlug's RX to the SOUT pin and the TX to the SIN pin. The PropPlug's VSS needs to be connected to the LRF's "GND" pin. You'll need some way of connecting the "GND" pin to both the PropPlug and the LRF's power source.
  • zappmanzappman Posts: 418
    edited 2015-01-09 14:27
    Publison wrote: »
    Did you try Joe Grand's web site?

    I have not gone through all the files available.

    http://www.grandideastudio.com/portfolio/laser-range-finder/

    Hi Publison, yes I tried Joe Grand's web site. I could not find the the version 1.1 software on his site. His site only has a link to the version 1.2 software located on the Parallax site.
  • zappmanzappman Posts: 418
    edited 2015-01-09 14:51
    Duane Degn wrote: »
    My guess is the bridge program is either not keeping up with the higher data rates or messing up the timing of the bytes so the program doesn't receive them when it would be normally expected (too much latency).
    Makes sense, maybe the data is getting back to the Laser Range Finder Image Viewer V1.2 software too slow.
    Duane Degn wrote: »
    Do you have a PropPlug or other USB to serial device? I'd think the program would have a better chance of success using a USB to serial device than with using a serial bridge written in Spin.
    I found my PropPlug. Hooked it up to the LRF, Laser Range Finder Image Viewer V1.2 works at all baud rates.

    I have the LRF hooked to my spare Activity Board, because I am trying to write a Propeller C program, to use the LRF on my "FrankenBot" robot. I was getting intermittent errors when using the "v" version command, and "h" help command at baud rates over 19200. That is why decided to the configure the Activity Board into the bridge mode. Besides, taking distance measurements, I would like my "FrankenBot" robot to be able to save pictures to the Activity Boards sd card.
    Duane Degn wrote: »
    If you don't have a USB to serial device, and need to use the Activity Board as a bridge, it might help to use serial drivers with larger buffers.
    I am a beginner at programing, I will search for "serial drivers that have larger buffers".
  • zappmanzappman Posts: 418
    edited 2015-01-09 15:57
    I have edited post 1 and 6 of this thread since the Laser Range Finder Image Viewer V1.2 software works at all baud rates using my PropPlug.

    I would still like to use the Laser Range Finder Image Viewer V1.2 software with an Activity Board and a serial bridge program.

    My ultimate goal is to have a Propeller C program, that can save LRF image grabs to the sd card on an Activity Board.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-09 16:12
    zappman wrote: »
    I am a beginner at programing, I will search for "serial drivers that have larger buffers".

    Tracy Allen's version of the four port serial driver allows one to set the buffer sizes. I often use his driver even if I'm only using it with a single port. His driver correctly catches framing errors which are missed by most other serial drivers.

    I've had trouble using the driver with multiple ports at high bit rates. If you need two ports communicating at 115200bps both at the same time, you'll probably want to use two serial objects similar to the two instances of FullDuplexSerial in the bridge program.

    Unlike FullDuplexSerial, you can't just use two instances of the four port driver.

    Where previously we used:
    OBJ
    
      Com[2] : "FullDuplexSerial"                 ' uses two cog
    

    to declare the two drivers, if you want to do something similar with the four port driver you'll need:
    OBJ
    
      Com : "FullDuplexSerial4portB"                        ' uses one cog
      ComIo : "DataIo4PortB"
                                                     
      Aux : "FullDuplexSerial4port"                         ' uses one cog
      AuxIo : "DataIo4Port"
    

    "FullDuplexSerial4portB" can't be an exact copy of "FullDuplexSerial4port" with just a different name. The object has to have been changed so the compiler doesn't see it as the same object.

    If you want to use two 4 port drivers, you could use the "FullDuplexSerial4portB.spin" file in my GitHub "Cleaver" repository. You may also need "DataIo4PortB" which has many of the I/O methods such as "Dec" and "Hex". You shouldn't need either of the "DataIo4Port" objects if you're just modifying the serial bridge program.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-09 16:29
    I found the four port serial objects a bit intimidating the first time I used one.

    Here's the bridge program converted to use Tracy Allen's driver.
    {{ ParallaxLaserRangeFinderBridge-002.spin
      ____________________________________________
      Code written by Duane Degn for
      use with Say It Module
      ____________________________________________
      Modified for use with
      Parallax Laser Range Finder
      Product ID 28044
      by M.Sapp 2015_01_09 
    
      Image grab works at 19200 and 9600 baud
      using 28044-LRF-ImageViewer-1.2 software
      and Propeller Activity Board Rev B
    
      This program must be loaded into EEPROM
      on the Propeller Activity Board.
      Then, "power off then on", "both the LRF and
      the Propeller Activity Board".
      Then, run the  "LRF-ImageViewer" software.
    
      REMEMBER: LRF Power must be cycled for theLRF to
      set to a new baud rate.
      _____________________________________________
    }}
        
    CON
    
      _Clkmode = xtal1 + pll16x     ' 80MHz  Change these two settings to match
      _Xinfreq = 5_000_000          ' your setup.
    
      ' Pin Assignments
      ' _LrfLed = 26                ' Connected to Led on Say It  15
     
      _LrfTx = 6                    ' Connected to Rx (Sn on LRF)
      _LrfRx = 7                    ' Connected to Tx (Sout on LRF)
      _DebugTxPin = 30
      _DebugRxPin = 31
     
      _LrfBaud = 19200             '11520 57600 38400 19200 9600  
       
    OBJ
    
      Com : "FullDuplexSerial4portB"                        ' uses one cog
                                    
      Aux : "FullDuplexSerial4port"                         ' uses one cog
      
    PUB Main | localIndex, localAttmpts
    
      Com.Init 
      Com.AddPort(0, _DebugRxPin, _DebugTxPin, -1, -1, 0, 0, _LrfBaud)
      Com.Start                                            
     
      Aux.Init
      Aux.AddPort(0, _LrfRx, _LrfTx, -1, -1, 0, 0, _LrfBaud)
      Aux.Start                                    
    
      waitcnt(clkfreq / 4 + cnt)
    
      repeat
        result := Com.rxcheck(0)
        if result <> -1 and result <> 0
          Aux.tx(0, result)
        result := Aux.rxcheck(0)
        if result <> -1 and result <> 0
          Com.tx(0, result)
    

    The program compiles but I haven't tested it.

    The buffers may be adjusted in Tracy's driver by adjusting these constants.
    ' The following constants declare the sizes of the rx and tx buffers.
    ' Enter in the needed size in bytes for each rx and tx buffer
    ' These values can be any size within available memory. They do not have to be a power of two.
    ' Unused buffers can be reduced to 1 byte.
      RX_SIZE0                      = 80  ' receive buffer allocations
      RX_SIZE1                      = 80
      RX_SIZE2                      = 80
      RX_SIZE3                      = 80
    
      TX_SIZE0                      = 20  ' transmit buffer allocations
      TX_SIZE1                      = 20
      TX_SIZE2                      = 20
      TX_SIZE3                      = 20
    

    Apparently you're not supposed to set any of the buffers to zero but you could change the buffers to the unused ports to one if you wanted to same some RAM.

    You may want to set "RX_SIZE0" and "TX_SIZE0" to larger values.

    To make it easier to find all the objects, I attached the archive to this post.
  • zappmanzappman Posts: 418
    edited 2015-01-09 18:43
    ParallaxLaserRangeFinderBridge-002.spin does not work as good as ParallaxLaserRangeFinderBridge-001.spin

    I can load ParallaxLaserRangeFinderBridge-001.spin into the Activity Board and Laser Range Finder Image Viewer V1.2 can do image grabs at 19200 baud.

    When I load ParallaxLaserRangeFinderBridge-002.spin into the Activity Board and Laser Range Finder Image Viewer V1.2 can NOT do image grabs at 19200 baud. Also, the LRF will not set it's baud rate using ParallaxLaserRangeFinderBridge-002.spin.

    If I set the LRF baud rate with -001 loaded into the Activity Board, then switch the Activity Board to running -002, I can sometimes send the r, l, v, h commands to the LRF and get a response. But, I can't do an image grab, I get the out of bounds error.

    If you look at fullDuplexSerial4Port object page at http://obex.parallax.com/object/248 there is a comment that says:

    ksltd replied on Thu, 2013-12-26 12:47
    Confusion about transmit and receive loops

    Hi,

    I have a couple of questions about this object:

    1) It would seem that every character transmitted is preceded by a Mark bit that immediately precedes the Space that is the Start Bit. This means that each transmitted character is 11 bit times rather than just the 10 that are necessary. Am I missing something about the transmit code sequence? Is this extra bit necessary to get correct operation of the receive code?

    2)The receive code syncs to the start bit and then offsets 1/4 of a bit time before beginning to sample the next 9 bits. Is there a reason that the offset is 1/4 bit time rather than something closer to 1/2 bit time?

    Thanks!

    Maybe this is what is keeping "ParallaxLaserRangeFinderBridge-002.spin" from working?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-09 19:07
    zappman wrote: »
    Maybe this is what is keeping "ParallaxLaserRangeFinderBridge-002.spin" from working?

    It's very interesting to hear the FullDuplexSerial appears to work better in this situation. I'm not sure, but I thought full duplex serial also had the extra bit.

    Did you try changing the buffer sizes? I'd suggest making both the TX and RX buffers on port zero (in both objects) 1,000 bytes just make sure the buffer size isn't causing an issue.
  • zappmanzappman Posts: 418
    edited 2015-01-09 19:35
    I just tried making both the TX and RX buffers on port zero (in both objects) 1,000 bytes as shown below and I still can't get an image grab:
    ' The following constants declare the sizes of the rx and tx buffers.
    ' Enter in the needed size in bytes for each rx and tx buffer
    ' These values can be any size within available memory. They do not have to be a power of two.
    ' Unused buffers can be reduced to 1 byte.
      RX_SIZE0                      = 1000  ' receive buffer allocations    was 80
      RX_SIZE1                      = 80
      RX_SIZE2                      = 80
      RX_SIZE3                      = 80
    
      TX_SIZE0                      = 1000  ' transmit buffer allocations    was 20
      TX_SIZE1                      = 20
      TX_SIZE2                      = 20
      TX_SIZE3                      = 20   '
    
Sign In or Register to comment.