E
I am a relatively new S7 programmer, so maybe I've missed something. I created a new program with only one FB in OB1, which is the lib function F3 for the CP340. I renamed it to FB1000, imported it into OB1, and set it up as follows:
REQ = DB1000.0
R = DB1000.1
LADDR = DB1002 (=272 below)
DBNO = DB1004 (=1001 below)
DBBNO = DB1006 (start byte 0 below)
LEN = DB1008 (length below = 15)
Done = DB1010.0 (done bit out per interface)
ERROR = DB1010.1 (error bit per interface)
STATUS = DB1012 (word for status per interface)
DB1000 contains setup info for the CP340
start = BOOL FALSE
reset = BOOL FALSE
Laddr = INT 272 (from hardware setup for CP)
Dbno = INT 1001 (db to contain ascii data)
Dbbno = INT 0 (start byte of ascii in 1001
Len = INT 15 (end of string in 1001
error = BOOL FALSE (for error out
done = BOOL FALSE (for dione bit from CP340
status= WORD W#16#0 (status result from CP
In addition, there is an instance DB for FB1000 called DB1002, of type instance DB linked to FB1000 (in call hierarchy and thru properties), which I initialized so the values are correct just in case.
There is a DB called DB1001 for the string data, initialized so the first 15 chars are a string (the DB1000 data points to DB1001 in DBNO, and the start and len is 0 and 15 respectively.
This is exactly what is listed in the Cp ref manual. I checked all the values to be sure they are as listed. I call FB1000 with DB1002 as an instance DB, it should send the chars from DB1001 starting at 0 and going for 15 chars. I go into OB1, CPU in RUN, everything is fine. I toggle the start (REQ) bit on the FB and the CPU immediately faults. CPU error says "I/O error accessing parameter area 1010" or something like that. Then I get the usual complaint about the CPU stopping because OB122 is not able to run (not in program). Now cannot for the life of me figure out what it does not like. The instance DB is exactly like the parameter DB I set up, I checked it a hundred times. The ref to DBNO is an INT (as called for in CP340 manual) so it SHOULD reference DB1001, which contains the string, and since we are starting at 0 (DBBNO) and going for 15 chars (len) we should output the 15 chars to the CP340. I give up. There are NO refernces anywhere in the program to 1010 of anything, so what the heck is the "I/O parameter 1010..." thing about. The hardware config confirms the channel #'s for the CP340 and no conflicts. In fact, the ONLY other channels used above 100 are for an analog card which is at 259-271. Any ideas?
BTW: this is the "stripped" CP340 with RS232 only, not the one with selection for Printer/ASCII/3694. This one is 3694 ONLY.
Also, after it faults, I go in and look at the instance DB and it is zero so it does not look like it is even getting to the point of loading the IDB.
Appreciate any ideas. Thanks in advance
Ed
REQ = DB1000.0
R = DB1000.1
LADDR = DB1002 (=272 below)
DBNO = DB1004 (=1001 below)
DBBNO = DB1006 (start byte 0 below)
LEN = DB1008 (length below = 15)
Done = DB1010.0 (done bit out per interface)
ERROR = DB1010.1 (error bit per interface)
STATUS = DB1012 (word for status per interface)
DB1000 contains setup info for the CP340
start = BOOL FALSE
reset = BOOL FALSE
Laddr = INT 272 (from hardware setup for CP)
Dbno = INT 1001 (db to contain ascii data)
Dbbno = INT 0 (start byte of ascii in 1001
Len = INT 15 (end of string in 1001
error = BOOL FALSE (for error out
done = BOOL FALSE (for dione bit from CP340
status= WORD W#16#0 (status result from CP
In addition, there is an instance DB for FB1000 called DB1002, of type instance DB linked to FB1000 (in call hierarchy and thru properties), which I initialized so the values are correct just in case.
There is a DB called DB1001 for the string data, initialized so the first 15 chars are a string (the DB1000 data points to DB1001 in DBNO, and the start and len is 0 and 15 respectively.
This is exactly what is listed in the Cp ref manual. I checked all the values to be sure they are as listed. I call FB1000 with DB1002 as an instance DB, it should send the chars from DB1001 starting at 0 and going for 15 chars. I go into OB1, CPU in RUN, everything is fine. I toggle the start (REQ) bit on the FB and the CPU immediately faults. CPU error says "I/O error accessing parameter area 1010" or something like that. Then I get the usual complaint about the CPU stopping because OB122 is not able to run (not in program). Now cannot for the life of me figure out what it does not like. The instance DB is exactly like the parameter DB I set up, I checked it a hundred times. The ref to DBNO is an INT (as called for in CP340 manual) so it SHOULD reference DB1001, which contains the string, and since we are starting at 0 (DBBNO) and going for 15 chars (len) we should output the 15 chars to the CP340. I give up. There are NO refernces anywhere in the program to 1010 of anything, so what the heck is the "I/O parameter 1010..." thing about. The hardware config confirms the channel #'s for the CP340 and no conflicts. In fact, the ONLY other channels used above 100 are for an analog card which is at 259-271. Any ideas?
BTW: this is the "stripped" CP340 with RS232 only, not the one with selection for Printer/ASCII/3694. This one is 3694 ONLY.
Also, after it faults, I go in and look at the instance DB and it is zero so it does not look like it is even getting to the point of loading the IDB.
Appreciate any ideas. Thanks in advance
Ed