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

Thread: Frequency input pin Teensy4

  1. #1
    Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    92

    Frequency input pin Teensy4

    Hi all,

    For my Power and SWR meter with frequency range between 1 to 50 MHZ I like to add a frequency counter.

    Two questions can I use the same diagram so as attached and witch pin on the Teensy 4 can be used.

    Best,
    Johan


    Click image for larger version. 

Name:	td_libs_FreqMeasure_sch.gif 
Views:	2 
Size:	3.3 KB 
ID:	17534

  2. #2
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    300
    Be aware that T4 is not 5 volt tolerant.

    I used to consider external components for beefing up a low sinsusoid signal, but then discovered the delights of using the internal comparators (in T3 and T4). These are great for very low level signals. You might have a look at this thread for an example of how to code (see #6)... https://forum.pjrc.com/threads/57359...=telephonebill

    External components have an advantage of protecting the input, so you may need some protection diodes and a series resistance (in addition to series capacitor for a.c. and mid 3v3 point bias resistors) depending on the threats from external signals.

    Get a copy of the iRMXT1060 reference manual and look up page 3425 (Ch 64) for more info.

    Edit. By the way, this idea uses the internal DAC voltage reference to compare against your signal input, and that's what switches it up and down.
    Last edited by TelephoneBill; 09-08-2019 at 10:27 AM.

  3. #3
    Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    92
    Wow this is a difficult one..... so you use pin 18 as input for your signal right?

    Is below still working?

    if (FreqCount.available()) {
    unsigned long count = FreqCount.read();
    Serial.println(count);
    }

  4. #4
    Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    92
    And where is the code below going?
    CCM_CCGR2 |= CCM_CCGR2_XBAR1(CCM_CCGR_ON); //turn clock on for xbara1
    XBARA1_SEL3 = 0x001C; //This connects XBAR1_OUT6 to XBAR1_IN28 (ACMP3_OUT)
    IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_04 = 3; //ALT3 connects XBAR1_INOUT6 to T4 Pin 2
    IOMUXC_GPR_GPR6 |= 0b00000000000001000000000000000000; //IOMUXC_XBAR_DIR_SEL_6 = 1 (direction select for XBAR_INOUT6)
    CCM_CCGR3 |= 0x03000000; //enable clocks to CG12 of CGR3 for ACMP3
    CMP3_CR0 = 0b00000000; //FILTER_CNT=0; HYSTCTR=0
    CMP3_CR1 = 0b00010111; //SE=0, high power, COUTA, output pin, enable; mode #2A
    CMP3_DACCR = 0b11011111; //Set DAC = 1/2 of VIN2 (3.3v)
    CMP3_MUXCR = 0b00000111; //CMP_MUX_PSEL(0) | CMP_MUX_MSEL(7) Input pins select; plus = IN0 (pin 18), minus = DAC (code 7). PSTM = 0 (Pass Through Mode Disabled)

  5. #5
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    300
    Not used "FreqCount" library myself, so maybe someone else can advise about this library. The comparator input signal goes in on Pin 18 and the sq wave output comes out on Pin 2 (and the code would go into Setup).

    If you have a T4 at hand and a scope to see the waveforms, have an experiment to see just the comparator in action.

    Edit. As a Radio Ham myself, I should emphasize that high power R.F. signals have a nasty habit of invading/inducing wiring, so can do a lot of damage. If you are thinking of building your own Freq Counter make sure you experiment with a low power sig generator first. And when it comes to using in a "harsh" environment, your screening/earthing/isolating will have to be first class.
    Last edited by TelephoneBill; 09-08-2019 at 11:27 AM.

  6. #6
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    FreqCount library is functional for the T4 and yes it been tested up to about 75Mhz. But as @Telephone Bill pointed out the T4 is not 5v tolerant so you have to make sure your signal is staying at 3.3v.

  7. #7
    Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    92
    Mike,

    Do I need the code then from @Telephone Bill or can I use simple the FreqCount library?

    Little confusing ....

    I put the code from @Telephone Bill in the setup and can compile without errors.

    Pin 18 is in my case used for i2c touchscreen can we use a other pin than 18?

    Many questions....

    Thanks,
    Johan

  8. #8
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    FreqCount library is standalone. You don't need the code from Telephone Bill.

    To use frequence count library you can only use Pin 9. All other pins are available.

  9. #9
    Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    92
    Aha that make sense, I will test this, if I can show my transmitter frequency on the display.

    Thanks as always!

  10. #10
    Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    92
    The frequency count works out of the box, I tested it till 7MHz. Now building a small input circuit with a 74HC14 at 3.3 V

    Thanks again Mike.

    Johan

Posting Permissions

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