Differences
This shows you the differences between two versions of the page.
en:software:qview:qview_6:qcl_library:dw11sermodma [2017/02/24 16:51] – created qem103 | en:software:qview:qview_6:qcl_library:dw11sermodma [2019/08/29 17:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== DW11SerModMa ====== | ||
+ | |||
+ | **D = **// | ||
+ | |||
+ | **W = **//Writing functions// | ||
+ | |||
+ | The DW11SerModMa function simulates the Modbus MASTER Protocol through the use of a SERCOM device.\\ | ||
+ | In particular the function sorts an array (named " | ||
+ | The choosing whether to execute a writing or reading on the Slave device, must be made by the user of the function through the setting of the " | ||
+ | The " | ||
+ | The " | ||
+ | |||
+ | The Modbus functions supported by the function are: | ||
+ | * Function 3 - Read Holding Register | ||
+ | * Function 16 - Force Multiple Register (multiple word writing) | ||
+ | |||
+ | ===== IMPLEMENTATION ===== | ||
+ | |||
+ | **DW11SerModMa (sercom1, Buffer, idcard, modWrite, address, points, error)** | ||
+ | |||
+ | Parameters: | ||
+ | |||
+ | ^IN/ | ||
+ | | IN | INTDEVICE | ||
+ | | IN | ARRSYS / ARRGBL | ||
+ | | IN | GLOBAL | ||
+ | | IN | GLOBAL | ||
+ | | IN | GLOBAL | ||
+ | | IN | GLOBAL | ||
+ | | OUT | GLOBAL | ||
+ | |||
+ | ==== Error ==== | ||
+ | |||
+ | After calling the function if there are any errors the error variable having the following values:\\ | ||
+ | 0 - No error\\ | ||
+ | 1 - Number char in reception > Buffer dimension (64 items). (Check on " | ||
+ | 2 - Error Checksum\\ | ||
+ | 3 - Address > maximum size of user Buffer\\ | ||
+ | 4 - Number of bytes required to answer > 64 (maximum limit of the buffer device)\\ | ||
+ | 5 - Time Out: The slave does not respond within 200ms\\ | ||
+ | 6 - Function Type of mismatch response\\ | ||
+ | 7 - Number of characters in response does not match the expected number | ||
+ | |||
+ | === Example === | ||
+ | |||
+ | // | ||
+ | <code QCL> | ||
+ | INTDEVICE | ||
+ | ; | ||
+ | Sercom1 | ||
+ | </ | ||
+ | |||
+ | //TASK_00// | ||
+ | <code QCL> | ||
+ | sercom1: | ||
+ | sercom1: | ||
+ | sercom1: | ||
+ | sercom1: | ||
+ | sercom1: | ||
+ | |||
+ | OPENCOM sercom1 | ||
+ | WAIT sercom1: | ||
+ | |||
+ | gfIniz = 1 | ||
+ | </ | ||
+ | |||
+ | //TASK_01// | ||
+ | <code QCL> | ||
+ | |||
+ | | ||
+ | MAIN: | ||
+ | IF gfIniz | ||
+ | ;----- READING -------- | ||
+ | modWrite = 0 ;Set READING | ||
+ | address = 20 ; | ||
+ | points = 5 ; | ||
+ | DW11SerModMa (sercom1, Buffer, idcard, modWrite, address, points, error) | ||
+ | |||
+ | IF NOT error | ||
+ | glVariabile1 = Buffer [20] ; | ||
+ | glVariabile2 = Buffer [21] ; | ||
+ | glVariabile3 = Buffer [22] ; | ||
+ | glVariabile4 = Buffer [23] ; | ||
+ | glVariabile5 = Buffer [24] ; | ||
+ | ENDIF | ||
+ | |||
+ | ;----- WRITING -------- | ||
+ | Buffer [50] = cnCounter: | ||
+ | |||
+ | modWrite = 1 ;Set READING | ||
+ | address = 50 ; | ||
+ | points = 1 ; | ||
+ | DW11SerModMa (sercom1, Buffer, idcard, modWrite, address, points, error) | ||
+ | ENDIF | ||
+ | |||
+ | WAIT 1 | ||
+ | JUMP MAIN | ||
+ | END | ||
+ | </ | ||
+ | |||
+ | === Note === | ||
+ | |||
+ | * It is recommended that you implement the function in a specific task whereas the same contains instructions to WAIT that might block the Task itself. | ||
+ | |||
+ | === Limits === | ||
+ | |||
+ | Modbus functions supported by this function are: | ||
+ | * Function 3 - Read Holding Register | ||
+ | * Function 16 - Force Multiple Register (multiple word writing) | ||
+ | |||
+ | The restriction on the number of variables that you can exchange is as follows | ||
+ | * Function 3 : maximum 30 word readable at the same time | ||
+ | * Function 16 : maximum 28 word writable at the same time | ||