Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 1 of 1

Thread: Problems with FTM to generate XY2_100 Signals

  1. #1
    Junior Member
    Join Date
    Jun 2022

    Problems with FTM to generate XY2_100 Signals

    for my Project i need to generate XY2_100 Signals to control a laser galvanometer.
    I found this library on github wich should do what i need:
    Sadly i cant get it to work on my Teensy LC.
    Im using the Arduino IDE version 1.8.19 with Teensyduino version 1.56 to compile the code and Programm the Teensy.

    The problem i have is that i cant even get the example "BasisTest" from the library to work.
    It seems that there is a problem with the timer.
    Since with the default frequency of 4MHz defined in the XY2_100.cpp line 67 no signals are being generated by the Teensy.
    The probelm for that seems to be that the Programm "stops/hangs" while doing the function setXY() wich is called in the BasicTest during the Setup.
    Because if i turn on the LED on the Teensy after the function is done it stays off.
    But the Programm still completes the ISR after the DMA is done, this can be verified by the toggle of Pin 9, wich is commented out by default at the start and end of the ISR.
    This Pin toggles at a frequency of around 500KHz during my tests, for a frequency value of 4MHz.

    IF you lower the Frequency in the XY2_100.cpp line 67 to a value of 20, the Programm "works".
    That meaning differential signals are beeing generated. But the clock signal has a frequency of 590Hz.
    IF the frequency value is 10 the clock frequency is 1,5kHz.

    For a frequency value of 20 the galvanometer reacts to the signals but instead of a rectangle it just results in the laser jumping between multiple positions.
    The intended frequency for this protocol is 2Mhz, this could be the reason for not generating a rectangle.
    Also if the delay between setSignedXY() calls is 100ms or bigger the programm stops working again, wich is weird.
    Does anyone have any idea why the library/programm acts this way and how to fix it.
    I have attached the nessesary files but all of them except the XY2_100 protocol pdf can be found in the GitHub repo with more information.


    I have done more testing and with this code i can kind of control the galvo.
    #include <XY2_100.h>
    XY2_100 galvo;
    void setup() {
      pinMode(13, OUTPUT);
      digitalWriteFast(13, HIGH);
    void loop() {
      static int32_t max_ = 65530, min_ = 22;
      const uint16_t pause = 15;
      galvo.setXY(min_, min_);
      galvo.setXY(min_, max_);
      galvo.setXY(max_, max_);
      galvo.setXY(max_, min_);
    The frequency in the library is still set to 20.
    and the pause value has to be somewhere between 10 and 20.
    Also not all values for setXY() work, for example with 10 and 51 as small values the galvo stays still.
    But this code controls the laser in 4 different positions, but these have a variance and are not fixed.

    So it is still not usable for me and im still confusedwhat even is going on.

    Also to add, i can control the Galvo over and external control board and Programm, so i have verified the correct functionality of the scanner.
    And i have analyzed the Signal produced by the external control board, and it uses a 2MHz clock and all works fine with it.
    Attached Files Attached Files
    Last edited by Der_Frosti; 06-20-2022 at 03:30 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts