View previous topic :: View next topic |
Author |
Message |
see it plz... Guest
|
about controlling voltage monotony |
Posted: Tue May 11, 2004 5:37 am |
|
|
i have to control the monotony of voltage acquisition with 16F876 during 10ms however i sets the timer2 to sample voltage every 100us then i will compare voltage[i]<voltage[i+1]<voltage[i+2] ...... so should i declare a table of 100 case where i will store samples to compare them?
i have the idea but i can't realize it.
so anyone help me. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue May 11, 2004 7:20 am |
|
|
I'm confused.... Do you want to measure the STABILITY of a voltage over a 10ms period? There are algorythms to calculate the Standard Deviation of a string of readings without having to store every reading in an array. I know my pocket calculator can find the SDEV of more numbers than it has memory to store. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
see it plz... Guest
|
re |
Posted: Tue May 11, 2004 7:26 am |
|
|
no, i want to control the evolution monotony of the voltage like this
if ((read_ADC[i]<=read_ADC[i+1]) && (read_ADC[i+1]<=read_ADC[i+2]) && ((read_ADC[i+2]<=read_ADC[i+3]))
output_high(led1);
else output_high(led2);
so how can i store 100 values of voltage to perform the comparison between them. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Tue May 11, 2004 7:52 am |
|
|
Unless you are controlling a missil head director, I would average consecutive AD
readings and according to the resulting tendency take an action. Why so fast ??
Regards,
Humberto |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue May 11, 2004 9:03 am |
|
|
It seems like an application I once had where an instrument was lowered into the ocean by a winch. The winch was occasionally stopped and that was supposed to trigger the instrument to take readings at each stopping point. A pressure sensor monitored depth and when it stopped getting deeper the instrument took measurements. With the heaving of the ship and the erratic behavior of the winch it required a lot of filtering to prevent false triggers.
Anyway, I see two methods. First just use an array of readings. Any book on C will tell you how to use an array. If you don't have enough memory a less flexable way would be to just store the last reading and compare to the current reading to get a differential. If the differential is positive then increment a counter. If the differential is neagtive then zero the counter. When the counter = 100 you have "evolution monotony." _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|