OK, I have the math to a point where it is calculating somewhere near the number I want.
I have connected the hardware. A MPXV4006 pressure sensor which is connected to a MCP3201 ADC which in turn goes via SPI to a 18F14K50 PIC.
Attached is the setup.
I can see the data coming in on the scope. If I move the plunger of the syringe, I get the data changing, but always get a Zero when I send it out to the serial port.Code:' Variables SCK VAR PORTB.6 'Clock pin CS VAR PORTC.1 'Chip Select Active low SDI VAR PORTB.4 'Data In pin COUNTS var word lbit var COUNTS.byte0 hbit var COUNTS.byte1 '------------------------------------------------------------------------------- Define LOADER_USED 1 INCLUDE "MODEDEFS.BAS" DEFINE OSC 12 DEFINE SHIFT_PAUSEUS 10 'gives a 50KHZ clock pulse TRISB.4 =1 ' set PortB 4 as an input TRISB.6 =0 ' set PortB 6 as an output TRISC =%00000000 knots var long knotsRem var long HIGH CS START: LOW CS PAUSEUS 50 'delay after CS goes low for conversion to start. Probably not needed SHIFTIN SDI,SCK,2,[counts\14] ' using mode 2 for SPI high cs 'knots = ((SQR(counts*100))*1563)/10000 'knotsRem = (SQR(counts*100)*1563)//10000 'serout2 portb.7,396,[ #Knots,".",dec3 knotsRem," ",#counts,","," Knots",13,10] serout2 portb.7,396,[ #lbit," ",#hbit,13] ' Just send out ADC value to start GOTO START: END
I havent used the shiftin command before. It looks right so I'm not sure where I am going wrong.
Any help would be appreciated.
TIA
aajgss
Bookmarks