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

Thread: What is the max output frequency of analog ouput Teensy3.1?

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Location
    Paris
    Posts
    19

    What is the max output frequency of analog ouput Teensy3.1?

    Hi all,

    I searched for informations to known how I can generate 10Mhz to 15Mhz sinus signal on analog output (that it will be use to control a NE612 mixer).
    It's possible with Teensy 3.1 ?
    It's depend of the setup in makefile (from fresh generated project with avr-project cmd line ):
    line 21 of Makefile: -> CLOCK = 8000000 must be set to 75000000 ????

    Teensy 3.1 must be over-clocked ?
    It seem that the nominal frequency of Teensy 3.1 is 72Mhz ( https://www.pjrc.com/teensy/teensy31.html#specs )

    Thank you in advance. Bruno

  2. #2
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    I don't think you're going to get that high on the DAC. My recollection is that it's set up for audio signals in the kHz range, ie less than 44.1kHz.

    I use one of the digital PWM pins as a clock input to a MCP3910 and the highest I've gotten that without over clocking was 12 MHz. With over clocking the pin may reach 15MHz.

    So I would be surprised if you could get a teensy to put out a MHz-level sinusoid signal. Methinks you'd have to invest in a external DAC. Whether the teensy could control it adequately is a different question. But it seems likely that a faster processor is necessary. Anyhow, I'd still buy a teensy - they are awesome MCU's.
    Last edited by Constantin; 09-19-2014 at 02:17 PM.

  3. #3
    Junior Member
    Join Date
    Sep 2014
    Location
    Paris
    Posts
    19
    Thank for your reply.

    In fact, I was looking for the easiest way to inject a signal to a NE612 without a colpitts. So as I understand it, the better it is Colpits and an analog output of Teensy3.1 to drive it in VCO.

    So, a question again. How can I set CLOCK speed in make file. With this:
    CLOCK = 75000000

    Any help is welcome.
    Thank, Bruno.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,227
    Start with Arduino, even if you never intend to really use it. Arduino has a "verbose info" option in File > Preferences. Then you can see the compile commands. The clock is set with F_CPU.

    There's also a sample makefile in hardware/teensy/cores/teensy3.

  5. #5
    I think Paul meant that response for a different thread.

    I haven't done it myself, but I suspect your best bet will be a direct digital synthesis (DDS) IC. I understand some of those have built-in mixers and might reduce your component count and complexity overall.

    Regards,
    Dave

  6. #6
    Junior Member
    Join Date
    Sep 2014
    Location
    Paris
    Posts
    19
    Hi,
    Yes Mr drg, I don't known that is best solution but the goal is "how to reduce":
    - capacitors ajustement ( UHF spectrum )
    - the number of component on the PCB
    - circuitry
    In a first time, 2 new teensy3.1 are expected and are not delivered yet :-(
    Thank at all. Bruno

  7. #7
    Junior Member
    Join Date
    Sep 2014
    Location
    Paris
    Posts
    19
    Hi all,

    Here the benchmark with my Teensy 3.1. The goal was to known the max output frequency on DAC (A14 output). The conditions of tests are:
    . Teensy must generate an sine wave and square wave in "good form" with minor distortion or best, no distorsion.
    . Teensy program don't do nothing else.

    Click image for larger version. 

Name:	Capture d’écran 2014-10-14 à 09.16.04.png 
Views:	1099 
Size:	62.6 KB 
ID:	2790

    sine program here:
    /*
    Sine generator.
    It works with A14/DAC on Teensy 3.1
    Autor: Bruno Poultier.
    Goal: Testing the max frequency available on A14/DAC with sine wave

    Tests conditions:
    . The same source has been compiled whith various CPU clocks: 96Mhz, 72Mhz, 48Mhz and 24Mhz
    . 12 bits resolution (max)
    . the output is free of charge (no capacitor, resistor, etc)
    . the output signal must be clean (beautiful sine)

    This example code is based on PJRC project.
    */


    float _2pi = 3.14159265 * 2;

    // 2 * pi() ~ 6.28 / 0.01 => 628 dots
    const int DOT = 628;
    float amplitude[DOT];

    /**
    Fill array with all values.
    arg: none
    return: none
    **/
    void fillAmplitude(){
    for ( int x = 0 ; x < DOT ; x++){
    amplitude[x] = (sin( x * 0.01 ) * 2000.0 ) + 2050.0F;
    } // eo for
    }

    /**
    Create the sine wave with the precalculated values
    arg: none
    retur: none
    **/
    void preCalculatedAmplitude(){
    // sine wave
    while(1){
    for ( int i = 0 ; i < DOT ; i++){
    analogWrite(A14, amplitude[i]);
    }//eo for
    }//oe while 1
    }

    /**
    create sine wave dynamically and send value to the A14.
    arg: none
    return: none
    **/
    void computeSine(){
    float phase = 0.0F;
    while(1){
    float amp = sin(phase) * 2000.0 + 2050.0;
    analogWrite(A14, (int) amp);
    phase = phase + 0.01;
    if (phase >= _2pi) phase -= _2pi;
    }//eo while 1
    }

    /**
    initialize all mandatory elements
    arg: none
    return: none
    **/
    void setup() {
    analogWriteResolution(12); // DAC setup.
    fillAmplitude();
    }


    void loop() {
    preCalculatedAmplitude();
    // computeSine();
    }


    Square program here:
    /*
    Square generator.
    It works with A14/DAC on Teensy 3.1 only.
    Autor: Bruno Poultier.
    Goal: Testing the max frequency available on A14/DAC with square output wave

    Tests conditions:
    . The same source has been compiled whith various CPU clocks: 96Mhz, 72Mhz, 48Mhz and 24Mhz
    . 12 bits resolution (max)
    . the output is free of charge (no capacitor, resistor, etc)
    . the output signal must be clean (beautiful sine)

    This example code is pjrc project samples.
    */

    elapsedMicros usec = 0;

    /**
    initialize all mandatory elements
    arg: none
    return: none
    **/
    void setup() {
    analogWriteResolution(12); // DAC setup.
    }

    void sleep(unsigned int t){
    while ( usec < t )
    usec = usec - t;

    }

    void loop() {
    int _Zero = 1000;
    int _One = 4000; // middle of max output capability
    // Results from oscilloscope HITACHI V-212
    // time slope to pass from 0 to 1.
    // 1 | 0.7us
    // 2 | 0.65us
    // 3 | 0.65us
    // 4 | 0,65us
    // 5 | 0.7us
    // 6 | 0,7us
    // 7 | 0.64us
    // 8 | 0.66us
    // 9 | 0.64us
    //10 | 0.66us
    //15 | 0.68us
    //20 | 0.6us
    //50 | 0.65us
    //100 | 0.62us
    int t = 1 ; // tempo. We need to add a delay to have a nive square signal. No delay gives one "triangular" wave generated

    while(1){
    analogWrite(A14, _Zero);
    //delayMicroseconds(t);
    analogWrite(A14, _One);
    //delayMicroseconds(t);
    }
    }

  8. #8
    Junior Member
    Join Date
    Sep 2014
    Location
    Paris
    Posts
    19
    Hi all,

    Here the benchmark with my Teensy 3.1. The goal was to known the max output frequency on DAC (A14 output). The conditions of tests are:
    . Teensy must generate an sine wave and square wave in "good form" with minor distortion or best, no distorsion.
    . Teensy program don't do nothing else.
    . These tests has been processed 3 times to be more precise.

    Sorry in advance because I have only one digital oscilloscope and I can not put photo of wave sine output.
    The dynamic sine calculous has been tested but the output frequency is low. The benchmark results are not in the sheet.
    Click image for larger version. 

Name:	Capture d’écran 2014-10-14 à 09.16.04.png 
Views:	1099 
Size:	62.6 KB 
ID:	2790

    sine program here:
    /*
    Sine generator.
    It works with A14/DAC on Teensy 3.1
    Autor: Bruno Poultier.
    Goal: Testing the max frequency available on A14/DAC with sine wave

    Tests conditions:
    . The same source has been compiled whith various CPU clocks: 96Mhz, 72Mhz, 48Mhz and 24Mhz
    . 12 bits resolution (max)
    . the output is free of charge (no capacitor, resistor, etc)
    . the output signal must be clean (beautiful sine)

    This example code is based on PJRC project.
    */


    float _2pi = 3.14159265 * 2;

    // 2 * pi() ~ 6.28 / 0.01 => 628 dots
    const int DOT = 628;
    float amplitude[DOT];

    /**
    Fill array with all values.
    arg: none
    return: none
    **/
    void fillAmplitude(){
    for ( int x = 0 ; x < DOT ; x++){
    amplitude[x] = (sin( x * 0.01 ) * 2000.0 ) + 2050.0F;
    } // eo for
    }

    /**
    Create the sine wave with the precalculated values
    arg: none
    retur: none
    **/
    void preCalculatedAmplitude(){
    // sine wave
    while(1){
    for ( int i = 0 ; i < DOT ; i++){
    analogWrite(A14, amplitude[i]);
    }//eo for
    }//oe while 1
    }

    /**
    create sine wave dynamically and send value to the A14.
    arg: none
    return: none
    **/
    void computeSine(){
    float phase = 0.0F;
    while(1){
    float amp = sin(phase) * 2000.0 + 2050.0;
    analogWrite(A14, (int) amp);
    phase = phase + 0.01;
    if (phase >= _2pi) phase -= _2pi;
    }//eo while 1
    }

    /**
    initialize all mandatory elements
    arg: none
    return: none
    **/
    void setup() {
    analogWriteResolution(12); // DAC setup.
    fillAmplitude();
    }


    void loop() {
    preCalculatedAmplitude();
    // computeSine();
    }


    Square program here:
    /*
    Square generator.
    It works with A14/DAC on Teensy 3.1 only.
    Autor: Bruno Poultier.
    Goal: Testing the max frequency available on A14/DAC with square output wave

    Tests conditions:
    . The same source has been compiled whith various CPU clocks: 96Mhz, 72Mhz, 48Mhz and 24Mhz
    . 12 bits resolution (max)
    . the output is free of charge (no capacitor, resistor, etc)
    . the output signal must be clean (beautiful sine)

    This example code is pjrc project samples.
    */

    elapsedMicros usec = 0;

    /**
    initialize all mandatory elements
    arg: none
    return: none
    **/
    void setup() {
    analogWriteResolution(12); // DAC setup.
    }

    void sleep(unsigned int t){
    while ( usec < t )
    usec = usec - t;

    }

    void loop() {
    int _Zero = 1000; // 0 could be bad without delay.
    int _One = 4000; // middle of max output capability
    // Results from oscilloscope HITACHI V-212
    // time slope to pass from 0 to 1.
    // 1 | 0.7us
    // 2 | 0.65us
    // 3 | 0.65us
    // 4 | 0,65us
    // 5 | 0.7us
    // 6 | 0,7us
    // 7 | 0.64us
    // 8 | 0.66us
    // 9 | 0.64us
    //10 | 0.66us
    //15 | 0.68us
    //20 | 0.6us
    //50 | 0.65us
    //100 | 0.62us
    int t = 1 ; // tempo. We need to add a delay to have a nice square signal. No delay gives one "triangular" wave generated when CPU clock < 72Mhz. After, it's sine.

    while(1){
    analogWrite(A14, _Zero);
    //delayMicroseconds(t);
    analogWrite(A14, _One);
    //delayMicroseconds(t);
    }
    }




    Sorry for my poor english :-(
    Bruno.
    Last edited by bpoultier; 10-14-2014 at 08:32 AM.

Posting Permissions

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