Small jitter to avoid schwebung
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
Voltage measurement device over WiFi (batched, 30 Hz)
|
||||
Voltage measurement device over WiFi (batched, ~30 Hz with jitter)
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "nvs_flash.h"
|
||||
|
||||
#include "esp_adc/adc_cali.h"
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#include "esp_adc/adc_cali_scheme.h"
|
||||
@@ -21,12 +20,12 @@
|
||||
|
||||
#define SERVER_URL "http://192.168.178.157:8080/data"
|
||||
|
||||
#define SAMPLE_RATE_HZ 30
|
||||
#define SAMPLE_RATE_HZ 20
|
||||
#define SAMPLE_PERIOD_MS (1000 / SAMPLE_RATE_HZ)
|
||||
#define BATCH_SIZE 100
|
||||
|
||||
#define CHANNEL ADC_CHANNEL_6
|
||||
#define CALIBRATION_FACTOR 1650.0f
|
||||
#define CALIBRATION_FACTOR 1600.0f
|
||||
|
||||
#define EXAMPLE_ESP_WIFI_SSID "Jaguar"
|
||||
#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
|
||||
@@ -193,8 +192,9 @@ static void measure_task(void *arg)
|
||||
count = 0;
|
||||
}
|
||||
|
||||
int jitter = (rand() % 10) - 5; // ±2 ms random
|
||||
vTaskDelayUntil(&last_wake,
|
||||
pdMS_TO_TICKS(SAMPLE_PERIOD_MS));
|
||||
pdMS_TO_TICKS(SAMPLE_PERIOD_MS + jitter));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user