View Full Version : Need help getting a SCP1000 Altimeter (from SparkFun) to interface with the Pro

01-14-2009, 03:11 AM
I'm trying (so far unsuccessfully) to get my PropStick USB to communicate with an SCP1000 altimeter from SparkFun (www.sparkfun.com/commerce/product_info.php?products_id=8161 (http://www.sparkfun.com/commerce/product_info.php?products_id=8161)). It uses SPI for communication.

I attached a screen capture of the SPI communication example for a simple command (get the revision id of the board). It's from page 24 of the specification document for the SCP1000 (also attached). The PST output is also attached.

Below is the code I tried using to get the RevId. Using SPI, transmit %00000000 and it should return 03hex, but it just returns %00000000

If some kind soul out there could help me find the err of my ways, I'd greatly appreciate it.


_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000


High = 1
Low = 0
Out = %1

'Pin on Prop Chip for LED Indicator
PIN_LED = 15

'//Pin assignments for VTI SCP1000-D01
SPI_CSB = 0 'Chip select out connected to SCP1000 CSB pin
SPI_SCK = 3 'Clock out to SCP1000 SCK pin
SPI_MISO = 1 'Data in connected to SCP1000 MISO pin
SPI_MOSI = 2 'Data out connected to SCP1000 MOSI pin
SPI_DRDY = 4 'Data ready connected to SCP1000 DRDY pin


long DataValue, objSPI


Debug : "FullDuplexSerial"

PUB start | data,i

'start debugger

'set pin direction for LED to output

'flash the LED to confirm the program is running
repeat 10
waitcnt(clkfreq / 2 + cnt) '0.5 seconds

'blank the screen

'start H48C accelerometer
debug.Str(string("Starting SPI..."))
objSPI := false
objSPI := SPI.Start

'test startup of H48C
if (objSPI)
debug.Str(string("Started Successfully!",13))
debug.Str(string("Failed to Start!",13))

'display data from H48C & HM55B
if (objSPI)

data := %10101010

data := GetRev
debug.str(string("GetRev should equal 03h = "))

debug.str(string("Error: SPI failed to start. Terminating...",13))

PRI GetRev : datar | i

'set MOSI, CSB, SCK out
dira [ SPI_MOSI ] := Out
dira [ SPI_CSB ] := Out
dira [ SPI_SCK ] := Out
dira [ SPI_MISO ] := %0

'set CLK, MOSI low
outa [ SPI_SCK ] := Low
outa [ SPI_MOSI ] := Low

'set CSB high, then low to reset it
outa [ SPI_CSB ] := High
outa [ SPI_CSB ] := Low

repeat 8
outa [ SPI_SCK ] := High 'set CLK High
outa [ SPI_MOSI ] := %0 'transmit bin '0' on MOSI
outa [ SPI_SCK ] := Low 'set CLK low

repeat i from 7 to 0
outa [ SPI_SCK ] := High 'set CLK High
'read MISO
if ina[SPI_MISO] == 1 'read MISO
datar |= |< i ' set bit i HIGH
datar &= !|< i ' set bit i LOW
outa [ SPI_SCK ] := Low 'set CLK low

outa [ SPI_CSB ] := High

return datar

01-14-2009, 06:29 AM
Attached is a demo that worked for me.

01-18-2009, 12:28 AM

Thank you for trying to help. I appreciate it very much.

However, I don't think your code works with the SCP1000 sensor. Your hex codes to pull the Temperature ($84) and Pressure ($7c and $80) are not found anywhere in the SCP1000 specification (attached).

With my circuit & sensor (which I have very little faith in to begin with), the outputs (without any division or manipulation) are: Pressure = 16777215, Temperature = 65535.

I tried changing the hex codes you had for Temp and Pres, but they resulted in the same outputs. Furthermore, I think 65535 is the max value for an integer, which makes the Temperature value look very suspicious.

01-18-2009, 12:39 AM
Well, I've gotten a bit further (I think) using BS2_Functions. I've read through the Specification several times and think I'm executing the setup commands needed to get the Temperature and Pressure data.

During my Initialization function, I am pulling the REVID successfully. I am performing a ASIC Self Test, which is passing. The Operation Init function is working. The Status is returning as a success. I'm performing the 'low noise' calibration (which might or might not be needed). So, it looks like the sensor *should* be setup properly.

However, the raw temperature and pressure data is essentially blank/empty.

I have attached the SPIN code as an archive. A picture of the circuit and the specifications are attached to a previous post.

The output from PST is:

Initialize SCP1000...

REVID is ok...00000111
data from SPI_RESET = 00000000
Self Test is ok...00000011
Operation Init is ok...00000011
STATUS is ok...00001100
DATARD8 is ok...00000011
data from reset = 11111110
write(SPI_ADDPTR, $2D) = 00000000
write(SPI_DATARW, $03) = 00000000
data from mode set = 00000000

Starting data capture...

OPSTATUS = 00000011
tempurature = 00000011
pressure = 0000000000001100

So what's the problem? Is my sensor toast? Is my circuit wrong? Is the way I'm pulling the Temperature and Pressure values wrong?

01-18-2009, 05:18 AM
Travis_ said...
However, I don't think your code works with the SCP1000 sensor. Your hex codes to pull the Temperature ($84) and Pressure ($7c and $80) are not found anywhere in the SCP1000 specification (attached).

Sorry Travis, mine works OK. The addresses are left shifted 2 bits $84 =$21 (Temp out), $7C = $1F (Data8) and $80 = $20(Data16). I am using mode 0x0A (continous high resolution). This was just a simple test I put together from someone elses code and have not finished the complete driver as yet.

When I sent this, I was in US and did not have access to my lab to test. I have returned homw now and have just benched tested the unit and it still works as before. I did not use the resistors shown in the diagram as it is the only thing connected at this time. I had planned on using the same SPI as the SD card reader which was why the resistors are shown. My display is attached.