Iam trying to read some bits from the PLC. I used:
res = dc.readBits(libnodave.daveDB, 1, 492, 16, buf)
to read 16 bits starting from v492.0. But I do not know how to seperate the bits and use it in the vb.net program. There is a link to "Read and Set bits" (file name bitfunctions.html) in the getting started doc. But this file is not included in the Libnodave package.
Can you please help me with this? Thank you very much in advance.
- Sriram.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, you cannot read more than 1 bit. The bit count parameter to readBits has to be allways one. So why is the parameter there at all? In the protocol, there is a field that serves as a count in case of bytes and is 1 in case of bits. Is Siemens would decide to support multiple bit transfers in future versions of CPUs or their firmware, it would probably work.
Next, instead of reading 16 bits, you can read 2 bytes and extract the value of the single bits from them.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Reading 1 bit at a time, with daveReadBits, you have to set the start address to 8*492+0, 8*492+1... etc.
But as I told you before, I should not do that. It is very far from efficient.
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2016-04-12
Post awaiting moderation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Iam trying to read some bits from the PLC. I used:
res = dc.readBits(libnodave.daveDB, 1, 492, 16, buf)
to read 16 bits starting from v492.0. But I do not know how to seperate the bits and use it in the vb.net program. There is a link to "Read and Set bits" (file name bitfunctions.html) in the getting started doc. But this file is not included in the Libnodave package.
Can you please help me with this? Thank you very much in advance.
- Sriram.
Sorry, you cannot read more than 1 bit. The bit count parameter to readBits has to be allways one. So why is the parameter there at all? In the protocol, there is a field that serves as a count in case of bytes and is 1 in case of bits. Is Siemens would decide to support multiple bit transfers in future versions of CPUs or their firmware, it would probably work.
Next, instead of reading 16 bits, you can read 2 bytes and extract the value of the single bits from them.
Thanks. But how do I address 492.0, 492.1...etc if I read 1 bit at a time?
Reading 1 bit at a time, with daveReadBits, you have to set the start address to 8*492+0, 8*492+1... etc.
But as I told you before, I should not do that. It is very far from efficient.
Thomas