Shop OBEX P1 Docs P2 Docs Learn Events
Interfacing Basic Stamp 2 and Labview — Parallax Forums

Interfacing Basic Stamp 2 and Labview

FardeenFardeen Posts: 9
edited 2004-12-17 03:32 in BASIC Stamp
Has anyone worked on a project that involves the BS2 and Labview??
I·got the below code from one of the manuals for BS2 and can see the output of the ADC0831 (8 bit analog to digital converter) on the DEBUG screen of the Stamp Editor.
****************************************************************

'{$STAMP· BS2}······· 'STAMP directive (specifies a BS2)
'
[noparse][[/noparse] Initialization ]
CS CON 2
CLK CON 1
RD1 CON 0········ ' Read Signals via Specified Pins
TD16 CON 16······ ' Transmit data serially
baud CON 16624··· ' N9600 for BS2
sig VAR Byte···· ' Bytes to store the signals
DEBUG CLS········ ' Start display.
looping:

'
[noparse][[/noparse] Declarations ]
adcBits VAR Byte
v VAR Byte
r VAR Byte
v2 VAR Byte
v3 VAR Byte

'
[noparse][[/noparse] Main Routine ]
GOSUB RDSIG1········· ' Read the signal
GOSUB Calc_Volts···· ' Calculate the signal in voltage form
GOSUB Display········ ' Display the results
SEROUT TD16, baud, [noparse][[/noparse]RD1]
GOTO looping

'
[noparse][[/noparse] Subroutines ]
RDSIG1:
HIGH CS
LOW CS
LOW CLK
PULSOUT CLK, 210
SHIFTIN RD1,CLK,MSBPOST,[noparse][[/noparse]adcBits\8]
RETURN

Calc_Volts:
v = 5 * adcBits / 255
r = 5 * adcBits // 255
v2 = 100 * r / 255
v3 = 100 * r // 255
v3 = 10 * v3 / 255
IF (v3 < 5) THEN skip_a_line
v2 = v2 + 1
skip_a_line:
IF (v2<100) THEN skip_out
v = v + 1
v2 = 0
skip_out:
RETURN

Display:
DEBUG HOME
DEBUG "8-bit binary value: ", BIN8 adcBits
DEBUG CR, CR, "Decimal value: ", DEC3 adcBits
DEBUG CR, CR, "DVM Reading: "
DEBUG DEC1 v, ".", DEC2 v2, " Volts"
RETURN
PAUSE 1000
RETURN

**********************************************************************


When I try to send this data via serial cable RS232 to analyse and display the results in Labview, I am not able to read the data coming out of it.
I am getting an error message during VISA READ and timeout expired before the completion of operation.
Can anybody advice what I might be doing wrong???
I have attached my Labview file along with. It is simply supposed to receive 8 bits, convert them to decimal value and do some math on it to get the required display.

There are 4 connections between BS2 and RS232 namely SOUT, SIN, ATN, VSS on one end while the other end goes into the COM port.

Comments

  • edited 2004-12-17 03:32
    There are some articles on the Parallax site on how to use LabView with the BASIC Stamp 2.· You can use the Search field on the Parallax home page to find them.· Make sure to select Downloads from the Search menu (not Products·& Part #s).· Enter LabView into the search field, click "Go",·then look for the article by Clark Radcliffe.
Sign In or Register to comment.