Joe Grand's Laser Range Finder--Speed Up

I was disappointed that the time to take a measurement was 1.2 seconds. I started looking at the code. Here is a possible speed up. Tested on a demo board, not the range finder. The code does some byte swapping
I replaced that with this code
Attached is an archive of my test code.
John Abshier
repeat index from 0 to (5119) ' For each long in the buffer... 263 milliseconds
val := LONG[fbPtr][index] ' Read value from memory
tmp.BYTE[0] := val.BYTE[3] ' move Y0 into array location 0
tmp.BYTE[2] := val.BYTE[1] ' move Y1 into array location 2
LONG[fbPtr][index] := tmp ' write long back into main memory
I replaced that with this code
repeat index from 0 to (5119) ' For each long in the buffer...
long[fbPtr][index] <-= 8
Original is 264 milliseconds. Rotate version is 117 milliseconds. Savings of 147 milliseconds.Attached is an archive of my test code.
John Abshier
Comments
Very cool - I'll add this to my list of optimizations. I'm open to any other suggestions people may find, as well. The beauty of an open-source design is allowing lots of sets of eyes (and brains) to examine the inner workings.
I do have a few ideas on how to increase the camera frame rate (currently at a 2MHz pixel clock), which would decrease the time-per-measurement. The current 1Hz sample rate is OK for certain applications, but the faster the rate, the more potential uses there are!
Take care,
Joe
repeat iy from 0 to (blob[ix * 4 + g#BLOB_RIGHT] - blob[ix * 4 + g#BLOB_LEFT]) ' for each column X within the blob {** repeat iy from blob[ix * 4 + g#BLOB_LEFT] to blob[ix * 4 + g#BLOB_RIGHT] **} {** val := roi[iy] **} {** blob[ix * 4 + g#BLOB_MASS] += val **} {** tmp += iy * val **} {** blob[ix * 4 + g#BLOB_CENTROID] := (tmp / blob[ix * 4 + g#BLOB_MASS]) ** } val := roi[(blob[ix * 4 + g#BLOB_LEFT]) + iy] ' get the current column's sum blob[ix * 4 + g#BLOB_MASS] += val ' add column sum to the total mass of the blob tmp += (iy + 1) * val ' weighted sum of all positive pixels in the blob blob[ix * 4 + g#BLOB_CENTROID] := (tmp / blob[ix * 4 + g#BLOB_MASS]) + blob[ix * 4 + g#BLOB_LEFT] - 1 ' calculate the true centroid (e.g., where in the blob the weight is centered)
John Abshier
John Abshier
Great! I'll take a look into this. I've also added it to my optimization list and will do some testing (when time permits) on the speed increases. I think these, coupled with some frame grab optimizations, will be a very nice improvement.
Joe
Can't help there.
Thanks!
Joe
Just to be correct, I was responding to the Aculux sensors portion of the post, not the speed of the current Parallax product.
BTW, this link works for me:
http://www.aculux.com/Products.htm