Author Topic: Setsystem  (Read 46020 times)

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Setsystem
« on: August 14, 2012, 02:51:24 PM »
Hi,

I need to set the PLC ID from within the PLC program, I've tried SETSYSTEM 8, (&hDM[65]) and a few other permutations but keep getting syntax errors.

I guess the value needs to be in Hex also but cannot see an easy way to convert from dec to hex, plenty of options the other way round or am I missing something?!?

Cheers

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Setsystem
« Reply #1 on: August 14, 2012, 07:47:16 PM »
Have you tried something even simpler:

SETSYSTEM 8, DM[65]

This passes muster with the simulator.

Adding the &H to get &HDM[65] should get you a syntax error.  The &H prefix is only used to give the TBASIC interpreter the "heads up" that you are trying to enter a numeric constant in hexadecimal notation.

A = F      assigns the value of the variable F to variable A
A = &HF  assigns the hexadecimal value "F" (15 decimal) to variable A

TBASIC will see &HDM[65] and will be fine with the &HD part, but when it parses the "M" it will blowup as "M" is not a legal hex digit. The interpreter will never get to the [65] part...

Gary D
« Last Edit: August 14, 2012, 10:13:10 PM by garysdickinson »

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Setsystem
« Reply #2 on: August 15, 2012, 01:12:48 AM »
Hi Gary,

Yes I tried that but the PLC does not change the ID to the value in the DM field so i figured it needs to be in hex?

FYI we have a lot of PLC's on a site in Scotland (20 ish) and they all auto ID themselves based on the IP address.  All this does is take the last three numbers from the IP address and place the value into DM[65].  The HMI and webpages displays this value as the panel ID.

I did this so I can use one version of software for the whole site and it works very well.

My problem is the main site HMI wants to see each PLC have a different ID even though they are different IP addresses.

I thought I could use my auto ID code to also set the PLC ID via the setsystem command so I set this up on a first scan function but the PLC ID remains at 1?????

Cheers

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Setsystem
« Reply #3 on: August 15, 2012, 01:41:59 AM »
Hi

I've been testing today and i dont think the setsystem command works from within the program.........

I thought maybe the setsystem line may have been trying to send a 0 from DM[65] if the auto ID code had not finished although this shouldn't be possible because the CF should finish before moving on to another CF.......

I tried:

IF DM[65] > 1
SETSYSTEM 8, DM[65]       ' Set Device ID ti IPaddress last three values
SETIO ID_Set
ENDIF

and.....

IF DM[65] > 1
SETSYSTEM 8,&H2       ' Set Device ID ti IPaddress last three values
SETIO ID_Set
ENDIF

Instead of using a 1st scan I have used a NC relay contact (ID_Set) to call the code.  if the value of DM[65] is grater than 1  set the system ID with the value from DM[65].  when done set the relay to stop the code being called again until reboot etc

The value of DM[65] can be anything from 1 to 255.

This didn't work so i tried setting the ID with a fixed &H2 but this didn't work either???????????

Any Ideas appreciated!

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Setsystem
« Reply #4 on: August 15, 2012, 09:42:22 AM »
FYI,

FMD16 FW r76 I think

Cheers

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Setsystem
« Reply #5 on: August 15, 2012, 10:05:49 AM »
Unfortunately the SetSystem 8, id did not work on firmware before r76A. It is a very rarely used feature and the bug was not discovered earlier and was only fixed after r76A was released.

All new PLC with firmware >= r76A should support this feature.

So for the current system what you can do is to change the ID from the i-TRiLOGI or TLServer software and the ID will be saved into non volatile flash memory which will not need to change again.
« Last Edit: August 15, 2012, 10:08:30 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Setsystem
« Reply #6 on: August 15, 2012, 10:09:29 AM »
Hi,

Ok thanks for that.

 I think i have some r76A too i'll check and com back to you.

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Setsystem
« Reply #7 on: August 15, 2012, 10:18:49 AM »
Hi,

Some of the PLC's are r76A but the code still doesn't work?

Cheers

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Setsystem
« Reply #8 on: August 15, 2012, 10:30:24 AM »
Hello again.......

Just tried this with a r78A FMD with the same results  ???

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Setsystem
« Reply #9 on: August 15, 2012, 11:55:24 AM »
There was a change to the SETSYSTEM 8, n syntax to make it more flexible as follow:

   SETSYSTEM 8, n

    COMM1:  n = &H0001 to &H00FF
    COMM2:  n = &H0101 to &H01FF
    COMM3:  n = &H0201 to &H02FF
    COMM4 (Ethernet): n = &H0301 to &H03FF

i.e. it is now possible to change the PLC ID individually for each COMM port and the Ethernet port.

Note that the ID changed by SETSYSTEM 8 is volatile so you have to run the SETSYSTEM 8, n on 1st.Scan to make it work.


« Last Edit: August 15, 2012, 11:55:53 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Setsystem
« Reply #10 on: August 16, 2012, 01:20:19 AM »
Morning,

This now works from a fixed hex ID i.e.

SETSYSTEM 8,&H03FF ID is changed to FF.

Going back to my initial post, how can I set the ID via the DM field value?

SETSYSTEM 8,&H03 + DM[66] compiles ok but doesn't change the ID

ScarBelly

  • Newbie
  • Posts: 6
  • I'm a llama!
    • View Profile
Re:Setsystem
« Reply #11 on: August 16, 2012, 04:49:10 AM »
You might try setting a variable to the DM like: S= DM[66]
and using S.  

The only reason I say this is because some other functions behaved for me this way.  For instance, I found that while
A$ = CHR$(DM[32]) works, STRCMP(B$,  CHR$(DM[32])) did not.

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Setsystem
« Reply #12 on: August 16, 2012, 04:58:43 AM »
Hi,

Ok good point.  I'll try that in a bit!

Cheers

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Setsystem
« Reply #13 on: August 16, 2012, 07:58:21 AM »
Marcus,

I'm still a little worried about this line:

SETSYSTEM 8,&H03 + DM[66]

I think you want something more like this:

SETSYSTEM 8,&H0300+ DM[66]

I assume that dm[65] holds a decimal value in the range of 1..255. If dm[65] holds the value 7 then your version will compute to a value of 10.

In my version you should get &h307

Best regards,

Gary d

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Setsystem
« Reply #14 on: August 16, 2012, 12:05:11 PM »
Hi Gary,

I agree and I will investigate further.  

I have a a bigger issue that I need assistance from ASAP.

I have been trying to set the PLC ID's  using the Trilogi software and for all the r78A, r77 and some of the r76A's no problem however, on four PLC's with FW r76A are behaving very erratically.

When I changed the ID the PLC rebooted but from this point I was unable to re-connect to the PLC via the ethernet port.

I went to the PLC's, I expected a re-boot would solve the issue but it didn't.

Some of the PLC's had the pause LED on, some had the pause LED and the run error LED on.   Despite reloading the program locally via the serial port I could not gain any access to the ethetnet port.  I couldn't even ping the PLC.

I used the TL server to check the ID and it was as per what I had set from the ethernet port as above pre-crash .  I re-set the PLC to ID of 1 and instantly the problems disappeared and the ethernet port was responsive again.  - HELP!!!!!!!!!

I have a small HMI on the RS232 serial port looking for an address of 1 and a power meter on the RS485 port which I can can change to match the ethernet port ID if need be.  However i cannot do this if the Ethernet port turns off if the ID is not 1!!!

I guess I need a work around for changing the Ethernet port ID to any number other than 1 or the FW to make all my PLC's r78A as the flexible setsystem command would work a treat for me on this application.



PLEASE HELP ASAP