I have a big problem which I cant quite figure out how to get around it.
I am PWMing pin 10 of Arduino Mega at 4 KHz which is driving a gate driver and that is driving a N-Channel mosfet, and the mosfet is switching a low resistance (0.5 Ohm) load at 12V.
I am supplying the power for arduino and my sensors from the same 12V. There are chokes and big capacitors (3300uF) and small capacitor (10uF) to filter out the noise on the 12V line before getting into the Arduino.
However I am still seeing a lot of noise in the sensor data.
What more do i need to do to fully suppress this noise?
The power supply ground goes to a grounding block. The grounding block received all the grounds: the sensors, the high current components, and the arduino.
No, the high current wires are separated by a fair distance from the sensor wires...
Make sure the wires carrying the sensor's ground do not carry the return current for the PWM.
A photo and drawn schematic would help.
What sort of noise are you seeing?
I can drop the voltage to 9V for the Arduino, but I need 12V for one of my sensors. And if the 12V line is fluctuating, then the data from that sensor will be unreliable.
So... we are back to the beginning: to filter out the 4 KHz noise from the 12V line caused by PWMing...
I can drop the voltage to 9V for the Arduino, but I need 12V for one of my sensors.
Dropping down to 9V is not mutually exclusive with still having 12V for your sensors.
Feed the 12V into a 9V regulator and feed your sensors from the 12V input.
There are chokes and big capacitors (3300uF) and small capacitor (10uF) to filter out the noise on the 12V line before getting into the Arduino.
Don't connect the ground sides of the sensors to the grounding block. Instead, connect them to one of the ground pins of the Arduino, and don't connect anything else to that ground pin. Connect a different Arduino ground pin to your grounding block.
Use differential sensing. Use two of your 12v sensors so that common-mode noise is ignored by the differential outputs after standard processing of the two outputs. Both sensor outputs will have noise but it will be a common mode noise not a different noise. This technique is explained in the literature.