-----Original Message-----
From: Jon Kreft <JKreft@concentric.net>
To: basicstamps@egroups.com <basicstamps@egroups.com>
Date: Tuesday, May 23, 2000 11:36 PM
Subject: Re: [basicstamps] BS2, Serout and Visual Basic
>Why cant I
· remove any of the text
· " The Temperature is"
· from the serout
> command
· without
· messing
· up
· the way
· the data
· is received by my
program?
You have the .InputLen set to 5 which limits you to read 5 bytes. Each
character is going to be a byte.
So if you decrease the length of your string
· " The Temperature is" then
Mid(Data, 1, 1) <> "s"
· will never see the "s" in the first position. If
your going to do it this way I would set the .InputLen value to 1 and read
just the first character until you find the "s", then you could just
continue reading in one byte at a time concatenating it in a variable and
then updating the screen when you find the " ". The problem with this is you
may continue to get more data in the buffer while you are reading as well as
have more than one reading in the buffer. If the stamp is only sending every
few seconds this probably won't be an issue.
The oncomm event maybe a better technique, although I have not had the
occasion to use it. You would need to have your string sent at a fixed
length such as
serout 16,16468,["T=",dec ftemp, " "]
where ftemp would be a 3 digit number string such as "005". Then set your
on_Comm trigger which is MSComm1.RThreshold = 6 so it triggers the onComm
event when it receives 6 bytes.
I have interfaced with a programmable temp controller that took the temp set
point as (setpoint*10)+1000. The 1000 allowed the temperature to always be 4
digits and the *10 removed the decimal. Once the controller got the string
it converted the value back to its original form by reversing the process.
The controller also reported values in the same way which made communicating
with it pretty easy. All I had to do was look for a 4 character string and a
return. If you have free memory space in the stamp maybe you could use the
same technique.
Hope this helps
Jon Kreft
Engineering Technician
St. Jude Medical CRMD
----- Original Message -----
From: <
samhell@samhell.com>
To: <
basicstamps@egroups.com>
Sent: Tuesday, May 23, 2000 7:26 PM
Subject: [basicstamps] BS2, Serout and Visual Basic
> I am having a problem using data from a BS2,
· that
·· is
· coming
· from a
BOE
> that has
· a photodiode and AD592
· from the Earth Measurements kit....the
> problem
· is
· that right
· now,
· the code
· works
· as needed,
· but
· I dont
> understand why.
· Here
· is the relevant part
· of
· my
· BS2
· code
>
////////////////////////////////////////////////////////////////////////////
> /////////////
> serout 16,16468,[" Temperature is",dec ftemp, " "]
>
////////////////////////////////////////////////////////////////////////////
> /////////////
> ( taken straight from the
· Parallax manual,
· I'm
· no pioneer )
> (Ftemp of course, is my variable name for F temperature)
>
> here
· is the relevant part of the VB 6
· code
> //////////////////////////////////////////////////////////////////////////
> Private Sub cmdcon_Click()
> 'error trapping
> If MSComm1.PortOpen = True Then
> Exit Sub
> End If
> 'Comm port
> MSComm1.CommPort = cbocomm.ListIndex + 1
> MSComm1.Settings = "9600,N,8,1" ' 9600 baud, no parity, 8 data, and 1 stop
> bit.
> MSComm1.InputLen = 5 ' read entire buffer
> MSComm1.RThreshold = 5
> MSComm1.InBufferSize = 12
> MSComm1.PortOpen = True ' Open the port.
> End Sub
>
>
> Private Sub Timer1_Timer()
> Dim data As String
> Data = MSComm1.Input
>
···· If Mid(Data, 1, 1) <> "s" Then
>
···· MSComm1.InputLen = 1
>
···· Do While start <> "s"
>
···· start = MSComm1.Input
> Loop
> StatusBar1.SimpleText = "Connected"
> MSComm1.InputLen = 8
> temp = Mid(Data, 1, 4)
> ////////////////////////////////////////////////////////////////////////
>
> Why cant I
· remove any of the text
· " The Temperature is"
· from the serout
> command
· without
· messing
· up
· the way
· the data
· is received by my
program?
> I have
· poured
· over
· the manual
· in the serout section
· but
· cannot
· seem
> to get
· this
· to work right.
· Strangely
· enough,
· this
· code
· that you see
> will
· make
· the temperature update
· a textbox
· in real time......without
> any
· of
· the
· goofy
· text
· thats
· in the
·· serout
· command......just
· the
> correct
· numbers!
>
> BUT!
· If
· I remove any
· or
· all
· of the
· text
· from the serout command,
· I
> then
· get
· all sorts
· of
· garbage text,
· sometimes
· bits
· and
· pieces
· of
> "The Temp is",
· and
· sometimes
· it
· crashes
· the app
· without
· connecting
> at all!
· I have
· tried
· to understand
· how
· this
· could
· work...but
· have
> run out of things
· to try.
> Can someone help me on
· the serout command,
· because
· I think thats
· where
> the problem lies.
>
>
> Dave
>
>
>
>
>
Bookmarks