Shop OBEX P1 Docs P2 Docs Learn Events
serial out issues w/ usb — Parallax Forums

serial out issues w/ usb

HieroHiero Posts: 1
edited 2008-05-02 15:51 in BASIC Stamp
Hello I am currently trying to get my basic stamp in conjunction with the DLS 190 to read the current temperature and send it via serial out to a wireless chip. I have been unable to see what the serial out is producing due to a weird error saying the "com port is currently occupied" so I can't see my debug window let alone what is being sent out pin 1 (serout). My application is to use the board of learning to program the BS2 and then transfer it over to a carrier board for connection to the wireless chip. Below is a copy of my program. Any help would be much appreciated.

Another issue is that when I turn the board off and on again it only part of the time starts reading and sending data (blinking red led) not sure if my program needs some sort of starting clause or not.

Side question w/ some relivance. Should I change the value of Dsdata from a Var Word to BIN, if I am sending it out via serial?

' {$STAMP BS2}
' {$PBASIC 2.5}

'W.E.S.N temperature sensor configurartion
'Chirs Russo
'March 1, 2008.


'==========Definde Pins and Variables=============

DQ CON 11 'Pin 11 <=>DQ.
CLK CON 10 'pin 10 => CLK
RST CON 9 'pin 9 => (high = active)
DSdata VAR Word 'Word variable to hold 9bit data
Sign VAR DSdata.BIT8 'sign bit of raw temperature data
T_sign VAR Bit 'saved sign bit for converted temperature

'==============Define DS1620 Constatns ==============

'>>> Constants for cinvitureing the DS1620
Rconfig CON $AC 'protocol for read congiguration
Wconfig CON $0C 'Protocol for write congiguration
CPU CON %10 'Config bit: Serial Thermometer mode
NoCPU CON %00 'Config bit: standalone thermostat mode.
OneShot CON %01 'Config bit: one vonversion per start reequest
CONT CON %00 'Config bit: continuous conversions after start

'>>> Constatnts for Serial thermometer applications
StartC CON $EE 'protocol for 'start converstion'
StopC CON $22 'protoclol for 'stop conversion'
Rtemp CON $AA 'protocol for 'read temperature'

'>>> Constants for programing thermostat functions
RhiT CON $A1 'Protocol for Reatd High-Temperature setting
WhiT CON $01 'protocol for Write High-Temperature setting
RloT CON $A2 'Protocol for Read Low-temperature setting
WloT CON $02 'Protocol for Write Low-Temperature setting

'============= Begin Program ============

LOW RST 'deactivate '1620 for now
HIGH CLK 'put clock in starting state
PAUSE 100 'catch breath and settle for a moment
HIGH RST 'activate the 1620 and set for continuous
SHIFTOUT DQ,CLK,LSBFIRST,[noparse][[/noparse]Wconfig,CPU+Cont] 'Temp conversions.
LOW RST 'Done--deactivate
PAUSE 50 'Wait for the EEPROM to self program
HIGH RST 'Now activate it againd and send the...
SHIFTOUT DQ,CLK,LSBFIRST,[noparse][[/noparse]StartC] 'send start conversion protocol
LOW RST 'Done, Deactivate

'The loop below continuously reads the latest temperature from
'the DS1620 temp sensor

again:
PAUSE 1000 'wate a second between readings.
HIGH RST 'activate the 1620
SHIFTOUT DQ,CLK,LSBFIRST,[noparse][[/noparse]Rtemp] 'request to reat temperature
SHIFTIN DQ,CLK,LSBPRE,[noparse][[/noparse]DSdata\9] 'get temperature reading
LOW RST
T_sign = Sign 'save the sign bit of the reading
DSdata = DSdata/2 'scale reading to whole degrees C
IF T_sign = 0 THEN no_neg1
DSdata = DSdata | $FF00 'EXTend sign bits for negative temps
no_neg1:
'DEBUG SDEC DSdata,"degrees C",CR 'Show signed temperature in C
DSdata = (DSdata */$01CC) 'Multiply by 1.8
IF T_sign = 0 THEN no_neg2
no_neg2:
DSdata = DSdata + 32

DEBUG SDEC DSdata, "degrees F",CR 'show signed temperature in F
SEROUT 1, 84, [noparse][[/noparse]DSdata]
GOTO again 'and the loop goes on...and on....and on...

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-05-02 15:51
    A COM Port in use error means that some other application has control of the COM port. This is often Palm/PDA software such as Active-Sync/Hot-Sync or even something like Weather Bug I have heard has some new features that can do this. In any event, you will need to determine what is taking over your port if you’re going to need reliable communication on it. Whatever is taking over the port may also be affecting the DTR line, which could end up resetting your module. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.