pluxbiosignals / android-sample

Working example of PLUX's Android API.
https://plux.info
4 stars 3 forks source link

intepretation of analogdata #1

Closed weihangChen closed 4 years ago

weihangChen commented 4 years ago

i have purchased the biosignalplux kit and experiment using the android app for the following code to get the frame

handler = new Handler(getMainLooper()) {
            @Override
            public void handleMessage(Message msg) {
                final Bundle bundle = msg.getData();

                if (bundle.containsKey(FRAME)) {
                    final Parcelable frame = bundle.getParcelable(FRAME);

                    if (frame.getClass().equals(BiopluxFrame.class)) { //biosignalsplux
                        String frameStr = frame.toString();
                        biopluxResultsTextView.setText(frameStr);

                    } else if (frame.getClass().equals(BITalinoFrame.class)) { //BITalino
                        resultsTextView.setText(frame.toString());
                    }
                } else if (bundle.containsKey(ELAPSED_TIME_EVENT)) {
                    final long elapsedTime = bundle.getLong(ELAPSED_TIME_EVENT);

                    if (elapsedTextView == null) {
                        return;
                    }

                    elapsedTextView.setText(getTimeString(elapsedTime));
                }
            }
        };

frameStr returns


D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 2000; AnalogData: [32960]; DigitalInput: 0; Comments: null
D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 3000; AnalogData: [32916]; DigitalInput: 0; Comments: null
D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 4000; AnalogData: [32888]; DigitalInput: 0; Comments: null
D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 5000; AnalogData: [32800]; DigitalInput: 0; Comments: null
D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 6000; AnalogData: [32840]; DigitalInput: 0; Comments: null
D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 7000; AnalogData: [32808]; DigitalInput: 0; Comments: null
D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 8000; AnalogData: [32796]; DigitalInput: 0; Comments: null
D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 9000; AnalogData: [32712]; DigitalInput: 0; Comments: null
D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 10000; AnalogData: [32800]; DigitalInput: 0; Comments: null
D/DeviceActivity: Identifier: 00:07:80:F9:DD:CB; Sequence: 11000; AnalogData: [32712]; DigitalInput: 0; Comments: null

but i have no idea how to interpret the analogdata number there, when i drag and press the sensor, in the opensignal app, i can see the value goes up and down but here in the android app, the number varies very little. also in the documentation it is not very clear about how the source should be defined. sources.add(new Source(1, 16, (byte) 0x01, 100));

where is the documentation about the port and mask? here i dont see much, https://biosignalsplux.com/downloads/apis/PLUX_Android.pdf

the channel we have is RESP, while the sensor is connected to the first connector.

v-gramos commented 4 years ago

Hi Marc,

Thank you for your message. I am not sure that I have fully understood your question. If the following does not clarify your doubts please do not hesitate to tell me so.

I assume that you are using a respiration sensor. If that's the case and you are looking to obtain data in specific units, such as electric tension (V), you just need to use the transfer function that you can find on the sensor datasheet. You may visit biosignalsplux website to check further information regarding this and other sensors.

To define one source you just need to set which port you wish to use, the resolution, the channel mask, and the frequency divisor. Regarding the channel mask, you can find some notes on the sample app. In most cases the channel mask should be set to 0x01. Other cases are applied, for example, when you are using digital sensors. These sensors require only one connection but provide multiple output signals. The number of desired output signals determines which channel mask must be used.

Best regards, Vanessa Ramos

weihangChen commented 4 years ago

Hi Vanessa

Now I have taken some pictures so hopefully it will make the communication easier. so step1, we do a connect to the device, and we only plugin the sensor to connector 1 connect

step2: I modify the source code sources.add(new Source(1, 16, (byte) 0x01, 100)); in order to get analogdata out, and here the value range is 32712 to 32960, when i stretch the sensor, I assume the value should go up a lot, but it does not. big_sensor_value

step3: So i replay the sensor with a small one, so you see the value when i do not bend it, it is 22768, small_sensor_low_value

step4: I start to bend the sensor, and i get a value of 34656 small_sensor_high_value

so here are my questions

  1. why the big sensor value does not change so much while the small one does? (i have verified both using desktop application, so both should work)
  2. i dont have so much domain knowledge, but this value that i get back like 32712, how do i do conversion back to a normal scaled value that we used to see on a graph like below? normal_scale
  3. based on the configuration that is showed in the image, is the configuration code correct? sources.add(new Source(1, 16, (byte) 0x01, 100));
v-gramos commented 4 years ago

Hi again,

Thank your for the detailed explanation and the pictures.

Answering your questions:

  1. Those are two different sensors: piezoelectric respiration (PZT) sensor and an inductive respiration (RIP) sensor. Having different working principles it is normal to get the differences that you are seeing.

  2. To get the converted values such as the ones on the graph that you sent you need to apply the following transfer function: image

  1. Yes, using that configuration, your code is correct.
weihangChen commented 4 years ago

thanks, it works.... if possible would you mind taking a look at the other issue that I opened? it always got into an exception at start and the device stops sending info.plux.android.sample.DeviceActivity.FRAME after 32 seconds