Some more analog read optimizations done - the measurement should be some kind of noise free.

This commit is contained in:
klaute 2016-09-27 16:30:52 +02:00
parent 82a8606616
commit 25114f4350
3 changed files with 24 additions and 8 deletions

View file

@ -201,7 +201,7 @@ void cc_startMeasurement()
si5351.drive_strength(SI5351_CLK0, drive_str); // 2 4 6 8ma
uint8_t t = 0;
for (t = 0; t < 200; t++)
for (t = 0; t < 100; t++)
{
uint16_t tmp = analogRead(A0);
tmp = analogRead(A1);
@ -225,13 +225,13 @@ void cc_startMeasurement()
uint8_t t = 0;
uint16_t ta0 = 0;
uint16_t ta1 = 0;
for (t = 0; t < 20; t++)
for (t = 0; t < MEAS_LOOP_CNT; t++)
{
ta0 += analogRead(A0);
ta1 += analogRead(A1);
}
a0_sum += (ta0 / 20);
a1_sum += (ta1 / 20);
a0_sum += (ta0 / MEAS_LOOP_CNT);
a1_sum += (ta1 / MEAS_LOOP_CNT);
delay(1);
}

View file

@ -21,8 +21,18 @@ enum si5351_drive drive_str = SI5351_DRIVE_2MA;
void setup()
{
pinMode(A0, INPUT);
pinMode(A1, INPUT);
// manage the analog pins
pinMode(A0, INPUT); // forward SWR measurement
pinMode(A1, INPUT); // backward SWR measurement
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A6, OUTPUT);
pinMode(A7, OUTPUT);
digitalWrite(A2, LOW);
digitalWrite(A3, LOW);
digitalWrite(A6, LOW);
digitalWrite(A7, LOW);
// Init the serial connection
Serial.begin(115200);
@ -39,6 +49,8 @@ void setup()
si5351.output_enable(SI5351_CLK1, 0); // disable clock output 1
si5351.output_enable(SI5351_CLK2, 0); // disable clock output 2
analogReference(DEFAULT); // 5V reference
}
void loop()

View file

@ -1,6 +1,10 @@
/*****************************************************************************/
#define MEAS_LOOP_CNT 20
/*****************************************************************************/
/* Message byte definitions: */
#define MSG_SOM1 0x3c
#define MSG_SOM2 0x3e