From 3e4d4c2df4f4be8447ce268f4de0688610c0bbda Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Fri, 20 May 2022 13:41:12 +0000 Subject: [PATCH] Added python script --- documentation/project_progress.tex | 184 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 177 insertions(+), 7 deletions(-) diff --git a/documentation/project_progress.tex b/documentation/project_progress.tex index 4227987..15e43a9 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}. @@ -39,7 +60,7 @@ \end{figure} -The connector has pinout shown in the data table. According to the \cite{productFamilyDatasheet}, pins 5 and 9 shoud be used for synchronization. From the pinout, pin number 8 could be used to power up electronics. However, no data about electrical characteristics of power supply is given (max current?). +The connector has pinout shown in the data table. According to the \cite{productFamilyDatasheet}, pins 5 and 9 shoud be used for synchronization. From the pinout, pin number 8 could be used to power up electronics. However, no data about electrical characteristics of power supply is given (max current?). \textbf{The cables in use, have a red wire at pin 1.} @@ -67,17 +88,166 @@ \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+} + +For fast communication Nordic Semiconductor chip nRF24l01+ is used. It operates on 2.4 GHz frequency band, supports multiple channels, raw communication with possibilities of ACK/NoACK. The delay of wirelessly transporting the trigger should be minimal with pair of nRF24 where one is designated as transmitter and one as receiver. There is possibility of full duplex communication. No protocol is defined yet, so we have multiple possibilities on implementation. + +As an advenced feature of the receiving end, there is a posibility to measure round trip of data transfer, therefore, the receiver can calculate the delay caused by the transmission and compensate for it, if the receiver does not need to trigger the event. As an example, this could be implemented when accelerometer is read and should be synchronized with camera frame capture. The receiver can measure acceleration beforehand in short intervals and put it into cyclic buffer. When the trigger is received and knowing the trigger transmission delay and accelerometer reading frequency, we can look up the value for acceleration at the exact time the camera published the event at the transmitter side. With this, we have possibility to minimize trigger delay. + +nRF24l01 modules are used, where everyting regarding radio is implemented. Module has SPI and power supply pins on its connector. Image of module with its pinout is presented in figure \ref{fig:nrfpinout}. + +\begin{figure}[htb] + \begin{center} + \begin{minipage}{0.45\linewidth} + \includegraphics[width=0.9\linewidth]{figures/nrf_pinout.png} + \end{minipage} + \begin{minipage}{0.45\linewidth} + \includegraphics[width=0.9\linewidth]{figures/nrf_electrical.png} + + \end{minipage} + \end{center} + \caption{nRF24l01 module pinout and its electrical characteristics. \cite{nrfInterfacing}}\label{fig:nrfpinout} +\end{figure} + + + +Connection to ESP32 module is as presented in the following table: + +\begin{tabular}{l | l | l} +nRF pin & ESP32 pin & comment \\ \hline + 1 & GND & Power and signal ground \\ + 2 & 3.3V & Power supply \\ + 3 & 22 & CE (Chip enable) \\ + 4 & 21 & CSN \\ + 5 & 18 & SCK \\ + 6 & 23 & MOSI \\ + 7 & 19 & MISO \\ \hline +\end{tabular} + + \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} + +\subsection{Debug receiver} + +To measure trigger delay and for other debugging purposes, A simple debug receiver can be programmed. On this receiver, the nRF21l01 must be connected the same way as on trasmitter. The following code works as debug interface. The code can also be a reference for receiver design. + +\begin{verbatim} +#include <RF24_config.h> +#include <nRF24L01.h> +#include <RF24.h> +#include <printf.h> + +RF24 radio(22, 21); // CE, CSN +const byte address[6] = {'R','E','C','V', '1'}; +char val[4]; + +void setup() { + Serial.begin(115200); + radio.begin(); + radio.openReadingPipe(0, address); + radio.setPALevel(RF24_PA_MIN); + radio.startListening(); + +} + +void loop() { + delay(5); + radio.startListening(); + if ( radio.available()) { + while (radio.available()) { + + radio.read(&val, sizeof(val)); + Serial.print("Received = "); + Serial.println(val); + } + } + +} +\end{verbatim} \end{document} -- Gitblit v1.9.3