I've looked though the forums, and there are lots of helpful topics to on how to create a square wave of variable frequency. I was wonder how I could build upon a 0-5V square wave output to produce a 100 Hz -0.8 to -1.4V square wave.
My first thought:
Use two PWM ports to create a 0.8V and 1.4V reference via RC filtering.
Use 2 unity gain inverting amps to invert references
Use a third digital port with the tone() function to modulate a SPDT between the outputs from step 2
I had a few questions before:
is there a better way? I don't want to get too many external components involved...
Most switches i see online have some considerable on-state resistance. Won't that resistance affect my output voltage? For some context, the square wave is driving a fairly large impedance load, the gates to some MESFETS.
You can use an inverting amplifier but will need a negative 5V voltage supply.
Alternatively if your external ciruit permits you can use the Vcc rail as a reference, and just use a simple voltage divider.
The simplest way to create a negative voltage is to use a virtual ground that is X volts above your desired minimum voltage. This approach is typically used to turn a 0-5V swing into a -2.5v to 2.5v swing. The weakness of this approach is that the current output will be limited to the current output of the op-amp (typically 20-40 mA). I think this is what someone has already suggested.
johnerrington:
Alternatively if your external ciruit permits you can use the Vcc rail as a reference, and just use a simple voltage divider.
Use two PWM ports to create a 0.8V and 1.4V reference via RC filtering.
Use 2 unity gain inverting amps to invert references
Use a third digital port with the tone() function to modulate a SPDT between the outputs from step 2
None of those steps will create a negative voltage, they all create a positive ones. Do you really need negative voltages if you are driving FETs anyway?
Also FETs normally need driving a lot harder than 0.8 to 1.4V, where did you get these numbers from? It looks like you are misunderstanding something fundamental here, but with so little information it is hard to say what.