|
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-1by Hsiao-Ho Hsu This PicBasic Pro sample reads a Merlin Systems Stretch Sensor in a .Wheatstone Bridge circuit. See also the Op Amp Bridge code sample. Back to Stretch Sensor report.
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 20 ' Set sampling time in uS
SensorValue var word
'tx var portc.6
'rx var portc.7
n9600 con 16468
output portb.7
output portb.3
'for keyboard
' Set PORTA to all input
TRISA = %11111111
' Set up ADCON1
ADCON1 = %10000010
Main:
HIGH portb.3
'adding pull-down resistors tightens the range.
ADCin 0, sensorValue
if SensorValue < 500 then ' 500 is when you strecth a bit but not much.....
' since our user may just be able to move a bit
high portb.7
else
low portb.7
endif
'serout2 tx, n9600, [Dec sensorValue, 13,10 ] 'the only diff btwn this and
pause 50 'the other code is DEC(ascii cmnd)
Goto main
|