Samo Penic
2022-03-28 d6fc89518a6a3a21d53823d83d2a8cf64957d678
Added test interrupt code.
2 files modified
1 files added
80 ■■■■■ changed files
documentation/project_progress.tex 38 ●●●●● patch | view | raw | blame | history
firmware/debug_receiver_interrupt/receiver_interrupt/receiver_interrupt.ino 40 ●●●●● patch | view | raw | blame | history
firmware/trigger_firmware/trigger_firmware.ino 2 ●●● patch | view | raw | blame | history
documentation/project_progress.tex
@@ -60,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.}
 
@@ -212,6 +212,42 @@
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}
firmware/debug_receiver_interrupt/receiver_interrupt/receiver_interrupt.ino
New file
@@ -0,0 +1,40 @@
#include <RF24_config.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
#define IRQ_PIN 17
RF24 radio(22, 21); // CE, CSN
const byte address[6] = {'R','E','C','V', '1'};
char val[4];
void isrCallbackFunction() {
  bool tx_ds, tx_df, rx_dr;
  radio.whatHappened(tx_ds, tx_df, rx_dr); // resets the IRQ pin to HIGH
  if ( radio.available()) {
    while (radio.available()) {
      radio.read(&val, sizeof(val));
      Serial.print("Received = ");
      Serial.println(val);
    }
  }
}
void setup() {
  pinMode(IRQ_PIN, INPUT);
  attachInterrupt(digitalPinToInterrupt(IRQ_PIN), isrCallbackFunction, FALLING);
  Serial.begin(115200);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MAX);
  radio.maskIRQ(1, 1, 0);
  radio.startListening();
}
void loop() {
  // put your main code here, to run repeatedly:
}
firmware/trigger_firmware/trigger_firmware.ino
@@ -37,7 +37,7 @@
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.setPALevel(RF24_PA_MAX);
  //radio.setDataRate( RF24_250KBPS );
  pinMode(IN_TRIGGER, INPUT_PULLUP);