Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Slm1352p sound level meter scripting

Mahruz

Member level 1
Member level 1
Joined
May 16, 2022
Messages
34
Helped
0
Reputation
0
Reaction score
1
Trophy points
8
Visit site
Activity points
399
Hi All,

I am trying to capture the sound decibel level from a RS PRO SLM1352P sound level meter using python.


I use python 3 and with pyserial, I can send commands and I can see the instrument getting updated.
However, I am not able to receive the serial data from the com port it is connected to.

Has anyone been able to use python and capture sound decibel data from the above device?

Thanks for the advice
 
I don't see a RS PRO SLM1352P manual, do you have it?
Hi Fvm,
If you download the software, it has a manual inside the folder. The software can be found at:



The PDF has an RS232 format and has commands. The commands can be used to send instructions to the device. But when I try to receive or query from the device, I am unable to obtain correct information.

Any advice is greatly appreciated.

Thanks,
 

Attachments

  • Screenshot_20250113-215949~2.png
    Screenshot_20250113-215949~2.png
    46.5 KB · Views: 15
Hi,

I personally would not download the whole software..

Why dont you make helping easy by:
* showing us the section of the documentation where it describes the according command(s)
and
* showing your actual command / python code
and
* telling exactly what you expect and what happens instead.

Then many more people are able/willing to assist you.

Klaus
 
Attached is the manual PDF
It has the rs232 commands that's can b used with pyserial to send commands in byte array format.

But to receive data from instrument is what I don't understand on how to.
 

Attachments

  • Manual.pdf
    1.3 MB · Views: 11
and
* showing your actual command / python code
and
* telling exactly what you expect and what happens instead.
still no code and no description ...

Are you sure you want people to help you?
For me speaking: I´m getting demotivated ...

Klaus
--- Updated ---

Added:

The manual does neither mention "sound" nor "TES1352" ... instead it talks about a "solar meter" .... same is with the shown pictures in the manual.
I personally doubt that this manual is for a sound meter at all.

Klaus
 
Last edited:
Hi Klaus and FvM,

Apologies in the delay. I reckon there is major time difference between me and the other members in the group.

I have re-uploaded the information from my laptop rather than my phone which made it more difficult.

Sound meter: RS PRO SLM1352P
URL for sound meter: https://au.rs-online.com/web/p/soun...4lqzP4kcRK-fiAVlYBcLEH5MzQYsduqtIBPchTjng8MLd
Manual: Attached below.
URL for Manual: TES-1352P
Commands used from Manual: PDF page 2 Section 3(Commands)
Python 3.11 Scripts: Attached (renamed to .txt to upload it here)
Actual Output: Attached image below
1736804638325.png


Expected Output:
Attached image below marked in red rectangle.
What I want: To obtain the 62.2 dB value from the serial port in a readable format (ASCII or any other)
Issue I have: I am not sure what the serial output is or what format it is. I tried to decode it using python command ( xxxx.decode() ) but the decoding does not give me ASCII values.
1736804569815.png



Thank you for the support.

Thanks
 

Attachments

  • Manual.pdf
    1.3 MB · Views: 15
  • SLM1352P_Data_Logging.txt
    1,003 bytes · Views: 8
Hi,

Thanks for the informations. Now we have soemthing to work with.

One mistake:
you code says:
Code:
port = 'COM6',
    baudrate = 39400,
    timeout = 1,
--> please change baudrate to "38400"

I expect the baudrate mismatch to cause wrongly received bytes.

Thus - before further investigstion - you need to repeat the test with the corrected baud rate setup.

*******
Instead of posting a .PNG --> please post the receiver output as text, best if formatted as code. Please press the [C O D E ] butten then copy and paste the message.
(do the same when uploading your code)

Some worries:
* please make the output to be displayed as HEX. Most of the output already seems to be so, but there are additional characters like "U" and "i" and "!" .. I could not explain for now.

For sure your python code needs to be completed to detect the frames sent by the meter. The frame should look like this:
"0x02; data0; data1; data2, data3; 0x03"
it needs to detect 0x02 as frame START and 0x03 as frame END.

******

But first let´s see how the correct baud rate setting will perform...

Klaus
 
Hi,

Thanks for the informations. Now we have soemthing to work with.

One mistake:
you code says:
Code:
port = 'COM6',
    baudrate = 39400,
    timeout = 1,
--> please change baudrate to "38400"

I expect the baudrate mismatch to cause wrongly received bytes.

Thus - before further investigstion - you need to repeat the test with the corrected baud rate setup.

*******
Instead of posting a .PNG --> please post the receiver output as text, best if formatted as code. Please press the [C O D E ] butten then copy and paste the message.
(do the same when uploading your code)

Some worries:
* please make the output to be displayed as HEX. Most of the output already seems to be so, but there are additional characters like "U" and "i" and "!" .. I could not explain for now.

For sure your python code needs to be completed to detect the frames sent by the meter. The frame should look like this:
"0x02; data0; data1; data2, data3; 0x03"
it needs to detect 0x02 as frame START and 0x03 as frame END.

******

But first let´s see how the correct baud rate setting will perform...

Klaus


Hi KlausST,

Thank you for your response.

I updated the baud rate to the correct one.
The below is the updated python code.

Python:
import time
import serial
 

# Obtained the below information from the Manual
ser = serial.Serial(
    port = 'COM6',
    baudrate = 38400,
    timeout = 1,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS
)
ser.isOpen()


## Write data to SLM 1352P Sound Level Meter

## Fast / Slow
ser.write(bytearray(b'D\r')) #--> This command works and updates can be seem on the SLM 1352P Sound Level Meter display
time.sleep(2)

## Level up
ser.write(bytearray(b'E\r')) #--> This command works and updates can be seem on the SLM 1352P Sound Level Meter display
time.sleep(2)

## Level down
ser.write(bytearray(b'F\r'))  #--> This command works and updates can be seem on the SLM 1352P Sound Level Meter display
time.sleep(2)



## Reading the data from the serial port.
## This will be running in an infinite loop.
while 1 :
    bytesToRead = ser.inWaiting()
    data = ser.read(bytesToRead)
    time.sleep(1)
    print(data)

    # decode_data = data.decode()
    # print(decode_data)


The result that I obtained with the above python code is provided below:

Code:
b''
b'\x02\x03!\x02`\x03\x02\x03!\x02`\x03\x02\x03!\x02d\x03'
b'\x02\x03!\x02d\x03\x02\x03!\x02c\x03\x02'
b'\x03!\x02c\x03\x02\x03!\x02c\x03\x02\x03!\x02^\x03'
b'\x02\x03!\x02^\x03\x02\x03!\x02^\x03\x02\x03!\x02q\x03'
b'\x02\x03!\x02q\x03\x02\x03!\x02h\x03'
b'\x02\x03!\x02h\x03\x02\x03!\x02h\x03\x02\x03!\x02a\x03'
b'\x02\x03!\x02a\x03\x02\x03!\x02a\x03\x02\x03!\x02n\x03'
b'\x02\x03!\x02n\x03\x02\x03!\x02a\x03'
b'\x02\x03!\x02a\x03\x02\x03!\x02a\x03\x02\x03!\x02W\x03'


From your list of worries:

1. * please make the output to be displayed as HEX. Most of the output already seems to be so, but there are additional characters like "U" and "i" and "!" .. I could not explain for now.

How can I change the code to make it display HEX?


2. For sure your python code needs to be completed to detect the frames sent by the meter. The frame should look like this:
"0x02; data0; data1; data2, data3; 0x03"
it needs to detect 0x02 as frame START and 0x03 as frame END.

This is the part where I am not confident on how to understand and decode the packets. Is there something that I can refer to, to better understand how to decode packets using python?


Thanks,
 
How can I change the code to make it display HEX?

Please do according the discussion to get the desired "0x02; data0; data1; data2, data3; 0x03" output
We need this to find out how the dB value is coded. (It could be 4 nibbles BCD, or integer with "0.1 dB" uints ... or ???)
Show the output. And also please give the reading of the meter´s display ... so we know what value it means

This is the part where I am not confident on how to understand and decode the packets. Is there something that I can refer to, to better understand how to decode packets using python?
Basically I recommend to read byte by byte.
There are several methods how to store / process a stream of bytes.
* if you are familiar with a ring buffer --> use it

* but you also can use an array with six bytes,
Not very nice ... but you could do on every incoming byte: (pseudo code)

Code:
byte(1) = byte(2); byte(2) = byte(3); byte(3) = byte(4); byte(4) = byte(5); byte(5) = byte(6); byte(6) = ser.read(1);
// this generates the same byte order as in the manual, page #2
if ((byte(1) == 0x02) AND (byte(6) == 0x03)) --> // then you may assume the frame in the buffer is correct
    ... next step is to process the bytes(2) ... byte(5)
  if ((byte(2) AND 0x07) == 0x00) --> min = 80;
  if ((byte(2) AND 0x07) == 0x01) --> min = 70;  
  if ((byte(2) AND 0x07) == 0x02) --> min = 60;
   ... and so on
 max = min + 60;
 ... and so on

Klaus
 
I wonder if you get meaningful measurement output when operating the meter with TES1352 software? If yes, you can dump the RS232 communication. If no, the specified readout commands are possibly not working with SLM1352P.
 
Hi KlausST and FvM,

Using the TES1352 software, I can get the sound meter display, i get real time measurements like 62.5dB.

1736917068431.png




Thank you for sharing the links (KlausST). It is very helpful.
I used a serial monitor and obtained the data

Code:
35  2025-01-15 15:59:52.383414    0.205174    IRP_MJ_READ    UP    0x102    02 03 20 02 5b 03     .. .[.
36    2025-01-15 15:59:52.749789    0.366335    IRP_MJ_READ    UP    0x102    02 03 20 02 55 03     .. .U.
38    2025-01-15 15:59:53.122535    0.372544    IRP_MJ_READ    UP    0x102    02 03 20 02 55 03     .. .U.
40    2025-01-15 15:59:53.505112    0.382413    IRP_MJ_READ    UP    0x102    02 03 20 02 55 03     .. .U.
42    2025-01-15 15:59:53.878926    0.373593    IRP_MJ_READ    UP    0x102    02 03 20 02 42 03     .. .B.
44    2025-01-15 15:59:54.248446    0.369265    IRP_MJ_READ    UP    0x102    02 03 20 02 42 03     .. .B.
46    2025-01-15 15:59:54.622671    0.374062    IRP_MJ_READ    UP    0x102    02 03 20 02 42 03     .. .B.
48    2025-01-15 15:59:55.013211    0.390305    IRP_MJ_READ    UP    0x102    02 03 20 02 83 03     .. ...
50    2025-01-15 15:59:55.394792    0.381312    IRP_MJ_READ    UP    0x102    02 03 20 02 83 03     .. ...
52    2025-01-15 15:59:55.758396    0.363550    IRP_MJ_READ    UP    0x102    02 03 20 02 43 03     .. .C.
54    2025-01-15 15:59:56.134659    0.376106    IRP_MJ_READ    UP    0x102    02 03 20 02 43 03     .. .C.
56    2025-01-15 15:59:56.505623    0.370877    IRP_MJ_READ    UP    0x102    02 03 20 02 43 03     .. .C.
58    2025-01-15 15:59:56.895157    0.389449    IRP_MJ_READ    UP    0x102    02 03 20 02 55 03     .. .U.
60    2025-01-15 15:59:57.257807    0.362344    IRP_MJ_READ    UP    0x102    02 03 20 02 55 03     .. .U.
62    2025-01-15 15:59:57.631789    0.373811    IRP_MJ_READ    UP    0x102    02 03 20 02 48 03     .. .H.
64    2025-01-15 15:59:58.014031    0.382012    IRP_MJ_READ    UP    0x102    02 03 20 02 48 03     .. .H.

A random packet that I selected from the above, after trying alot, I understood that it gets decoded as below:
02 03 20 02 42 03

02 --> Byte 1 --> Starting byte
03 --> Byte 2 --> If I change the "level" on the instrument, then (like you said) 03 changes to 04(50 to 110) or 05(30 to 90) and so on...
If the sound level meter instrument shows "Over", then the 03 changes to 83(over and level of 50 to 110), 84(over and level of 40 to 100)
20 --> Byte 3 --> If I change the "slow/fast" on the instrument, then 20 changes to 21(slow). if I press it again, then it changes to 20(fast)
If I change the "A/C" on the instrument, then 20 changes to 00(A). if I press it again, then it changes to 20(C)
Not sure about BIT 5 and BIT6 and also BIT7. How to decode those or understand them better??
02 --> Byte 4 --> Not sure what data high byte means as per the manual.
02 --> Byte 5 --> Not sure what data low byte means as per the manual.
03 --> Byte 6 --> Ending



You had mentioned the below:
We need this to find out how the dB value is coded. (It could be 4 nibbles BCD, or integer with "0.1 dB" uints ... or ???)
Is there a way to decode Byte 4 and Byte 5 using python?


Also, in your pesduo code:
Code:
if ((byte(2) AND 0x07) == 0x00) --> min = 80;
where did you get 0x07 from?


Thanks
 
Last edited:
where did you get 0x07 from?
The datasheet is rather clear in this:
Page#2 --> 2. Transfer Format --> Function 1 Byte (byte 2) --> Bits2:0
0x07 = 0b 0000 0111

Code:
instead of
  if ((byte(2) AND 0x07) == 0x00) --> min = 80;
you also could write
  if ((byte(2) AND 0b00000111) == 0b00000000) --> min = 80; the "AND" masks (=selects) the lower 3 bits,

If I change the "A/C" on the instrument, then 20 changes to 00(A). if I press it again, then it changes to 20(C)
--> the same way as above
Code:
weighting = 'A' // preset for 0x00 = "A"
if ((byte(3) AND 0b01100000) == 0b00100000) -->weighting = 'C'; the "AND" masks (=selects) the bits 5 and 6,
if ((byte(3) AND 0b01100000) == 0b01000000) -->weighting = 'Z'; the "AND" masks (=selects) the bits 5 and 6,
if ((byte(3) AND 0b01100000) == 0b01100000) -->weighting = 'F'; the "AND" masks (=selects) the bits 5 and 6,

Is there a way to decode Byte 4 and Byte 5 using python?
.. if you did what I told you to do ....

here I wrote
Show the output. And also please give the reading of the meter´s display ... so we know what value it means
02 03 20 02 42 03
As soon as you tell me what´s the dislayed (reading of the meter) value ... I can answer your question.
I could guess. But I usually don´t solve technical problems by guessing.

Klaus
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top