oSerial Object
An Object that provides an asynchronous serial I/O port.
Description:
 A Hardware Object that encapsulates the OOPic's serial communication (SC) module which uses 1 Input line and 1 Output line of the OOPic's thirty-one Input/Output Lines and transmits and receives serial data at a specified baud rate.
Operation:
 When a value is written to the Value property, the value is sent serially out I/O Line 22. When a value is received serially from I/O line 23 it is stored in the Value property and the Received property is set to cvTrue. After the Received property is set to cvTrue, reading the Value property will clear the Received property to cvFalse.

The Baud property specifies at which baud rate to send and receive data .  It can specify a baud rate of 31500, 1200, 2400, or 9600 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 Volts 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 burnout the TTL level circuitry.

The serial communication (SC) module provides a high-speed serial communication port capable of communicating at 1200, 2400, 9600, and 31500 BPS. It can be configured as full duplex asynchronous or synchronous and can communicate with serial devices such as CRT terminals and personal computers. It uses the standard non-return-to-zero (NRZ) format asynchronous mode (one start bit, eight data bits, and one stop bit). The SC module transmits and receives the lowest significant bit first. The SC module’s transmitters and receiver are functionally independent but use the same data format and baud rate.

Each dimensioned instance of the oSerial 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 oSerial Object and will deactivate any other oSerial and oSerialPort Objects that were previously activated. 

Remarks:
 One physical serial port is implemented within the OOPic.

The oSerial Object does not provide flow control.  It is recommended that applications that require flow control of steaming data use the oSerialPort or the oSerialX Object.  The oSerialPort and the oSerialX Objects have flow control properties and the oSerialPort Object uses a buffer for incoming data. 

Storage size & Availability:
 

The following table lists the size and availability of the oSerial Object:

ObjectSizeVersion
oSerial4 BytesA.1.0 and greater
Properties:
 The following table lists the Properties of the oSerial Object:
PropertyDescription
AddressReturns a pointer to the address of the oSerial Object instance.

Data-Type: Number-Pointer ,Read-Only

Data-Range: 0 - 127

BaudA value that specifies the baud rate of the serial port.

Data-Type: Nibble

Data-Range: 0 - 3

The following table lists the values of the Baud Property:

BaudConstantDescription
0cvMidiThe UART communicates at 31,250 Baud. (Midi)
1cv1200The UART communicates at 1200 Baud.
2cv2400The UART communicates at 2400 Baud.
3cv9600The UART communicates at 9600 Baud.
ModeA value that specifies if the serial port operates synchronous or asynchronous.

Data-Type: Bit

Data-Range: 0 - 1

The following table lists the values of the Mode Property:

ModeConstantDescription
0 The serial port operates asynchronous
1 The serial port operates synchronous
OperateA value that specifies whether or not the oSerial Object will receive or send data.

Data-Type: Bit Flag

Data-Range: 0 - 1

The following table lists the values of the Operate Property:

OperateConstantDescription
0cvOffThe serial port is not operating
1cvOnThe serial port is operating at the specified baud rate.
ReceivedA value specifying if a byte of data has been received. Set when 8 bits of data have been successfully received. Cleared when the Value property is read.

Data-Type: Bit, Flag

Data-Range: 0 - 1

The following table lists the values of the Received Property:

ReceivedConstantDescription
0cvFalseNo new data has been received.
1cvTrueNew data has been received.
StringThe Value property represented as a string.

Note: The String property is available in OOPic Basic Version 2

Data-Type: String

TransmittingA value specifying if the serial port's transmit buffer is full. Set when the Value property is written to. Cleared when the 8 bits of data has begun to transmit. Any write to the Value property when Transmitting is 1 will be ignored.

Data-Type: Bit, Flag, Read-Only

Data-Range: 0 - 1

The following table lists the values of the Transmitting Property:

TransmittingConstantDescription
0cvFalseNo data is currently being sent.
1cvTrueData is currently being sent.
ValueThe value of the received and transmitted data. If written to the data is sent serially through the UART's transmit line located on I/O line 22. If read it returns the last data received by the UART through the receive line located on I/O line 23.

Data-Type: Byte, Default

Data-Range: 0 - 255

Example:
 In the following examples, the oSerial Object is used

'This program reads an oA2D Object
'and sends the value to a PC 
'connected via a serial port.
'Note: No flow control is used.

Dim A As New oSerial
Dim B As New oA2D

Sub Main()
  B.IOLine = 1
  B.Operate = cvTrue
  A.Baud = cv9600
  A.Operate = cvTrue
  Do  
    A.String = Str$(B)
    A.Value = 13
    A.Value = 10
  Loop
End Sub

'This program takes any serial
'data that a oSerial Object 
'has received and sends it
'back out the oSerial Object.
'Note: No flow control is used.

Dim A As New oSerial

Sub Main()
  A.Baud = cv9600
  A.Operate = cvTrue
  Do  
    If A.Received = cvTrue then
      A.Value = A.Value
    End If
  Loop
End Sub
See Also:
 oSerialPort - A hardware based serial port with a buffer.
oSerialX - A serial port that can use any I/O line.