Question

Your help is badly needed...

I'm trying to read data and print it to the python console from a load cell. My setup is as follow:

The load cell is a MD type from Eilersen connected to a load cell signal converter of type MCE2040 Seriel Communication Module also from Eilersen. The MCE2040 is connected to my PC through a USB to seriel connector like this link_http://www.usbgear.com/USB-COM-I-SI.html (I'm only allowed two links) one.

The load cell is connected to COM 1.

I have tried to run this snippet:

import serial
ser = serial.Serial(0)  # open first serial port
print ser.portstr       # check which port was really used
#ser.write("hello")      # write a string
ser.close()

...and that prints 'COM1' to the console so I guess my connection should be okay.

My problem is that I don't know how to proceed. In the end I'd like to plot a graph of the incoming data and output a data file with time stamps, but for starters I'd like to print some load cell data to the console.

Any help will be highly appreciated. If further information is needed, please let me know.

Thx in advance.

Edit:

I have some documentation re MCE2040:

3.1 EVC Mode (without time stamp)

Specification: RS232/RS4422

Baudrate: 115200 bps

38400 bps (select with SW1.5)

Data bits: 7

Parity: Even

Stop bits: 1

Protocol: EVC protocol described below (Transmit Only)

3.1.1 EVC Protocol Format

After each sample period a new weight telegram is transmitted. The transmitted telegram has the following format:

<LF>WWWWWWWW<CR>

Each telegram contains a line feed character, a weight result and a carriage return character. The telegram contains:

<LF>    Line Feed character (ASCII 0Ah).
WWWWWWWW    Weight value for the loadcell. The value is an 8 byte ASCII hex number with MSB first.
<CR>    Carriage Return character (ASCII 0Dh).

I was able to get some output from the following code:

import serial
ser = serial.Serial(0, baudrate=115000 ,timeout=100) 

print ser.portstr      
x = ser.read(50)
print x
ser.close()  
print 'close'

Output:

COM1

ÆÆÆÆA0·5
ÆÆÆÆA0·6
ÆÆÆÆA0·5
ÆÆÆÆA0·±
ÆÆÆÆA0·±
close
Was it helpful?

Solution

First of all make sure it's really your com port, since COM1 is used by a lot of computers i'm not sure it's your com port.

You can use a simple wire to loop back info by connecting TX to RX at the USB to Serial converter, it will result in an echo (you will read what you write) it's a very simple way to verify that you are talking with the right com port.

Regarding how to continue:

Useful basic commands:

ser.write("command") with this command you send to the device some command.

ser.read(n) is for read n bytes from the device

ser.readline() will read line until it reached \n (new line)

Steps:

  1. Send a command to your device.
  2. Read all the data by some end byte (Frame Synchronization).
  3. Parse data to structure (list or something like that..)
  4. Plot it to graph.

Useful Links:

  1. pyserial docs
  2. tips for reading serial
  3. plotly for graphs in python
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top