My question is that can the arduino vary the voltage during a PWM?
[u]PWM[/u] switches between 0 and 5V and you can control the duty cycle to control the average voltage.
You can filter/average the voltage to get variable DC (or AC if the PWM frequency is much higher than the AC frequency). But that's NOT a great way to do it... A digital-to-analog converter (DAC) is a better way to do it. (The "standard" Arduinos have an ADC but no built-in DAC.)
If I used my PWM output to create the 'average voltage' using the duty cycle. This signal then into a DAC and then into an Op-Amp?
While it will have an average voltage determined by the duty cycle this will have no effect on the peak voltage and so will not affect anything.
This is an X-Y problem, why do you want the waveform you claim and what impedance does it have to be? that means what current are you expecting this signal to drive?
This will create my AC signal matching what I need in the first post?
To create an AC signal you will need to have a split supply to drive the op amps. That is one with a +12 ground and -12 V output.
I am wanting to create the signal to fool the vehicle ECU into thinking the engine is running when it isn't.
So the signal is driving an ECU.
The shape therefore is not going to matter but the amplitude needs to be above the minimum amplitude to drive the ECU, which may or may not be what you see when you look at it. The ECU will be looking at the frequency to know what speed the engine is doing.
However this is a closed loop system so the ECU will expect to see some response when it alters other parameters like the mixture from the carburettor. So just a simple fixed frequency might just whack all the other outputs high and not leave you with a system configuration that is useful.
So why do you want to trick the ECU into thinking the engine is running?
So the ECU is an EDC15 ECU running the Land Rover TD5 engine.
The vehicle has had an engine transplant replacing the TD5 engine with a BMW M57 engine, so now the engine ECU is not communicating to the body ECU that the engine is in a running state.
The rpm output from the BMW ECU is a square wave 12 volt signal.
My aim is to replicate the TD5 crank signal into the ECU dependent on the frequency of this 12v square wave from the BMW ECU.
I have already tested that the crank shaft speed signal is all that is needed by jumping a wire from another running TD5 engined Land Rover to the ECU in the transplanted vehicle.
This signal gets altered by the TD5 engine ECU and is an output to other vehicle ECU's such as the leveling suspension, traction control etc.