Dec 21 2008
Modbus ASCII Protocol between ADAM-4056S and Visual Basic 6.0
ADAM-4056S is a 12-channel sink type isolated digital output module for critical applications. The open collector output can provide voltage from +5 to +40 V and the status reading output could see on the LED indicator. On this article, I would like share my experience on communication between ADAM-4056S and Visual Basic 6.0. Although ADAM-4056S support for ASCII and Modbus/RTU protocols, on this article I just explain for ASCII protocol.
I have successful communicate Visual Basic 6.0 to ADAM 4056S via PCI-1612CU-AE (4-port RS-232/422/485 Universal PCI COMM Card w/Isolation & Surge Protection). For the information, ADAM-4056S only using RS-485 cable for their communication,
so we should have RS-232 to RS-485 converter for our PC or Laptop. I choose PCI-1612CU-AU because I have plan to perform the communication between my PC and other device with different protocol. Beside that, PCI-1612CU-AU is very easy and simple on change RS-232/422/485 protocol, I will show later how to change the configuration.
PCI-1612CU-AE have 4 channels that could selected by individually for RS-232/422/485 protocol. The default jumper on pin 2 and 3 is for RS-422/485 where PCI-1612CU-AE could adjust automatically for RS-422 or RS-485 depend on different data flow from/to external device. If we want to use channel 3 and 4 for RS-232 we should change the jumper into pin 1 and 2. Don’t forget to download the PCI-1612CU-AE driver on here.
PCI-1612CU-AE using DB-25 port on their communication to external hardware. But, when we have bought PCI-1612CU-AE package from Advantech, the DB-25 female converter to 4 cables DB-9 female available on there. The important thing when we want use PCI-1612CU-AE for Modbus/RTU or ASCII protocol is on pin cable configuration for DB-9. Usually, when we want use DB-9 male for RS-485 cable we use pin 2 for Data-, pin 3 for Data+ and pin 5 for Ground. But on DB-9 male for PCI-1612CU-AE pin 1 for Data-, pin 2 for Data+ and pin 5 for Ground.
Then we should configure hexadecimal address, baud rate, check sum, and standard ASCII protocol for ADAM-4056S before we perform the simple VB 6.0 programming. Don’t forget to change pin on ADAM-4056S to *.INIT mode before perform the configuration.
After that please following step by step this video tutorial to make the simple VB programming. Don’t forget to select exactly CommPort and Settings for MSComm. The standard syntax of ASCII command to set DO value for ADAM-4056S is
#AABB(data)(cr)
Where # is a delimiter character, AA (range 00-FF) represents the 2-character hexadecimal address, BB is a channel address on ADAM-4056S that will be set and (data) is 4 characters of the digital output value. This is the example of ASCII command to set DO2 value at address 10 for ADAM-4056S :
Set “True” → #0A120001
Set “False” → #0A120000
Then the standart syntax of ASCII command to access the DO status of ADAM-4056S is
$AA6(cr)
Where $ is a delimiter character, AA (range 00-FF) represents the 2-character hexadecimal address of the module, and 6 is the Digital Data In command. This is the example of ASCII command to access DO status of ADAM-4056S at address 05 :
$056 → request DO status at address 05
and the feedback received is
!017A00 → hexadecimal number that represent the 12 channels DO status. In the digital value it become 000101111010, mean that channels 1, 3, 4, 5, 6. 8 have “True” status and other channels have “False” status.
This is the simple example of VB programming to set DO value of ADAM-4056S. If you need more ASCII command for ADAM-4056S or ADAM-4000 series, you could download the detail user manual for ADAM-4000 on here.
No responses yet
Print This Post
Related Posts