Back to the original challenge, I'd do it in software:
Code:
IF ADC > 127 THEN ;Assuming 8-bit ADC
ADC_VAL = (ADC * 4) / 5 ;Yields 80% of value
ENDIF
The above snippet will deliver <128 results as soon as ADC > 128. I don't think that's what you want. So we have to add a filter:
Code:
IF ADC > 127 THEN ;Assuming 8-bit ADC
B0 = ADC - 127 ;Use a temporary variable to determine how much above 128 our result is
B1 = (B0 * 4) / 5 ;Get 80% of only the amount > 128
ADC_VAL = B1 + 128 ;Yields mid-point + 80% of overage
ENDIF
Bookmarks