One more question about testing the program on PC. After I have written a program that works, how am I going to test what resolution work best and how many samples I need to calculate? :roll:
One more question about testing the program on PC. After I have written a program that works, how am I going to test what resolution work best and how many samples I need to calculate? :roll:
Basically you need to generate data for different waveshapes, a sinewave is the obvious first choice, and you can generate that from the Sin() function included in most high level languages. As you're planning an 8 bit A2D, the maximum value can go from 0-255, so you need to write the generation routine accordingly - scaling it to give results in that range.
For a start I would try generating a run of 256 samples, and try your maths on that - then try 128 samples, and see if you get the same result, then 64 samples - you can do this easily by only using every 2nd sample, or third sample etc.
This simulates different numbers of samples, while keeping the data identical. You should also try doing the same with other waveshapes, to simulate real world conditions.
To try different A2D resolutions, scale the original numbers differently, this time from 0-1023 for 10 bit resolution - although this will give you even more memory problems on an 8 bit PIC. But I see no reason why 8 bit resolution won't be OK.
That's the sort of idea, now generate some sample waveforms and make sure it works - then try different numbers of samples, to try and find the optimum point between small numbers of samples and high numbers of samples. Presumably there will be a point where you start to lose too much accuracy, you need to find it and keep just above it.
P-P is easy, simply search for the lowest and highest values, they are the two peaks.
Basically you need to generate data for different waveshapes, a sinewave is the obvious first choice, and you can generate that from the Sin() function included in most high level languages.
What you mean by generate data for different waveshapes? Is it means that find the most suitable number of samples for different types of waveshape? The waveforms that I need to generate is it a function in the programing part, for example: y=sin(x) and from here I test different number of samples on it?
All the test is it mainly on the programming part only :?:
What others waveshape I need to generate? (analogue waveforms)
Sorry, this is the first time I do these. So, I need to be 100% sure.
Basically you need to generate data for different waveshapes, a sinewave is the obvious first choice, and you can generate that from the Sin() function included in most high level languages.
What you mean by generate data for different waveshapes? Is it means that find the most suitable number of samples for different types of waveshape? The waveforms that I need to generate is it a function in the programing part, for example: y=sin(x) and from here I test different number of samples on it?
All the test is it mainly on the programming part only :?:
What others waveshape I need to generate? (analogue waveforms)
Yes, different analogue wave shapes, obviously a sinewave is probably the first one to test (as it's a common wave shape and easy to generate), you should also test square waves (again, easily generated), triangle waves (still easy), sawtooth waves (easy again) - then more complicated waves, the sort of wave shapes you get in the real world, a note from a guitar, or a trumpet, a voice etc.
For the 'real world' type samples you would probably find it easiest digitising a sample in Windows, and using data from the WAV file. Or you could simply plot analogue wave shapes manually.
Yes, different analogue wave shapes, obviously a sinewave is probably the first one to test (as it's a common wave shape and easy to generate), you should also test square waves (again, easily generated), triangle waves (still easy), sawtooth waves (easy again) - then more complicated waves, the sort of wave shapes you get in the real world, a note from a guitar, or a trumpet, a voice etc.
Thanks Nigel :wink:
Is square waves also consider as an analogue waveform too :?:
For my project, is it necessary to test a more complicated waves like what you had mentioned:a note from a guitar, or a trumpet, a voice etc?
I thought that my project is only use to measure electric signal? :?
Is square waves also consider as an analogue waveform too :?:
For my project, is it necessary to test a more complicated waves like what you had mentioned:a note from a guitar, or a trumpet, a voice etc?
I thought that my project is only use to measure electric signal? :?
Test what you need to, a square wave is an analogue signal, although it could also be considered a digital signal as well. As for measuring electrical signals, any kind of waveform in an electrical circuit is an electrical signal - what sort of electrical signals had you in mind?.
As for measuring electrical signals, any kind of waveform in an electrical circuit is an electrical signal - what sort of electrical signals had you in mind?.
At first, I thought that it would be only sinewave that I need to consider. Well, I think I'm wrong now. Actually, I don't really get it why I need to test for a more complicated waves as well? Do I really need to measure those you have said for my project? eg: a note from a guitar, trumpet, and a voice. :roll: OR is it just only a test to determine the number of samples for different types of waveform?
At first, I thought that it would be only sinewave that I need to consider. Well, I think I'm wrong now. Actually, I don't really get it why I need to test for a more complicated waves as well? Do I really need to measure those you have said for my project? eg: a note from a guitar, trumpet, and a voice. :roll: OR is it just only a test to determine the number of samples for different types of waveform?
Your requirement was to display RMS values for the incoming data, if your incoming data is always a sinewave you can do so very, very simply, a normal cheap analogue or digital meter will do that - both types just read the sinewave directly, and simply scale it to read RMS - BUT THIS ONLY WORKS FOR THE EXACT WAVE IT WAS CALIBRATED FOR!.
If you want to read RMS values for differing waveshapes it's a lot more complicated, you need to calculated the RMS value, and if you don't test it with differing waveshapes how do you know if it works or not?.
If you want to read RMS values for differing waveshapes it's a lot more complicated, you need to calculated the RMS value, and if you don't test it with differing waveshapes how do you know if it works or not?.
Thanks for your advice!! Nigel :wink: I have the idea now.
After I had done the test for different waveshapes, how can I apply it to my project? (Since there are different values of sample for different waveshapes) :idea:
Thanks for your advice!! Nigel :wink: I have the idea now.
After I had done the test for different waveshapes, how can I apply it to my project? (Since there are different values of sample for different waveshapes) :idea:
You simply use the tried and tested maths routines that you used on the PC, knowing full well that they work and give correct RMS readings for any waveshape you happen to feed it. The waveshape you monitor with your PIC design then doesn't matter, it will be correct for any waveshape - as an RMS routine has to be.
You simply use the tried and tested maths routines that you used on the PC, knowing full well that they work and give correct RMS readings for any waveshape you happen to feed it.
hmm, I don't really get what you mean, Nigel. :roll: You asked me to simply use the tried and tested maths routines on the PC to confirm that it gives correct readings for any waveshape. Is it test on the programming part by feed in different values?(in the code that i write for different waveshapes :?: )
Nigel Goodwin said:
The waveshape you monitor with your PIC design then doesn't matter, it will be correct for any waveshape - as an RMS routine has to be.
You simply use the tried and tested maths routines that you used on the PC, knowing full well that they work and give correct RMS readings for any waveshape you happen to feed it.
hmm, I don't really get what you mean, Nigel. :roll: You asked me to simply use the tried and tested maths routines on the PC to confirm that it gives correct readings for any waveshape. Is it test on the programming part by feed in different values?(in the code that i write for different waveshapes :?: )
No, you need to write code that works with any waveshape, if you have to write different code for different shapes your routine isn't working. RMS means Root Mean Square, and gives the same heating effect as the same DC voltage - so 230V DC fed to a heater works the same as 230V RMS, the waveshape doesn't matter, it still contains the same amount of energy.
Nigel Goodwin said:
The waveshape you monitor with your PIC design then doesn't matter, it will be correct for any waveshape - as an RMS routine has to be.
You need to write different routines for them, they are totally different things - but RMS is the hard one!.
Have a look at http://www.epemag.wimborne.co.uk under downloads and PIC's, they have done various projects over the years, including scope type designs. "Micro PICScope" uses an LCD and a PIC16F877 to give a simple scope, it also calculates frequency and P-P, it could be worth looking at. They also did a PIC based scope that connects to the PC parallel port, the PC software (written in BASIC) could be worth a look.
No, you need to write code that works with any waveshape, if you have to write different code for different shapes your routine isn't working....
:arrow:
You need to write different routines for them, they are totally different things - but RMS is the hard one!.
All the codes (for different waveshapes) & routines should write in a single program correct?
Thanks for your information, Nigel!! :wink: I have already seen it earlier. For the PICScope, can I use the code for my peak-to-peak and frequency calculations? Do you know the rating of the MICRO-PIC Scope?
Thanks for your information, Nigel!! :wink: I have already seen it earlier. For the PICScope, can I use the code for my peak-to-peak and frequency calculations? Do you know the rating of the MICRO-PIC Scope?
I see no reason why you can't use the routines, design your project round a similar scheme.
The rating of the MICRO-PICScope isn't really given, it just specifies "basically audio", but it does give 17KHz as the highest frequency, limited by the sampling rate.