Académique Documents
Professionnel Documents
Culture Documents
PDF
Beck IPC GmbH
E-Mail: info@beck-ipc.com
www.beck-ipc.com
A member of the Festo group
Beck IPC GmbH
Grninger Weg 24
35415 Pohlheim/Germany
Application note: Universal Bluetooth driver
Bluetooth as replacement for the serial ports used in applications,
demonstrated with CoDeSys.
Introduction
This Application Note describes the software package for a universal Bluetooth
driver for the IPC@CHIP
), configures the serial port and terminates. After that the Bluetooth
module is in a transparent data mode. An application can still use the standard
fossil API commands for the serial port and use the serial Bluetooth connection.
The application does not have to be changed.
This method is very fast and no permanent driver creating CPU load is needed.
The BT01 itself provides the possibility to ensure a permanent connection.
The driver is provided in source code and can be extended for your special
needs.
Configuration
Usually BT01 applications read their configuration from the chi p. i ni section
[ BLUETOOTH] . In addition the BTdr v. exe reads its configuration from a
second section called [ BT_DRV] into a struct called Bl uet oot hDr i ver .
The [ BT_DRV] has to contain the communication parameters (baud rate,
parity etc.) of the application which will use the Bluetooth connection as
replacement for the wired serial connection.
Please note: Dont mismatch this section with the [ BLUETOOTH] section used
by the BT01 Library. Some of the entries are similar (baud rate, parity etc.) but
in [ BLUETOOTH] the values define the communication parameters between
BT01 and IPC@CHIP
starts with 0.
CoDeSys IPC@CHIP
COM 1 COM0 (EXT)
COM 2 COM1 (COM)
COM 3 COM2
COM 4 COM3
For this example on DK60 the BT01 is connected to IPC@CHIPCOM2 so in
CoDeSys programming language COM3 has to be used!
System 1: You need a CoDeSys run time system (RTS) on your IPC@CHIP
.
For further information please refer to the CoDeSys manuals.
If you create the RTS for the IPC@CHIP
of system
1. The chi p. i ni has to contain the communication parameters that are used
by the CoDeSys program (see Example2.pro). As in Example 1 the
Bluetooth device address (BT_DRV_REMOTEDEVI CE) has to be modified to
your constellation:
[ BT_DRV]
BT_DRV_BAUDRATE=19200
BT_DRV_PARI TY=NO
BT_DRV_WORDLENGTH=8
AN_BluetoothDriver.PDF
Beck IPC GmbH
E-Mail: info@beck-ipc.com
www.beck-ipc.com
A member of the Festo group
Beck IPC GmbH
Grninger Weg 24
35415 Pohlheim/Germany
BT_DRV_STOPBI TS=1
BT_DRV_FLOWCONTROL=RTSCTS
BT_DRV_REMOTEDEVI CE=0012f 304f c05
Start the BTdr v. exe and afterwards the myr t s. exe. The BT01 connects to
the remote device of the second system.
Load the project Example2.pro in CoDeSys.
At the beginning of PLC_PRG the communication parameters are defined.
They have to match the entries in chi p. i ni defined earlier. Remember that
COM3 in CoDeSys is COM2 on the IPC@CHIP
.
ComSet t . Por t : =COM3;
ComSet t . dwBaudRat e: =19200;
ComSet t . bySt opBi t s: =1;
ComSet t . byPar i t y: =0;
If you want to change the parameters here, dont forget to change them in
chi p. i ni as well. The string sText is written to the COM Port with
SysComWr i t e and transferred to the remote Bluetooth device of System 2:
sText : = ' Thi s i s a t est st r i ng. ' ;
SysComWr i t e( g_dwPor t Handl e, ADR( sText ) , SI ZEOF( sText ) , 100) ;
System 2: Can be configured like in Example 1. Remote.exe will echo the
received data:
Figure 2: r emot e. exe receiving data from CoDeSys
AN_BluetoothDriver.PDF
Beck IPC GmbH
E-Mail: info@beck-ipc.com
www.beck-ipc.com
A member of the Festo group
Beck IPC GmbH
Grninger Weg 24
35415 Pohlheim/Germany
Example 3 CoDeSys Workbench
The third example demonstrates the communication between a PC with one
BT01 connected to the IPC@CHIP
. Start
the BTdr v. exe. After BTdr v. exe has initialized the BT01 myr t s. exe can
be started. The BT01 is now waiting for an incoming connection from your PC.
The next step is setting up a virtual COM port for your Bluetooth adapter on
the PC. Because there are many different PC-Bluetooth adapters available,
the following screenshots are only examples. The Windows driver for your
system might be different (an ASUS BTD202 USB dongle was used for this
example).
First search for available BT devices and try to connect with the Serial Port
Profile (SPP) to the BT01 (see Figure 4). The name of the BT01 is the defined
name in chip.ini (here EXAMPLE 3). Enter the PIN, if defined. In this example
it is set to 1234.
Figure 4:Searching and connecting to Bluetooth devices
AN_BluetoothDriver.PDF
Beck IPC GmbH
E-Mail: info@beck-ipc.com
www.beck-ipc.com
A member of the Festo group
Beck IPC GmbH
Grninger Weg 24
35415 Pohlheim/Germany
After connecting, Windows will assign a COM Port (here COM4, this may vary
for your PC) to the Bluetooth connection (Figure 5):
Figure 5: A virtual comport has been created on COM4
Please note, that CoDeSys only supports connections until COM32, so make
sure your virtual COM port is 32 or below.
Once a virtual COM port has been defined for your PC Bluetooth adapter you
can connect to the BT01. In CoDeSyS go to Online|Communictaion
Parameters (Figure 6). Please choose the COM Port (here COM4) that
Windows has assigned to your virtual COM port earlier. As stated above, the
other values may not be changed and have to be like:
Figure 6: CoDeSys communication parameters
AN_BluetoothDriver.PDF
Beck IPC GmbH
E-Mail: info@beck-ipc.com
www.beck-ipc.com
A member of the Festo group
Beck IPC GmbH
Grninger Weg 24
35415 Pohlheim/Germany
After the communication is set up you can log on to the IPC@CHIP (via Bluetooth),
download the small CoDeSys example3.pro program and start it (Figure 7).
Figure 7: CoDeSys workbench communication via Bluetooth