Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/13/08 01:53
Read: times


 
#152198 - Here is the block which now works 100%
Responding to: ???'s previous message
I've got my block working, and doing what I want it to do. I'm sure it could be simplified but it is not really needed. I found out that I should have used:

unsigned int SR;

instead of

unsigned char SR;

So it was a ma bad situation. Here is the final result, my next post after this one will be an operational question that doesn't make sense. Thanks for the input folks.



    unsigned char S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15,S16; //input samples from ADC    
    unsigned int SR;        // Sample end result value
    unsigned char size;     // ADC conversion variable
    SR = 0;                 // Initialize sample results variable
    
    
    Wait(1); //16X sampling of incoming data from potentiometer
    S1=AD1DAT2;
    Wait(1); //Wait 10mS for next sample   
    S2=AD1DAT2;
    Wait(1);    
    S3=AD1DAT2;
    Wait(1);    
    S4=AD1DAT2;
    Wait(1);
    S5=AD1DAT2;
    Wait(1);
    S6=AD1DAT2;
    Wait(1);
    S7=AD1DAT2;
    Wait(1);
    S8=AD1DAT2;
    Wait(1);
    S9=AD1DAT2;
    Wait(1);
    S10=AD1DAT2;
    Wait(1);
    S11=AD1DAT2;
    Wait(1);
    S12=AD1DAT2;
    Wait(1);
    S13=AD1DAT2;
    Wait(1);
    S14=AD1DAT2;
    Wait(1);
    S15=AD1DAT2;
    Wait(1);
    S16=AD1DAT2;
    Wait(1);

    SR = (S1 + S2 + S3 + S4 + S5 + S6 + S7 + S8 + S9 + S10 + S11 + S12 + S13 + S14 + S15 + S16);
    SR = (SR / 16);                                             
    size = SR;          // Local SR = Sampled result average


List of 26 messages in thread
TopicAuthorDate
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      

Back to Subject List