Wow just sitting there you almost analysed my problem correctly.
Well one thing is sure that Spikes occur when PWM is on and when probe is connected to it. When i remove the blue channel then there are no spikes.
There is noting connected to PWM channel, later i will only connect it with LCD LED via transistor.
To some extent you are right that PWM has nothing to do with ADC, so i removed The scope probes and displayed directly the reading i am getting from ADC i.e. 0-1023. Now when i set PWM to 20kHz then i get error of 4-6 bits max. setting it to 10KHz gives 2bit error and setting it to 1KHZ gives only 1 bit error. What do you think?
Well right now oscilloscope has 3 pins in its power jack, hot wire, neutral, and earth but my line connection has no earth.
Unfortunately i just passed out of my University and this is my first scope and its only 25MHZ as i thought it will fulfill my requirements.
Yes when i unplugged the supply (both +/-) from the bread board, even then there is noise upto 3mV. when scope probe is attached to its ground plug and nothing else then -800 microvolts. while they are still attached and i connect to any metal or wire then there is error up to 3mV.
SajjadBro,
First, a 25MHz scope is a very useful scope. I have no problem with that.
I hope you will not get upset by comments on safety from some people. There are many people in this forum who would be absolutely devastated if they heard that one of our members was badly hurt due to a lack of an appropriate safety warning. The motivation for warnings is a genuine concern for people, even if the concern comes across in the wrong way.
The reason that the lack of an earthing system is a problem for oscilloscopes is that they are not "double insulated" so they are not designed to be safe without proper earth wiring. A single fault could make the ground on the oscilloscope live. In an normal earthed power system, this would blow a fuse, or trip an earth leakage breaker. Without a proper earth, an oscilloscope is just not designed to be safe. In this respect, test instruments like oscilloscope's are very different from double insulated appliances like TV's.
Now lets get to how this can affect your measurements.
What you are seeing on the scope is a lot of phantom noise that it seems can be triggered by low energy transitions. Without a proper scope earth, then the scope's circuitry is linked back to the mains via paths like the switching transformer's winding-to winding capacitance in series with its leakage inductance. The power supply for the test circuit also is similarly coupled to the mains. The behaviour of these types of couplings are unpredictable, but they definitely could ring in the way you are seeing in the spikes. It is possible that it will be hard to trust what you are seeing on the scope without some common earth connection.
So what if your work bench had all the all the earth connections of the powerpoints shorted together, but not going to switchboard earth?
Your scope may behave much better, but your whole bench is now far more dangerous. A failure in any one instrument can make the earth of everything on the bench live. If you then somehow touch something that is in electrical contact with the actual ground under the house you while you are using an instrument and you can get a shock.
For now, as a next step in tracking down this noise problem, I think it is worth trying to power the test circuit from a battery rather then a power supply, and see if the waveforms become cleaner.
When you were talking about the ADC, I didn't quite understand what kind of errors you meant. Is this the ADC variation with a constant applied voltage?
Richard.