I can read single bit M100.1 this way on the c# but i want to write signle bit can you help me please?
private void PlcMerkerRead() { int Result; byte[] Buffer = new byte[1]; Result = PLC.MBRead( 100, 1, Buffer); TxtDump.Text = Convert.ToString(GetBit(Buffer[0], 0)); }
public bool GetBit(byte byt, int index) { if (index < 0 || index > 7) throw new ArgumentOutOfRangeException(); byte bitMask = (byte)(1 << index); byte masked = (byte)(byt & bitMask); return masked != 0; }
Use Read/WriteArea that can address a single bit
Can you give to me one sample
Log in to post a comment.
I can read single bit M100.1 this way on the c# but i want to write signle bit can you help me please?
private void PlcMerkerRead()
{
int Result;
byte[] Buffer = new byte[1];
Result = PLC.MBRead( 100, 1, Buffer);
TxtDump.Text = Convert.ToString(GetBit(Buffer[0], 0));
}
Last edit: Ersin 2015-09-09
Use Read/WriteArea that can address a single bit
Can you give to me one sample