diff --git a/README.md b/README.md
index bdcd76c..b314e6f 100644
--- a/README.md
+++ b/README.md
@@ -4,3 +4,21 @@ A simple oscilloscope application that reads the values at serial port generated
Main window
+
+
+ Settings
+
+Flash oscilloscpe.ino to an arduino board. In the Oscilloscope gui settings select the serial port with correct properties. By default 1000000bps, 8bits, no paraty, 1 stop bot and no flow control and an interval of 100ms between analog readings.
+
+For ATmega based boards there is a PWM signal at pin B2(OC1B). To test the Oscilloscope app connect pin B2 to pin A0
+Adjust PWM signal with PWM_FREQ and PWM_DUTY. Default is 100Hz, 50% duty.
+
+Pin B2 location:
+ - Uno, Leonardo: pin 10
+ - ATmega2560: pin 12
+
+To build the Oscilloscope app:
+- install qt
+- cd to src/qt folder
+- qmake
+- make
diff --git a/images/img2.png b/images/img2.png
new file mode 100644
index 0000000..f3db7dd
Binary files /dev/null and b/images/img2.png differ
diff --git a/src/arduino/oscilloscope/oscilloscope.ino b/src/arduino/oscilloscope/oscilloscope.ino
index df74971..9e2555c 100644
--- a/src/arduino/oscilloscope/oscilloscope.ino
+++ b/src/arduino/oscilloscope/oscilloscope.ino
@@ -1,24 +1,37 @@
-#define FREQ 100 // HZ
-#define DUTY 0.5 // %/100
+/* Interval between analog readings. It has to be the same as defined in the Oscilloscope settings */
+#define INTERVAL 100// microseconds (us)
+
+/* PWM signal properties */
+#define PWM_FREQ 100 // HZ
+#define PWM_DUTY 0.5 // %/100
#define MS_TO_COMP(SCALER) (F_CPU / (SCALER * 1000.0))
void setup() {
pinMode(A0, INPUT);
Serial.begin(1000000);
-
- // PWM 100Hz, 50% DUTY, PIN B2
+
+#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328PB__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__)
+ /* PWM signal is available at pin B2(OC1B). To test the Oscilloscope app connect pin B2 to pin A0
+ Adjust PWM signal with PWM_FREQ and PWM_DUTY
+ Pin B2:
+ Uno, Leonardo: pin 10
+ ATmega2560: pin 12
+ PWM 100Hz, 50% DUTY, PIN B2
+ */
DDRB |= _BV(DDB2);
TCCR1A = _BV(WGM11) | _BV(WGM10);
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS11); // scaler 8
TCCR1A |= _BV(COM1B1);
- OCR1A = 1000 / 100 * MS_TO_COMP(8);
- OCR1B = 0.5 * OCR1A;
+ OCR1A = 1000 / PWM_FREQ * MS_TO_COMP(8);
+ OCR1B = PWM_DUTY * OCR1A;
+#endif
+
}
void loop() {
static uint16_t ts = 0;
- if ((uint16_t)micros() - ts > 100)
+ if ((uint16_t)micros() - ts > INTERVAL)
{
ts = micros();
uint8_t val = analogRead(A0) >> 2;