diff options
Diffstat (limited to 'wpd/WpdBasicHardwareDriver/firmware')
9 files changed, 0 insertions, 886 deletions
diff --git a/wpd/WpdBasicHardwareDriver/firmware/compass_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/compass_wpd_enabled.bs2 deleted file mode 100644 index 335d2c7e..00000000 --- a/wpd/WpdBasicHardwareDriver/firmware/compass_wpd_enabled.bs2 +++ /dev/null @@ -1,94 +0,0 @@ -' Compass_wpd_enabled.bs2 -' -' Displays x (N/S) and y (W/E) axis measurements along with the direction the -' Compass Module is pointing, measured in degrees clockwise from north. -' -' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -' PARTICULAR PURPOSE. -' -' Copyright (c) Microsoft Corporation. All rights reserved -' -' {$STAMP BS2} -' {$PBASIC 2.5} -' ============================================================================ - -' -----[ Pins/Constants/Variables ]------------------------------------------- -DinDout PIN 6 ' P6 transceives to/from Din/Dout -Clk PIN 5 ' P5 sends pulses to HM55B's Clk -En PIN 4 ' P4 controls HM55B's /EN(ABLE) - -Reset CON %0000 ' Reset command for HM55B -Measure CON %1000 ' Start measurement command -Report CON %1100 ' Get status/axis values command -Ready CON %1100 ' 11 -> Done, 00 -> no errors -NegMask CON %1111100000000000 ' For 11-bit negative to 16-bits - -x VAR Word ' x-axis data -y VAR Word ' y-axis data -status VAR Nib ' Status flags -angle VAR Word ' Store angle measurement - -SensorID VAR Byte 'Sensor identifier = 5 for PIR -ElementSize VAR Byte 'Size (in bytes) of each element -ElementCount VAR Byte 'Count of elements in packet -Padding VAR Byte 'Padding for the 8-byte element - -SensorID = 1 -ElementSize = 1 -ElementCount = 3 '3-bytes for compass data; - -NewInterval VAR Word 'New interval requested by user -Interval VAR Word 'Interval value utlized by firmware - -LFD CON $10 'Linefeed character - -Interval = 200 '.20 of a second interval -NewInterval = 200 - -' -----[ Main Routine ]------------------------------------------------------- - -Main: - GOSUB PollSensor 'Was motion detected? - GOSUB RetrieveInterval 'Retrieve units data - -' -----[ Subroutines ]-------------------------------------------------------- - -Timeout: - SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC3 angle, DEC5 Interval,LFD] - GOTO Main - -PollSensor: ' Compass module subroutine - - HIGH En: LOW En ' Send reset command to HM55B - SHIFTOUT DinDout,clk,MSBFIRST,[Reset\4] - - HIGH En: LOW En ' HM55B start measurement command - SHIFTOUT DinDout,clk,MSBFIRST,[Measure\4] - status = 0 ' Clear previous status flags - - DO ' Status flag checking loop - HIGH En: LOW En ' Measurement status command - SHIFTOUT DinDout,clk,MSBFIRST,[Report\4] - SHIFTIN DinDout,clk,MSBPOST,[Status\4] ' Get Status - LOOP UNTIL status = Ready ' Exit loop when status is ready - - SHIFTIN DinDout,clk,MSBPOST,[x\11,y\11] ' Get x & y axis values - HIGH En ' Disable module - - IF (y.BIT10 = 1) THEN y = y | NegMask ' Store 11-bits as signed word - IF (x.BIT10 = 1) THEN x = x | NegMask ' Repeat for other axis - - angle = x ATN -y ' Convert x and y to brads - angle = angle */ 360 ' Convert brads to degrees - - RETURN - - -RetrieveInterval: - SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval - IF NewInterval >= 10 AND NewInterval <= 60000 THEN - Interval = NewInterval - ENDIF - RETURN
\ No newline at end of file diff --git a/wpd/WpdBasicHardwareDriver/firmware/flex_force_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/flex_force_wpd_enabled.bs2 deleted file mode 100644 index 9b9e5b2c..00000000 --- a/wpd/WpdBasicHardwareDriver/firmware/flex_force_wpd_enabled.bs2 +++ /dev/null @@ -1,60 +0,0 @@ -' Flex_force_wpd_enabled.bs2 -' -' Displays R/C Discharge Time in BASIC Stamp DEBUG Window -' -' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -' PARTICULAR PURPOSE. -' -' Copyright (c) Microsoft Corporation. All rights reserved -' -' {$STAMP BS2} -' {$PBASIC 2.5} -' ========================================================================= - -' -----[ Declarations ]---------------------------------------------------- - -rawForce VAR Word ' Stores raw output -sensorPin CON 15 ' Flexiforce sensor circuit - -' -----[ Main Routine ]---------------------------------------------------- - -SensorID VAR Byte 'Sensor identifier = 5 for PIR -ElementSize VAR Byte 'Size (in bytes) of each element -ElementCount VAR Byte 'Count of elements in packet -Padding VAR Byte 'Padding for the 8-byte element - -SensorID = 3 -ElementSize = 1 -ElementCount = 5 '4-bytes for pressure data; 5 for interval - -NewInterval VAR Word 'New interval requested by user -Interval VAR Word 'Interval value utlized by firmware - -Interval = 200 -NewInterval = 200 - -LFD CON $10 'Linefeed character - -Main: - - GOSUB PollSensor 'Was motion detected? - GOSUB RetrieveInterval 'Retrieve units data - -Timeout: - SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC5 rawForce, DEC5 Interval, LFD] - GOTO Main - -PollSensor: - HIGH sensorPin ' Discharge the capacitor - PAUSE 2 - RCTIME sensorPin,1,rawForce ' Measure RC charge time - RETURN - -RetrieveInterval: - SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval - IF NewInterval >= 10 AND NewInterval <= 60000 THEN - Interval = NewInterval - ENDIF - RETURN diff --git a/wpd/WpdBasicHardwareDriver/firmware/h48c_3-axis_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/h48c_3-axis_wpd_enabled.bs2 deleted file mode 100644 index daba0fc9..00000000 --- a/wpd/WpdBasicHardwareDriver/firmware/h48c_3-axis_wpd_enabled.bs2 +++ /dev/null @@ -1,175 +0,0 @@ -' h48c_3-axis_wpd_enabled.bs2 -' -' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -' PARTICULAR PURPOSE. -' -' Copyright (c) Microsoft Corporation. All rights reserved -' -' {$STAMP BS2} -' {$PBASIC 2.5} -' -' ========================================================================= - -' -----[ Program Description ]--------------------------------------------- -' -' Test program for the H48C 3-Axis Accelerometer module. -' -' Connections: -' -' +------------+ -' | * | -' CLK | o o | Vdd (+5v) -' | +--+ | -' DIO [ o | | o | CS\ -' | +--+ | -' Vss | o o | 0G (free-fall indication) -' | | -' +------------+ -' -' How it Works: -' -' An onboard MCP3204 12-bit ADC is used to read the VRef, X-, Y-, and -' Z-axis outputs from the Hitachi H48C accelerometer. The reference -' voltage output from H48C is 1.65 volts (3.3 / 2). -' -' After reading the reference voltage and an output channel the g-force -' for the channel is calculated with this formula: -' -' axis - vref 3.3 -' G = ----------- x ------ -' 4095 0.3663 -' -' For use in the program the forumla can be simplified to: -' -' G = (axis - vref) x 0.0022 -' -' To allow the display of fractional g-force in the integer system of the -' BASIC Stamp we multiply 0.0022 by 100 -- this will allow us to display -' g-force in 0.01g units. - - - -' -----[ I/O Definitions ]------------------------------------------------- - -Dio PIN 15 ' data to/from module -Clk PIN 14 ' clock output -CS PIN 13 ' active-low chip select - - -' -----[ Constants ]------------------------------------------------------- - -XAxis CON 0 ' adc channels -YAxis CON 1 -ZAxis CON 2 -VRef CON 3 - -Cnt2Mv CON $CE4C ' counts to millivolts - ' 0.80586 with ** -GfCnv CON $3852 ' g-force conversion - ' 0.22 with ** - -' -----[ Variables ]------------------------------------------------------- - -axis VAR Nib ' axis selection -rvCount VAR Word ' ref voltage adc counts -axCount VAR Word ' axis voltage adc counts -mVolts VAR Word ' millivolts -Gforce VAR Word ' axis g-force - -xGforce VAR Word ' x-axis force -yGforce VAR Word ' y-axis force -zGforce VAR Word ' z-axis force - -dValue VAR Word ' display value -dPad VAR Nib ' display pad - -' Below lines are WPD additions - -SensorID VAR Byte 'Sensor identifier = 9 for Hitachi -ElementCount VAR Byte 'Count of elements in packet -ElementSize VAR Byte 'Size (in bytes) of each element - - -NewInterval VAR Word 'New interval requested by user -Interval VAR Word 'Interval value utlized by firmware - -SensorID = 9 -ElementSize = 4 'Each element contains a sign byte, followed by a G-force integer value, followed by a G-force fraction (in hundredths). -ElementCount = 3 'Each element corresponds to one of the three axis (X, Y, and Z) - -Interval = 2000 -NewInterval = 2000 - - -' -----[ EEPROM Data ]----------------------------------------------------- - - -' -----[ Initialization ]-------------------------------------------------- - -Reset: - HIGH CS ' deselect module - -' -----[ Program Code ]---------------------------------------------------- - -Main: - GOSUB GetGforces 'Retrieves G-forces along 3 axis - GOSUB RetrieveInterval 'Retrieves event-interval data - - Timeout: - SEROUT 16, 16780, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC1(xGforce.BIT15), DEC1(ABS xGforce/100),DEC2(ABS xGforce),DEC1(yGforce.BIT15),DEC1(ABS yGforce/100),DEC2(ABS yGforce),DEC1(zGforce.BIT15),DEC1(ABS zGforce/100),DEC2(ABS zGforce),DEC5 Interval ] - GOTO Main - - GOTO Main - - -' -----[ Subroutines ]----------------------------------------------------- - -' Retrieves the event-interval property from the WPD driver -RetrieveInterval: - SERIN 16, 16780, Interval, Timeout, [DEC NewInterval] 'Retrieve interval - IF NewInterval >= 10 AND NewInterval <= 60000 THEN - Interval = NewInterval - ENDIF - -' Retrieves G forces along all three axis -GetGforces: - FOR axis = XAxis TO ZAxis ' loop through each axis - GOSUB Get_H48C ' read vRef & axis counts - ' calculate g-force - ' -- "Gforce" is signed word - IF (axCount >= rvCount) THEN - Gforce = (axCount - rvCount) ** GfCnv ' positive g-force - ELSE - Gforce = -((rvCount - axCount) ** GfCnv) ' negative g-force - ENDIF - IF (axis = XAxis) THEN - xGforce = Gforce - ENDIF - IF (axis = YAxis) THEN - yGforce = Gforce - ENDIF - IF (axis = ZAxis) THEN - zGforce = Gforce - ENDIF - NEXT - RETURN - -' Reads VRef and selected H48C axis through an MCP3204 ADC -' -- pass axis (0 - 2) in "axis" -' -- returns reference voltage counts in "rvCount" -' -- returns axis voltage counts in "axCounts" - -Get_H48C: - LOW CS - SHIFTOUT Dio, Clk, MSBFIRST, [%11\2, VRef\3] ' select vref register - SHIFTIN Dio, Clk, MSBPOST, [rvCount\13] ' read ref voltage counts - HIGH CS - PAUSE 1 - LOW CS - SHIFTOUT Dio, Clk, MSBFIRST, [%11\2, axis\3] ' select axis - SHIFTIN Dio, Clk, MSBPOST, [axCount\13] ' read axis voltage counts - HIGH CS - RETURN - diff --git a/wpd/WpdBasicHardwareDriver/firmware/memsic2125_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/memsic2125_wpd_enabled.bs2 deleted file mode 100644 index 80449357..00000000 --- a/wpd/WpdBasicHardwareDriver/firmware/memsic2125_wpd_enabled.bs2 +++ /dev/null @@ -1,107 +0,0 @@ -' memsic2125_wpd_enabled.bs2 -' -' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -' PARTICULAR PURPOSE. -' -' Copyright (c) Microsoft Corporation. All rights reserved -' -' {$STAMP BS2} -' {$PBASIC 2.5} -' -' ========================================================================= - -' -----[ Program Description ]--------------------------------------------- -' -' Read the pulse outputs from a Memsic 2125 accelerometer and converts to -' G-force -' -' g = ((t1 / 10 ms) - 0.5) / 12.5% -' -' www.memsic.com - - -' -----[ Revision History ]------------------------------------------------ - - -' -----[ I/O Definitions ]------------------------------------------------- - -Xin PIN 8 ' X input from Memsic 2125 -Yin PIN 9 ' Y input from Memsic 2125 - - -' -----[ Constants ]------------------------------------------------------- - -' Set scale factor for PULSIN - -#SELECT $STAMP - #CASE BS2, BS2E - Scale CON $200 ' 2.0 us per unit - #CASE BS2SX - Scale CON $0CC ' 0.8 us per unit - #CASE BS2P - Scale CON $0C0 ' 0.75 us per unit - #CASE BS2PE - Scale CON $1E1 ' 1.88 us per unit -#ENDSELECT - -HiPulse CON 1 ' measure high-going pulse -LoPulse CON 0 - -' -----[ Variables ]------------------------------------------------------- - -xRaw VAR Word ' pulse from Memsic 2125 -xmG VAR Word ' g force (1000ths) - -yRaw VAR Word -ymG VAR Word - -'disp VAR Byte ' displacement (0.0 - 0.99) - - -' Below lines are WPD additions - -SensorID VAR Byte 'Sensor identifier = 1 for memsic -ElementSize VAR Byte 'Size (in bytes) of each element -ElementCount VAR Byte 'Count of elements in packet - -NewInterval VAR Word 'New interval requested by user -Interval VAR Word 'Interval value utlized by firmware - -SensorID = 6 -ElementSize = 1 -ElementCount = 6 '6-bytes for g-force - -LFD CON $10 'Linefeed character - -Interval = 100 '.10 of a second interval -NewInterval = 100 - -' -----[ Program Code ]---------------------------------------------------- - -Main: - GOSUB Read_G_Force 'reads G-force - GOSUB RetrieveInterval 'Retrieve units data - - Timeout: - SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC1(xmG.BIT15), DEC1(ABS xmG/1000),DEC1(ABS xmG/10),DEC1(ymG.BIT15),DEC1(ABS ymG/1000),DEC1(ABS ymG/10),DEC5 Interval,LFD] - GOTO Main - - - RetrieveInterval: - SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval - IF NewInterval >= 10 AND NewInterval <= 60000 THEN - Interval = NewInterval - ENDIF - -' -----[ Subroutines ]----------------------------------------------------- - -Read_G_Force: - PULSIN Xin, HiPulse, xRaw ' read pulse output - xRaw = xRaw */ Scale ' convert to uSecs - xmG = ((xRaw / 10) - 500) * 8 ' calc 1/1000 g - PULSIN Yin, HiPulse, yRaw - yRaw = yRaw */ Scale - ymG = ((yRaw / 10) - 500) * 8 - RETURN
\ No newline at end of file diff --git a/wpd/WpdBasicHardwareDriver/firmware/piezo_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/piezo_wpd_enabled.bs2 deleted file mode 100644 index ff5a7b55..00000000 --- a/wpd/WpdBasicHardwareDriver/firmware/piezo_wpd_enabled.bs2 +++ /dev/null @@ -1,55 +0,0 @@ -' Piezo_wpd_enabled.bs2 -' -' This program demonstrates using the LDT0 as a switch/trigger -' -' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -' PARTICULAR PURPOSE. -' -' Copyright (c) Microsoft Corporation. All rights reserved -' -' {$STAMP BS2} -' {$PBASIC 2.5} -' ========================================================================= - -SensorID VAR Byte 'Sensor identifier = 8 for piezo -ElementSize VAR Byte 'Size (in bytes) of each element -ElementCount VAR Byte 'Count of elements in packet -bVibration VAR Byte 'Vibration-detection variable (single element for PIR) -Padding VAR Byte 'Padding for the 8-byte element - -SensorID = 8 -ElementSize = 1 -ElementCount = 1 '1-byte for motion data; 5 for interval - -NewInterval VAR Word 'New interval requested by user -Interval VAR Word 'Interval value utlized by firmware - -Interval = 500 -NewInterval = 500 - -LFD CON $10 'Linefeed character - - -' -----[ Program Code ]---------------------------------------------------- - -Main: - - GOSUB PollSensor 'Was motion detected? - GOSUB RetrieveInterval 'Retrieve units data - -Timeout: - SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC1 bVibration, DEC5 Interval, LFD] - GOTO Main - -PollSensor: - bVibration = IN0 ' Assign status of P0 to bMotion - RETURN - -RetrieveInterval: - SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval - IF NewInterval >= 10 AND NewInterval <= 60000 THEN - Interval = NewInterval - ENDIF - RETURN diff --git a/wpd/WpdBasicHardwareDriver/firmware/ping_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/ping_wpd_enabled.bs2 deleted file mode 100644 index e2af29a7..00000000 --- a/wpd/WpdBasicHardwareDriver/firmware/ping_wpd_enabled.bs2 +++ /dev/null @@ -1,57 +0,0 @@ -' Ping_wpd_enabled.bs2 -' -' Measure distance with Ping))) sensor and display in both in & cm -' -' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -' PARTICULAR PURPOSE. -' -' Copyright (c) Microsoft Corporation. All rights reserved -' -' {$STAMP BS2} -' {$PBASIC 2.5} -' ========================================================================= - -' Conversion constants for room temperature measurements. -CmConstant CON 2260 -cmDistance VAR Word -time VAR Word -SensorID VAR Byte 'Sensor identifier = 5 for PIR -ElementSize VAR Byte 'Size (in bytes) of each element -ElementCount VAR Byte 'Count of elements in packet -Padding VAR Byte 'Padding for the 8-byte element - -SensorID = 4 -ElementSize = 1 -ElementCount = 5 '4-bytes for pressure data; 5 for interval - -NewInterval VAR Word 'New interval requested by user -Interval VAR Word 'Interval value utlized by firmware - - -LFD CON $10 'Linefeed character - -Interval = 200 '.20 of a second interval -NewInterval = 200 - -Main: - GOSUB PollSensor 'Was motion detected? - GOSUB RetrieveInterval 'Retrieve units data - -Timeout: - SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC5 cmDistance, DEC5 Interval,LFD] -GOTO Main - -PollSensor: - PULSOUT 0, 5 - PULSIN 0, 1, time - cmDistance = cmConstant ** time -RETURN - -RetrieveInterval: - SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval - IF NewInterval >= 10 AND NewInterval <= 60000 THEN - Interval = NewInterval - ENDIF -RETURN
\ No newline at end of file diff --git a/wpd/WpdBasicHardwareDriver/firmware/pir_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/pir_wpd_enabled.bs2 deleted file mode 100644 index 259c5025..00000000 --- a/wpd/WpdBasicHardwareDriver/firmware/pir_wpd_enabled.bs2 +++ /dev/null @@ -1,50 +0,0 @@ -' Pir_wpd_enabled.bs2 -' -' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -' PARTICULAR PURPOSE. -' -' Copyright (c) Microsoft Corporation. All rights reserved -' -' {$STAMP BS2} -' {$PBASIC 2.5} -' ========================================================================= - -SensorID VAR Byte 'Sensor identifier = 5 for PIR -ElementSize VAR Byte 'Size (in bytes) of each element -ElementCount VAR Byte 'Count of elements in packet -bMotion VAR Byte 'Motion-detection variable (single element for PIR) -Padding VAR Byte 'Padding for the 8-byte element - -SensorID = 5 -ElementSize = 1 -ElementCount = 1 '1-byte for motion data; 5 for interval - -NewInterval VAR Word 'New interval requested by user -Interval VAR Word 'Interval value utlized by firmware - -LFD CON $10 'Linefeed character - -Interval = 500 '.500 of a second interval -NewInterval = 500 - -Main: - - GOSUB PollSensor 'Was motion detected? - GOSUB RetrieveInterval 'Retrieve units data - -Timeout: - SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC1 bMotion, DEC5 Interval,LFD] - GOTO Main - -PollSensor: - bMotion = IN0 ' Assign status of P0 to bMotion - RETURN - -RetrieveInterval: - SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval - IF NewInterval >= 10 AND NewInterval <= 60000 THEN - Interval = NewInterval - ENDIF - RETURN
\ No newline at end of file diff --git a/wpd/WpdBasicHardwareDriver/firmware/qti_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/qti_wpd_enabled.bs2 deleted file mode 100644 index fdfdff7c..00000000 --- a/wpd/WpdBasicHardwareDriver/firmware/qti_wpd_enabled.bs2 +++ /dev/null @@ -1,63 +0,0 @@ -' Qti_wpd_enabled.bs2 -' -' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -' PARTICULAR PURPOSE. -' -' Copyright (c) Microsoft Corporation. All rights reserved -' -' {$STAMP BS2} -' {$PBASIC 2.5} -' ========================================================================= - -' -----[ I/O Definitions ]------------------------------------------------------ -LineSnsrPwr CON 10 ' line sensor power -LineSnsrIn CON 9 ' line sensor input - -' -----[ Constants ]------------------------------------------------------------ -'CLREOL CON 11 ' clear to end of line (DEBUG) - -' -----[ Variables ]------------------------------------------------------------ -Sense VAR Word ' sensor raw reading - -SensorID VAR Byte 'Sensor identifier = 5 for PIR -ElementSize VAR Byte 'Size (in bytes) of each element -ElementCount VAR Byte 'Count of elements in packet -Padding VAR Byte 'Padding for the 8-byte element -NewInterval VAR Word 'New interval requested by user -Interval VAR Word 'Interval value utlized by firmware - -SensorID = 7 -ElementSize = 1 -ElementCount = 4 '4-bytes for sensor data -Interval = 200 -NewInterval = 200 - -LFD CON $10 'Linefeed character - -' -----[ Main Code ]------------------------------------------------------------ -Main: - - GOSUB PollSensor 'Retrieve sensor value - GOSUB RetrieveInterval 'Retrieve units data - -Timeout: - SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC4 Sense, DEC5 Interval, LFD] - GOTO Main - -PollSensor: - HIGH LineSnsrPwr ' activate sensor - HIGH LineSnsrIn ' discharge QTI cap - PAUSE 1 - RCTIME LineSnsrIn, 1, Sense ' read sensor value - LOW LineSnsrPwr ' deactivate sensor -RETURN - -RetrieveInterval: - SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval - IF NewInterval >= 10 AND NewInterval <= 60000 THEN - Interval = NewInterval - ENDIF - RETURN - diff --git a/wpd/WpdBasicHardwareDriver/firmware/temp_humidity_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/temp_humidity_wpd_enabled.bs2 deleted file mode 100644 index bc2982f7..00000000 --- a/wpd/WpdBasicHardwareDriver/firmware/temp_humidity_wpd_enabled.bs2 +++ /dev/null @@ -1,225 +0,0 @@ -' Temp_humidity_wpd_enabled.BS2 -' This program demonstrates the interface and conversion of SHT11/15 data -' to usable program values. This program uses advanced math features of -' PBASIC, specifically the ** operator. -' -' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -' PARTICULAR PURPOSE. -' -' Copyright (c) Microsoft Corporation. All rights reserved -' -' {$STAMP BS2} -' {$PBASIC 2.5} - -' -' ========================================================================= -' ------------------------------------------------------------------------- -' I/O Definitions -' ------------------------------------------------------------------------- -ShtData PIN 1 ' bi-directional data -Clock PIN 0 -' ------------------------------------------------------------------------- -' Constants -' ------------------------------------------------------------------------- -ShtTemp CON %00011 ' read temperature -ShtHumi CON %00101 ' read humidity -ShtStatW CON %00110 ' status register write -ShtStatR CON %00111 ' status register read -ShtReset CON %11110 ' soft reset -Ack CON 0 -NoAck CON 1 -No CON 0 -Yes CON 1 -DegSym CON 186 ' degrees symbol for DEBUG -' ------------------------------------------------------------------------- -' Variables -' ------------------------------------------------------------------------- -ioByte VAR Byte ' data from/to SHT11 -ackBit VAR Bit ' ack/nak from/to SHT11 -toDelay VAR Byte ' timeout delay timer -timeOut VAR Bit ' timeout status -soT VAR Word ' temp counts from SHT11 -tC VAR Word ' temp - Celcius -tF VAR Word ' temp - Fahrenheit -soRH VAR Word ' humidity counts -rhLin VAR Word ' humidity; linearized -rhTrue VAR Word ' humidity; compensated -status VAR Byte ' status byte - -'------------------------------------------------------------------------- -' WPD Variables -'------------------------------------------------------------------------- -SensorID VAR Byte 'Sensor identifier = 2 for Sensiron Temp/Humidity -ElementSize VAR Byte 'Size (in bytes) of each element -ElementCount VAR Byte 'Count of elements in packet -Padding VAR Byte 'Padding for the 8-byte element - -SensorID = 2 -ElementSize = 1 -ElementCount = 7 '4-bytes for temp, 3-bytes for relative humidity - -NewInterval VAR Word 'New interval requested by user -Interval VAR Word 'Interval value utlized by firmware - -LFD CON $10 'Linefeed character - -Interval = 2000 -NewInterval = 2000 - -' ------------------------------------------------------------------------- -' EEPROM Data -' ------------------------------------------------------------------------- -' ------------------------------------------------------------------------- -' Initialization -' ------------------------------------------------------------------------- -Initialize: -GOSUB SHT_Connection_Reset ' reset device connection -' ------------------------------------------------------------------------- -' Program Code -' ------------------------------------------------------------------------- -Main: - GOSUB SHT_Measure_Temp 'Retrieve temperature - GOSUB SHT_Measure_Humidity 'Retrieve humidity - GOSUB RetrieveInterval 'Retrieve interval data - -SendData: - SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC4 (tF), DEC3 (rhTrue), DEC5 Interval, LFD] - GOTO Main - -RetrieveInterval: - SERIN 16, 16468, Interval, SendData, [DEC NewInterval] 'Retrieve interval - IF NewInterval >= 10 AND NewInterval <= 60000 THEN - Interval = NewInterval - ENDIF -RETURN - -' ------------------------------------------------------------------------- -' Subroutines -' ------------------------------------------------------------------------- -' connection reset: 9 clock cyles with ShtData high, then start sequence -' -SHT_Connection_Reset: -SHIFTOUT ShtData, Clock, LSBFIRST, [$FFF\9] -' generates SHT11 "start" sequence -' _____ _____ -' ShtData |_______| -' ___ ___ -' Clock ___| |___| |___ -' -SHT_Start: -INPUT ShtData ' let pull-up take high -LOW Clock -HIGH Clock -LOW ShtData -LOW Clock -HIGH Clock -INPUT ShtData -LOW Clock -RETURN -' measure temperature -' -- celcius = raw * 0.01 - 40 -' -- fahrenheit = raw * 0.018 - 40 -' -SHT_Measure_Temp: -GOSUB SHT_Start ' alert device -ioByte = ShtTemp ' temperature command -GOSUB SHT_Write_Byte ' send command -GOSUB SHT_Wait ' wait for measurement -ackBit = Ack ' another read follows -GOSUB SHT_Read_Byte ' get MSB -soT.HIGHBYTE = ioByte -ackBit = NoAck ' last read -GOSUB SHT_Read_Byte ' get LSB -soT.LOWBYTE = ioByte -' Note: Conversion factors are multiplied by 10 to return the -' temperature values in tenths of degrees -tC = soT ** $1999 - 400 ' convert to tenths C -tF = soT ** $2E14 - 400 ' convert to tenths F -RETURN -' measure humidity -' -SHT_Measure_Humidity: -GOSUB SHT_Start ' alert device -ioByte = ShtHumi ' humidity command -GOSUB SHT_Write_Byte ' send command -GOSUB SHT_Wait ' wait for measurement -ackBit = Ack ' another read follows -GOSUB SHT_Read_Byte ' get MSB -soRH.HIGHBYTE = ioByte -ackBit = NoAck ' last read -GOSUB SHT_Read_Byte ' get LSB -soRH.LOWBYTE = ioByte -' linearize humidity -' rhLin = (soRH * 0.0405) - (soRH^2 * 0.0000028) - 4 -' -' for the BASIC Stamp: -' rhLin = (soRH * 0.0405) - (soRH * 0.002 * soRH * 0.0014) - 4 -' -' Conversion factors are multiplied by 10 to return tenths -' -rhLin = (soRH ** $67AE) - (soRH ** $83 * soRH ** $5B) - 40 -' temperature compensated humidity -' rhTrue = (tc - 25) * (soRH * 0.00008 + 0.01) + rhLin -' -' Conversion factors are multiplied by 10 to return tenths -' -- simplified -' -rhTrue = (tC - 250) * (soRH ** $34) + rhLin -RETURN -' sends "status" -' -SHT_Write_Status: -GOSUB SHT_Start ' alert device -ioByte = ShtStatW ' write to status reg cmd -GOSUB SHT_Write_Byte ' send command -ioByte = status -GOSUB SHT_Write_Byte -RETURN -' returns "status" -' -SHT_Read_Status: -GOSUB SHT_Start ' alert device -ioByte = ShtStatW ' write to status reg cmd -GOSUB SHT_Read_Byte ' send command -ackBit = NoAck ' only one byte to read -GOSUB SHT_Read_Byte -RETURN -' sends "ioByte" -' returns "ackBit" -' -SHT_Write_Byte: -SHIFTOUT ShtData, Clock, MSBFIRST, [ioByte] ' send byte -SHIFTIN ShtData, Clock, LSBPRE, [ackBit\1] ' get ack bit -RETURN -' returns "ioByte" -' sends "ackBit" -' -SHT_Read_Byte: -SHIFTIN ShtData, Clock, MSBPRE, [ioByte] ' get byte -SHIFTOUT ShtData, Clock, LSBFIRST, [ackBit\1] ' send ack bit -INPUT ShtData ' release data line -RETURN -' wait for device to finish measurement (pulls data line low) -' -- timeout after ~1/4 second -' -SHT_Wait: -INPUT ShtData ' data line is input -timeOut = No ' assume no timeout -FOR toDelay = 1 TO 250 ' wait ~1/4 second -IF (ShtData = 0) THEN EXIT -PAUSE 1 -NEXT -IF (toDelay = 250) THEN timeOut = Yes ' loop completed = timeout -RETURN - -' reset SHT11/15 with soft reset -' -SHT_Soft_Reset: -GOSUB SHT_Connection_Reset ' reset the connection -ioByte = ShtReset ' reset command -ackBit = NoAck ' only one byte to send -GOSUB SHT_Write_Byte ' send it -PAUSE 11 ' wait at least 11 ms -RETURN
\ No newline at end of file |
