You should consider Gain-Bandwidth product for Opamp. I down't know what GBW for PSoC6 internal Opamp, but for PSoC4/5 it is about 10^6 (gain = 1 at F=1 MHz). For such opamp with gain of 100, the bandwidth will be roughly 10 kHz - not enough to amplify 40 kHz ultrasound signal. Such opamp will perform as LPF, cutting down signal amplitude and shifting its phase. I would try fast external opamp instead, look for 10 MHz at least (there are many).
I'm not familiar with ultrasound signals.
You indicated that your input PWM is -Vcc/2 to +Vcc/2.
I have some questions:
What is the expected Vcc value? If it is ~= to Vdd = 3.3V then you should be able to use a comparator with the trip threshold set to ~ Vcc/4.
Do you expect a lot of noise in the system? If your PWM frequency is constant (and known) you should be able to count transitions within the PWM period. You should only have two. More than that means noise above the comparator threshold. You can either perform a wider windowed averaging scheme or increase the comparator reference threshold.
You indicate a -Vcc/2. I assume this is below the Vss rail of the PSoC. You should place diode protection to prevent going below Vss-0.6V.
I assume the bottom halve of the wave is not needed? If it is needed, you need a level translator to shift your signal so that the lower voltage is at least 0V. If you use a signal transformer as level-shifter you gain multiple benefits.
- Transformers are galvanomicly isolated. This allows you more easily keep bad transients away from the CPU-side of the circuit.
- Transformers are basically DC-isolated. This allows you to place the GND on one pin of the CPU-side of the transformer. This allows the signal to be automatically shifted into the CPU usable range. Additionally it prevents bad-ground loop issues with other equipment not using the same grounding scheme.
- Transformers can be configured to be signal amplifiers. For example: A transformer with twice as many turns on the secondary-side (CPU-side) as the primary-side should amplify the primary-side signal by a factor of 2. Three times as many turns, 3 times the signal. This should eliminate the need for an Opamp.
Just some thoughts ...