VS-ECG Programming Guide (V1.0)

5.0 VSC Mode Control Flow

Before we start any coding, we would like to introduce the VSC Mode.

VSC Mode is the BLE protocol designed for fetching real-time ECG and related patient’s vital signal information.  To use VSC Mode is pretty easy. There are only three major commands for control the whole VSC Mode :

  • VSC MODE START – start the VSC Mode.
  • VSC MODE READ   – read the VSC mode with ID
  • VSC MODE STOP   – stop the VSC Mode.

The following chart is the example for the flow:

The VSC MODE START and VSC MODE STOP command are simple. Like the other BLE commands introduced before. The VSC MODE READ command will be a little more complicated. When user issues the VSC_MODE_READ commad, device will send back 968 bytes data. The next section will give you a more detail description about the VSC Mode Data Format. Each VSC MODE READ command carries 200 ms ECG data and related information. It means user has to issues at lease 5 times VSC MODE READ command every second or the data will be overflow.

5.1 VSC Mode Data Format

As mentioned, There are 968 bytees of returning data of VSC MODE READ. It includes two parts:

ECG DATA  (800 bytes) – 2 channel ECG datas

INFO DATA (168 bytes) – 42 information

The detail description is listed below:

The  INFO Data included 26 information for user to do the monitoring. It is listed below:

It includes Time (1), temperature(2), ECG data(2, 3), G-Sensor (5, 6, 7), Battery Status (8, 9),  HRV (10, 11, 12, 13, 14, 15, 16), Barometer values(17, 18), and  5 G-Sensor points during the period (GS_X0..5, GS_Y0..5, GS_Z0..5).

Since the G-Sensor inside will keep monitor patient’s activity in a sampling rate of 25 Hz. A VSC Mode Data includes 200 ms information and it means the VSC Mode Data will have 5 points of G-Sensor data and they are GS_X0..5, GS_Y0..5, GS_Z0..5.

It is very useful for your motion artifacts removal algorithm.

5.2 VSC Mode Sample code

Please try to git out the souce code from github
https://github.com/juangjl/vs-ecg.git

the sampe as the previous examples, please git clone  the vs-ecg data folder  if you have nerver done the procedure and enter to the VscMode folder. Issues make clean and make all to build the sample code. 

$ git clone https://github.com/juangjl/vs-ecg.git
$ cd vs-ecg/VscMode
$ make clean
$ make all
$ sudo ./script/start.sh

This example will measure the ECG data . so, before the execution, please put the VSH101 onto your left chest.

Please make sure you have the root priority.

If not, please issues sudo su.

issues ./script/start to run the sample. 

 

$ sudo su
$ sudo ./script/start.sh

Please well set your VSD101 name in the config.txt file and select the VSH101 as the previous samples.

Additionally in the example:

1. Social security number read

We will get the social security number into the device. In this case, we will read a string “000-00-0000′.  You can find in the sample code of how to set the number to the device that will help you to do a well patient data control.

2. VSC Mode Start

3. VSC mode file name prepare

It will store the info.csv, gsen.csv, and ch0 and ch1 data of ECG.

 

4. VSC Mode read for 10 seconds. 

It keeps monitor the user for 10 seconds. Of cource, in your case you can modify it ro any seconds you want.

5. VSC Mode Stop

You can find the detail stting and protocol in the sample code.

After that  you can find the data store. in “data/VS/000-00-000000

5.3 ECG Data

After execute the whole  procedure, you will get two ecg data , ch0.csv. and ch1.csv.

ch0.csv – the raw data with base lince cancellation

ch1.csv – the filterred data.

If you want to develop your own motion artifacts removal ch0.csv is good for you otherwise ch1.csv is very suitable for all your usage.

If you put the ch1.csv into an Excel and plot the value, it might looks like the diagram below.  In the very first second, the base line cancellation is working, so there might have a rising slop in the begging of the chart. You can just skip it depend on your application.

 

Values in the csv file is in mV (0.001 V).  You can just save the data you want or do any other kind of data process in your needs.

The .reso files such as ch0.reso and ch1.reso are resolution file. In this case the 1.000 means the unit of value in the csv file is 1.000 mV.

5.4 Information Data

Besides of the ECG raw data, VSC mode provides user a continous patient information records. You can find the info.csv file. In this example, it might looks like this below:

Patient’s information will be collected in a csv file. However, this is just an example, you can try to pot it in charts or put it to the cloud, or set the data to ayour database server depend on your needs.

Please note that the HRV information in freqency domain such LF, HF, VLF, TP might need  5 more minutes to have values.

5.5 G-Sensor Data

VSC Mode provide 25 Hz G-Sensor sample rate data. You can find the dagta in gsen.csv. The data shall be similar to the chart below:

There value is X, Y and Z. The value here is in mG (0.001 G).

5.4 Now, customize your application

After these examples,  users can modify the source code to create the application like the video shows below.