Fast Input Handling

Status
Not open for further replies.

fishbone

New member
Hello folks!
First of all: Thank you for all the great work and help you already provided me! I profited a lot from just reading from the forum and other users questions.

For now I am stuck with a little problem, where I need help. I couldn't find the solution or hints so far anywhere in this forum. This may be related to the fact that I don't really know what I have to search for. So here is my problem:

Board: Teensy 4.0

Task:
High speed reading of a couple of inputs into an array/buffer.

Signal:
input_signal_long.PNG

Distance between Signals:
signal_distance.PNG

Zoomed Signal:
input_signal.PNG

The input signal which has to be analyzed looks as in the images above. The input is general high and drops to low upon measurement/programstart. The measurement should be initialized with an interrupt (FALLING).
The zoomed signal contains the part of the signal, which contains the information needed and is repeated several times. In the image above there is one bit out of a total of 16 possible bits low. There may be up to 4 bits low.

I want to read the zoomed signal into a 16bit (or 2x8bit) value. As the zoomed signal contains 16bit.

Timings:
time for one bit: ~40us
time for 16 bits: ~779us


How can I implement this reliably and good? Unfortunately I do not have any possibility in making this signal slower in order to get it to work with digitalRead().

Thank you for any help! :)
 
@luni : many thanks! I think with the TeensyTimerTool i should get the task done!

EDIT: Library is working so far! One simply needs to install it properly... (whistle)
Installationinstructions can be found here: https://forum.pjrc.com/threads/59112-TeensyTimerTool?p=231529&viewfull=1#post231529
and here: https://www.arduino.cc/en/guide/libraries#toc4

But I struggle with using it together with my Teensy 4.0 :
Code:
C:\Users\user\AppData\Local\Temp\arduino_build_750528\sketch\prototypet-1.ino.cpp.o: In function `TeensyTimerTool::ITimerChannel::trigger(float)':

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/ITimerChannel.h:13: undefined reference to `TeensyTimerTool::postError(TeensyTimerTool::errorCode)'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/ITimerChannel.h:13: undefined reference to `TeensyTimerTool::postError(TeensyTimerTool::errorCode)'

C:\Users\user\AppData\Local\Temp\arduino_build_750528\sketch\prototypet-1.ino.cpp.o: In function `TeensyTimerTool::errorCode TeensyTimerTool::BaseTimer::begin<int>(std::function<void ()>, int, bool)':

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/baseTimer.h:39: undefined reference to `TeensyTimerTool::postError(TeensyTimerTool::errorCode)'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/baseTimer.h:46: undefined reference to `TeensyTimerTool::postError(TeensyTimerTool::errorCode)'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/baseTimer.h:38: undefined reference to `TeensyTimerTool::postError(TeensyTimerTool::errorCode)'

C:\Users\user\AppData\Local\Temp\arduino_build_750528\sketch\prototypet-1.ino.cpp.o:c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/baseTimer.h:54: more undefined references to `TeensyTimerTool::postError(TeensyTimerTool::errorCode)' follow

C:\Users\user\AppData\Local\Temp\arduino_build_750528\sketch\prototypet-1.ino.cpp.o: In function `TeensyTimerTool::OneShotTimer::OneShotTimer(TeensyTimerTool::ITimerChannel* (*)())':

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/oneShotTimer.h:23: undefined reference to `TeensyTimerTool::GPT2'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/oneShotTimer.h:23: undefined reference to `TeensyTimerTool::TMR1'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/oneShotTimer.h:23: undefined reference to `TeensyTimerTool::GPT1'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/oneShotTimer.h:23: undefined reference to `TeensyTimerTool::TMR2'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/oneShotTimer.h:23: undefined reference to `TeensyTimerTool::TCK'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/oneShotTimer.h:23: undefined reference to `TeensyTimerTool::TMR3'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/oneShotTimer.h:23: undefined reference to `TeensyTimerTool::TMR4'

c:\users\user\appdata\local\temp\arduino_build_750528\sketch\teensytimertool-master\src/oneShotTimer.h:23: undefined reference to `TeensyTimerTool::BaseTimer::BaseTimer(TeensyTimerTool::ITimerChannel* (*)(), bool)'

collect2.exe: error: ld returned 1 exit status

Error compiling for board Teensy 4.0.

I took your sample code from the linked example and did minor adjustments:
Code:
#include "Arduino.h"

#include "./TeensyTimerTool-master/src/TeensyTimerTool.h"
using namespace TeensyTimerTool;

OneShotTimer trpClkTimer(TMR1);  // TMR @150MHz, prescaler 1

uint32_t bitCnt;

void trpClk()
{  
  digitalWriteFast(3, HIGH);  
  delayNanoseconds(80);
  digitalWriteFast(3, LOW);
  if(--bitCnt > 0)
  {
    trpClkTimer.trigger(1.15);  // retrigger the timer
  }   
}

void pinISR()
{
  bitCnt = 16;
  trpClkTimer.trigger(0);  // first call
}

void setup()
{
  pinMode(0, OUTPUT);       // packet signal generator
  pinMode(17, INPUT_PULLUP); // packet signal input (jumper 0->1)
  
  //pinMode(2, OUTPUT);       // packed detected output
  pinMode(3, OUTPUT);       // timer isr;

  attachInterrupt(17, pinISR, FALLING);
  trpClkTimer.begin(trpClk);
}

void loop()
{
}

Maybe I am doing something wrong when using the TeensyTimerTool? (I simply downloaded it from github, put the whole folder into my teensy project and adjusted the include path.

Thanks in advance! :)
 
Last edited:
I tried the posted code, it compiles without errors, but I'm confused about this line

Code:
./TeensyTimerTool-master/src/TeensyTimerTool.h

If you need to give the full path to the header file something is not installed correctly. A simple
Code:
#include "TeensyTimerTool.h"
Should be enough. Can it be that you copied it to the library folder without restarting the Arduino IDE? AFAIK the IDE checks for new libraries only at startup.

BTW: The library can now be installed from the Arduino LibraryManager. (Sketch|Include Library|Manage Libraries...) Can you try to shut down the IDE, delete the manually installed library folder and reinstall with the library manager?
 
@luni:
Thanks for the help! I managed to understand that I screwed it up... :)
I edited the post accordingly:
EDIT: Library is working so far! One simply needs to install it properly... (whistle)
Installationinstructions can be found here: https://forum.pjrc.com/threads/59112...l=1#post231529
and here: https://www.arduino.cc/en/guide/libraries#toc4

and the code works! :) I now need to figure out and code all the other things I need, but I will post back once i have some nice code (or again post silly questions...)
 
Status
Not open for further replies.
Back
Top