Dtynin
Dtynin
Synchronizing Sensor Data Over CAN Bus with AVR128DA48 and Zephyr
I’ve integrated temperature, vibration, and pressure sensors with the AVR128DA48, and have set up CAN Bus communication running Zephyr. Each sensor is connected to a separate CAN node, and data is being collected. However, I’m having trouble synchronizing the sensor readings. Sometimes, readings from different sensors are out of sync or arrive too late on the CAN network. This is the current code snippet I'm using for CAN data transmission:
void send_sensor_data() {
struct zcan_frame temp_frame = {
.id = 0x101,
.dlc = 2,
.data = {temperature >> 8, temperature & 0xFF},
};
can_send(can_dev, &temp_frame, K_MSEC(100), NULL, NULL);

struct zcan_frame press_frame = {
.id = 0x102,
.dlc = 2,
.data = {pressure >> 8, pressure & 0xFF},
};
can_send(can_dev, &press_frame, K_MSEC(100), NULL, NULL);
}
void send_sensor_data() {
struct zcan_frame temp_frame = {
.id = 0x101,
.dlc = 2,
.data = {temperature >> 8, temperature & 0xFF},
};
can_send(can_dev, &temp_frame, K_MSEC(100), NULL, NULL);

struct zcan_frame press_frame = {
.id = 0x102,
.dlc = 2,
.data = {pressure >> 8, pressure & 0xFF},
};
can_send(can_dev, &press_frame, K_MSEC(100), NULL, NULL);
}
What should I do to ensure sensor data is transmitted synchronously over the CAN Bus, ensuring that all sensor readings arrive at the same time for proper analysis? Any tips?
1 replies