I need to comunicate a 314 Siemens CPU with a PC. I know there are instructions that do it in the library "Libnodave", but i have tryed it many times and i couldn't do it. Well, i can acces to the PLC, and the test programs that are with the library works fine. The problem is that i have to access to some PLC "outputs", "inputs" and "marks". Some of them are bits and other are bytes (digital or analogical data). I know the existence of the functions "daveReadBytes" and "daveReadBits" as "daveWriteBytes" and "daveWriteBits" but i have tryed to make use of them to manipulate the values of the PLC outputs (eg: A4.0, A5.0, ..) and marks (eg: M1.0, M1.1, ...), but no positive result was obtained. Using the fragment code below, the result was allways the same "The value of A5.0 = 1". I forced the "A5.0" to 0 (bit value) at the PLC and no changes was visible. I did the same with others outputs and marks, but it never worked.
Here is a fragment of the code i made use of:
if (fds.rfd>0) {
di =daveNewInterface(fds,"IF1",0, useProtocol, daveSpeed19k);
daveSetTimeout(di,5000000);
dc =daveNewConnection(di,2,0,useSlot); // insert your rack and slot here
if (0==daveConnectPLC(dc)) {
printf("Connected.\n");
// di->timeout=1000;
printf("\nTrying to read 1 bit A5.0\n");
res=daveReadBits(dc, daveOutputs, 5, 0, 1,&value);
printf("function result:%d=%s\n", res, daveStrerror(res));
printf("The value of A5.0: %d\n", value);
}
else{
printf("No se puede establecer la conexión con el PLC.\n");
return -2;
}
}
else{
printf("Fallo conexion puerto TCP.\n");
return -1;
}
What do you think i'm doing wrong? All the variables are correctly declared at the main.
I will be very GRATEFUL if u can help me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is my little problem:
I need to comunicate a 314 Siemens CPU with a PC. I know there are instructions that do it in the library "Libnodave", but i have tryed it many times and i couldn't do it. Well, i can acces to the PLC, and the test programs that are with the library works fine. The problem is that i have to access to some PLC "outputs", "inputs" and "marks". Some of them are bits and other are bytes (digital or analogical data). I know the existence of the functions "daveReadBytes" and "daveReadBits" as "daveWriteBytes" and "daveWriteBits" but i have tryed to make use of them to manipulate the values of the PLC outputs (eg: A4.0, A5.0, ..) and marks (eg: M1.0, M1.1, ...), but no positive result was obtained. Using the fragment code below, the result was allways the same "The value of A5.0 = 1". I forced the "A5.0" to 0 (bit value) at the PLC and no changes was visible. I did the same with others outputs and marks, but it never worked.
Here is a fragment of the code i made use of:
if (fds.rfd>0) {
di =daveNewInterface(fds,"IF1",0, useProtocol, daveSpeed19k);
daveSetTimeout(di,5000000);
dc =daveNewConnection(di,2,0,useSlot); // insert your rack and slot here
if (0==daveConnectPLC(dc)) {
printf("Connected.\n");
// di->timeout=1000;
printf("\nTrying to read 1 bit A5.0\n");
res=daveReadBits(dc, daveOutputs, 5, 0, 1,&value);
printf("function result:%d=%s\n", res, daveStrerror(res));
printf("The value of A5.0: %d\n", value);
}
else{
printf("No se puede establecer la conexión con el PLC.\n");
return -2;
}
}
else{
printf("Fallo conexion puerto TCP.\n");
return -1;
}
What do you think i'm doing wrong? All the variables are correctly declared at the main.
I will be very GRATEFUL if u can help me.