Internet PLC Forum

General => Technical support => Topic started by: BC SYSTEMS on August 14, 2012, 02:51:24 PM

Title: Setsystem
Post by: BC SYSTEMS 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
Title: Re:Setsystem
Post by: garysdickinson 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
Title: Re:Setsystem
Post by: BC SYSTEMS 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
Title: Re:Setsystem
Post by: BC SYSTEMS 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!
Title: Re:Setsystem
Post by: BC SYSTEMS on August 15, 2012, 09:42:22 AM
FYI,

FMD16 FW r76 I think

Cheers
Title: Re:Setsystem
Post by: support 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.
Title: Re:Setsystem
Post by: BC SYSTEMS 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.
Title: Re:Setsystem
Post by: BC SYSTEMS on August 15, 2012, 10:18:49 AM
Hi,

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

Cheers
Title: Re:Setsystem
Post by: BC SYSTEMS on August 15, 2012, 10:30:24 AM
Hello again.......

Just tried this with a r78A FMD with the same results  ???
Title: Re:Setsystem
Post by: support 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.


Title: Re:Setsystem
Post by: BC SYSTEMS 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
Title: Re:Setsystem
Post by: ScarBelly 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.
Title: Re:Setsystem
Post by: BC SYSTEMS on August 16, 2012, 04:58:43 AM
Hi,

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

Cheers
Title: Re:Setsystem
Post by: garysdickinson 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
Title: Re:Setsystem
Post by: BC SYSTEMS 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
Title: Re:Setsystem
Post by: support on August 16, 2012, 03:01:38 PM
We are not aware of the reported issue.

Was what you experienced a result of using SETSYSTEM 8, n to change the ID?

Did you try changing the ID from the TLServer or i-TRiLOGI instead of using the SETSYSTEM 8, n method? That is the traditional method of changing the ID which should work without any issue.

Title: Re:Setsystem
Post by: BC SYSTEMS on August 16, 2012, 03:26:43 PM
Hi,

I was using the trilogi program "get hardware info"  > Change ID and the change ID in the TL server locally when the TCP was out.

The address range i need is 101 to 125 but I will attempt using 1 to 25 tomorrow to see if this makes any difference.

The panels are located around a landfill site and are active 24/7.  the ethenet communication is via wifi antennas and as a whole the system works very well.

What about the FW upgrade solution?  I cannot remove the PLC's from the panels now they are "in service"

Cheers  
Title: Re:Setsystem
Post by: support on August 16, 2012, 03:46:38 PM
Note that when you use the i-TRiLOGI change ID to enter ID it should be in hex (00 to FF) and not in decimal.

101 = &H65
125 = &H7D

Firmware upgrade can only be done at the factory. There is no field upgrade option available unfortunately.
Title: Re:Setsystem
Post by: BC SYSTEMS on August 16, 2012, 03:58:18 PM
I'm aware the ID is in Hex.

What are my options now then ???  And why not the field upgrade FW option?    

Of all the things that can have their FW upgraded I would have thought this would be one of them? ::)
Title: Re:Setsystem
Post by: support on August 16, 2012, 04:26:11 PM
We tested setting the ID via Ethernet and didn't encounter any problem that you described. There is no need to reboot the PLC as changing the ID take effect immediately. Also when you transfer program to the PLC try to use the "Reset" command instead of "Reboot" command except in the case of changing the IP address etc.

For FW upgrade the board would need to be replaced and shipped back to the factory. In your case if you can set the ID manually via i-TRiLOGI software it doesn't appear to be worth the trouble to upgrade it just to run the SETSYSTEM 8, n command.

Implementing user upgradable firmware for a PLC in our opinion can lead to a lot of problems as product development engineering may not be as thorough in testing (afterall if any bugs are found  the user can upgrade it via firmware fix) so we chose not to implement it.  Also it is between using up precious program memory for more sophisticated features or to implement boot loader to allow field FW ugprading, and we chose the former.
   
Title: Re:Setsystem
Post by: BC SYSTEMS on August 17, 2012, 01:16:13 AM
Hi,

when you change the ID via the Trilogi program it has a note that says "Changing ID will reset PLC"

I don't agree about the FW but that's just my opinion.

I'm going to try and nail down whats happening today and i will let you know the outcome.
Title: Re:Setsystem
Post by: BC SYSTEMS on August 17, 2012, 01:21:46 AM
HI Changed the ID from 01 to 02 and 03 no problem, when i tried 75 (117 in Dec the PLC kicks me out of the ethernet port.

Title: Re:Setsystem
Post by: BC SYSTEMS on August 17, 2012, 02:58:09 AM
Hi,

It looks Like any ID higher than 09 causes the ethernet port to become unresponsive.

I have re-ID the PLC's with this problem with the ID range 01 - 09, although one PLC would take longer to respond the higher the ID i.e. if the ID was 07 it would ping in 400ms and drop 50 of the packets, now its set to 02 i get all four packets and the response is 5-15 ms???

I have used the following setsystem command for the HMI:

SETSYSTEM 8, &H0001             ' Set Comm Port 1 ti ID 1 for RL

This works on all PLCs r76A to r78A.

For future systems i will use the:

'SETSYSTEM 8,&H0375 '+ DM[66]      ' Set Device ID &h03 = cOMM4 ETHERNET IP

But going back to my original request, how to i convert the dec data from the DM field into hex?

Cheers

Title: Re:Setsystem
Post by: support on August 17, 2012, 08:49:01 AM
I tried setting the ID to 75 (hex) via the Change ID button on the "Get Hardware Info" and have no problem changing it to 75. I can then re-connect to the PLC using ID=75 (it is reported by detect ID). My ping result of the IP address of this PLC (r76A firmware) did not show any slower response. So this is a bit strange.

What Gary suggested would work:


SETSYSTEM 8, &H0300 + DM[66] ' DM[66] contains 1 to 255 decimal

You can even use the decimal version of &H0300 (= 768) as follow:

SETSYSTEM 8, 768 + DM[66]


Note that a hexadecimal number is really just a representation of a number for human to more easily understand since every 4 binary bits map to a single hex digit. Inside a computer a number is a number and is always represented in binary.  When we write a program, the following two program lines:

A = 768
A = &H0300

are identical when compiled into machine readable form.
Title: Re:Setsystem
Post by: BC SYSTEMS on August 17, 2012, 03:00:52 PM
Hi,

Thanks for the info. I was only trying to convert to hex becaus of the syntax errors.

One thing you could try:

Open a blank program
Go controller > connect to controller
Enter IP and connect. I'd not needed here yet.
Now click get hardware and notice ID is blank
Don't detect ID
Enter new ID 75
Hit change ID

Try that for size.

  I also had the online monitor open at one stage which may have contributed???
I only have the issue with a couple of r76A PLC's. Whilst onsite I replaced a PLC with a blown analogue input.  I'm not sure what level of FW is in this plc but I will test and let you know if it responds the same way.

Can the Plc be repaired? If not and it does have the address error do you want me to and it over to you to look at?
Title: Re:Setsystem
Post by: support on August 17, 2012, 04:24:07 PM
Tried that on a r76A.  I could change the ID (when current ID is blank) to 75 and then go back online monitoring and detect ID would return 75 and no trouble going online monitoring. The PLC still run as per normal.

Did you say while online monitoring is going on you make an ID change? That could have contributed to making the system unstable. Changing ID should be done only sparingly and when the system is not running full operation otherwise it may be a bit hard to predict what could break.

Most of the time the PLC can be repaired if some peripheral ICs are damaged. However if the main CPU is damaged then we normally will not repair it.
Title: Re:Setsystem
Post by: BC SYSTEMS on August 18, 2012, 12:49:00 AM
Ok thanks.

I'll test the Plc and let you know.

Cheers