|
CLASS DOCUMENTS
REPORTS & ASSIGNMENTS
CLASS CONTENT
USING THIS SITE
registered authors login here You are: (logout) For more on PMWiki, see pmwiki.org |
Stretch Sensor-2by Hsiao-Ho Hsu This PicBasic Pro sample reads a Merlin Systems Stretch Sensor in a Wheatstone Bridge circuit and an LM358 Op Amp circuit. See also the Wheatstone Bridge code sample. Back to Stretch Sensor report. has to change ADCON to a different setting in order to use ADC compare here..... ' Analog difference ' This program takes two analog inputs and returns ' the difference of the two. ' ' It's useful when you have a sensor with V+ and V- ' outputs, but no clear +5V and ground outputs. ' Define ADCIN parameters ' Set number of bits in result DEFINE ADC_BITS 10 ' Set clock source (3=rc) DEFINE ADC_CLOCK 3 ' Set sampling time in microseconds DEFINE ADC_SAMPLEUS 10 ' serial constants and pin assignments: tx var portc.6 rx var portc.7 n9600 con 16468 adcVar VAR WORD ' Create variable to store result adcvar2 var word result var word ' Set PORTA to all input TRISA = %11111111 ' Set up ADCON1 ADCON1 = %10000010 Pause 500 ' Wait .5 second main: ADCIN 0, adcVar ' Read channel 0 pause 10 ' let the ADC settle adcin 1, adcvar2 ' read channel 1 ' get the difference between the two: result = abs(adcvar - adcvar2) ' send out the result SEROUT2 tx, n9600, [DEC result, 10, 13] Pause 10 ' let the ADC settle GoTo main |