| ??? 03/13/08 07:36 Read: times |
#152207 - Simplify Responding to: ???'s previous message |
You don't seem to be using the 16 individual readings for anything else, so you can simplify it to:
unsigned int SR; // Sample end result value
unsigned char size; // ADC conversion variable
Wait(1); //16X sampling of incoming data from potentiometer
SR=AD1DAT2;
Wait(1); //Wait 10ms for next sample
SR=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR+=AD1DAT2;
Wait(1);
SR = (SR / 16);
size = SR; // Local SR = Sampled result average
Of course, rather than manually code 16 individual reads of the ADC, and 16 individual calls to Wait(), you could put it all int o a loop... |
| Topic | Author | Date |
| Math not functioning with proper headers? | 01/01/70 00:00 | |
| horrible method | 01/01/70 00:00 | |
| Lots of issues | 01/01/70 00:00 | |
| Code Op at level 8 | 01/01/70 00:00 | |
| Try multiple steps | 01/01/70 00:00 | |
| ah hah moment arrived......omg | 01/01/70 00:00 | |
| 01/01/70 00:00 | ||
| Here is the block which now works 100% | 01/01/70 00:00 | |
| Operation question in C | 01/01/70 00:00 | |
| Because | 01/01/70 00:00 | |
| Simplify | 01/01/70 00:00 | |
| what's the point ? | 01/01/70 00:00 | |
| What's the point | 01/01/70 00:00 | |
| simpler, but | 01/01/70 00:00 | |
| Not right | 01/01/70 00:00 | |
| use shift right instead of divide | 01/01/70 00:00 | |
| If you're lucky... | 01/01/70 00:00 | |
| Use a rount trip buffer | 01/01/70 00:00 | |
| Bad names | 01/01/70 00:00 | |
| System use names ???? | 01/01/70 00:00 | |
| Common naming convention ? | 01/01/70 00:00 | |
| ISO/IEC 9899:1990... | 01/01/70 00:00 | |
| Comments | 01/01/70 00:00 | |
| same effect as a "circular array" | 01/01/70 00:00 | |
| think I like this the best | 01/01/70 00:00 | |
Use a loop with deglitching and averaging | 01/01/70 00:00 |



