9 Replies Latest reply on Oct 9, 2018 2:23 PM by user_342122993

    Ideas how to switch output voltage between V1 and V2 on TTL signal?

    user_342122993

      Hi,

      I have a voltage-controlled current driver for a laser diode, which input needs to be modulated between two preset voltages V1 and V2. The V1 is typically in the range 0.9-1.2V (low brightness) and V2 in the range 1.5-2.0V (high brightness). I have external modulation TTL signal at frequency <40kHz, which should switch voltage output  between V1 and V2.

       

      It would be nice to have minimal and predictable latency between TTL input and voltage response due to high operation frequency.

      I also would like to fit 4 of such separate outputs (with their own V1/V2) into a single PSoC5, all controlled by a single TTL input.

       

      After some thinking of how to accomplish this, I decided that many heads is better then one.

      Can you share your ideas of how to accomplish this task in PSoC5?

       

      Sincerely,

      /odissey1

      TTL+modulation_3.png

        • 1. Re: Ideas how to switch output voltage between V1 and V2 on TTL signal?
          user_119654

          /odissey1,

           

          If your application for V1 and V2 are < 2.5KHz and you drive any high current circuits external to the PSoC, then the simplest implementation is to use the WaveDAC8 component.  The WaveDAC8 panel below shows the V1 and V2 voltage thresholds you listed for low and high brightness.

          Note:  This suggestion assumes a very regular switching pattern needed.  I effect, you can eliminate the input.  It is built into the output waveform.  You would enable the WaveDAC8 when needed and you can adjust many of the parameters including the amplitude and offset on-the-fly at runtime.

           

          If you have a required switching input you can't control or predict, then you can use the following circuit:

           

           

          Set VDAC8_1 to 0.9V and VDAC8_2 to 1.2V and VIN muxes between the two voltages with very minimal delays.  The latency should be limited to the clock frequency driving the mux.

           

          To achieve other high and low voltages, modify the set values in VDAC8_1 and VDAC8_2.

           

          Notes on limitations:

          • The current drive of a mux is limited.  If needed, you can route VOUT to the input of a Opamp.   If configured correctly, you can source about 25mA.
          • The VDAC8s are 8 bit.  Therefore you have voltage granularity of 16mV (@ 4.080V FSR).  A Dithered VDAC is available if needed (9 to 12 bit) for up to 1mV granularity (@ 4.080V FSR).

           

          Len

          1 of 1 people found this helpful
          • 2. Re: Ideas how to switch output voltage between V1 and V2 on TTL signal?
            user_342122993

            Len,

            Thank you for for the input. I didn't think of WaveDAC approach, but it has some potential. The issue with WaveDAC is that the DMA pointer  is not guaranteed to maintain its position in coherence with the input strobe (external modulation frequency). At high modulation frequency (or input glitch) it is possible that DMA cycle is skipped or delayed, and VDAC output phase gets inverted. For example, if you set WaveDAC number of points to 256 (sine), then output sine frequency tops at about 17.5 kHz, and after that DMA cycles start skipping and coherency with strobe is lost forever. 

             

            The second approach (two VDACs and a AMUX) is good, but it won't fit all 4 channels, requiring 8 VDACs out of only 4 available on PSoC5.

             

            More ideas are welcome.

            /odissey1

            • 3. Re: Ideas how to switch output voltage between V1 and V2 on TTL signal?
              user_119654

              /odissey1,

               

              You are correct, there is no direct control of the WaveDAC8 output.

               

              Do all channels need to operate independently?  If not, you can reprogram two VDAC8s to new values @ run time.

               

              Len

              • 4. Re: Ideas how to switch output voltage between V1 and V2 on TTL signal?
                user_342122993

                After some tinkering, I settled on direct DMA transfer of V1 and V2 values from RAM to VDAC internal buffer. The VDAC is set to double-buffered mode, when writing the register value updates VDAC output only on hardware strobe signal (hardware controlled). This way all switching between voltage settings V1 and V2 occurs at hardware timing, while using 8 DMA channels to populate VDAC buffers in the interim. Notice that DMA transfers an opposite value, which is not immediate, but a value for the next strobe cycle, which makes DMA timing is not critical (see picture attached). The output of VDAC 1-4 can switch without issues even at 1MHz rate (@bus clock 48MHz), which is a limit for VDAC and OpAmp analog bandwidth. All of this at zero CPU load.

                 

                Attached is a project, timing diagram, and scope screenshots (3x analog outputs and TTL) with (400kHz) and without Opamp (40kHz).

                Optional rotary encoder library can be download here: Quad Decoder with Button Switch component for rotary shaft encoders

                /odissey1

                V1V2_DMAx4_02a.png

                 

                V1V2_DMAx4_01c.png

                 

                V1V2_DMAx4_VDAC_40kHz.png

                 

                V1V2_DMAx4_OpAmp_400kHz.png

                • 5. Re: Ideas how to switch output voltage between V1 and V2 on TTL signal?
                  user_119654

                  /odissey1,

                   

                  It looks like from the plots you were able to get it to work to your acceptable requirements.

                   

                  In essence, you created your own WaveDAC8 with an addition of an input strobe.  Maybe Cypress can take the "hint" and add one as per your application information provide here.

                  Congrats!

                   

                  Len

                  • 6. Re: Ideas how to switch output voltage between V1 and V2 on TTL signal?
                    user_49271930

                    Just wondering:

                    Why not satisfied with the idea of Len?

                    What is DMA for?

                    Let me remind you that the PSoC5LP has a separate power for each port (Vddio0-Vddio3)

                    Perhaps this can be used as sources for V1 and V2

                    1 of 1 people found this helpful
                    • 7. Re: Ideas how to switch output voltage between V1 and V2 on TTL signal?
                      user_342122993

                      Evgeniy,

                      Unlike WaveDAC, which increments DMA pointer position in each clock, in the above example DMA copies data from the fixed location in RAM. This way it is always guaranteed that positive edge strobe copies next value as V1, and negative edge (after inversion) will always copy V2, because there is DMA no pointer shift.

                       

                      I didn't think about Vddio0-Vddio3, probably because they are not available separately on KIT-059, thank you for idea.

                      /odissey1  

                      • 8. Re: Ideas how to switch output voltage between V1 and V2 on TTL signal?
                        user_49271930

                        No no. I do not understand the need for DMA.

                        Why can not control the switch directly?
                        mux1.png

                        1 of 1 people found this helpful
                        • 9. Re: Ideas how to switch output voltage between V1 and V2 on TTL signal?
                          user_342122993

                          Evgeniy,

                          good idea! I run some simulations using sine input instead of digital modulation. In short, the digital input needs to be conditioned and scaled down to 0-1V (maybe with zener diode and trimpot). The Vref can be adjusted with trimpot. To achieve desired values for V1 (min) and V2 (max) both Vin amplitude and Vref have to be adjusted. This is not very convenient, because V1 and V2 are usually independent parameters: V1 - dark current, V2-diode rollover, but may be useful in some cases.

                          /odissey1

                           

                           

                          OpAmp analog modulation out_01.png