Archive

Archive for the ‘Communications’ Category

Aug
19

 

“Serial Communications” is a comprehensive book which details various methods for implementing serial communications between a Microchip PIC microcontroller and an external device. Asynchronous serial communications is covered both by using an on-chip USART and by bit-bang methods. The RS-232 standard is explained. A discussion of synchronous serial communications includes the I2C (Philips Semiconductors), SPI (Motorola) and Microwire (National Semiconductor) protocols.


The Dallas Semiconductor 1-Wire bus is described. Many code examples are included as modules which will provide the basis for the readers own PIC microcontroller applications. By Roger Stevens (8-1/2 x 11″, 520 pages).








bullet

View Serial Communications Table of Contents

bullet

Download The Source Code For Serial Communications

Aug
19

Serial ports used to be easy to program on a PC. Then they got more complex, then unreachable. Now they can be made to look simple again.



Introduction


Anyone porting 16-bit serial communication code to 32-bit Windows NT or Windows 95 faces a common problem: the familiar methods of implementing communication are at the very least different and at the worst, no longer present. Some of the Win32 API function for setting up the communications port have not changed with respect to their Win16 counterparts. However, the functions used to open, close, read, and write to the port do not exist, nor do the messages generated by the driver when an I/O event occurs. If, like me, you move from 16-bit DOS right into 32-bit Windows, the change is even more pronounced, as you can no longer use an interrupt routine to perform serial communications and you must learn new methods of performing the required tasks of serial I/O.


Having said that, the Win32 API does offer improved support for communication devices. Win32 eliminates the need to deal with communication devices in a nonstandard way; it also eliminates the need to deal with the hardware directly. Instead, you perform serial communication with the standard Win32 file I/O functions. For those moving from 16-bit Windows, Table 1 lists the Win32 API equivalents for the 16-bit API functions.

 

































16-bit API Win-32 API
OpenComm CreateFile
CloseComm CloseHandle
FlushComm PurgeComm
GetComError ClearCommError
ReadComm ReadFile
WriteComm WriteFile
SetCommEventMask SetCommMask
GetCommEventMask GetCommMask
EnableCommEventNotification WaitComEvent*
UngetCommChar -None-
*WaitCommEvent will not post WM_COMMNOTIFY messages

Table 1: 16-bit Communication Functions and their Win32 Equivalents


While the Win32 API does make it simple to open a port and start sending and receiving data, I soon found that there is more to serial I/O than that. For example, as always, you must configure the port with the right set of options and timeout values for these operations to work as expected. This article presents a class that encapsulates the Win32 API functions used for serial communication and simplifies their use. This class also provides some member functions that make it easy to start and stop a separate thread for sending and receiving data. Some sample programs are included on the CUJ ftp site to demonstrate how the class can be used. (See p. 3 for instructions on downloading source code from CUJ.) I developed and tested the code using Borland C++ 5.01 and Visual C++ 4.2.


Class CSerialPort


Listing 1 (SerialPort.h) shows the class declaration for CSerialPort and its supporting definitions. The class consists of some protected data members that track the state of the object, a set of configuration functions, a set of I/O functions, and wrappers for the Win32 API functions relating to serial communication. The class also provides built-in support for overlapped I/O and for starting and stopping a separate thread to send and/or receive data via the port. More often than not, the basic class can be used as is unless there is a need for specialized read/write operations. In those cases, its fairly easy to derive a class from CSerialPort and override one or more of its virtual functions. This will enable you to set up customized, multithreaded, serial communications. To date, I have not needed the classs overlapped read/write features beyond the polled I/O support provided by the WaitCommEvent and CheckForCommEvent functions. Most of my applications have made good use of the StartCommThread function, though.


To create a communication object, simply pass its constructor the name of the port you want to open. By default CSerialPort initializes the port for 19,200 bps, no parity, eight data bits, one stop bit, hardware flow control, no read timeouts, one-second write timeouts, and enables monitoring of EV_RXCHAR events. Once the object is created, you can alter these settings with the configuration member functions shown in Table 2. The Win32 wrapper functions such as SetCommState, SetupComm, and SetCommTimeouts can be used if necessary, but the functions in Table 2 take care of many of the low-level details associated with initializing the required structures. Each of the functions in Table 2 also combines several steps into a single function call. Once the port is opened and configured, use the ReadCommBlock and WriteCommBlock member functions to send and receive data.

 





















Function Purpose
SetBaudRate Sets the baud rate (bps)
SetParityDataStop Change parity, data bits, stop bit settings
SetBufferSizes Change input/output buffer sizes used by Windows
SetReadTimeouts Change the read timeouts
SetWriteTimeouts Change the write timeouts
SetCommMask Specify which set of comm events to monitor

Table 2: CSerialPort Configuration Functions


Listing 2 (Terminal.cpp) shows the ubiquitous dumb terminal program, reworked to take advantage of the 32-bit environment and utilize the basic CSerialPort class. The DumbTerminal function calls the StartCommThread member function to start a separate thread to handle incoming serial data (signaled by the EV_RXCHAR communication events) while the main thread waits for keyboard input and writes it out to the port. Note that by allowing a separate thread to handle incoming serial port data you can eliminate the need to continuously poll for both forms of input in the main thread. Thus the application consumes less CPU time without the programmer expending any special effort.


TermPoll.cpp, included on the CUJ ftp site, is a less efficient implementation of Terminal.cpp that illustrates this point. In the TermPoll version, the Sleep function must be called to introduce a slight delay in the main loop. This prevents the CPU from reaching 100% continuous utilization. Using separate threads instead to send and recieve data especially makes sense in a GUI application; the main thread remains responsive to user-interface events.


A CSerialPort object can receive notification of certain communication events. To select which notifications your object will receive, use the SetCommMask member function. The events are specified by ORing together constants such as EV_RXCHAR, EV_ERR, etc. defined in WINBASE.H. When constructed, the class enables EV_RXCHAR automatically, so if thats the only notification you need, you dont need to call SetCommMask in your application.


Selecting which notifications the object is to receive is different than enabling the object to actually receive notification. After selecting the events of interest with SetCommMask, you must enable the object to receive notification by calling WaitCommEvent. (This situation is analogous to setting an interrupt mask and then later enabling interrupts by executing a special instruction.) I did not implement WaitCommEvent quite like its API equivalent in Win32. My version splits the APIcall into two separate functions. Member function WaitCommEvent should be used to enable notification; use CheckForCommEvent to see if any have occurred.


I implemented these functions this way to enable a program to either block while waiting for an event to occur (by calling CheckForCommEvent(TRUE)) or poll for events as needed (CheckForCommEvent(FALSE)). The return value is a bit mask of the events that have occurred; it is zero if none are available or an error occurred. As with the Win32 API, WaitCommEvent must be called again to re-enable event notification after CheckForCommEvent returns a value other than zero. Refer to the CommReader thread function in Listing 2 for an example of their use.

The GUITerm Example


The GUITerm example demonstrates the use of CSerialPort in an MFC application. It provides a dumb terminal much like the console mode example and it can also perform a basic XMODEM file transfer. This example also demonstrates stopping and restarting a thread function for the port object and a way to use timeouts on read operations. The application uses the document/view model. In this case, the document manages the serial port object and the view simply displays received data and passes key presses on to the document for transmission. When the Connect option is chosen, the document object opens the serial port and starts a thread to handle incoming data. This approach is similar to that of the Terminal.cpp example presented above. The difference here is that when data arrives, the receiver thread sends a WM_COMMDATA message (defined by the application as WM_USER + 500) to the view object, which causes it to insert the received data into the edit control used for display purposes. This application behaves somewhat like 16-bit Windows, in which the communications driver generates a WM_COMMNOTIFY event when data arrives.


The XMODEM protocol used for the file transfer requires specific timeout values for its read and write operations. The application temporarily alters the ports timeout settings for the duration of the transfer and resets them afterwards. Under Windows, all communications resources have an associated set of timeout parameters that affect the behavior of read and write operations. Timeouts can cause a read or write operation to finish even though the specified number of characters have not been read or written. When this occurs, it is not treated as an error. The read or write functions return value indicates success but the count of bytes actually read or written will be less than what was requested.


There are two types of timeouts: interval timeouts and total timeouts. Read operations can utilize either or both forms of timeout. Write operations only use total timeouts. An interval timeout occurs when the time between the receipt of any two characters exceeds a specified number of milliseconds. Timing starts when the first character is received and is restarted when each new character arrives. A total timeout occurs when the total amount of time consumed by a read or write operation exceeds a calculated number of milliseconds. Timing starts immediately when the I/O operation begins. The number of milliseconds is calculated as follows:

Total_Timeout = (Multiplier * Number_Of_Bytes) + Constant

The use of a multiplier value allows for longer timeouts based on the number of bytes being read or written. If you do not need both a multiplier and a constant, you can set the unwanted parameter to zero. If both parameters are zero, total timeouts are disabled for the given operation and the read or write will not return until all bytes have been read or written.


Table 3 summarizes the various values and combinations of valid read timeouts. Because read operations can utilize either or both forms, you must take extra care to ensure that they are set correctly for your application. Setting the read timeouts too low can result in a read operation stopping early and possibly giving the impression that data loss occurred. Setting timeouts too high usually is not a problem, especially when a separate thread is handling the receive operation. However, it may become a problem if the receiver thread is also responsible for other operations besides checking the port for incoming data. With a little experimentation, you can determine whether or not the classs default behavior of disabling read timeouts and setting the write timeout to one second is sufficient for your needs.

  I = Interval ms
T = Total ms (Multiplier * Bytes_Requested) + Constant

Interval Total Behavior
——————————————————
MAXDWORD 0 No read timeouts. Return immediately
with any available data.

MAXDWORD * Special case. If the interval and
multiplier values are both set to
MAXDWORD, and the constant is set to
any non-zero value less than MAXDWORD,
one of the following occurs:

If there are any characters in the
input buffer, return immediately with
those characters.

If there are no characters in the
input buffer, wait until a character
arrives and then return immediately.

If no character arrives within the
time specified by the constant value,
a timeout occurs.

0 0 Return only when the buffer is
completely filled. Timeouts are not
used.

0 T Returns when the buffer is completely
filled or when T milliseconds have
elapsed since the beginning of the
operation.

I 0 Returns when the buffer is completely
filled or when I milliseconds have
elapsed between the receipt of any two
characters. Timing does not begin
until the first character is received.

I T Returns when the buffer is completely
filled or when either type of timeout
occurs.

Table 3: Behavior of Read Timeout Value Combinations

Conclusion


This article and the example code cover the most common uses for the CSerialPort class. Instead of covering the remaining member functions in detail, I refer you to the appropriate Win32 online documentation provided with the compilers. The wrapper functions are identical in name and form except for the omitted handle parameter that the class manages internally. One final point worth mentioning is that the wrapper functions will keep track of any error code resulting from the call. The inline member function CSerialPort::GetLastError will return the proper error value even if your application has called other Win32 functions that alter what the API-level ::GetLastError returns.


To date, I have used CSerialPort to communicate with other PCs and modems as well as with hand-held data collection devices and cash registers. It is a versatile class in its own right and provides a solid foundation from which to build specialized serial communication classes. By letting CSerialPort handle the underlying details it also makes the transition from the 16-bit to the 32-bit platform a much easier task.

Jul
07

IEEE1394


IEEE1394, also called “FireWire”

“1394 right now is specified to run up to 400Mbits per second and 800Mbits in the future. It will be plug and cable backwards compatible. ”

Often used to transfer movies from digital camcorders machine_vision.html#digital_cameras machine_vision.html#IEEE-1394_digital_camera


    “Services is a big part of IT. Hardware is increasingly underappreciated, so it comes down to other factors like price or services,” Intelligent Businsess Research Services analyst Kevin McIsaac told ZDNet Australia.

    The company is also attempting to redefine itself in other ways. Dell recently acquired hosted e-mail archiving and security company MessageOne for $155 million. But perhaps its most significant move was the $1.4 billion acquisition of EqualLogic, a player in the nascent iSCSI storage market, repositioning the PC maker as an owner of storage IP for the first time, rather than simply a reseller.

Jul
07

Human beings have devised many activities which have been focussed on the basic purpose of getting the items that they need. Hence the barter system saw the light of a bright sunny day with the businesses now being the major as well as the latest form of the activities that human beings have undertaken for the purpose of earning money as it is the exchange item for the items that human beings who are operating these businesses. VoIP is becoming the latest form of technologies which are being used in providing services in the new form of carrying out businesses with the medium of internet.


A business VoIP solution is therefore, now being provided as an offer into most of the VoIP service provider websites. These offers are mainly focussed on the whole communication needs of the organisation with features being offered to serve the various needs of a business regarding communication that are likely to arise. Hence the offers that are being offered by the various VoIP solution providers have features which are concentrated on handling the system of communication on a large scale and that too at the same time.


The global scenario has seen a major shift in the processes that are being the primary part of business and communication has therefore assumed quite an important role for the working of businesses. VoIP business solution has hence, assumed one of the major features in most of the prevalent forms of business with some of them reaping in record number of profits and also many new innovative tools for businesses. One of them is a VoIP PBX System which enables the offices and branches residing in all the major corners of the world to have a common communication medium in the form of a sort of a ‘global intranet’.

Almost every organisation and individual can enhance its business sales or image by using these business solutions. VoIP has been the major technology behind these business solutions and has been quite successful in improving the performance of the businesses that are harvesting the features of this fantastic technology. The world is therefore now a frequent visitor to the field of excellence of businesses the money has started to flow in amounts which are larger than they have ever been as a result of the inclusion of this majestic technology.


There have been many features that have led to the success of VoIP solutions for business to become a success. The organisations which have been using this feature are able to boast of the satisfied feedbacks of the customers about the advanced level of the quality of calls that are being frequently made. Hence, the elements like poor sound quality and irritating echoes are no longer a part of any call made to a distant location where a business deal has to be finalised and hence, the employee is quite busy negotiating with the client and can take the feature of unnecessary hassles described above.


Therefore, the VoIP solution provider who is in the process of giving the magnificent services of VoIP to business organisations is liable to have a successful business of its own and with the performance being a habitual feature in most of the offers, large number of business establishments are harping the advantages in an effort to stay one step ahead of their rivals. A VoIP business solution is therefore, being used by almost all those businesses who have a dynamic character and are therefore, always involved in the process of either inventing or discovering new technologies and then using them to accomplish their needs regarding communication in a manner which is always viable to be better than others.


 

Jul
07

This experiment demonstrates how a serial data communication protocol can be successfully monitored. Serial data communications represents the fundamental method by which information is transported in our modern world.


Convergence between communications and computers has caused all forms of information to be digitized for easy transport in serial format. Unlike analog waveforms such as sine waves and square waves that are periodic in nature, serial data comm waveforms are generally aperiodic. Using a modern digital instrument such as the PICO ADC200/20 makes capture and viewing of serial data easy.

This experiment demonstrates:
This experiment is suitable for:

  • First introductory data communications course for college/university.
  • Electronics experimenter such as a amateur radio operator.

Equipment Required:



  • ADC200/20 scope, scope probe.
  • PC with serial port.
  • Terminal program such as Hyperterminal for Win95/98, Terminal Win3.1 or Telix Linux.

Safety

Always keep in mind that the ground of the ADC200/20 is common to the ground of the PC and thus common to AC ground.

Experimental Setup

The experimental setup is shown in Figure 1. Serial data is accessed from the serial port on a standard PC. The serial port is generally either a DB9 connector or DB25 connector. Figure 2 shows a picture of a standard PC DB9 type serial port. An appropriate serial cable consisting of female/male DB9 connectors is connected to this port.

The ADC200/20 CH A input is connected to the Transmit Data and Ground connections on the serial port via the serial cable. Note that you can use the same PC that the ADC200/20 is connected to for the serial transmission or you can use a standalone PC. Figure 1 shows separate PCs for convenience.


Showing the connection between the serial port and the ADC-200/20
Figure 1 Experimental Setup


A DB male connector used for serial communication
Figure 2 Photo of PC Serial Port DB Male Connector


Experimental Procedure

1. Terminal Software Setup

One of the simplest serial data comm protocols is sending ASCII characters via a PC terminal program. Several popular terminal programs exist, depending on the PC operating system  (Win95/98, Win3.1, Linux, DOS, etc). Let�s examine Hyperterminal that commonly comes as part of the Win95/98 operating system.


To access Hyperterminal, follow the Start Button:
Start/Programs/Accessories/Communications/HyperTerminal/Hypertrm.exe

Once you have located the Hyperterminal directory, find the Hypertrm program and double click it. The program screen is shown below in Figure 3.



The hyperterminal screen
Figure 3 Hyperterminal Screen


Now you must setup the terminal parameters. Under File, locate New Connection. Give the connection the name Picotech and click OK. The Connect To box appears. Select the Connect using parameter to Direct to Com1 (assuming that serial port used is Com1. Check with your PC manual for settings for serial port). Click OK. Next the Port Settings box appears.


Accept the parameters as listed below:


  • Bits per sec = 2400
  • Data bits = 7
  • Parity = none
  • Stop bits = 1
  • Flow control = hardware


Finally under File, go to the Properties parameter and select the Settings tab. Go to ASCII Setup
and check off the box Echo typed characters locally. Save all settings under Picotech.htm. The terminal program is now setup. The proper settings are shown below in Figure 4.


The hyperterminal and COMM port configuration
Figure 4 Hyperterminal Terminal Properties Setup


2. ADC200/20 Scope Setup

Once the terminal program is configured, we are ready to send serial data. The terminal program will send data via the serial port in RS-232 format. Figure 9 shows the pinouts of the DB9 and DB25 type RS-232 connectors commonly found on serial ports.


Connect the ADC200/20 scope probe with the center conductor connected to the Transmit Data Terminal #3 and the ground conductor to Ground Terminal #5. Note this setting is for a DB9 connector. Adjust accordingly for a DB25.


In order to capture the one time asynchronous signal, the scope must be set for one time trigger.


Set the instrument as follows:


  • TxData to Input A, +/- 20V, DC, Probe x 1, Input B off
  • Time base = 500usec/div
  • Trigger = single, Input A, rising, 1000mV, -10% delay

Note that the scope is set to trigger with a rising voltage > 1 volt on input A.

3. Sending Serial Asynchronous Data and Capturing Results

With the Terminal PC we are now ready to send and capture ASCII data. Try sending an ASCII G first. To do this, first set Cap Lock on the keyboard to on. Then simply press G. Ensure that the correct character is sent out, as it will echo on the Hyperterminal display. If you are using the same PC for both Terminal and the ADC200/20 display, you will have to size both windows so that they are visible.


Now in order to capture and display the result on the scope, hit the run button. The scope will now trigger with any voltage rising on input A >1 volt. Press the G again. You should see a display similar to Figure 5 below. Note the cursors have been set to measure the duration of the start bit.


Try another character, say the numeral 8. The display for 8 is shown in Figure 6. Note to clear the display press stop, then run again.



ADC-200/20 screen shot for the ASCII character code G
Figure 5 ASCII G As Displayed on ADC200/20



ADC-200/20 screen shot for the ASCII character code 8
Figure 6 ASCII 8 As Displayed on ADC200/20


Further Questions



  • Does the waveform shown in Figure 6 match what should be seen for ASCII 8 ?.
  • How wide would a bit be if the data speed was changed to 4800 bit/sec?.

Jul
07

4.1 Serial Communication


In the factory-default configuration, the TCP/IP Development Board has one RS-232 (3-wire) serial channel, one RS-485 serial channel, and one synchronous CMOS serial channel. The TCP/IP Development Board may be configured for 5-wire RS-232 or two 3-wire RS-232 channels. The exact configuration instructions depend on the version of the TCP/IP Development Board you have. This information is etched on the bottom side of the printed circuit board, or you can readily determine your version by examining the diagrams below to find the one that matches your board.

Version 175-0188 Rev. A & B


The RS-232 transceiver may be used as a 5-wire RS-232 channel or as two 3-wire RS-232 channels at the expense of the RS-485 channel by adding 0 W surface-mounted resistors at R61 and R62 as shown in Figure 6(a). The RS-485 chip (U10) and the associated bias and termination resistors (R58, R59, and R60) shown in Figure 7 must be removed when configuring the TCP/IP Development Board for either one 5-wire RS-232 or two 3-wire RS-232.





Figure 6(a). RS-232/RS-485 Serial Communication Options

Table 2(a) summarizes the options. Note that the parameters in the serMode software function call must also be set to match the hardware configuration being used.
















































    Table 2(a). Serial Communication Configurations (Version 175-0188 Rev. A & B)

    Item

    Factory Default

    One 3-wire RS-232
    & RS-485

    Two 3-wire RS-232

    One 5-wire RS-232
    R58-R60

    In
    Out
    Out
    R61-R62

    Out
    In
    In
    U10

    In
    Out
    Out
    J7-3 & J5-3

    RS-485+
    TxB
    TxB
    J7-4 & J5-4

    RS-485-
    RxB
    RxB
    J7-6

    TxC
    TxC
    RTS
    J7-7

    RxC
    RxC
    CTS


Version 175-0188 Rev. C


The RS-232 transceiver may be used as a 5-wire RS-232 channel or as two 3-wire RS-232 channels at the expense of the RS-485 channel, which is connected through 0 W surface-mounted resistors at R82 and R83 as shown in Figure 6(b). R82 and R83, shown in Figure 6(b), must be removed when configuring the TCP/IP Development Board for either one 5-wire RS-232 or two 3-wire RS-232. U10 and the associated bias and termination resistors (R58, R59, and R60) must also be removed, but R82 and R83 are left installed, if you wish the TxB and RxB RS-232 signals to be available on header J5.




Figure 6(b). RS-232/RS-485 Serial Communication Options

Table 2(b) summarizes the options. Note that the parameters in the serMode software function call must also be set to match the hardware configuration being used.











































































    Table 2(b). Serial Communication Configurations (Version 175-0188 Rev. C)

    Item

    Factory Default

    One 3-wire RS-232
    & RS-485

    Two 3-wire RS-232

    One 5-wire RS-232

    RS-232
    on J5
    R58-R60

    In


    Out
    R61-R62

    Out
    In
    In
    In
    R82-R83

    In
    Out
    Out
    In
    U10

    In
    In
    In
    Out
    J7-3

    RS-485+
    TxB
    TxB
    TxB
    J7-4

    RS-485-
    RxB
    RxB
    RxB
    J7-6

    TxC
    TxC
    RTS
    TxC or RTS
    J7-7

    RxC
    RxC
    CTS
    RxC or CTS
    J5-3

    RS-485+


    TxB
    J5-4

    RS-485-


    RxB


Version 175-0206


The RS-232 transceiver may be used as a 5-wire RS-232 channel or as two 3-wire RS-232 channels at the expense of the RS-485 channel, which is connected through jumpers across header JP7 as shown in Figure 6(c). The jumper configurations are shown in Figure 6(c).





Figure 6(c). RS-232/RS-485 Serial Communication Options

Table 2(c) summarizes the options. Note that the parameters in the serMode software function call must also be set to match the hardware configuration being used.





































































    Table 2(c). Serial Communication Configurations (Version 175-0206)

    Item

    Factory Default

    One 3-wire RS-232
    & RS-485

    Two 3-wire RS-232

    One 5-wire RS-232

    RS-232
    on J5
    Header JP7

    3-5
    4-6
    1-3
    2-4
    1-3
    2-4
    1-5
    2-6
    Header JP6

    1-2
    5-6


    No jumpers installed
    U10

    In
    In
    In
    Out
    J7-3

    RS-485+
    TxB
    TxB

    J7-4

    RS-485-
    RxB
    RxB

    J7-6

    TxC
    TxC
    RTS
    TxC or RTS
    J7-7

    RxC
    RxC
    CTS
    RxC or CTS
    J5-3

    RS-485+


    TxB
    J5-4

    RS-485-


    RxB


4.1.1 RS-232


The TCP/IP Development Boards RS-232 serial channel is connected to an RS-232 transceiver, U11. U11 provides the voltage output, slew rate, and input voltage immunity required to meet the RS-232 serial communication protocol. Basically, the chip translates the Rabbit 2000s 0 V to +Vcc signals to RS-232 signal levels. Note that the polarity is reversed in an RS-232 circuit so that +5 V is output as approximately -10 V and 0 V is output as approximately +10 V. U11 also provides the proper line loading for reliable communication.

The maximum baud rate is 115,200 bps. RS-232 can be used effectively at this baud rate for distances up to 15 m.


4.1.2 RS-485


The TCP/IP Development Board has one RS-485 serial channel, which is connected to the Rabbit 2000 Serial Port B through U10, an RS-485 transceiver. The chips slew rate limiters provide for a maximum baud rate of 250,000 bps, which allows for a network of up to 1200 m (or 4000 ft). The half-duplex communication uses the Rabbit 2000s PC0 pin to control the data enable on the communication line.


The RS-485 signals are available on pins 3 and 4 of header J7, and on J5, the RJ-12 jack.


The TCP/IP Development Board can be used in an RS-485 multidrop network. Connect the 485+ to 485+ and 485- to 485- using single twisted-pair wires (nonstranded, tinned).


Alternatively, the RS-485 multidrop network may be hooked up using cables with RJ-12 plugs. Note that the RJ-12 jack has +RAW_485 and GND, which means that only one TCP/IP Development Board needs to be connected to an external power source via an AC adapter. When doing so, ensure that the AC adapter has sufficient capacity for the network — each TCP/IP Development Board nominally draws 100 mA at 24 VDC.








CAUTION:
If you plan to connect a power supply to more than one TCP/IP Development Board in an RS-485 network using the RJ-12 jacks, rework the RS-485 cables so they do not connect +RAW_RS485 through the RJ-12 jack to the boards in the network.







NOTE The RS-485 port is available only in the factory default configuration. The RS-485 port will not be available when you select the configuration option for both 3-wire RS-232 ports or one 5-wire RS-232 port.


The TCP/IP Development Board comes with a 220 W termination resistor and two 680 W bias resistors installed and enabled with jumpers across pins 1-2 and 5-6 on header JP6, as shown in Figure 7.




Figure 7. RS-485 Termination and Bias Resistors

The bias and termination resistors in a multidrop network should only be enabled on both end nodes of the network. Disable the termination and bias resistors on the intervening TCP/IP Development Boards in the network by removing both jumpers from header JP6. Note that older versions of the TCP/IP Development Board do not have this jumper feature, and the surface-mounted bias and termination resistors shown in Figure 7 have to be removed in networks containing more than 10 TCP/IP Development Boards.


4.1.3 Programming Port


The TCP/IP Development Board has a 10-pin programming header labeled J4. The programming port uses the Rabbit 2000s Serial Port A for communication. The Rabbit 2000 startup-mode pins (SMODE0, SMODE1) are presented to the programming port so that an externally connected device can force the TCP/IP Development Board to start up in an external bootstrap mode.






NOTE Refer to the Rabbit 2000 Microprocessor Users Manual for more information related to the bootstrap mode.


The programming port is used to start the TCP/IP Development Board in a mode where the TCP/IP Development Board will download a program from the port and then execute the program. The programming port transmits information to and from a PC while a program is being debugged.


The TCP/IP Development Board can be reset from the programming port.

The Rabbit 2000 status pin is also presented to the programming port. The status pin is an output that can be used to send a general digital signal.


4.1.4 Serial Communication Software


Library files included with Dynamic C provide a full range of serial communications support. The RS232.LIB library provides a set of circular-buffer-based serial functions. The PACKET.LIB library provides packet-based serial functions where packets can be delimited by the 9th bit, by transmission gaps, or with user-defined special characters. Both libraries provide blocking functions, which do not return until they are finished transmitting or receiving, and nonblocking functions, which must be called repeatedly until they are finished. For more information, see the Dynamic C Users Manual and Technical Note 213, Rabbit 2000 Serial Port Software.

The following function calls are specific to the TCP/IP Development Board.







int serMode (int mode);




User interface to set up up serial communication lines for the TCP/IP Development Board. Call this function after serXOpen().
Parameters

mode is the defined serial port configuration of the devices installed.

























    Mode

    Serial Port

    B

    C

    0
    RS-485
    RS-232, 3-wire

    1
    RS-232, 3-wire
    RS-232, 3-wire

    2
    RS-232, 5-wire
    CTS/RTS

Return Value


0 if correct mode, 1 if not.
See Also

    serB485Tx, serB485Rx






void serB485Tx();




Sets pin 3 (DE) high to disable Rx and enable Tx.
See Also

    serMode, serB485Rx






void serB485Rx();




Resets pin 3 (DE) low to enable Rx and disable Tx.
See Also

    serMode, serB485Tx

4.1.4.1 Sample Serial Communication Programs

RS-232




  1. Connect RX to TX as shown in Figure 8 below.





Figure 8. TCP/IP Development Board Setup
for RS-232 Serial Communication Demonstration



  1. Connect the programming cable to header J4 on the TCP/IP Development Board. Apply power to the TCP/IP Development Board.



  2. Open the sample program SAMPLESICOMICOM232.C and press F9.


This program demonstrates a simple RS-232 loopback displayed in the Dynamic C STDIO window.

RS-485




  1. Connect 485+ to 485+, 485- to 485-, and GND to GND as shown in Figure 9 below. If you do not have a separate wall transformer for the other board, also connect PWR to PWR as shown in Figure 9.




Figure 9. TCP/IP Development Board Setup
for RS-485 Serial Communication Demonstration



  1. Connect the programming cable to header J4 on one TCP/IP Development Board. This will be the slave, the other board will be the master. Apply power to the TCP/IP Development Boards.



  2. Open the sample program SAMPLESICOMICOM485.C. You will find some code for the master, and some code for the slave. Copy and save the master and slave versions separately.



  3. Open the sample slave program and press F9.



  4. Connect the programming cable to header J4 on the master TCP/IP Development Board.



  5. Open the master program and press F9.


This program demonstrates a simple RS-485 transmission of lower-case letters to a slave. The slave will send back converted upper case letters back to the master, which then displays them in the Dynamic C STDIO window.

4.2 Digital I/O


4.2.1 Digital Inputs


Pins 8-11 on header J7 have the four digital inputs IN0-IN3. Each of the four digital 0 V to 5 V inputs is protected over a range of -36 V to +36 V. The TCP/IP Development Board is factory-configured for the digital inputs to be pulled up to +5 V, but the digital inputs can also be pulled down by moving the surface-mounted jumper at JP4. The jumper settings and the location of JP4 are shown in Figure 10.





Figure 10. Surface-Mounted Jumper Configurations for Selecting
Pullup/Pulldown on the Digital Inputs

4.2.2 Digital Outputs


Pins 12-15 on header J7 have the four digital outputs OUT0-OUT3. Each of the four open-collector digital outputs can sink up to 200 mA at 40 V DC.


4.2.3 Digital I/O Software







void digOut (int channel, int value);




Sets the state of a digital output.
Parameters


channel is the output channel number (0, 1, 2, or 3).


value is the output value (0 or 1).
Return Value


None.
See Also

    digIn






int digIn (int channel);




Reads the state of a digital input.
Parameters


channel is the input channel number (0, 1, 2, or 3).
Return Value


The state of the input (0 or 1).
See Also

    digOut

4.2.4 Sample Digital I/O Programs




  1. Connect the programming cable to header J4 on the TCP/IP Development Board. Apply power to the TCP/IP Development Board.



  2. Open the sample program SAMPLESICOMICOMIO.C and press F9.


This program demonstrates how to turn the I/O on and off.

Jul
07

Our new comDebug program lets you communicate with almost any RS232, RS422, RS485 or Modbus serial device. Whats more, its free! Its extensive trouble-shooting capabilities make it ideal for solving comms problems, or for quickly checking that you can communicate with your instrument before starting to automatically acquire data.


Features



  • No programming required
  • Free technical support for life
  • Easy to use
  • Understands ASCII or binary data
  • For serial instruments that continually send data and those that need prompting
  • Quickly identify and correct communication errors

  • Insert cyclic redundancy checks (CRCs)
  • Send ASCII values, 16-bit 2s complement integers, unsigned integers, single bits of data, etc, to instruments
  • Control the state of the PCs serial port output lines
  • See the state of the serial port input lines
  • Send acknowledgements
  • Save settings in a file
  • Full hypertext Help
  • Up to 38400 baud
  • For Windows 95 and later
  • Optionally, with the new Windmill COMIML or free LabIML serial driver, continually send data from the instrument to the Windmill logging, charting and other data acquisition applications, or to third-party Windows software like Excel

No Programming Required


Simply select your communication settings or type your instruments commands: no need for any programming.


Serial Driver Software


What sort of Devices can you Read with comDebug?


With comDebug you can control both those serial devices that continuously output messages, and those that require commands before supplying data. With a flexible approach to building command strings, and parsing the received data strings to extract data values, the majority of analytical instruments are supported. These include GPS, sonar, DMR, gas analysers, pH transmitters, data loggers, titrators, particle analysers, pressure transmitters, water baths, hygrometers, I2C devices, plcs and laboratory scales.


You have the freedom to mix and match equipment from many different manufacturers in many combinations. For example, serial devices from A&D, Anton Paar, Ashtec, Bruël & Kjær, Datel, Datataker, Ecom, Edge Tech, Electro Industries, Fisher, Furuno, Garmin, Honeywell, Horiba, Mettler Toledo, Motorola, Molyteck, Newmar, NovAtel, Nu-Metrics, Omnistar, Omron, Orion, Parallax, Paroscientific, Patton, Phytron, Quantum Logic, Quest Scientific, Sartorius, Siemens, Telegan, Telemecanique, Texas Instruments, Transcell and TTi have all been handled by Windmill. Many channels of data can be accepted from each instrument.

“I would recommend ComDebug to any one who has to trouble shoot a serial card problem. I used it to locate a defective com card which the manufacturer said could not be. ”
Doyal J. McVicker Jr.


“Your software works great; its the only package that allows me to set the DTR line low…required by the TI (Texas Instruments) development board configuration.”
R E Rogers



“comDebug solved a problem I had debugging Phytron motor controllers”
J Stirling



“comDebug helped me solve an HP-IL (old Hewlett-Packard interface) to RS-232 interfacing problem.”
M O Tjebben



“Used it to simulate the data output of a Resistance Weld Control into our Web enabled PLC (programmable logic controller).”
J Franks



Free Technical Support for Life


award-most-popular


Our software is so easy to use we offer free technical support for life. If you have a question the first places to look are in the programs Help file or our FAQ. If you dont find the answer there then fill in our technical support form, fax us on +44 (0)161 833 2190 or call us on +44 (0)161 833 2782 (9 to 5 GMT or BST).


“comDebug is so easy to use I have not needed to read anything.”
RT, Reservoir Engineering Specialist Oil and Gas Production – Research. Using ParoScientific Quartz pressure transmitter.


“Great Software!”
GH, Audio Systems Engineer using Audion Precision System Two Cascade.



“No problems, it did exactly what I wanted it to do.”
SM, Electrical Engineer performing tests on a Modbus Variable speed drive.



“Outstanding little tool! Best freebie Ive ever seen! No problems, it worked perfectly.”
JF, Industrial Control Engineer.



“No problems, comDebug is a great resource.”
DA, Mineral Chemistry (Quantitative).



“Great little tool. Worked as advertised, no problems.”
JF, Industrial controls.



Download COMIML and comDebug Leaflet

You can download the COMIML and comDebug leaflet in pdf format.



  • For best quality but large file download comiml.pdf
  • For lower quality pictures but small file download comiml2.pdf.

source// http://www.windmill.co.uk/serial.html

Jul
07

standard protocols

  • http://webopedia.internet.com/Standards/Communications_Standards/ (pointers to the Hayes AT command set for modems, the RS-232c standard, the RS-485 standard, the CCITT Group 4 fax standard, and several file transfer protocols). [FIXME: last time I checked, left out any mention of S11 -- perhaps give them the pointers below ?]
  • http://www.rad.wfubmc.edu/~chim/modemstuff/chapter06.html#6.4 has lots of details on the “S” registers, including the S11 DTMF Dialing Speed register. For example, S11= sets the DTMF pulse time to milliseconds and the time between pulses to milliseconds.
  • http://www.gem.co.za/FAQ/FRAMES/Hayescommands.html also documents S11.
  • http://www.citilink.com/~kae/faq/connecting/general/hayes.html claims that the minimum value for S11 is 50 ms, which seems incorrect — my modem works fine with S11=[FIXME]
  • Protocols/Standards/Guides http://www.repairfaq.org/filipg/LINK/F_LINK_IN.html#LINKIN_004
  • Controller Area Network (CAN) #can
  • Standard for Sensor Transducer Interface http://standards.ieee.org/announcements/electindustrange.html
  • IEEE P1451.0 (TM), “Standard for a Smart Transducer Interface for Sensors and Actuators; Common Functions, Communication Protocols, and Transducer Electronic Data Sheet (TEDS) Formats,” will be a new standard containing a common set of functions, communications protocols and TEDS formats for various physical communications media. It will aid interoperability among IEEE 1451 (TM) standards and simplify the creation of standards for different physical layers.