PWM substitute? - Page 1
Forum section: electronics / beginners

author: ProAce
author_rank: Contributor
timestamp: April 25, 2016, 12:06:30 pm
content: HelloI want to drive motors and proportional valves (2W) with my PIC but the PWM keeps interfering with my measurement signal stability. I have attached my current schematic. Is there some kind of a driver that has linear response so I could make a use of an RC filter?

author: danadak
author_rank: Super Contributor
timestamp: April 25, 2016, 12:27:29 pm
content: What are you trying to measure ?Regards, Dana.

author: ProAce
author_rank: Contributor
timestamp: April 25, 2016, 12:35:48 pm
content: Quote from: danadak on April 25, 2016, 12:27:29 pmFlow, temperature, humidity...

author: danadak
author_rank: Super Contributor
timestamp: April 25, 2016, 01:04:55 pm
content: Referring to measurement signal integrity, is it the switching noiseof the PWM that is affecting measurements ? Describe how you aremaking measurements, a bridge circuit followed by an IA for example.Regards, Dana.

author: ProAce
author_rank: Contributor
timestamp: April 25, 2016, 02:27:10 pm
content: I'm not an engineer nor a good english speaker so I'm sorry for my poor explanation. When I drive pump with PWM(5kHz) it affects especially H2 sensor (/w analog voltage output) which is hooked to PIC via INA122P instrument amplifier. I guess this happens beacause of the switching noise as you hinted. I could be wrong though. When duty cycle is at 100% it measures normally. I can provide additional info but please use simple terms. 😊

author: amspire
author_rank: Super Contributor
timestamp: April 25, 2016, 03:18:10 pm
content: A few things can be happening.When the mosfet turns off, the inductors on the fet drain will send the drain voltage shooting up pretty fast, and the drain-gate capacitance means that for maybe 50nS, there is a positive voltage pulse coming from the gate that is opposing the PWM outputs attempt to go low. Increasing the 1K resistor to 10k will slow down the transitions at the expense of more dissipation in the mosfet.The diode may be taking time to turn on, so for perhaps 10 - 1000ns (depending on the type of diode), the drain voltage can go well above 9V.If the load inductors are still maintaining current through the diode when the mosfet turns on, the diodes take a time to turn off. During this time, you can get a very narrow pulse that can be many amps.If you are not using a Schottky diode, you could try it.You need capacitors directly between the mosfet source and the diode anode. Probably a combination of an electrolytic and a lower value non-electrolytic.Watch how the source of the mosfet connects to the 0 volts in the circuit. You should have the 9v supply connected to a large electrolytic cap on the board/breadboard. From the negative rail at that capacitor, you should have two separate 0v wires or tracks. One goes to the mosfet source, one goes to the micro. At no point should the micro be sharing the same 0v track as the mosfet. The micro must have its own filter capacitors directly across the micro supply voltage pins right next to the micro.Richard

author: danadak
author_rank: Super Contributor
timestamp: April 25, 2016, 04:09:05 pm
content: You would need help of a good technician or EE, here are some thoughts -1) Check the signal grounds for the analog and digital are split, and only jointogether at the point the leave the board or meet the power rails for thesystem.2) Use a scope and look for ground bounce on PIC power supply. It power shouldbe bypassed at chip with .01 and .1 uF ceramic disk and a 5 - 10 uF tantalum.Tant should be polymer tant for best performance. Same rules apply to IA.3) Try using signal averaging in code, read several samples, sum them, and divideby number of samples. That helps remove un-correlated noise (PWM noise iscorrelated).4) Any hi z signal path should be isolated on board from coupling of power rails,like MOSFET source/drain connections. Eg. use a trace that is surrounded by ground.See the following -https://www.dropbox.com/s/ruaf9booe17jk8n/PCB%20Layout.zip?dl=0Regards, Dana

author: Zero999
author_rank: Super Contributor
timestamp: April 25, 2016, 08:33:39 pm
content: What's the minimum length of time in which the PIC's ADC can take a sample?The noise due to the PWM only occurs when the signal changes state. If you only sample the sensor when the PWM signal is not changing (i.e. it's been high or low for long enough to reach steady state) then it won't pick up any noise from the PWM signal. Because your PWM signal is 5kHz, the ADC must be able to take a sample in significantly under 1/10 000 = 100µs. Ideally you need to sample much faster than that to be sure the steady state has been reached.

author: danadak
author_rank: Super Contributor
timestamp: April 25, 2016, 10:51:49 pm
content: Keep in mind synching the PWM and A/D sampling period is a good ideaif all L transients have died out to 1/2 LSB their final value. But also layoutand coupling issues can be the root source of your problems, not thesynchronicity of sampling.Trial, error, more measurements is the fix.....What resolution and accuracy are you trying to achive in the design, ppm orlsbs or measurement units...Regards, Dana.

author: ProAce
author_rank: Contributor
timestamp: April 26, 2016, 05:03:09 am
content: Thanks everybody. I will do some research, troubleshooting... and get back to you when I got something. Anyone knows any good books about this? Btw it doesn't need to be very accurate I just happens when I turn on the pump the reading rises for about 200ppm and the it slowly settles. I have to fiddle around more. I was just wondering if there is a chip solution that gets the job done.The interesting thing is that I have H2 sensor connected to the second PCB. It only shares power and ground lines.

author: matkar
author_rank: Regular Contributor
timestamp: April 27, 2016, 09:10:21 am
content: I had a similar problem. The ADC readings were corrupt if at the time of reading of the analog channel a transition occurred on the PWM line. I have solved the problem by turning off the PWM clock for the duration of the analog measurement. The measurement was executed once per second and lasted around 200us so it didn't affect the PWM that much. This resulted in a missing or a prolonged PWM pulse every second. The PWM was used to drive an electric motor which of course didn't react to the PWM "glitch" at all.If you're about to redesign the PCB make sure analog channel traces are well separated from digital switching lines by a grounded trace/plane.