Making a Custom Profile for ADC

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
18 posts / 0 new
Last post
herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
Making a Custom Profile for ADC

Hi there,

I would like to capture the ECG signals and then I want to convert them into heart rate which is in bpm and I want signal to be sent through the BLE to the smartphone. The smartphone will use BLE scanner to get the reading. I have modified the ble_app_peripheral example in the SDK folder so that I can be able to capture the data (see the attachment). I have realized that the problem is most probably due to the ADC function. Did I put at the wrong location and where should I put?

adc_init (GP_ADC_SE, GP_ADC_SIGN, GP_ADC_ATTN3X).....
....

Thank you very much.

Device:
herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
Hi there,

Hi there,

Besides that, I do not know how to link the adc output to the custom profile and basically the output from the ADC is in ECG signal and I need to convert them into heart rate. Do I need to use the hrpc.c, hrpc_task.c ? Thanks

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
Hi herochua617,

Hi herochua617,

没有祝福你任何实现values from the ECG and the ADC ? If yes then you can go to the next step and send the values through BLE. The heart rate profile files exist in order to send the hrp values using the SIG standard heart rate profile apart from that there is nothing else that tha profile will do for you, can can still send values from the sensor using your custom profile. Regarding the where you will have to place the reading ADC function you can do that right before sending the notification towards the stack. Regarding how to send the value, the sample variable that you have in the app_adcval1_timer_cb_handler() is the dummy value that it is send to the central every time the timer elapses, so you can replace that data with the value read from the ADC.

Thanks MT_dialog

herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
Hi MT_dialog,

Hi MT_dialog,

I would like to ask. If I want to run this profile from SPI, do I need to configure anything in the ble_peripheral_app? Since I can use smart snippets to straight away burn the coding inside the SPI and it will run automatically when I switch on the development kit when I run the development kit on coin cell battery supply? Am I right? Thanks

herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
Hi there,

Hi there,

What i am getting from the custom profile is not the heart rate. Is actually the ECG signal value which is the value obtained from the ADC output. i know that I need to fix the interval of the QRS complex of the ECG signal in order to obtain the heart rate value. But do you have any example on how to configure that? Thanks

chey856
Offline
Last seen:4 years 1 week ago
Joined:2017-01-06 11:30
1.Enable ADC value notify

1.Enable ADC value notify
ADC_VAL_1_UUID_128(UUID 0x17, 0xB9, 0x67, 0x98, 0x4C, 0x66, 0x4C, 0x01, 0x96, 0x33, 0x31, 0xB1, 0x91, 0x59, 0x00, 0x15)
2. write 0x01 to CTRL_POINT
CTRL_POINT_UUID_128 (0x20, 0xEE, 0x8D, 0x0C, 0xE1, 0xF0, 0x4A, 0x0C, 0xB3, 0x25, 0xDC, 0x53, 0x6A, 0x68, 0x86, 0x2D)
ADC func location you put is not wrong.

herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
Hi chey856,

Hi chey856,

Thank you very much!. I am able to see the value changing. Can I ask? What is the function of control point? Why I do need to turn on in order to obtain the value? Thanks

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
Hi herochua617,

Hi herochua617,

The control point characteristic that chey856 kindly mentioned is a characteristic that when written it enables a kernel timer in the fw. When the kernel timer elapses it triggers the sending of a notification towards the stack and eventually at your phone and resets the timer. So as soon as you write to that characteristic the function user_custs1_ctrl_wr_ind_handler() is triggered and starts the timer, and when the timer elapses the app_adcval1_timer_cb_handler() gets triggered.

Thaks MT_dialog

chey856
Offline
Last seen:4 years 1 week ago
Joined:2017-01-06 11:30
that's correct! thank you

that's correct! thank you very much Thaks
by the way can you tell the adc sample rate of DA14580

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
Hi chey856,

Hi chey856,

It is mentioned in the datasheet, "The Maximum sampling rate is 3.3 Msample/s".

Thanks MT_dialog

herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
Hi there,

Hi there,

What if I wanna take the data and convert them into heart rate so that the adc value 1 will give the result as in heart rate. Will I able to do it using my existing code? Thanks

chey856
Offline
Last seen:4 years 1 week ago
Joined:2017-01-06 11:30
heart rate = ( adc_get_sample

heart rate = ( adc_get_sample() * 1.2Volt * ADC_ATTN3X)/1023
if you did not set ADC_ATTN3X in adc_init(), set ADC_ATTN3X = 1 else set ADC_ATTN3X=3
1.2Volt is the reference voltage
10bit adc so it's resolution: 2^10 - 1 =1023
you should take a look at "projects\target_apps\peripheral_examples\adc\ batt_lvl" example

herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
static uint16_t heart_rate,

static uint16_t heart_rate, sample, sample2;

adc_init (GP_ADC_SE, 0, GP_ADC_ATTN3X);
adc_enable_channel (ADC_CHANNEL_P01);
sample = adc_get_sample ();

adc_init (GP_ADC_SE, GP_ADC_SIGN, GP_ADC_ATTN3X);
adc_enable_channel (ADC_CHANNEL_P01);
sample2 = adc_get_sample ();

heart_rate = (sample + sample2);
heart_rate = heart_rate/2;
heart_rate = (heart_rate*3.6)/1023;

req->conhdl = app_env->conhdl;
req->handle = CUST1_IDX_ADC_VAL_1_VAL;
req->length = DEF_CUST1_ADC_VAL_1_CHAR_LEN;
memcpy(req->value, &heart_rate, DEF_CUST1_ADC_VAL_1_CHAR_LEN);

ke_msg_send(req);

if (ke_state_get(TASK_APP) == APP_CONNECTED)
{
// Set it once again until Stop command is received in Control Characteristic
timer_used = app_easy_timer(100, app_adcval1_timer_cb_handler);
}
}

Here's my code. I got 0x01 from my ADC VAL 1 characteristics from the BLE Scanner app. Any advice?

Thanks

chey856
Offline
Last seen:4 years 1 week ago
Joined:2017-01-06 11:30
Sorry for late, It seems that

Sorry for late, It seems that your code is OK, can you tell me more details about your project?
My mailbox:cheyu856@gmail.com

herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
I've already replied to your

I've already replied to your mailbaox. Thanks

herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
Hi guys,

Hi guys,

Can I use the HRPS profile to work with my heart rate device? Will that be easier since there will be algorithm right in the HRPS that will convert my data into readable heart rate and not in hexadecimal values?

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
Hi herochua617,

Hi herochua617,

The hrps is just a SIG standard that it just formats the data of your sensor in a specific way in order to be read by other client devices, it has no algorithm implementation or anything extra, its just a standard way to express heart rate values in order for other devices to be able to interpret them.

Thanks MT_dialog

herochua617
Offline
Last seen:3 years 11 months ago
Joined:2017-01-18 12:46
Hi MT_dialog,

Hi MT_dialog,

谢谢。这解决了我的问题https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl.... Thanks. However, I am trying my own way of detecting the interval. I want to get the time between two peak thru thishttps://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl.... Thank you very much!