Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
km said:Thanks for all the advice, Nigel!! 8)
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:
PS:I apologize for my poor understanding.![]()
Nigel Goodwin said:Write in whatever software you are experienced in, Delphi, BASIC, C, Pascal, Prolog, Java - any language you like, just to prove it works
km said:Nigel Goodwin said:Write in whatever software you are experienced in, Delphi, BASIC, C, Pascal, Prolog, Java - any language you like, just to prove it works
Is it you mean to prove the programming code can be used to perform the calculations?
:arrow: For Example:
The C code for RMS calculations:
total = 0;
for (i=0; i<SMP_CNT; i++) //SMP_CNT=Sample Count
{
total += (sample*sample);
}
RMS = sqrt(total / SMP_CNT);
PS: Anyone has the C code for the frequency/peak-to-peak/average/duty cycle calculations feel free to send me. Thank you :wink:
Nigel Goodwin said: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.
km said:Nigel Goodwin said: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)
Nigel Goodwin said: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.
km said:Nigel Goodwin said: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?.
Nigel Goodwin said: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?.
km said: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?
Nigel Goodwin said: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?.
km said: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:
Nigel Goodwin said: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.
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.
km said:Nigel Goodwin said: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.
What about peak-to-peak, frequency, average and duty cycle routines? The results will be correct also?
Nigel Goodwin said: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!.
km said: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?
km said:Hi Nigel, I have something to ask you. My college programmer doesn't support PIC 16F628. Do I need to buy a programmer :?: OR build one :?:
Nigel Goodwin said:An obvious easy value (for an 8 bit processor) would be 256 samples, but you don't have anywhere to store them in a 16F84.