Browse Source

increase sample rate from 400 to 500 Hz (measured 495 Hz)

Fabian Peter Hammerle 3 years ago
parent
commit
e0fd86e934
2 changed files with 6 additions and 5 deletions
  1. 2 1
      arduino-sketch.ino
  2. 4 4
      scope.grc

+ 2 - 1
arduino-sketch.ino

@@ -1,5 +1,5 @@
 // https://www.arduino.cc/reference/en/language/functions/time/micros/
-const unsigned long SAMPLE_INTERVAL_MICROSECONDS = 2500L;
+const unsigned long SAMPLE_INTERVAL_MICROSECONDS = 2000L;
 
 void setup() {
     // $ stty -F /dev/ttyUSB0 | grep speed
@@ -17,6 +17,7 @@ void loop() {
     // https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/
     unsigned short reading = analogRead(A0);
     // $ tail --follow /dev/ttyUSB0 | od --format=u2 --endian=big --width=2
+    // 16 bits/sample / 115200 Baud * 1e6 μs/sec = 139 μs/sample
     Serial.write(reading >> 8);
     Serial.write(reading & 0xff);
 }

+ 4 - 4
scope.grc

@@ -53,7 +53,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [749, 18]
+    coordinate: [767, 18]
     rotation: 0
     state: true
 - name: resistor_2_ohm
@@ -65,14 +65,14 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [747, 117]
+    coordinate: [765, 117]
     rotation: 0
     state: true
 - name: sample_rate_hz
   id: variable
   parameters:
     comment: ''
-    value: 1e6 / 2500
+    value: 1e6 / 2000
   states:
     bus_sink: false
     bus_source: false
@@ -89,7 +89,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [752, 216]
+    coordinate: [770, 216]
     rotation: 0
     state: true
 - name: blocks_multiply_const_vxx_0