From c0cf4ba34364b0f4e619eab939848a4c02387c47 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Sun, 27 Mar 2022 20:55:14 +0000
Subject: [PATCH] Finalziing a pre-version of documentation

---
 documentation/project_progress.tex |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 102 insertions(+), 6 deletions(-)

diff --git a/documentation/project_progress.tex b/documentation/project_progress.tex
index b8825c7..0338f55 100644
--- a/documentation/project_progress.tex
+++ b/documentation/project_progress.tex
@@ -1,10 +1,31 @@
 \documentclass[12pt]{article}
 \usepackage{graphicx}
-\begin{document}
-\section{Camera}
-\subsection{Model and make}
+\title{Development of trigger circuit for Intel Realsense D455}
+\author{Samo Peni\v{c}}
+\date{\today}
 
-Intel Realsense D455
+\begin{document}
+\maketitle
+\tableofcontents
+\section{Introduction}
+
+The scope of this document is a description of the development of the camera trigger circuit. The camera Intel Realsense D455 can output trigger signal and that signal needs to be level shifted in order to trigger the ADC in use for accelerometer/strain gauge measurements and it is mounted on the back side of the camera. The electrical specifications for the level shifter is as following:
+
+\begin{tabular}{l l l}
+	Parameter & Value & Comment \\ \hline
+	Input trigger voltage & 1.8 V & - \\
+	Output trigger voltage & 3.3 V & - \\
+	Power supply voltage & 3.3 V & - \\
+	Power consumption & $< 50$ mA & Estimated value \\
+	Wireless trigger frequency & 2.4 GHz & - \\
+	Wired Output trigger delay & - & Not yet measured\\
+	Wireless Output trigger delay & - & Not yet measured\\
+\end{tabular}
+
+
+
+\section{Camera}
+
 
 \subsection{Mechanical specifications}
 At the rear of the camera there are two M4 holes for mounting additional modules to the camera. The mechanical drawing is not that clear about the hole size, since there is also a mention of M3 at the same drawing. The part of the mechanical drawing regarding the back of the camera is presented in figure \ref{fig:rearmechanical}.
@@ -67,6 +88,15 @@
 	\caption{ESP32 pinout.}\label{fig:esppinout}
 \end{figure}
 
+\subsection{Connection input and output trigger signals}
+
+Input trigger is connected to the GPIO17 pin. The input level of 1.8 V should be enough to trigger the event in the microcontroller, however, there are possibilities to include internal pullups or even add small electronics circuit to raise the voltage lever before it reaches the microcontroller.
+
+Output trigger is connected to the GPIO16 pin on the microcontroller. It has 3.3 V pulses, which are enough to trigger 5 V CMOS logic.
+
+\subsection{Connection of the power for microcontroller}
+
+The whole electronics is powered from the camera. The camera provides 3.3 V power supply at its connector. That power is routed to 3.3 V input on the microcontroller. The ground is shared with the signals and should be routed to one of the GND pins of the microcontroller. 
 
 \subsection{Connecting nRF24l01+}
 
@@ -108,14 +138,80 @@
 
 \section{Firmware}
 
+Firmware is written in Arduino. Arduino IDE has support for ESP32, however it needs to be installed from the inside of the IDE.
+
+Aditionally RF24 library is needed for communication with nRF24l01.
+
+
 \subsection{Energy conservation}
 
-WiFi.mode(WIFI\_OFF);
+Since no WiFi or BTLE communication from ESP32 is planned, it is suggested to turn off radion within Arduino IDE by issuing the following commands:
+
+\begin{verbatim}
+WiFi.mode(WIFI_OFF);
 btStop();
+\end{verbatim}
 
 \subsection{Input trigger and interrupt}
 
-https://lastminuteengineers.com/handling-esp32-gpio-interrupts-tutorial/
+Input trigger is routed into ESP32 module on pin GPIO17 and can be changed on any free pin. Output trigger is output to pin GPIO16 and can also be changed if necessary.
+
+The GPIO17 (shorter: pin 17) has an interrupt attached to it, so the processor responds on rising edge of the camera trigger signal as soon as possible. The attachemnt is done in setup part of the code.
+
+\begin{verbatim}
+ //pinMode(IN_TRIGGER, INPUT_PULLUP);
+  pinMode(OUT_TRIGGER, OUTPUT);
+  attachInterrupt(IN_TRIGGER, isr, RISING);
+\end{verbatim}
+
+Input internal pullup resistors are not enabled, but they shoud be if the trigger will behave erratically.
+
+The interrupt service routine is handling all the triggering on the output pin:
+
+\begin{verbatim}
+
+void IRAM_ATTR isr() {
+    digitalWrite(OUT_TRIGGER, HIGH);
+    delay(1);
+    digitalWrite(OUT_TRIGGER,LOW);
+}
+\end{verbatim}
+
+
+There is 1 ms pulse length on the output. It can be prolonged if necessary. Input trigger will possibly work on 1.8 V input voltage level. The output trigger has voltage level of 3.3 V and is well above the minimal 5 V CMOS voltage level specifications.
+
+%https://lastminuteengineers.com/handling-esp32-gpio-interrupts-tutorial/
+
+\subsection{nRF24l01 transmission code}
+
+The library RF24 that needs to be installed supports nRF21l01 communication. The nRF21l01 chip needs to be initialized by defining radio in the root of the code:
+
+\begin{verbatim}
+RF24 radio(22, 21); // CE, CSN
+
+const byte address[5] = {'R','E','C','V', '1'};
+char dataToSend[4] = "TRG";
+\end{verbatim}
+
+
+The radio will send a short, yet meaningful message (namely ``TRG'')to the receiver that will listen at the 5 byte address corresponding to the ascii letters of RECV1. The radio has pins 22 and 21 as CE and CSN connections.
+
+The second part of initalizations happens within the setup
+
+\begin{verbatim}
+  radio.begin();
+  radio.openWritingPipe(address);
+  radio.setPALevel(RF24_PA_MIN);
+\end{verbatim}
+
+It presets radio to low power transmission and defines the address of the receiver.
+
+In isr routine presented above, we just need to send a message by issuing:
+
+\begin{verbatim}
+radio.write( &dataToSend, sizeof(dataToSend) );
+\end{verbatim}
+
 
 \end{document}
 

--
Gitblit v1.9.3