Using WinSDR with the Raspberry PI Shake 

Created: 04/05/2018 - Last Updated: 05/19/2018

 Download WinSDR Version 4.7.8b9 Setup File: 64-Bit or 32-Bit

Executable Only Zip Files: 64-Bit or 32-Bit Use one of these if you already have WinSDR installed on your system

Use wget http://www.seismicnet.com/software/wsserver_14.zip to get the current version of WinSDR Server (wsserver)


Index:


Introduction:

My WinSDR datalogger program has been modified to work with the Raspberry Shake digitizers. Both methods described below use the UDP packets sent out by the RShake's data producer service. More information about the data producer service can be found here.  The TCP/IP connection mode uses a WinSDR Server program running on the Raspberry PI. It receives the UDP packets from the data producer and send Analog to Digital data for each channel to WinSDR over a TCP/IP connection. The second method uses the UDP packets directly from the RShake. I think you will find the TCP/IP connection to be more reliable do to the difference between UDP packets and TCP/IP connections. To use WinSDR with the RShake you will need to be able to run a few commands from the command line and be able to edit files using SSH or a keyboard and monitor connected up to your RShake.   

RShake Setup:

For this write up I am using a Raspberry PI Zero W and RShake version 11. The instructions below should work on any Raspberry PI board supported by the RShake digitizer. The first thing I needed to do after booting up the image was to change the default keyboard mapping. I used 

sudo nano /etc/default/keyboard 

and changed the "gb" to "us", saved the file and rebooted (sudo reboot). Since the PI Zerro W does not have a Ethernet port on it I added my WIFI SSID and password to this file.  See https://manual.raspberryshake.org/wifi.html for more information. 

/etc/wpa_supplicant/wpa_supplicant.conf 

After a reboot I checked that an IP address was assigned to the board using 

sudo ifconfig.  

The IP address will be under the wlan0 or eth0 section on the inet_addr line . Once you can SSH into your RShake you can removed the keyboard and monitor and use SSH for the rest of the setup. The next thing you should do is run the following command 

sudo apt-get update 

to update the install package database.


TCP/IP Mode using WinSDR Server:

This method of sending data to WinSDR uses a small program that normally runs on the Raspberry Shake system. The program, WinSDR Server (wsserver), receives the UDP packets containing the A/D data from the RShake's data producer and sends the data onto any WinSDR client as TCP/IP packets. To use this method you must install and run wsserver on your PI. First create a directory called wsserver 

mkdir wsserver 

and cd to it using

cd wsserver 

Type pwd to see your working directory. It should be /home/myshake/wsserver. 

Now get a copy of WinSDR Server using 

wget http://www.seismicnet.com/software/wsserver_14.zip 

Unzip the file using 

unzip wsserver_12.zip

Recompile the WinSDR Server using this command 

./clean; make 

WinSDR Server can be run from the command line, under the Linux screen utility or as a service. First we will run the program from the command line for testing. Wsserver requires one input parameter, the name of the configuration file. The zip file you downloaded contains 3 config files wsserver_1d.conf, wsserver_3d.conf and wsserver_4d.conf. The user should start the program using 

./wsserver config_file_name  

Example: ./wsserver wsserver_1d.conf. 

Below is an example configuration file for the RShake 4D model.

# WsServer config file for 4D digitizer
#
# Network ID sent to WinSDR.
network = AM
#
# Port number to receive UDP data from the SHAKE digitizer.
udpPort = 8888
#
# Port number WinSDR will use to send data to the clients.
winsdrPort = 16064
#
# Set to 1 to log all incoming data on the udpport to the file /tmp/rawudp.dat.
logRaw = 0
#
# Set to 1 for receiver and server debugging.
debugReceiver = 0
debugServer = 0
#
# The following tells WsServer if it is running as a service.
runningAsService = 1
#
# Wait a maximum of x seconds before exiting do to no data timeout.
maxStartWait = 600
#
# Channel name to WinSDR's sensor/station ID name mapping. Also used to supply the
# 2 character Location ID and to enable or disable sending channel to WinSDR.
#
#        Shake WinSDR
# Key    Chan  ID   Loc Send
channel = EHZ SHKHZ  00  1
channel = ENZ SHKNZ  00  1
channel = ENN SHKNN  00  1
channel = ENE SHKNE  00  1

The purpose of the config file is to supply the program with information like the RShake Component Name (Example EHZ) to WinSDR Sensor ID Name (Example SHKHZ). This is the Sensor/Station ID that WinSDR will use as the Channel ID name. The order of the channel = line defines the channel number within WinSDR. So the first line will be WinSDR's channel 1 and the next line will be channel 2 etc. WinSDR's Sensor ID name can be between 3 and 6 characters in length. You can also disable a channel from being sent to WinSDR by setting the Send parameter to 0. The user should change the WinSDR Sensor ID to something unique for your station.

After starting up wsserver you can see if you can connect to it from WinSDR. See Using WinSDR below.

Once you get things work using the command line you will probably want to run WinSDR Server as a service so the program restarts after a system reboot. First you will need to edit the wsserver.service file located in your wsserver directory and change the configuration file name on the ExecStart line to your RShake model. If you installed wsserver in a different directory change the path to the wsserver executable file and configuration file.

Below is the wsserver.service file contained in the wsserver.zip file.

[Unit]
Description=WinSDR Server
After=ntpd.service docker.service
Wants=ntpd.service

[Service]
User=myshake
WorkingDirectory=/home/myshake/wsserver
#
# !! Remove # depending on your rshake model. Add # to unused models.
# !! Only one of these 3 lines should be uncommented.
ExecStart=/home/myshake/wsserver/wsserver /home/myshake/wsserver/wsserver_1d.conf
#ExecStart=/home/myshake/wsserver/wsserver /home/myshake/wsserver/wsserver_3d.conf
#ExecStart=/home/myshake/wsserver/wsserver /home/myshake/wsserver/wsserver_4d.conf
#
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=4

[Install]
WantedBy=multi-user.target

Install the WinSDR Server service using this install script

./install.sh

or you can manually install the server using these commands

sudo cp wsserver.service /etc/systemd/system/
sudo systemctl enable wsserver.service
sudo systemctl start wsserver.service

The last line should start the service. Use 

ps -A | grep wsserver 

to see if wsserver is running. Use sudo systemctl disable wsserver.service if you want to disable the WinSDR Server. If you need to make any changes to the wsserver.service file disable the service, make your changes and rerun the 3 command lines above.


UDP Packet Mode:

This method of receiving data from the RShake uses the UDP packets directly from the Data Producer Service. For this to work you must create a UDP-data-streams.conf file in the /opt/settings/user directory. See this section https://manual.raspberryshake.org/udp.html#configuration-of-additional-udp-ports of the Data Producer Service documentation. My file UDP-data-streams.conf looks like this:

{
    "UDP-destinations" : [
        { "dest" : "UDP-NETWORK-WS"}
    ],

    "UDP-NETWORK-WS" : {
        "Hostname" :  "192.168.1.14",
        "Port" :      "8889"
    }
}

Note - You will need to change the "Hostname" IP Address to the address of the system running WinSDR. 

You can test to see if your RShake is sending out UDP packets by installing tcpdump (sudo apt-get install tcpdump).  This command

 sudo tcpdump -i docker0 udp port 8888 -vv -X

will display the raw data from the Data Producer Service (Docker0). If you use the config file above you should also see packets using

sudo tcpdump -i wlan0 udp port 8889 -vv -X (WIFI interface) or sudo tcpdump -i eth0 udp port 8889 -vv -X (Ethernet interface)

If you can see data on port 8889 on either the WIFI or Ethernet interface you are ready to run WinSDR.


Using WinSDR:

You will need to install this version of WinSDR (32-Bit or 64-Bit).  Please note that this release of WinSDR no longer uses the RShake's MiniSEED server. You must run WinSDR Server on your RShake or use the UDP mode above to use WinSDR with your RShake. 

After installing WinSDR startup the program and use the 

Settings -> System...  

menu items to open the System Settings dialog box. Now select the 

Server/Client/RShake  

tab. There do the following in the Client group. 

TCP/IP Mode Using WinSDR Server:

WinSDR RShake TCP Mode Screenshot

UDP Mode Setup:

WinSDR RShake UDP Mode Screenshot

The first time you run WinSDR in the RShake UDP Mode press the RShake Channels button and make sure all fields are cleared. WinSDR will fill in the channel list once the program receives the data from the RShake.

After closing the System Settings dialog box WinSDR will attempt to connect to your RShake system. If all goes well you should see a trace in the real-time window. See the WinSDR documentation for more information on how to run the program. 

If you have a 1D RShake you can skip the following. In the TCP/IP mode the channel order is controlled by the order of the channel = keywords in the wsserver configuration file. In the UDP mode the channel order is set in the RShake Channels settings dialog box. This dialog box is opened using the Settings -> System... ->Server/Client/RShake tab -> RShake Channels button. After running WinSDR you should see 1 to 4 channel component names under RShake Channels. Again, if you have a 1D RShake do not make any changes. To change the channel order change the RShake Channel component name list. As an example say you have a RShake 4D and the channel order list is 1:ENZ, 2:ENE, 3:EHZ, 4:ENN. Here the geophone is the third channel. If we want to group all of the strong motion channels together we would change the list to 1:ENZ, 2:ENE, 3:ENN, 4:EHZ or maybe move the geophone channel to channel 1 1:EHZ, 2:ENZ, 3:ENN, 4:ENE.

A word about TCP/IP and the UDP modes. I highly recommend you use the TCP mode and setup WinSDR Server on your RShake. Especially if you plan to send the data over the internet or a slow WIFI network. UDP packets are sent out using a connectionless protocol. This means the user is not guaranteed that they will receive a packet and the packets can be out of order. If you see a lot of messages like this  

RShake - High Time Difference Error = 2.000 Seconds, LastTime=1523400870.733 Now=1523400873.733

in WinSDR's log file you are dropping packets and should move over to the TCP/IP mode. 


Larry Cochrane
Webtronics / Redwood City PSN


[ Home ] [ Top ]

This page viewed Counter Image times since April 5th, 2018

Larry Cochrane - www.seismicnet.com/contact.html