Hardware: AD-PQMON-SL
Goal:
Obtain the waveform when a power quality event occurs
Problem Description:
- When process_data = 1, interrupt event can be detected.
- When process_data = 0, interrupt event failed to be detected.
- iio_device_attr_write_double() failed to overwrite process_data from 0 to 1.
Error Video:
Troubleshooting step that has been taken:
In my full coding, I can overwrite process_data from 1 (default value) to 0 to enable waveform data collection.
Coding:
#include <stdio.h>
#include <stdlib.h>
#include <iio.h>
int main() {
// Configuration
struct iio_context* ctx = iio_create_context_from_uri("serial:/dev/ttyACM0,115200,8n1");
const struct iio_device* dev = iio_context_get_device(ctx, 0);
struct iio_channel* chn = iio_device_get_channel(dev, 10);
const char* chnName = iio_channel_get_name(chn);
printf("Channel[10] name: %s \n", chnName);
// Process Data
double process_data = 9.0;
iio_device_attr_write_double(dev, "process_data", 1.0);
iio_device_attr_read_double(dev, "process_data", &process_data);
printf("Process data: %lf \n", process_data);
// Read countEvent
double chnAttrValue = 0.0;
while (true)
{
iio_channel_attr_read_double(chn, "countEvent", &chnAttrValue);
if (chnAttrValue != 0.0)
{
printf("countEvent: %lf \n", chnAttrValue);
break;
}
}
iio_context_destroy(ctx);
}