EASTRON SDM120C - RS485 Modbus meter

framboos
Posts: 23
Joined: Fri Apr 10, 2015 7:43 pm

Re: EASTRON SDM120C - RS485 Modbus meter

Post by framboos » Sat May 02, 2015 5:49 pm

Hi,

Has anybody have a clue why mine data with the pooler485.sh script does not get in the metern1.txt file?
When I try it with the sdm120c command I get all the data on screen, but I cannot get it to write to the file.
(I get single parameter data but no values in the file if I leave the /dev/ttyUSB0 out of the pooler485)

Done everything below

To use pooler485.sh, create a symbolic link
ln -s /var/www/metern/comapps /usr/local/bin/pooler485
then add in /etc/rc.local
touch /run/shm/metern1.txt
chown www-data:www-data /run/shm/metern1.txt
pooler485 1 9600 /dev/ttyUSB0&

jeanmarc
Posts: 1767
Joined: Thu Aug 29, 2013 7:16 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by jeanmarc » Sat May 02, 2015 6:55 pm

Hi,
ln -s /var/www/metern/comapps /usr/local/bin/pooler485
ln -s /var/www/metern/comapps/pooler485.sh /usr/local/bin/pooler485
then add in /etc/rc.local
duh ? :shock:

I am not sure your www user have access to /run/shm/. Don't you have tmpfs as /tmp ?

framboos
Posts: 23
Joined: Fri Apr 10, 2015 7:43 pm

Re: EASTRON SDM120C - RS485 Modbus meter

Post by framboos » Sat May 02, 2015 8:05 pm

Sorry, I already did this for the pooler485 file (checked this with nano and I can open the file). I has to be something else. I already started several times over. I deleted everything I had from my solar data in Metern to start over like the example.

On raspberry the location for mine metern1.txt file
/run/shm/metern1.txt.

I don't get it why the sdm120c file with all the commands are working but the pooler485 is not. I'm sure if there is data in the metern1.txt file, MeterN would show it.
I don't get any error messages when running the pooler485 file manually, I have the SDM220 version like you.

Is there maybe something else that I can try?

jeanmarc
Posts: 1767
Joined: Thu Aug 29, 2013 7:16 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by jeanmarc » Sun May 03, 2015 7:31 am

1) I only use this poolSDM485.sh script

Code: Select all

#!/bin/bash

ADDRESS="$1"
BAUD_RATE="$2"
DEVICE="$3"

count=0
trap 'echo bye;rm /tmp/485live.txt;rm /tmp/485metern.txt; exit' EXIT SIGHUP SIGINT SIGQUIT SIGTERM 

while [ true ]; do

	VOLTAGE=""
	CURRENT=""
	POWER=""
	CURRENT=""
	POWERFACTOR=""
	FRQ=""
	RET=""

	CMD="sdm120c -a ${ADDRESS} -b ${BAUD_RATE} -p -v -c -f -g -e -i -t -q ${DEVICE}"
	VALUE=`$CMD`

	VOLTAGE=$(echo ${VALUE} | cut -d\  -f1)
	CURRENT=$(echo ${VALUE} | cut -d\  -f2)
	POWER=$(echo ${VALUE} | cut -d\  -f3)
	POWERFACTOR=$(echo ${VALUE} | cut -d\  -f4)
	FRQ=$(echo ${VALUE} | cut -d\  -f5)
	ENERGYIMPORT=$(echo ${VALUE} | cut -d\  -f6)
	ENERGYEXPORT=$(echo ${VALUE} | cut -d\  -f7)
	ENERGYTOT=$(echo ${VALUE} | cut -d\  -f8)
	RET=$(echo ${VALUE} | cut -d\  -f9)


	if [ "$RET" == "OK" ]; then
		count=0
		ID=$ADDRESS
		echo -e "$ID($VOLTAGE*V)\n$ID($CURRENT*A)\nTOT($POWER*W)\n$ID($POWERFACTOR*F)\n$ID($FRQ*Hz)" > /tmp/485live.txt
		echo -e "EIMP($ENERGYIMPORT*Wh)\nEEXP($ENERGYEXPORT*Wh)" > /tmp/485metern.txt
	else
		count=$(expr $count + 1)
		if [ $count -ge 100 ]; then
			rm /tmp/485live.txt
			rm /tmp/485metern.txt
			count=0
		fi
#		echo -e "$ID(0*V)\n$ID(0*A)\nTOT(0*W)\n$ID(0*F)\n$ID(0*Hz)" > /tmp/485live.txt
#		timestamp=$(date +"%Y-%m-%d %H:%M:%S")
#		echo "$timestamp $VALUE" >> /tmp/485meter.err

	fi
	#sleep 0.5
done
2) I made it wide available ln -s /var/www/metern/comapps/poolSDM485.sh /usr/local/bin/poolSDM485
3) I launch it as www-user via scripts/comappsdaemon.php

Q1) Does the poolSDM485 run as www user ? ps -ef | grep poolSDM485
Q2) Are the metern.txt permission ok ? Is the file updated ? ls -l /path to/metern.txt

ps: I don't run on a Rasp with Debian...

framboos
Posts: 23
Joined: Fri Apr 10, 2015 7:43 pm

Re: EASTRON SDM120C - RS485 Modbus meter

Post by framboos » Sun May 03, 2015 9:04 am

jeanmarc,

Thank you again, I tried with your script and now I get data in the 485live.txt and 485metern.txt
After a full night looking I found that the default pooler485.sh does not work out of the box for the sdm220modbus meter. The -e -t -i does not work when using it in the pooler485.sh file.
The strange thing is that is works when running it from the ./sdm120c command.

I'm learning a lot but it's very difficult for a beginner. For an example I just found out that i cannot copy info into a notepad file and upload it with psftp because it is a DOS format then.
I'm mostly stuck in the programming things. I understand the file rights and user permissions I check things running with the top command. So the most part I'm starting to understand.

If you ever have the time and it would be a great help if you can upload your full configuration.
I know every configuration is different and I know of the http://123solar.org/metern/tour/ screenshots but it will help me a lot to understand the php files. Even if it's very hard for me, If this is working a would like to start on the much more difficult way with the arduino like you gas and water meter. :)
I know I have to make mine own files and yours are only examples but I don't have the skills.

jeanmarc
Posts: 1767
Joined: Thu Aug 29, 2013 7:16 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by jeanmarc » Sun May 03, 2015 9:46 am

framboos wrote:The -e -t -i does not work when using it in the pooler485.sh file.
That's plain normal, this is a script that call sdm120c :?
framboos wrote:it will help me a lot to understand the php files.
You don't need to understand nor create php files behind uncommenting the daemon request in scripts/comappsdaemon.php

Well, you seriously better understand things by yourself, it's part of the deal ;) It not that difficult. First learn basics unix commands like ps, ls, chmod and so on...

jeanmarc
Posts: 1767
Joined: Thu Aug 29, 2013 7:16 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by jeanmarc » Mon Jul 27, 2015 5:38 pm

Hi,
Sometimes my RS485/USB converter crash for unknow reason, it happen after 9-10 days running sdm120c (looping like a freak)
Dmesg return this :

Code: Select all

[775378.170254] ERROR::handle_hc_chhltd_intr_dma:2030: handle_hc_chhltd_intr_dma: Channel 15, DMA Mode -- ChHltd set, but reason for halting is unknown, hcint 0x00000402, intsts 0x06000021

[775383.953431] ftdi_sio ttyUSB1: failed to get modem status: -110
[775385.053424] ftdi_sio ttyUSB1: ftdi_set_termios urb failed to set baudrate
[775388.193347] WARN::hc_xfer_timeout:2719: hc_xfer_timeout: timeout on channel 15
[775388.195221] WARN::hc_xfer_timeout:2721: 	start_hcchar_val 0x00d88840
[775388.201826] WARN::hc_xfer_timeout:2726: 	chn-15,ep1-IN:type:2,speed:1,len:64,addr3

[775390.053353] ftdi_sio ttyUSB1: urb failed to clear flow control
[775440.882807] urb_enqueue:urb(ee37a380) had been killed
[775440.882862] hid-generic 0003:051D:0002.0002: usb_submit_urb(ctrl) failed: -1
[775450.882671] urb_enqueue:urb(ee37a380) had been killed
[775450.882727] hid-generic 0003:051D:0002.0002: usb_submit_urb(ctrl) failed: -1
[775460.902556] urb_enqueue:urb(ee37a380) had been killed
[775460.902611] hid-generic 0003:051D:0002.0002: usb_submit_urb(ctrl) failed: -1
[775512.531809] ftdi_sio ttyUSB1: ftdi_set_termios urb failed to set baudrate
[775517.531745] ftdi_sio ttyUSB1: urb failed to clear flow control
[775522.531791] ftdi_sio ttyUSB1: failed to get modem status: -110
[775527.531618] ftdi_sio ttyUSB1: error from flowcontrol urb
[775535.451618] urb_enqueue:urb(ee37a380) had been killed
[775535.451673] hid-generic 0003:051D:0002.0002: usb_submit_urb(ctrl) failed: -1
[775538.541543] ftdi_sio ttyUSB1: ftdi_set_termios FAILED to set databits/stopbits/parity
[775539.541483] ftdi_sio ttyUSB1: ftdi_set_termios urb failed to set baudrate
[775545.451463] urb_enqueue:urb(ee37a380) had been killed
[775545.451543] hid-generic 0003:051D:0002.0002: usb_submit_urb(ctrl) failed: -1
[775549.541365] ftdi_sio ttyUSB1: urb failed to clear flow control
[775625.020573] urb_enqueue:urb(ee37a380) had been killed
[775625.020627] hid-generic 0003:051D:0002.0002: usb_submit_urb(ctrl) failed: -1
[775635.020339] urb_enqueue:urb(ee37a380) had been killed
[775635.020393] hid-generic 0003:051D:0002.0002: usb_submit_urb(ctrl) failed: -1
[775646.760153] ftdi_sio ttyUSB1: ftdi_set_termios urb failed to set baudrate
[775651.760094] ftdi_sio ttyUSB1: urb failed to clear flow control
[775656.760037] ftdi_sio ttyUSB1: failed to get modem status: -110
[775661.760025] ftdi_sio ttyUSB1: error from flowcontrol urb
[775672.769837] ftdi_sio ttyUSB1: ftdi_set_termios FAILED to set databits/stopbits/parity
[775673.769864] ftdi_sio ttyUSB1: ftdi_set_termios urb failed to set baudrate
[775683.769712] ftdi_sio ttyUSB1: urb failed to clear flow control
[775699.829516] ftdi_sio ttyUSB1: ftdi_set_termios FAILED to set databits/stopbits/parity
[775700.829510] ftdi_sio ttyUSB1: ftdi_set_termios urb failed to set baudrate
[775710.829430] ftdi_sio ttyUSB1: urb failed to clear flow control
and so on
The only solution is to reboot the machine. Does anyone have the same problem ? Is there any trick ?
Thanks

SamSpade
Posts: 2
Joined: Wed Aug 12, 2015 12:19 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by SamSpade » Wed Aug 12, 2015 12:43 am

Newbie here. I just got an SDM120C from RS Components, which is a rebranded Smart Process, in turn a rebranded Eastron.

Been playing with it for a couple days with both a Raspberry Pi 2 and a BeagleBone Black, via an FTDI USB-RS485 cable.

One thing I've noticed is that even if the documentation says the default serial setting is 2400,8,E,1, looking through a scope it's actually 2400,8,N,2. 2400 baud, 8 data, no parity, 2 stop bits. Might be something to look at for those who have intermittent communication problems.

So my setting is usually:
stty -F /dev/ttyUSB0 2400 cs8 -parenb -parodd cstopb -crtscts raw -iexten ignbrk -echo

The 'cstopb' parameters sets the port to 2 stop bits.



I have a different problem though. No matter which framework I use I can't seem to change the default address from 1.

The byte stream I see whem trying to change to address 2 is:
[01 10 00 14 00 02 04 40 00 00 00 E6 90]
which seems correct. But I always get this reply from the SDM120C:
[01 90 01 8D C0]
which from the Modbus spec says is 'unsupported function code'.

Any idea on how to get it to work? I think I'm missing something. I can read all values, including the current address. Just cam't seem to write.

SamSpade
Posts: 2
Joined: Wed Aug 12, 2015 12:19 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by SamSpade » Wed Aug 12, 2015 6:41 am

Ok, finally figured it out ... had to press the button on the SDM120C until "-SET-" appears in the display before sending the Modbus command.

That wasn't in the 4-page instruction manual I got (more like a specsheet).

Pongo
Posts: 30
Joined: Thu Sep 19, 2013 1:18 pm

Re: EASTRON SDM120C - RS485 Modbus meter

Post by Pongo » Tue Aug 18, 2015 10:40 pm

Hello, if it can be useful for you, I added a parameter to sdm120c communication program to set stop bits
https://github.com/gianfrdp/SDM120C

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest