News:

  • June 09, 2026, 07:08:22 PM

Login with username, password and session length

Author Topic: Manuel set of a single bit (ex: "B1000.1")  (Read 19635 times)

NitraMa

  • Guest
Manuel set of a single bit (ex: "B1000.1")
« on: June 05, 2007, 01:26:40 PM »
I want to test my program by turning on or off a single bit (B1000.1) but Directsoft tell me that the "Element is read only"

How can I do?

MikeS

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 264
    • Host Engineering, Inc.
Re: Manuel set of a single bit (ex: "B1000.1")
« Reply #1 on: June 05, 2007, 03:38:38 PM »
The addresses of form "Bxxxx.y" don't really exist, they are a shorthand notation used in DirectSOFT. In your example B1000.1 is pointing to the next-to-lowest bit of V1000, DirecSOFT is doing a bit-pick operation to present you with that data, which is why it's read-only.

To set that bit, you'll need to write a value of 2 to V1000.
Good design costs a lot. Bad design costs even more.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Manuel set of a single bit (ex: "B1000.1")
« Reply #2 on: June 05, 2007, 07:22:10 PM »
Actually, you need to read the current value in V1000 in hex, bitwise-or a 0x0002, then write that back.  Note that, however, other bits CAN BE CHANGING, making this operation potentially invalid, both by-hand, and via DirectSOFT.

That is to say, there is no single communication command to set a bit in normal V memory.  You have to do a Read/Modify/Write operation, which can take MULTIPLE PLC scans (read "you might lose some state changes of OTHER bits in V1000").

8bits

  • Inactive Email
  • Jr. Member
  • *
  • Posts: 19
Re: Manuel set of a single bit (ex: "B1000.1")
« Reply #3 on: July 01, 2007, 07:11:33 PM »
I was stumped on this one too. THen, what is the purpose of the SETB instruction?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Manuel set of a single bit (ex: "B1000.1")
« Reply #4 on: July 02, 2007, 12:07:23 AM »
SETB (actually SET in DirectSOFT) is an instruction in the PLC.  You can programatically set and reset bits using
SET B2000.1
RST B2000.15

However, you cannot use the DirectSOFT Data View and use COMMUNICATIONS to set or reset bits (because of what I described above).

You can OUT, SET, RST to Bit-of-word programatically.

The original post showed an error message from the data view in DirectSOFT "Element is read only", and my explanation dealt with using DirectSOFT's Data View to change a bit of word.  However, I incorrectly implied that you could not change it PERIOD.  :-[  This is definitely wrong.

You DEFINITELY can set it using OUT, SET and RST instructions in your PLC program, along with looking at their states in contacts using B2000.1 in a contact (just like X0), just as 8bits asked about   :)

Note that DirectSOFT uses OUT, SET, RST, not the handheld programmer instructions (OUTB, SETB, RSTB) because we have you enter bit of word as a single parameter Bvaddress.bitnumber where vaddress is a V memory address (without the "V") and bitnumber is a value 0..15 (decimal) corresponding to the bit number.

So, to SET bit 10 (the 11th bit) of V2000, you would do
SET B2000.10

In the handheld programmer, I think this would be a 2 parameter instruction with the V parameter and the K bit number (in decimal???)
SETB V2000 K10