oSerialPort Object

Main Index
Object List
Back to top of pageDescription:
 Provides a high-speed asynchronous serial I/O port with a 4-byte buffer.
 The following table lists the size and availability of the oSerialPort Object.
 ObjectSizeDescriptionA1A2B1B2C1
oSerialPort10 BytesProvides a high-speed asynchronous serial I/O port with a 4-byte buffer.xxxx
Back to top of pageOperation:
 

When a value is written to the Value property the value is sent serially out I/O Line 22 and when a value is received serially from I/O line 23 it is stored in a 4-byte buffer and the Received property is set to 1 (cvTrue). After the Received  property is set to 1 (cvTrue). Reading the Value property will read a byte out of the 4-byte buffer in a first-in-first-out fashion. If only one byte was in the buffer as the time that is was read then the Received property is set to cvFalse.

The value of the Received property can be link to an oDio1 Object that has its Direction property set to cvOutput thereby providing flow control for incoming serial data.  The device sending the serial data will be expected to stop sending the serial data while the output of the oDio1 Object is at +5 Volts.  If the device sending the serial data sends more than 3 bytes after the Received property is set then the 4-byte buffer will be overrun and data will be lost.

The Baud property specifies at which baud rate to send and receive data .  It can specify a baud rate of 1200, 2400, 4800, 9600, 19200, 31500, 38400, or 50000 Baud.

The serial input and output signals are TTL level signals providing 0 and 5 volts. Conversion to RS232 signals can be done with a TTL to RS232 signal converter chip such as the SN75188 or the MAX203 which will provide the voltage conversion to the RS232 levels of +12 and -12 Volts as well as providing the required signal inversion.

CAUTION: do not connect RS232 signals lines directly to the ooPIC's TTL level I/O.  The higher voltage of the RS232 lines will damage the TTL level circuitry.

When created, the oSerialPort Object also creates an instance of the oSerialH object which it uses to do the actual serial transmissions and receptions.  Most properties of the oSerialH instance can be adjusted and will affect the oSerialPort Object's operation. See the oSerialH Help for more detail on how serial data transmissions are made and received.

Each dimensioned instance of the oSerialPort Object internally uses this single serial communications module and thus only one instance may be active at any given time. Setting the Operate property to 1 activates an instance of the oSerialPort Object and will deactivate any other object that also uses the serial communications module which were previously activated.

Back to top of pageProperties:
 

The following table lists the properties of the oSerialPort Object:

Property

Description

Value
The value of the received data. If written to, transmits data.
Object Class: oFIFO4 Value Range: 0 - 255
Data Type: Numeric Default Value: 0
The Value property is a First-In-First-Out (FIFO) Object.  This object holds up to 4 bytes of data from the serial port which returns the the first byte received first and the last byte received last.
Received
A value that indicates if data has been received.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Set when 8 bits of data have been successfully received.
Cleared when the last byte of the 4-byte buffer is read via the Value property.
ReceivedConstantDescription
0cvFalseNo new data has been received.
1cvTrueNew data has been received.
IOLineF
A value that specifies which I/O Line to use for Flow Control.
Object Class: oIOLine Value Range: 0 - 31
Data Type: Numeric Default Value: 0
The IOLineF property is available as of Firmware version C.1.0.
Some I/O Lines have special purposes.  Be sure to see oIOLine help file for details.
Baud
A value that specifies the baud rate which controls the speed of the serial data stream.
Object Class: oProperty Value Range: 0 - 15
Data Type: Numeric Default Value: 0
When the Baud rate property is set, the Operate is checked.  If the Operate property is 1, then the Baud rate is set into the serial communications module's baud rate register.  If the Operate property is 0, then the serial communications module's baud rate register remains unchanged until the Operate property is set to 1.
The following table lists the values of the Baud property:
BaudConstantDescription
0cvMidiSerial data communicates at 31,250 Baud. (Midi)
1cv1200Serial data communicates at 1200 Baud.
2cv2400Serial data communicates at 2400 Baud.
3cv9600Serial data communicates at 9600 Baud.
4cv19200Serial data communicates at 19,200 Baud. (Available as of firmware version B.1.0)
5cv4800Serial data communicates at 4800 Baud. (Available as of firmware version B.1.0)
6cv50000Serial data communicates at 50,000 Baud. (Available as of firmware version B.1.0)
7cv38400Serial data communicates at 38,400 Baud. (Available as of firmware version B.2.0)
Operate
A value that selects whether or not serial data will be received or sent.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe serial port is not operating.
1cvOnThe serial port is operating at the specified baud rate.
Serial
The I/O object used that provides the serial I/O functions.
Object Class: oSerialH Value Range: 0 - 255
Data Type: Numeric Default Value: 0
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of pageExamples:
 In the following example, the oSerialPort Object is used to store incoming serial data into an EEPROM that is plugged into the E1 socket.
' This program uses an oSerialPort Object pointed to an
'  oDio1 Object for CTS flow control on I/O Line 18.
' First it sends "Hello" out the serial port.
' Second it stores all incoming serial data to
'  an EEPROM that is plugged into the E1 Socket.

Dim S As New oSerialPort
Dim W As New oWire
Dim CTS As New oDIO1
Dim E As New oEEProm

Sub Main()
  CTS.IOLine = 18
  CTS.Direction = cvOutput
  E.Node = cvE1
  E.Location = 0
  S.Baud = cv9600
  S.Operate = cvTrue
  W.Input.Link(S.Received)
  W.Output.Link(CTS.State)
  W.Operate = cvTrue
  S.Value = "Hello"
  Do
    If S.Received Then
      E.Value = S.Value
    End If
  Loop
End Sub
Back to top of pageConnections:
 Serial-out Line is I/O Line 22
Serial-in Line is I/O line 23
In Firmware A1 to B2, CTS Flow Control is handled by a link to a oDio1.

Back to top of pageRelated Items:

 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oSerialHProvides a high-speed asynchronous serial I/O port using hardware specific I/O lines.xxxxx
oSerialLProvides a low-speed asynchronous serial Input or Output on any I/O line.xxx
oSPILProvides a low-speed Serial Peripheral Interface on any I/O line.xx
Back to top of pageVersion History and Bug List:
 Firmware Ver A.2.0: Introduced.
Firmware Ver B.1.0: 19200, 4800, and 50000 baud added.
Firmware Ver B.2.0: 38400 baud added.
Firmware Ver C.1.0: The IOLineF property was added.

The property ReceivedOut is no longer supported.  It has been replaced with the IOLineF property in Firmware C1.

Bugs: No known bugs.


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.