Help hacking a laser tape measure?

N

N_Cook

Guest
Firstly for anyone else playing with these neat cheap laser diode
measuring devices.
I'm initially playing with a (Lidl) Parkside PLEM 50 (50m range), to
eventually use a Lomvum LV 120 (120m range) coupled to a pc via
Pi/Arduino. Both have 4 line 7segment LCD plus annunciators display with
a "chip on glass" look-up page chip for decoding and driving the LCD.
Made by SZYCLCD.COM and ident YGFB178004-A1 on the .5mm spacing ribbon
and I know by swapping between each, they are compatible between both
devices , completely different external and internal appearance, but
same STM micro. 14 way ribbon to LCD , 2 w for backlight, 2w for power
to chip on glass and a number of apparently inactive lines in
measurement mode anyway . So d0 clock , d3 and d4 used for SPI update
principal lastline of LCD and d2 +d3 active during power-up/first page
but not in measure mode.
Breaking-out at the ZIF ribbon socket and using Hobbycomponents
"matchbox" pulse analyser and Sigrok/Pulseview and pairs of readings on
the lower line of the LCD, ie switch unit on, then just pressing
"measure" once initiates the SPI clock pulses. The LCD is updated from
switch-on display in 0.5 to 1 seconds , so the data must be contained
within the first 2 or 3 frames of data. Short duration bursts of clock
then various amounts of dead space , as much as 400mS between frames,
highly variable duration.
I was hoping the same as

https://www.mictronics.de/2018/02/laser-distance-meter-hack/4/
LookupTableLcdLastLine.pdf , on link
https://www.mictronics.de/?wpfb_dl=156
on seeing 17 4 bit words per frame (mainly, sometimes 13, sometimes 16)
The first frame seems to have only 4 variants and is re-used for totally
different last-line readings. Whatever I set sampling speed, clock
polarity or phase etc I cannot avoid the "smearing" between frames ,eg
348-384 : 05
378-403 : 00
403-428 : 04

429-1961499 : 0C

980976-981002 : 0D
981001-981026 : 00
981026-981051 : 04

how to tidy up word apportionment ?.

And then for pairs of metre/mm distance readings I cannot get any sense
of pertinent words to decode/look-up (redundant 0's removed here for
linwrap)
and only frames 2 and 3 including the "smears"
B1820 sequence looked promising as an ident but non appearance in one
dataset.


00012080049008B180208010400A200 =6.345a
8B18020400108A000001208004900 =6.345b

8B180200010400A4000044041002101 =5.085a
000120A000504CD0401048082004202 =5.085b
(B18020 sequence not appearing in any succeeding frame, well beyond 1
second)

00012080049088B180208010400A404 =1.564a
B180200010400A400008010400A404 =1.564b





--
Monthly public talks on science topics, Hampshire , England
<http://diverse.4mg.com/scicaf.htm>
 
On 8/5/2019 10:56 AM, N_Cook wrote:
Firstly for anyone else playing with these neat cheap laser diode
measuring devices.
I'm initially playing with a (Lidl) Parkside PLEM 50 (50m range), to
eventually  use a Lomvum LV 120 (120m range) coupled to a pc via
Pi/Arduino. Both have 4 line 7segment LCD plus annunciators display with
a "chip on glass" look-up page chip for decoding and driving the LCD.
Made by SZYCLCD.COM and ident YGFB178004-A1 on the .5mm spacing ribbon
and I know by swapping between each, they are compatible between both
devices , completely different external and internal appearance, but
same STM micro. 14 way ribbon to LCD , 2 w for backlight, 2w for power
to chip on glass and a number of apparently inactive lines in
measurement mode anyway . So d0 clock , d3 and d4 used for SPI update
principal lastline of LCD and d2 +d3 active during power-up/first page
but not in measure mode.
Breaking-out at the ZIF ribbon socket and using Hobbycomponents
"matchbox" pulse analyser and Sigrok/Pulseview and pairs of readings on
the lower line of the LCD, ie switch unit on, then just pressing
"measure" once initiates the SPI clock pulses. The LCD is updated from
switch-on display in 0.5 to 1 seconds , so the data must be contained
within the first 2 or 3 frames of data. Short duration bursts of clock
then various amounts of dead space , as much as 400mS between frames,
highly variable duration.
I was hoping the same as

https://www.mictronics.de/2018/02/laser-distance-meter-hack/4/
LookupTableLcdLastLine.pdf , on link
https://www.mictronics.de/?wpfb_dl=156
on seeing 17 4 bit words per frame (mainly, sometimes 13, sometimes 16)
The first frame seems to have only 4 variants and is re-used for totally
different last-line readings. Whatever I set sampling speed, clock
polarity or phase etc I cannot avoid the "smearing" between frames ,eg
348-384 : 05
378-403 : 00
403-428 : 04

429-1961499 : 0C

980976-981002 : 0D
981001-981026 : 00
981026-981051 : 04

how to tidy up word apportionment ?.

And then for pairs of metre/mm distance readings I cannot get any sense
of pertinent words to decode/look-up (redundant 0's removed here for
linwrap)
and only frames 2 and 3 including the "smears"
B1820 sequence looked promising as an ident but non appearance in one
dataset.


00012080049008B180208010400A200  =6.345a
8B18020400108A000001208004900    =6.345b

8B180200010400A4000044041002101   =5.085a
000120A000504CD0401048082004202   =5.085b
(B18020 sequence not appearing in any succeeding frame, well beyond 1
second)

00012080049088B180208010400A404   =1.564a
B180200010400A400008010400A404    =1.564b
What did he say?
Mikek
 
On 05/08/2019 16:56, N_Cook wrote:
> d2 +d3 active

d2 +d3 active should have read as d1 + d2 active

--
Monthly public talks on science topics, Hampshire , England
<http://diverse.4mg.com/scicaf.htm>
 
On Monday, 5 August 2019 16:55:48 UTC+1, N_Cook wrote:
Firstly for anyone else playing with these neat cheap laser diode
measuring devices.
I'm initially playing with a (Lidl) Parkside PLEM 50 (50m range), to
eventually use a Lomvum LV 120 (120m range) coupled to a pc via
Pi/Arduino. Both have 4 line 7segment LCD plus annunciators display with
a "chip on glass" look-up page chip for decoding and driving the LCD.
Made by SZYCLCD.COM and ident YGFB178004-A1 on the .5mm spacing ribbon
and I know by swapping between each, they are compatible between both
devices , completely different external and internal appearance, but
same STM micro. 14 way ribbon to LCD , 2 w for backlight, 2w for power
to chip on glass and a number of apparently inactive lines in
measurement mode anyway . So d0 clock , d3 and d4 used for SPI update
principal lastline of LCD and d2 +d3 active during power-up/first page
but not in measure mode.
Breaking-out at the ZIF ribbon socket and using Hobbycomponents
"matchbox" pulse analyser and Sigrok/Pulseview and pairs of readings on
the lower line of the LCD, ie switch unit on, then just pressing
"measure" once initiates the SPI clock pulses. The LCD is updated from
switch-on display in 0.5 to 1 seconds , so the data must be contained
within the first 2 or 3 frames of data. Short duration bursts of clock
then various amounts of dead space , as much as 400mS between frames,
highly variable duration.
I was hoping the same as

https://www.mictronics.de/2018/02/laser-distance-meter-hack/4/
LookupTableLcdLastLine.pdf , on link
https://www.mictronics.de/?wpfb_dl=156
on seeing 17 4 bit words per frame (mainly, sometimes 13, sometimes 16)
The first frame seems to have only 4 variants and is re-used for totally
different last-line readings. Whatever I set sampling speed, clock
polarity or phase etc I cannot avoid the "smearing" between frames ,eg
348-384 : 05
378-403 : 00
403-428 : 04

429-1961499 : 0C

980976-981002 : 0D
981001-981026 : 00
981026-981051 : 04

how to tidy up word apportionment ?.

And then for pairs of metre/mm distance readings I cannot get any sense
of pertinent words to decode/look-up (redundant 0's removed here for
linwrap)
and only frames 2 and 3 including the "smears"
B1820 sequence looked promising as an ident but non appearance in one
dataset.


00012080049008B180208010400A200 =6.345a
8B18020400108A000001208004900 =6.345b

8B180200010400A4000044041002101 =5.085a
000120A000504CD0401048082004202 =5.085b
(B18020 sequence not appearing in any succeeding frame, well beyond 1
second)

00012080049088B180208010400A404 =1.564a
B180200010400A400008010400A404 =1.564b

I'm not 'getting any sense of pertinent words' from this either.
Nor the reason for any of this.
 
Some of us have time on our hands.
Some of us have a perverse level of curiosity.
Which leads some of us to do strange things for no apparent reason.

Peter Wieck
Melrose Park, PA
 
On 8/6/19 7:36 AM, pfjw@aol.com wrote:
> Some of us have time on our hands.

And there are those of us that know how to use a text editor.

--
"I am a river to my people."
Jeff-1.0
WA6FWi
http:foxsmercantile.com
 
On 8/6/19 10:18 AM, tabbypurr@gmail.com wrote:
On Tuesday, 6 August 2019 13:36:38 UTC+1, pf...@aol.com wrote:
Some of us have time on our hands.
Some of us have a perverse level of curiosity.
Which leads some of us to do strange things for no apparent reason.

Peter Wieck
Melrose Park, PA

There is always a reason. The OP has not stated his.

Nigel doesn't need a reason.
He's constantly falling into these rabbit holes of no return.

--
"I am a river to my people."
Jeff-1.0
WA6FWi
http:foxsmercantile.com
 
On Tuesday, 6 August 2019 13:36:38 UTC+1, pf...@aol.com wrote:
Some of us have time on our hands.
Some of us have a perverse level of curiosity.
Which leads some of us to do strange things for no apparent reason.

Peter Wieck
Melrose Park, PA

There is always a reason. The OP has not stated his.
 
On 06/08/2019 16:18, tabbypurr@gmail.com wrote:
On Tuesday, 6 August 2019 13:36:38 UTC+1, pf...@aol.com wrote:
Some of us have time on our hands.
Some of us have a perverse level of curiosity.
Which leads some of us to do strange things for no apparent reason.

Peter Wieck
Melrose Park, PA

There is always a reason. The OP has not stated his.

A side-scan tide gauge (Google for one of those) Where no resident's
land is anywhere near the river water at low tide, just the top of the
tide. But 100m off land is about 98% of all the tide range , with large
collector lens (with bored=thru central hole for the outgoing laser )
works in lash-up so far. And unusually for tide gauges any wave action
increases the valid responses to the receiver at the required acute
angle. In line bright sunlight at 100m will probably be out though. Tide
height is then inversely proportional to the measured distance, as long
as the waves are not too high but that would just give a spread of
heights, averaging to about true presumably oe t least offsettable. A
"proper" geodometer with interface topc is far too expensive for this
sort of project.


--
Monthly public talks on science topics, Hampshire , England
<http://diverse.4mg.com/scicaf.htm>
 
I find simple curiosity to be both sufficient and necessary for this sort of quest. Nor do I see utility as having any particular value. But all-and-at the same time, I have many things that I am curious about that would come in way ahead of hacking a laser measure.

Peter Wieck
Melrose Park, PA
 
On 2019/08/06 9:26 a.m., N_Cook wrote:
On 06/08/2019 16:18, tabbypurr@gmail.com wrote:
On Tuesday, 6 August 2019 13:36:38 UTC+1, pf...@aol.com  wrote:
Some of us have time on our hands.
Some of us have a perverse level of curiosity.
Which leads some of us to do strange things for no apparent reason.

Peter Wieck
Melrose Park, PA

There is always a reason. The OP has not stated his.


A side-scan tide gauge (Google for one of those)  Where no resident's
land is anywhere near the river water at low tide, just the top of the
tide. But 100m off land is about 98% of all the tide range , with large
collector lens (with bored=thru central hole for the outgoing laser )
works in lash-up so far. And unusually for tide gauges any wave action
increases the valid responses to the receiver at the required acute
angle. In line bright sunlight at 100m will probably be out though. Tide
height is then inversely proportional to the measured distance, as long
as the waves are not too high but that would just give a spread of
heights, averaging to about true presumably oe t least offsettable. A
"proper" geodometer with interface topc is far too expensive for this
sort of project.

That would have been useful in the OP. Makes the project much more
interesting!

You could make (then secure and float) an IR reflector, much like a
radar reflector, for calibration.

https://www.instructables.com/id/Lightweight-Radar-Reflector/

John :-#)#
 
On Tue, 6 Aug 2019 02:00:38 -0700 (PDT), Phil Allison
<pallison49@gmail.com> wrote:

amdx wrote:


Nutcase_Kook wrote:


( snip pile of Kook's incomprehensible gibberish )





What did he say?

I can't get mine into games mode either.

** ROTFLMAO !!



.... Phil
 
On 06/08/2019 17:26, N_Cook wrote:
On 06/08/2019 16:18, tabbypurr@gmail.com wrote:
On Tuesday, 6 August 2019 13:36:38 UTC+1, pf...@aol.com wrote:
Some of us have time on our hands.
Some of us have a perverse level of curiosity.
Which leads some of us to do strange things for no apparent reason.

Peter Wieck
Melrose Park, PA

There is always a reason. The OP has not stated his.


A side-scan tide gauge (Google for one of those) Where no resident's
land is anywhere near the river water at low tide, just the top of the
tide. But 100m off land is about 98% of all the tide range , with large
collector lens (with bored=thru central hole for the outgoing laser )
works in lash-up so far. And unusually for tide gauges any wave action
increases the valid responses to the receiver at the required acute
angle. In line bright sunlight at 100m will probably be out though. Tide
height is then inversely proportional to the measured distance, as long
as the waves are not too high but that would just give a spread of
heights, averaging to about true presumably oe t least offsettable. A
"proper" geodometer with interface topc is far too expensive for this
sort of project.

Decoding so far, for anyone else doing similar (J makes an ideal search
engine term along with SZYCLCD.COM and ident YGFB178004-A1). 12MHz
sampling and 20 M samples per run on the analyser with d0 line for
trigger. SPI protocol with d3 as clock,d0 as MISO, d4 as MOSI, 4 bit
word length so superfluous analyser 8bit zeros removed in the following.
d1 and d2 only active during power-up page , not in measure mode.
For clarity and reduction, repeats in the coding via the following
look-up table.

J=
4,F,D,8,8,D,D,4,1,E,8,C,6,0,C,2,A,0,2,0,5,0,9,2,C,B,1,1,1,1,1,1,1,1,6,0,7,C,8,0,0,0,
K= 3,0,0,0,0,0,0,0,0,0,0,0,0,0,
L= 2,0,0,0,4,0,7,0,8,0,0,8,
N=2,0,A,0,0,8,4,0,8,0,0,4,
P=0,0,0,0,0,0,0,0,8,0,0,0,
Q=8,A,0,0,0,8,F,0,8,0,0,C,
R=0,0,4,0,5,0,8,0,0,8,
S=1,0,0,8,4,0,8,0,0,4,
T=1,0,0,8,F,0,8,0,0,C,
U=0,0,0,0,0,0,

Assuming J is invariant for this make and model in question, about 20
readings so far in the 1.000 to 2.000 display range ,it is invariant,
L to U would contain variation for units ,hundreds and thousands, DPs
and nulls and probably annunciators and other display rows data for the
other 3 lines in the display.

Single example of coding for the reading 1.264 in the bottom line for
the frames sent on pressing "measure" , running the analyser after
power-up each time and d0 line trigger occuring after pressing "measure"
, second frame is repeat of the first, powering down the measurer after
each reading.
1.264
J,K
L,K
N,K
Q,K
P,K
2,D,R,K
6,B,S,K
C,E,T,K
8,7,U,
J,K
2,D,R,K
6,B,S,K
C,E,T,K
8,7,U,

Preliminary decoding for readings in the range 1.0.. to 1.7..
for tenths in the rank P,K,*,x,R,K,*.y,S,K after the primary ident J,
where * is don't care/ignored and x,y is the coding
2 on the LCD codes to (x,y) D,B in the SPI
3 ~ D,7
5 ~ D,5
6 ~ D,D
7~ 9,7

for hundredths,
only *.*5* and *.*6* measures in the display so far
in the rank T,K,*,x,U
5 ~ SPI F
6 ~ 7
will probably require 1 or 2 other elements for the full set 0 to 9

for thousandths (for eventual use thousandths [mm] would be redundent)
R,K,x,*,S,K,y,*,T,K,z,*U
x, y, z SPI
1~ 6, 4, 0
2~ A, C, 4
3~ 6, C, 4
4~ 6, C, 8
6~ E, 8, C
7~ 6, 4, 4
8~ E, C, C


I might hookup an Arduino or a Pi , as in the intended usage , rather
than analyser ,for easier taking of pairs of readings/ LCD display
decoding look-up table determination , for the full set. There may be
transcription errors in the above of course.



--
Monthly public talks on science topics, Hampshire , England
<http://diverse.4mg.com/scicaf.htm>
 
On 24/08/2019 16:18, N_Cook wrote:
Decoding so far, for anyone else doing similar (J makes an ideal search
engine term along with SZYCLCD.COM and ident YGFB178004-A1). 12MHz
sampling and 20 M samples per run on the analyser with d0 line for
trigger. SPI protocol with d3 as clock,d0 as MISO, d4 as MOSI, 4 bit
word length so superfluous analyser 8bit zeros removed in the following.
d1 and d2 only active during power-up page , not in measure mode.
For clarity and reduction, repeats in the coding via the following
look-up table.

J=
4,F,D,8,8,D,D,4,1,E,8,C,6,0,C,2,A,0,2,0,5,0,9,2,C,B,1,1,1,1,1,1,1,1,6,0,7,C,8,0,0,0,

K= 3,0,0,0,0,0,0,0,0,0,0,0,0,0,
L= 2,0,0,0,4,0,7,0,8,0,0,8,
N=2,0,A,0,0,8,4,0,8,0,0,4,
P=0,0,0,0,0,0,0,0,8,0,0,0,
Q=8,A,0,0,0,8,F,0,8,0,0,C,
R=0,0,4,0,5,0,8,0,0,8,
S=1,0,0,8,4,0,8,0,0,4,
T=1,0,0,8,F,0,8,0,0,C,
U=0,0,0,0,0,0,

Assuming J is invariant for this make and model in question, about 20
readings so far in the 1.000 to 2.000 display range ,it is invariant,
L to U would contain variation for units ,hundreds and thousands, DPs
and nulls and probably annunciators and other display rows data for the
other 3 lines in the display.

Single example of coding for the reading 1.264 in the bottom line for
the frames sent on pressing "measure" , running the analyser after
power-up each time and d0 line trigger occuring after pressing "measure"
, second frame is repeat of the first, powering down the measurer after
each reading.
1.264
J,K
L,K
N,K
Q,K
P,K
2,D,R,K
6,B,S,K
C,E,T,K
8,7,U,
J,K
2,D,R,K
6,B,S,K
C,E,T,K
8,7,U,

Preliminary decoding for readings in the range 1.0.. to 1.7..
for tenths in the rank P,K,*,x,R,K,*.y,S,K after the primary ident J,
where * is don't care/ignored and x,y is the coding
2 on the LCD codes to (x,y) D,B in the SPI
3 ~ D,7
5 ~ D,5
6 ~ D,D
7~ 9,7

for hundredths,
only *.*5* and *.*6* measures in the display so far
in the rank T,K,*,x,U
5 ~ SPI F
6 ~ 7
will probably require 1 or 2 other elements for the full set 0 to 9

for thousandths (for eventual use thousandths [mm] would be redundent)
R,K,x,*,S,K,y,*,T,K,z,*U
x, y, z SPI
1~ 6, 4, 0
2~ A, C, 4
3~ 6, C, 4
4~ 6, C, 8
6~ E, 8, C
7~ 6, 4, 4
8~ E, C, C


I might hookup an Arduino or a Pi , as in the intended usage , rather
than analyser ,for easier taking of pairs of readings/ LCD display
decoding look-up table determination , for the full set. There may be
transcription errors in the above of course.

For units decodng

From the previous, for unit=1 eg 1.264
R=0,0,4,0,5,0,8,0,0,8,
S=1,0,0,8,4,0,8,0,0,4,
T=1,0,0,8,F,0,8,0,0,C,

unit is more simply represented by the first term of each of R,S and T
string and so preliminary look-up table
unit ~ SPI R(1) , S (1) , T(1)
1~ 0,1,1
2~ 3,2,1
5~ 1,3,2
6~ 3,3,2
8~ 3,3,3
9~ 1,3,3
10~ 3,5,7 (or maybe 0) , (plus 3,4 and 7 also unknown so far)
and the remaining 9 terms of R,S and T are invariant for the readings
taken so far.

When the sun goes down a bit, I'll try some pairings in the range 10 to
50 metres, for 10s decoding

--
Monthly public talks on science topics, Hampshire , England
<http://diverse.4mg.com/scicaf.htm>
 
Looks like tenths *.1** is 9,5 for the previous determinations.
Looks like processing for longer distances takes longer and timed-out
for 20M samples so will have to select more when I rerpeat.
Got display readings for 16.388, 26.766, 44.244 and 51.971m but full SPI
only for the shorter pair . I've had a display reading of >70m on this
when playing with the measurer on its own, so there is not an internal
timing/bounding limit to 50m. Resolution to 1mm in 70m but its absolute
accuracy , fixed positions and multiple readings, seems to be about
+/-1cm over 50m for outdoor nighttime atmosphere.
For the moment , as going above 10 involves coding changes in the Q and
T sections and only 2 valid SPI readings so far, staying with the units
decoding table of the previous and extending, maybe
unit/tens ~ SPI R(1) , S (1) , T(1)
1~ 0,1,1
2~ 3,2,1
5~ 1,3,2
6~ 3,3,2
8~ 3,3,3
9~ 1,3,3
10~ 3,5,7
16~ 3,7,6
26~ F,B,6

The tenths decoding of the 16... and 26.... agrees with the previous.
For eventual use, I'm only interested in the tens,units,tenths of metres
and then 100/110/120m for the 120m version.

--
Monthly public talks on science topics, Hampshire , England
<http://diverse.4mg.com/scicaf.htm>
 
A collection of LCD display readings and their SPI codings with the
repeated sections removed, leaving just 4 "rows" of 3 hex characters
(intervening repeated strings removed for clarity, described earlier in
this thread, would come into play for hundreds /thousands/other rows in
the diplay perhaps).
The first rank all even(eg 2,6,C,8 in the 1.014m reading is the mm
(thousandths) ,0 to 9
The second rank (eg C,D,5,C in the 1.014) is the cm (combined tenths and
hundredths) , 00 to 99
The third rank (eg 0,1,1,0 in the 1.014 or 7,D,7,5 in the 30.190 ) is
the combined units and tens
so 0, 1,2,3 ... 99
going by the pairings of "19" in 30.190 and 2.197, both coded to 9,5,7,3
and "20" in 8.206 and 9.206 , both coded to D,B,D,7
Perhaps someone can see octal coding or something , to avoid determining
two sets of 100 pairings, but so far I've not managed to reduce the
required look-up conversions required.

1.014
2,C,0,
6,D,1,
C,5,1,
8,C,0,

1.036
6,D,0,
E,D,1,
8,7,1,
C,D,0,

2.197
2,9,3,
6,5,2,
4,7,1
4,3,1,


4.235
6,D,0
6,9,3,
8,F,3,
C,5,0

5.265
6,D,1,
6,B,3,
8,E,2,
C,7,1,

6.243
6,C,3,
6,9,3,
C,F,2,
4,6,1,

7.112
6,8,0
A,5,1
C,5,1
4,0,1,


8.206
6,D,3,
E,B,3,
8,D,3,
C,7,1,

9.206
6,D,1,
E,B,3,
8,D,3,
C,7,1


10.217
2,C,3,
6,9,5,
4,D,7,
4,4,1,

16.388
6,D,3,
E,7,7,
C,F,6,
C,7,1,

22.136
6,9,F,
E,5,A,
8,7,5,
C,1,5,

26.766
6,9,F,
E,7,B,
8,6,6,
C,7,5,


30.190
6,9,7,
E,5,D,
4,7,7,
C,3,5,

30.191
2,9,7,
6,5,D,
4,7,7,
0,3,5,

30.192
6,9,7,
A,5,D,
C,7,7,
4,3,5,

30.195
6,9,7,
6,5,D,
8,7,7,
C,3,5,

30.196
6,9,7,
E,5,D,
8,7,7,
C,3,5,

The 30.19 set was setting up on a tripod and repeated grabbing codings
until I got a repeat reading. This was at dusk, after a sunny day, but
even so over 30m , for 6 readings involving switching off and on again ,
just a spread of 6mm and no guarantee my touching the buttons did not
upset the tripod a bit.

--
Monthly public talks on science topics, Hampshire , England
<http://diverse.4mg.com/scicaf.htm>
 
Analyzed display SPI communication.
uint8_t laser_buffer[71]; // 19 bytes SPI COMMANDS, + 4 groups of (3B SPI Address + 10B Display Data) 19 + 4 * (3+10)

I have STM32F103 cofigured as SPI slave parallel connection to laser tape SPI display.

It use SS,SCK and MOSI pins

Code:
int get_segment(int SegmentNo) // return 1if LCD segment SegmentNo is ON
{
    int group,byte,bit;
    group = SegmentNo / 80;
    byte = (SegmentNo / 8) % 10;
    bit = SegmentNo % 8;
    uint8_t Bit = (1 << bit);
    uint8_t c = raw_segment_data[group * 10 + byte];
    if(c & Bit)
        return 1;
    return 0;

}
uint8_t raw_segment_data[40];
void analyze_data(void)  // analyze 71bytes laser_buffer[71]
{
    uint8_t data[6];
    uint8_t decimal[8];
    uint8_t buffer[32];
    float distance = 0;
    long int distance_mm = 0;
    static long int last_distance_mm = 0;
    uint8_t c;
    int i;
// remove LCD_commands, only use LCD data
    for(i = 0; i < 10;i++)
        raw_segment_data[i +  0] = laser_buffer[22+i];
    for(i = 0; i < 10;i++)
        raw_segment_data[i +  10] = laser_buffer[35+i];
    for(i = 0; i < 10;i++)
        raw_segment_data[i +  20] = laser_buffer[48+i];
    for(i = 0; i < 10;i++)
        raw_segment_data[i +  30] = laser_buffer[61+i];
    memset(data,0,6);
// sign minus have SegmenNo 59, I do not use it 
    if(get_segment(300)) data[0] |= 0x02 | 0x04;
    if(get_segment(61))  data[1] |= 0x01;
    if(get_segment(141)) data[1] |= 0x02;
    if(get_segment(221)) data[1] |= 0x04;
    if(get_segment(301)) data[1] |= 0x08;
    if(get_segment(220)) data[1] |= 0x10;
    if(get_segment(60))  data[1] |= 0x20;
    if(get_segment(140)) data[1] |= 0x40;

    if(get_segment(63))  data[2] |= 0x01;
    if(get_segment(143)) data[2] |= 0x02;
    if(get_segment(223)) data[2] |= 0x04;
    if(get_segment(303)) data[2] |= 0x08;
    if(get_segment(222)) data[2] |= 0x10;
    if(get_segment(62))  data[2] |= 0x20;
    if(get_segment(142)) data[2] |= 0x40;

    if(get_segment(49))  data[3] |= 0x01;
    if(get_segment(129)) data[3] |= 0x02;
    if(get_segment(209)) data[3] |= 0x04;
    if(get_segment(289)) data[3] |= 0x08;
    if(get_segment(288)) data[3] |= 0x10;
    if(get_segment(128)) data[3] |= 0x20;
    if(get_segment(208))  data[3] |= 0x40;

    if(get_segment(51))  data[4] |= 0x01;
    if(get_segment(131)) data[4] |= 0x02;
    if(get_segment(211)) data[4] |= 0x04;
    if(get_segment(291)) data[4] |= 0x08;
    if(get_segment(290)) data[4] |= 0x10;
    if(get_segment(130)) data[4] |= 0x20;
    if(get_segment(210)) data[4] |= 0x40;

    if(get_segment(53))  data[5] |= 0x01;
    if(get_segment(133)) data[5] |= 0x02;
    if(get_segment(213)) data[5] |= 0x04;
    if(get_segment(293)) data[5] |= 0x08;
    if(get_segment(292)) data[5] |= 0x10;
    if(get_segment(132)) data[5] |= 0x20;
    if(get_segment(212)) data[5] |= 0x40;

    for(i = 0; i < 6; i++)
    {
        c = data[i];
        if(c == 0x00) decimal[i] = '0';            //    Empty leading zeros??
        else if(c == 0x3F) decimal[i] = '0';
        else if (c == 0x06) decimal[i] = '1';
        else if (c == 0x6D) decimal[i] = '2';
        else if (c == 0x4F) decimal[i] = '3';
        else if (c == 0x56) decimal[i] = '4';
        else if (c == 0x5B) decimal[i] = '5';
        else if (c == 0x7B) decimal[i] = '6';
        else if (c == 0x0E) decimal[i] = '7';
        else if (c == 0x7F) decimal[i] = '8';
        else if (c == 0x5F) decimal[i] = '9';
        else decimal[i] = 'X';
    }
    decimal[6] = 0;
    distance_mm = atol((char*)decimal);
    if(distance_mm == last_distance_mm) return;
    last_distance_mm = distance_mm;
    if(!distance_mm) return;
    distance = (float)(distance_mm) / 1000;
    if(get_segment(54) && get_segment(134))// metre
        i = sprintf((char*)buffer, "%.3f[m]\n\r",distance);
    if(get_segment(294)) // ft
        i = sprintf((char*)buffer, "%.3f[m]\n\r",distance * 0.3048);
//    if(get_segment(214) && get_segment(134)) // inch
        //i = sprintf((char*)buffer, "Change to meter!!\n\r");
    usart_print(buffer,i);
}
 

Welcome to EDABoard.com

Sponsor

Back
Top