I have a myRIO from NI. I use the FPGA to generate a sine and a cosine digitally for signal processing of a photo acoustical signal. The sine and cosine have the same frequency. I now want to output the sine over the 12 bit DAC and transform it into a square wave with the exact same frequency and 50% duty cycle. The maximum output rate is 345kSPS and the sine has a 5Vpp amplitude (0V to 5V). The square wave can have a high level between 3.33V and 5V, the low level should be 0V with a duty cycle of 50% to control a laser switch. The output Frequency can vary between 1kHz and 35kHz. That is why I also want to implement a low pass filter before the sine enters the Schmitt-Trigger. The picture shows my try in LTSpice, but although I use this calculator to get the right component values, I only have a DC signal after the LPF. If I try it without the LPF the output of the Schmitt-Trigger has no 50 duty cycle and the high voltage level is too low. Maybe the comparator is no good choice. I hope you can help me on that. current circuit

With LPF (LTC6244HV is uesd from LTSPice) I get this result: With LPF Any comments on the picture and on the low pass filter?

  • \$\begingroup\$ The schematic around the LM393 is a bit unclear, draw that like you did the LCT6241. Note that the LM393 has an open collector output, it can only pull the output low. If you connect R4 between output and Vdd your problem might be solved. \$\endgroup\$ Jan 10, 2016 at 15:33
  • 1
    \$\begingroup\$ Why don't you use the FPGA to generate the square wave based on the sign of the sine wave? \$\endgroup\$
    – Andy aka
    Jan 10, 2016 at 15:43
  • \$\begingroup\$ Re: "the output of the Schmitt-Trigger has no 50 duty cycle". Do you mean 50% duty cycle? If it is not 50% duty cycle, what is it then? 40%? 100%? 0%? \$\endgroup\$ Jan 10, 2016 at 16:11
  • \$\begingroup\$ Instead of going Schmitt trigger you may prefer zero crossing detector \$\endgroup\$
    – Photon001
    Jan 10, 2016 at 16:37
  • 1
    \$\begingroup\$ If your FPGA is generating the sinewave to sufficient accuracy then it should also generate a square wave to an accuracy that is no worse. \$\endgroup\$
    – Andy aka
    Jan 10, 2016 at 17:41

1 Answer 1


Presuming that pin5 is output of LM393 (not sure where you got that model for LM393). Also presuming pin2 is the (+) input.

LM393 is an open collector output op-amp. This means that the output of LM393 cannot go high (towards Vdd) without an external pull up resistor.

You could simply tie R4 to the positive rail, Vdd, instead of to ground.

Your resistors R1, R2, R3, are very low value. Things might work in a simulator with those low values. However, low resistance values require higher current and will effect the output transistor in a bad way. Look at the current required with 5v/100 ohms, that's 50mA current.

The LM393 output transistor isn't going to like that 50mA. Maximum sink current is 18mA.

EDIT : I made assumption R4 would change to value of 100 ohms so that output could pull higher. That is why I mentioned the caution on sinking high current.

2nd EDIT : The LTC6241 has maximum TOTAL supply voltage of 7 volts. You are using total of 10 volts. Move up to the LTC6241HV.

enter image description here

  • \$\begingroup\$ Ok, changing the components R1, R2 and R3 to 10kOhm and connecting R4 with Vdd instead of GND solved two issues: I now have an approximately 50% duty cycle and the amplitude of the square wave is fine. But the low pass filter is still not working. The design of the LM393 is downloaded from TI and the third party model is added via "autogenerated". \$\endgroup\$
    – Slev1n
    Jan 10, 2016 at 17:09
  • \$\begingroup\$ @Slev1n added information regarding LTC6241 \$\endgroup\$
    – Marla
    Jan 10, 2016 at 17:21
  • \$\begingroup\$ If a simpler LPF can be applied I would take it, since I do not have much experience wiith such issues. I only want to have a smoothed sine for the Schmitt-Trigger as the sine from the DAC will have many steps in it. \$\endgroup\$
    – Slev1n
    Jan 10, 2016 at 17:33
  • \$\begingroup\$ @Slev1n : the steps from your 12 bit DAC are small. You have a rather large hysterysis in your comparator. Try it without the Low Pass Filter. The hysterysis should allow ignoring the minor steps of you DAC. \$\endgroup\$
    – Marla
    Jan 10, 2016 at 17:40
  • \$\begingroup\$ @Slev1n You can see your changing setpoint (threshold) on pin 2 of LM393. \$\endgroup\$
    – Marla
    Jan 10, 2016 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.