bonjour
mon probleme que je poste ici concerne un peu les automaticiens
je realise une interface d essai qui me permetera de lire un mot memoire stocker dans l automate (twido)
le protocole utilise est le modbus
j envoie une trame modbus de lecture (01 03 00 01 00 01 xx xx) je lit le %mw1 les xx xx c est le crc de la trame 01 c est l adress automate 03 c le code fonction lecture des mots
voici ci joit mon code et une fenetre de sniffer de port serie
mon programe ne marche pas j aimerai avoir une reponse de l automate
corriger moi svp merci d avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 Résultat est un booléen Résultat = sOuvre(1, 2000, 2000) // Ouverture de COM1 SI Résultat = Vrai ALORS // SI LE PORT EST OUVERT ALORS ..... sFixeParamètre(1, 9600, 0, 8, 1) //JE REGLE LES PARAMETRES DE MON COM1 sEcrit(1,Caract(0x01)+Caract(0x03)+Caract(0x00)+Caract(0x01)+Caract(0x00)+Caract(0x01)+Caract(0xD5)+Caract(0xCA)) //J'ECRIT LA TRAMES MODBUS DE LECTURE DE %MW1(01 03 00 01 00 01 D5 CA) DE MON TWIDO R est un Buffer //JE DECLARE UNE VARIABLE POUR METTRE LA REPONSE DE MON TWIDO R=sLit(1,sDansFileEntrée(1)) //JE LIT CE QUI EST DANS LE BUFFER RS=R //J'AFFICHE SE QUE JE RECOIT DANS UNE ZONNE DE SAISIE SUR MA FENETRE INTERFACE sFerme(1) //JE FERME COM1 SINON Erreur("Erreur d'ouverture de COM1") //J AFFICHE UN MESSAGE SI ECHEC D OUVERTURE DE COM 1 FIN ----------------------------------------------------------------------------------- ----------------------------------------------------------------------------------- le sniffer de port serie 15:52:22 - --------------------------------------- 15:52:22 - Serial Port COM1 opened 15:52:22 - --------------------------------------- 15:52:22 - Application: C:\WinDev 10\Programmes\WDTST.EXE 15:52:22 - Timeouts changed to RIT: -1 RTTM: 0 RTTC: 0 WTTM: 0 WTTC: 0 15:52:22 - BaudRate changed to 9600 15:52:22 - DTR changed to ON 15:52:22 - Line control changed to StpBts: 0 Prty: 0 WrdLen: 8 15:52:22 - Flow control changed to CHSh: 1 FR: -2147483456 XOnL: 2048 XOff: 512 15:52:22 - BaudRate changed to 9600 15:52:22 - DTR changed to ON 15:52:22 - BaudRate changed to 9600 15:52:22 - DTR changed to ON 15:52:22 - Line control changed to StpBts: 0 Prty: 0 WrdLen: 8 15:52:22 - Flow control changed to CHSh: 1 FR: -2147483456 XOnL: 2048 XOff: 512 15:52:22 - Written 8 bytes: 15:52:22 - Read 0 bytes: 15:52:22 - --------------------------------------- 15:52:22 - Serial Port COM1 closed 15:52:22 - ---------------------------------------
Partager