Tuesday, April 1, 2008

Re: [oopic] Strange serial operations

I am using type S, ver B.2.2+. If I send data serially to the OOPic from
my PC, it all seems to work fine. The manual for the load cell display
that I am using states that "Data from MSG (Mars Scale Display) is
always terminated by CR." In Hyperterminal, that CR causes a line feed
and a character return. Is that messing with the OOPic? You'll see that
I "clear" the buffer with a series of ascii values before I send the
scale display's data to the oopic to help determine what's going on.
Sometimes the returned buffer values include a character return,
sometimes it also has a line feed but never both at the same time and
never the complete "kg" or "lb" unit.

ooPIC.Snode=1
Dim Serial As New oSerialPort
Dim In As New oDIO1 'input to trigger serial output
Dim LED As New oDIO1
Dim buffer As New oBuffer(30)
Dim i As Byte

Sub Main()
In.IOLine=26
In.Direction=cvInput
LED.IOLine=25
LED.Direction=cvOutput

Serial.Baud = cv9600
Serial.Operate = cvTrue

buffer.Location=0
For i = 0 To 30
buffer.Value=i+48
buffer.Location=buffer.Location+1 'buffer does not automatically
advance, in contradiction to online manual
Next i
buffer.Location=0

Do
If Serial.Received = 1 Then
LED.State.Invert
buffer.Value=Serial.Value
buffer.Location=buffer.Location+1
LED.State.Invert
End If

If In=1 Then
Wait Until In=0
LED.State.Invert
buffer.Location=0
For i = 1 To 20
Serial.Value=buffer.Value
buffer.Location=buffer.Location+1
Next i
buffer.Location=0
For i = 0 To 30
buffer.Value=i+48
buffer.Location=buffer.Location+1
Next i
buffer.Location=0
LED.State.Invert
End If
Loop
End Sub


ooPIC Tech Support wrote:
>
> What type of ooPIC are you using? Can you post some code?
>
> thanks,
> DLC
>
> m_elias wrote:
> > I'm using a TTL to RS232 converter to communicate with a load cell
> > scale Display. Sending commands to the Display works as expected but
> > receiving has some unexpected results. I can successfully communicate
> > with both OOPic and Display from my PC without any hardware control,
> > which is how I have the OOPic to Display setup. I am using the
> > oSerialPort object and my program copies the serial.value to
> > buffer.value as soon as the serial.received goes high. An example of
> > the value that is being sent to the OOPic from the Display is within
> > the quotes, " 0.355 kg" followed by a crlf. The leading
> > spaces/blanks and the numbers seem to consistently make it, but only 1
> > trailing space follows with a couple random characters, often either
> > ascii value 223 or 164. I can't see any reason why it should be a
> > buffer overrun. There is nothing else going on at the same time.
> > Anyone have any suggestions/experience with the OOPic's serial UART?
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>
> --
> ------------------------------------------------------
> Dennis Clark ooPIC Tech Support
> www.oopic.com
> ------------------------------------------------------
>
>

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:

http://groups.yahoo.com/group/oopic/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:

http://groups.yahoo.com/group/oopic/join

(Yahoo! ID required)

<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

http://docs.yahoo.com/info/terms/

No comments:

Post a Comment