AC signal for ADC [solved]

pls try to read more and write less.

Off I jolly well fuck then. Pity you think you are perfect and yet still don't know such basic stuff.

Grumpy_Mike: Off I jolly well fuck then. Pity you think you are perfect and yet still don't know such basic stuff.

my friend, the reason i say what i'm saying is that the circuit (alone) works in lots of applications so far, driving whatever it should drive. The problem arised when we thought of putting an uno to display the values. if you can understand this the "they happily lived ever after"....

And in the meantime key questions that may help solve the problem at hand remain unanswered, such as the expected frequency and shape of the signal and the frequency of the sampling. Also you mentioned that there is significant stray capacitance in the board. That can also have strange effects. Finally, another question: are you sure the Arduino measures incorrect values? As in: are you sure of what the value of what you measure really is, e.g. by measuring using other means?

I really do not understand what parts are you reading and what you expect to read.

wvmarle:
And in the meantime key questions that may help solve the problem at hand remain unanswered, such as the …shape of the signal

Initial post : READ : AC

wvmarle:
…and the frequency of the sampling.

Post 4 : READ : @CrossRoads: Sampling is continous for 1000 times on ch1 then processing, calculations, etc, then for 1000 times on ch2…

wvmarle:
And in the meantime key questions that may help solve the problem at hand remain unanswered, …measuring using other means

one post above : READ : the circuit (alone) works in lots of applications so far, driving whatever it should drive. The problem arised when we thought of putting an uno to display the values.

wvmarle:
…mentioned that there is significant stray capacitance in the board…

post17 : READ: Tried to “add” rectifying at output of existing, but find many problems because of pcb (smd, tight pack, capacitive feedback destroy original signal).
Stray capacitance on pcb comes when I insert external rectifier at output.

Come on guys.
It comes out boring.

I'm still waiting for your 366 page full schematic, that is boring.

Whandall: I'm still waiting for your 366 page full schematic, that is boring.

As I told you: you get your copy if you give 1 answer (or even tip) in the subject question. Do you want me to repeat it? Repetition is really boring

You are big-mouthed, but you know that already, don't you?

I gave you an answer and it ist not my fault that you don't like it. It's is still an answer.

Good luck.

demkat1: I really do not understand what parts are you reading and what you expect to read.

Initial post : READ : AC

It's AC, I read that already. There's AC and there's AC. AC just means that the current sometimes goes one way, sometimes the other way. You may have nice sine waves, perfect block waves, sawtooth waves, perfectly irregular mix of those and more, and at just about any frequency imaginable. The shape of the wave (especially fast changes like in a block wave) and frequency (you even didn't quote me on that part!) are things that may upset a simple ADC as in the Arduino.

Post 4 : READ : @CrossRoads: Sampling is continous for 1000 times on ch1 then processing, calculations, etc, then for 1000 times on ch2...

I read that as well. That is not a frequency. Frequency is measurements per second. How long time in between samplings? Or, how long does it take to read those 1,000 samples?

one post above : READ : the circuit (alone) works in lots of applications so far, driving whatever it should drive. The problem arised when we thought of putting an uno to display the values.

That a circuit drives what it should drive doesn't necessarily mean that the voltages are exactly what you expect them to be (or why bothering measuring them in the first place?). That's why: have you connected it to, say, a scope? And what's the result there? Same as the Arduino? Or different? This should be a basic step in your trouble shooting, but it seems you didn't do this. Make sure you know what you measure. If your measurements are not what you expect, it may be that your measuring method is wrong, it may also be that your signal is not what you expect.

post17 : READ: Tried to "add" rectifying at output of existing, but find many problems because of pcb (smd, tight pack, capacitive feedback destroy original signal). Stray capacitance on pcb comes when I insert external rectifier at output.

Ouch. Big fail here. Stray capacitance is a property of a PCB (and any real life electrical circuit for that matter), it doesn't magically appear if you add some external component. If it messes up the signal put through your rectifier, how can you be sure that this does not mess up the signal you send to the Arduino? Especially as you see this difference between in-phase and out-of-phase signals.

demkat1: Hello, I experience the following problem : I have an AC signal which I want to measure (volts) with Uno. Of course, since 328's ADCs are single polarity, I "cut " the negative part using a schotky diode (clamp to the ADC input), that means the ADC input goes maximum 0,15V negative (absolute maximum spec is -0.3V).

In practice I have 2 AC signals to measure. These signals are same frequency, but may be in phase or opposit phase (0 or 180 deg) in respect to a ref signal.

The strange part is that if the signals are in same phase between them (ie both 0 or both 180 deg to ref), measurements are ok, if they are opposite between them (one 0 the other 180 deg to ref), measurements are not ok. There comes an error which is related to their amplitude.

Any comments on possible input behavior of ADC because one input is positive and the neighbour (a little) negative?

Show your circuit - sounds like the rectification is biasing the signal source or something like that.

I'd strongly recommend not doing what you're doing, but measure ac-coupled centred on a mid-rail reference. Adding a non-linear element into the signal path isn't necessary.

demkat1: @Jobi-Wan: They are NOT zeners. they are Schottkies. (as a further step to your analysis : the diodes at input just protect the inputs, keeping difference in acceptable limits. IF they were zeners TES, they should be in series)

So you ARE aware inputs cannot be more than few hundreds mV apart? Are you SURE the maximum difference is not higher?

today at lab i put an “angle simulator” to produce 2 signals (sine, cosine) like the output of resolver. Angle selected by thumbwheels. Output go into :angle indicator, thatis a instrument that analyses the inputs and calculates the angle (display=thumbwheels)
Outputs also go to Uno with a series resistor and negative clamp shottky.

So, no use of any other circuit.

Can somebody explain the difference of the 2 displays in 135 and 315 degrees?

Does anybody need the maintainance manuals of the instruments to express an opinion if

ADC measurements are not accurate if one input is positive and other is slightly negative

A.JPG

45.JPG

135.JPG

225.JPG

315.JPG

It would be nice if you included the pictures so we don't have to download them:
A.JPG
45.JPG
135.JPG
225.JPG
315.JPG

demkat1: Can somebody explain the difference of the 2 displays in 135 and 315 degrees?

You call that a difference?

This is a difference in the FOURTH DIGIT. As you STILL didn't indicate the signal frequency or the sampling frequency, I'd say that's simply perfectly normal instrumental error (if you would care to give that information we may be able to give pointers on how to get even more close to your desired result).

Be proud that you get three significant digits instead, that's a pretty good job.

OK, I admit a point of failure here: me (and the other posters) forgot to ask "what values do you get, and what values do you expect?", however it actually is mentioned in the "how to use this forum" sticky that everyone should read. That'd have saved all of us a lot of work.

Hint: try to make minimal (non)working example. You have made a small step in this direction: applying known good signal and it is chceked by known good instrument (probably). But again - you are showing nearly nothing. The only information you provided so far is the analog circuit you are not using now. What is the code generating the number? A bug may be hidden here. There is plenty of parts on the breadboard - none is connected? What about power lines? Are they stable? How much current the signal sinks while negative? And what about voltage reference? You should try much easier setup. Try measuring a known DC signal with positive or negative DC applied to another pin. Is result the same or is there a difference? If it is OK record measured values while the AC signals are applied and look at the data (make a graph). Is there a glitch somewhere?

wvmarle:
You call that a difference?

This is a difference in the FOURTH DIGIT. As you STILL didn’t indicate the signal frequency or the sampling frequency, I’d say that’s simply perfectly normal instrumental error (if you would care to give that information we may be able to give pointers on how to get even more close to your desired result).

Be proud that you get three significant digits instead, that’s a pretty good job.

What troubles me more is that there error in 45 (from 0 to 90) and 225 (from 180 to 270) is …nothing (ok) but the other quadrants??? Also strange is that measurements are stable, they dont fliccer or fluctuate or… If there was any instability i could understand its a hardware limit.

Anyway
Signal Frequency is 400Hz.
Samling is continous 1000 times (for about 30-50 periods) so to “grab” Vmax
Signal amplitudes are 4,5Vp
Can you tell me what is your “accuracy calculations” and conclude that this is a small error?

demkat1: Signal Frequency is 400Hz. Samling is continous 1000 times (for about 30-50 periods) so to "grab" Vmax Signal amplitudes are 4,5Vp Can you tell me what is your "accuracy calculations" and conclude that this is a small error?

Hey, finally you start answering questions! That's helpful. I have to say you more and more give me the feeling you actually have no clue of what you're doing. Had you provided these basic numbers 30 replies ago we could have saved a few days and a lot of other theorising. Basic analyses of your system gives the answers: you get so tiny tiny errors due to DUMB LUCK. Here we go:

Arduino can take 9615 samples per second from its ADC. That was a quick Google search. Now at a 400 Hz signal that's only 24 samples per complete cycle, or a 15° resolution! That easily explains why you get a lower peak value: your sample moment is simply not exactly on the peak of the signal.

Why do you even complain about getting a 0.4° difference? That's orders of magnitude better than you should be dreaming of, and it's dumb luck that the numbers match up so closely. You only get these difference because it almost perfectly fits in the 24 samples: 45° at sample 3, 135 at sample 9, 225 at sample 15, 315 at sample 21.

Now change your input (or sampling) frequency a little bit and watch the numbers go off seriously, up to 7.5° either way.

The stability of the signal is interesting, it appears you have some form of trigger in your secret code that makes it start measuring at just the right moment.

So, what did we get from knowing the frequency? that i dont have alias errors? but we know that already from the stability of measurements...

You didnt tell me : since you didnt know the frequency how you conclude that 4th digit accuracy is good? What if the freq was 10Hz?

No my friend, open hearted speaking, i believe you dont understand the procedure. I want to grab, capture, the maximun (Vpeak). The only reason for taking samples over ...many periods is to achieve starting ADC's "sample & hold" in about signal's maximum. You see, since it is a S&H in the ADC's front end, the converted value has nothing to do with the conversion time, only with the instantaneous value of the S&H.

Do you have a better proposal for taking a maximum? (dont tell me about precision rectifying and peak detection circuit, discussion on this was at begin of 2nd page)

I wonder if it is some form of test from your side. Your error may come from 1) poor analog front end 2) ADC problems 3) code problems 4) some other unexpected cause

You ruled out 1) by supplying artificial signals directly. We can hardly help you with 2) because we don't know your setup. We cannot help you with 3) either since we don't know the code. Moreover both are quite complicated (you say) so I doubt anyone would care to try debug it for you for free. Until YOU rule out the problem is in 2) and 3) it is pointless to take more effort with 4). Insulting people who are trying to help you may give you feeling you are smart but will not help you solve the problem.

Smajdalf: I wonder if it is some form of test from your side.

No, it's just that OP really has no clue what he's doing (his latest question confirms that again, I'm beyond doubt now), and still doesn't realise this. The question was first about peak value (i.e. peak voltage), now it's about when in the cycle the peak falls, which are two different things to measure.

demkat1: You didnt tell me : since you didnt know the frequency how you conclude that 4th digit accuracy is good? What if the freq was 10Hz?

That's quite elemental. You take 1,000 samples. If that is just a single cycle (that's why I was asking for both signal AND sampling frequency! It's the combination that matters, the number of either is inconsequential, note that even the 9,615 per second sampling rate is my assumption based on best case scenario) your best error is 1/1000th of that cycle. That's 0.36° on a 360° total, or fourth digit accuracy. Any more than one cycle per 1,000 samples and the error becomes greater. Any less than once cycle per 1,000 samples and you're not even seeing the peak.

This is assuming the ADC is perfect, which it isn't. Take ten samples of the exact same voltage (and fluctuating the voltage in between) and you often don't have 10 exact same values: there's always a small spread. Therefore, the sample of the peak of the signal is not always the highest sample. Also with the limited 10-bit resolution of the ADC, it's very likely that you have a number of samples of maximum value (this depends on the actual waveform, which is why that unanswered info is important). Add those together, and it's just very unlikely that the peak sample is the exact same point of the peak of your signal.

Then there's this major distinction between precision and accuracy. A 6-digit precision (like you're doing) doesn't mean 6-digit accuracy. Your data may be way off, even if reproducible. The very low sampling rate actually helps with the reproducibility of the data (less chance the peak is at a different sample), the calculations provide the precision, but the accuracy is still just a result of dumb luck, and the value from the Arduino has actually very little meaning.

demkat1: So, what did we get from knowing the frequency? that i dont have alias errors? but we know that already from the stability of measurements...

Did you use an analog low-pass filter at the input to the arduino?