Serial Communication w/ the oopic

May 26, 2005 2 Replies

I've been having quite a bit of trouble getting the oopic microcontroler to communicate with my computer. I have a LabView program that sends a value, and the echo program provided with the oopic compiler echos it properly (so im fairly sure that the problem isnt on that end). The trouble comes when I try to make use of that data.



I've currently modified the Anounce program that comes with the oopic to beep a specific tone when it revieves a specific value. Its not working, and strangely enough when I add in the code to echo I get junk back.



I'm not very experienced with the oopic, and so have been very frustrated by this problem.


this is the code im using...



'This is the program that is in 'the OOPic-R when it is shipped



Dim A As New oFreq Dim B As New oDio1 Dim C As New oDio1 Dim D As New oDio1 Dim DataPass As New oSerial 'the serial port data Dim PassValue As New oByte 'a holding value that stores serial 'data



Sub Main() DataPass.Baud = cv9600 DataPass.Operate = cvTrue B.IOLine = 7 C.IOLine = 6 D.IOLine = 5 B.Direction = cvOutput C.Direction = cvOutput D.Direction = cvOutput B = 1 C = 1 D = 1 A.Beep(60000,10) A.Beep(61000,10) A.Beep(63000,10) B.Direction = cvInput C.Direction = cvInput D.Direction = cvInput Do If DataPass.Received = cvTrue Then PassValue.Value = DataPass.Value DataPass.Value = DataPass.Value 'the echo code If PassValue = 1 Then A.Beep(5000,5) A.Beep(51000,5) End If If PassValue = 2 Then A.Beep(47000,5) A.Beep(57000,5) End If If PassValue = 3 Then A.Beep(64000,5) A.Beep(51000,5) End If End If Loop End Sub



Amperage wrote: Here is what comes to mind:

Are you sending the ASCII code '1'? This is not the the number 1. The decimal number for the ascii value '1' = 49. When you get the value of oSerial with the .Value property, you are getting the decimal number. Similarly if you were to echo that value back, unchanged, you'd get a '1', but if you were to send the number 1 back, you'd get a control code displayed, not a number.

DLC

: I've been having quite a bit of trouble getting the oopic : microcontroler to communicate with my computer. I have a LabView : program that sends a value, and the echo program provided with the : oopic compiler echos it properly (so im fairly sure that the problem : isnt on that end). The trouble comes when I try to make use of that : data.

: I've currently modified the Anounce program that comes with the oopic : to beep a specific tone when it revieves a specific value. Its not : working, and strangely enough when I add in the code to echo I get junk : back.

: I'm not very experienced with the oopic, and so have been very : frustrated by this problem.

: this is the code im using...

: 'This is the program that is in : 'the OOPic-R when it is shipped

: Dim A As New oFreq : Dim B As New oDio1 : Dim C As New oDio1 : Dim D As New oDio1 : Dim DataPass As New oSerial 'the serial port data : Dim PassValue As New oByte 'a holding value that stores serial : 'data

: Sub Main() : DataPass.Baud = cv9600 : DataPass.Operate = cvTrue : B.IOLine = 7 : C.IOLine = 6 : D.IOLine = 5 : B.Direction = cvOutput : C.Direction = cvOutput : D.Direction = cvOutput : B = 1 : C = 1 : D = 1 : A.Beep(60000,10) : A.Beep(61000,10) : A.Beep(63000,10) : B.Direction = cvInput : C.Direction = cvInput : D.Direction = cvInput : Do : If DataPass.Received = cvTrue Then : PassValue.Value = DataPass.Value : DataPass.Value = DataPass.Value 'the echo code : If PassValue = 1 Then : A.Beep(5000,5) : A.Beep(51000,5) : End If : If PassValue = 2 Then : A.Beep(47000,5) : A.Beep(57000,5) : End If : If PassValue = 3 Then : A.Beep(64000,5) : A.Beep(51000,5) : End If : End If : Loop : End Sub

Beware, I don't know nothing about OOPIC, I'll just give some tries and at least you'll teach me something. :)

What about flow control, stop bit and data bit? Maybe you need to force them to the values used on the other side?

I don't understand what are you using this single-bit lines for. If they are pins used for RS232, then I don't understand where they are associated with the DataPass object.

Are you sure that this is a safe operation? I suppose that proprierty "Value" is a two-way channel, but maybe you can't write to itself without using a temporary variable.

tentatamente, Cthulhu

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required