I decided i am going to put relays instead of an H-bridge.
I recently obtained some nice sensors from Taosinc.com. I wrote this program but it does not work. The datasheet is not complicated, but maybe I missed something. I seems that i need to put SI to high after the 129th clock. maybe I am not using the pulsin command right.
datasheet:
http://www.taosinc.com/images/produc...401R-LF-E4.PDF
My program:
sensor var byte: counter var byte : pulse var byte
TRISB = %00000000
TRISA = %11111111
loop:
'clock input on RB0
'after 18 clock input at 1, count 111 clock cycles after the reset
pulse = 0
counting:
Pulsin PortA.1,1,pulse
pulse = pulse +1
if pulse = 18 then goto continue
goto counting
continue:
Pulsin PortA.1,1,pulse
pulse = pulse +1
if pulse = 130 then goto continue2
goto counting
continue2:
porb.0 = 1 'Si is now high
Pulsin PortA.1,1,pulse
pulse = pulse +1
if pulse = 131 then goto continue3
goto continue2
continue3:
ADCON0.2 = 1 'Start Conversion
porb.0 = 0 'put the SI back to zero
ADCIN 0, sensor 'Read channel PORTA.0
pause 50
Lcdout $fe, 1 'Clear screen
Lcdout "Sensor: ", Dec sensor
Pause 200
goto loop
end
Bookmarks