Author Topic: PWM substitute?  (Read 3945 times)

0 Members and 3 Guests are viewing this topic.

Offline ProAceTopic starter

  • Contributor
  • Posts: 19
  • Country: si
PWM substitute?
« on: April 25, 2016, 12:06:30 pm »
Hello
I want to drive motors and proportional valves (2W) with my PIC but the PWM keeps interfering with my measurement signal stability  :bullshit:. 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?
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: PWM substitute?
« Reply #1 on: April 25, 2016, 12:27:29 pm »
What are you trying to measure ?

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline ProAceTopic starter

  • Contributor
  • Posts: 19
  • Country: si
Re: PWM substitute?
« Reply #2 on: April 25, 2016, 12:35:48 pm »
What are you trying to measure ?

Regards, Dana.
Flow, temperature, humidity...
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: PWM substitute?
« Reply #3 on: April 25, 2016, 01:04:55 pm »
Referring to measurement signal integrity, is it the switching noise
of the PWM that is affecting measurements ? Describe how you are
making measurements, a bridge circuit followed by an IA for example.

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline ProAceTopic starter

  • Contributor
  • Posts: 19
  • Country: si
Re: PWM substitute?
« Reply #4 on: April 25, 2016, 02:27:10 pm »
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. 😊
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3810
  • Country: au
Re: PWM substitute?
« Reply #5 on: April 25, 2016, 03:18:10 pm »
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
« Last Edit: April 25, 2016, 03:22:54 pm by amspire »
 
The following users thanked this post: ProAce

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: PWM substitute?
« Reply #6 on: April 25, 2016, 04:09:05 pm »
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 join
together at the point the leave the board or meet the power rails for the
system.

2) Use a scope and look for ground bounce on PIC power supply. It power should
be 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 divide
by number of samples. That helps remove un-correlated noise (PWM noise is
correlated).

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=0

Regards, Dana
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 
The following users thanked this post: ProAce

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22381
  • Country: gb
  • 0999
Re: PWM substitute?
« Reply #7 on: April 25, 2016, 08:33:39 pm »
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.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: PWM substitute?
« Reply #8 on: April 25, 2016, 10:51:49 pm »
Keep in mind synching the PWM and A/D sampling period is a good idea
if all L transients have died out to 1/2 LSB their final value. But also layout
and coupling issues can be the root source of your problems, not the
synchronicity of sampling.

Trial, error, more measurements is the fix.....:)

What resolution and accuracy are you trying to achive in the design, ppm or
lsbs or measurement units...

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline ProAceTopic starter

  • Contributor
  • Posts: 19
  • Country: si
Re: PWM substitute?
« Reply #9 on: April 26, 2016, 05:03:09 am »
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.
« Last Edit: April 26, 2016, 06:09:23 am by ProAce »
 

Offline matkar

  • Regular Contributor
  • *
  • Posts: 153
  • Country: si
  • Sixty percent of the time it works EVERY time.
Re: PWM substitute?
« Reply #10 on: April 27, 2016, 09:10:21 am »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf