Step7 - Problems with FC5 - DI-STRNG

RMA

Member
Join Date
Sep 2004
Location
North of Hamburg, Germany
Posts
2,052
Can anybody see what's wrong with the following screen dump?

I need to display an integer in a text field (a 20 character String). Originally I intended to park the result of the FC5 conversion in a DB, but I couldn't persuade it to accept a pointer of the form P#DB1.DBX44.0 BYTE 22 in the RET_VAL parameter.

I decided to give it a try using a local address and although it accepted this as a parameter when I try to copy the result out to the display DB it's full of rubbish (checked in a VAT).

Anybody got any idea where the problem might be?

FC5_DI_STRNG.JPG
 
how have you checked it in a VAT, as its a temp. You would need to copy temp_str_nr into a succession of flags to see the actual value after FC5.

Something like

Code:
L LD28
T MD1000
L LD32
T MD1004
L LD ....  etc

and then monitor MD1000 - MD1020 to see the contents.

Also I believe String[20] would be 21 characters as I believe it starts from String[0], could be wrong though.
 
I've been checking the results in a VAT, because that's the only place you can see anything - apart from the OP screen of course. The String length is 22 Bytes because Step7 adds two Bytes to the actual String, which contain the maximum and actual lengths of the String.

I think I know why I couldn't enter the DB address as a Pointer - it's formatted as a STRING and FC5 requires an ANY Pointer - oops! just realised my TEMP is also formatted as a STRING, so that can't be it.

Or is that maybe the problem? I'll try changing it to any ANY Pointer and see if anything changes.

Still puzzled!

Cheers

Roy
 
That explains why It didn't like it when I tried changing my Temp to an ANY! Doesn't explain why it didn't like the DB address as a Pointer though.

More puzzled!

Cheers

Roy
 
Try putting the code similar to that above. I don't know what you are looking at in the VAT, but you are not looking at the result from FC5 as that is a TEMP flag.

To assure yourself that the FC5 part is working, you need to transfer the result into spare flags, similar to the bit of code above and then monitor them in a VAT as a string, once you have done that you can then eliminate or not FC5.

What block is COPY is that your own block?
 
Roy, when you create a string variable in the temp area, you have to manually set the maximum string length yourself otherwise it will be a random number.

Rgds, Simon
 
just checked, provided the data area [edit: in the DB] is formatted correctly as a string, you can enter it direct as the string output for FC5
 
Roy, when you create a string variable in the temp area, you have to manually set the maximum string length yourself otherwise it will be a random number.



I originally thought that was my problem - it defaulted to 254 characters, which I at first didn't notice, because the field was too narrow. However, even after changing it to 20 characters, it didn't help.

just checked, provided the data area [edit: in the DB] is formatted correctly as a string, you can enter it direct as the string output for FC5
That's strange, I'll have to go and try again, in case I did something silly with my formatting in the DB.

The FC132 "Copy" is a home-brew from the machine constructor, but I've used it before with no problems.

I'm looking at the results of the "Copy" with the VAT - i.e. DB110.DBB44 and onwards - your comments about "current" and "previous" Temp areas may have some bearing on things, that's an area that I still haven't really understood!

I'll try copying the TEMP to some Memory Bytes, so that I can check it out as you suggested.

Cheers

Roy
 
Roy,

Also from the english help for FC5:

'You can assign only a symbolically defined variable for the output parameter'


Kevin
 
Just to let you know how I entered the string straight from the DB.

I created DB100 called it "str". Inside created first variable called str, as STRING[20], which created space 22 long as you said.

When I addressed it in the FC5 output call, I entered P#db100.dbx0.0 byte 22.

It changed to "str".STAT0?

when I saved, closed and re-opened the block, it came up as "Str".str
 
Roy, declaring a string of any length in temp does not initialise the string length, you have to do it with code, for example say the string starts at LB20 you have to do the following:

L 20
T LB20
 
L D[AR2 said:
Roy, declaring a string of any length in temp does not initialise the string length, you have to do it with code, for example say the string starts at LB20 you have to do the following:

L 20
T LB20


strange it did when I was playing about with FC5, 'two' was created as STRING[20] and thats how much rrom it took.

stringtemp.JPG
 
I've not solved the problem yet, but I think I know what's wrong

After adding some code as suggested by Peter to check the result of FC5, I was surprised to see some of the values changing continually. I'd assumed (silly me!) that this bit of code would only be run through once, but in fact it is running continuously.

I still don't understand why it doesn't just repeat the conversion with the same results each time - but it doesn't!

I'll be losing my Internet access shortly, so I'll come back with a status report tomorrow.

By the way, I double-checked the DB entry and it is definitely a STRING[20]. I tried entering the Pointer with both Byte 20 and Byte 22, but in both cases it remains red - most peculiar!

Cheers

Roy

PS re your entry in Post 12, Peter, that's exactly what I did and it's in the same DB as "WT_nicht_erkannt" which is DB1.DBX0.0 Byte 22 and as you can see in the screen dump the COPY FC has accepted this with no problem - not so with FC5!
 
Last edited:

Similar Topics

Hi all, I will try and give as much info as possible to begin with but I am a graduate thrown in at the deep end so bear with me please. Upon...
Replies
12
Views
5,263
Hi Im trying to use SFC20 BLK Move in a piece of SCL code in Step7. I need to copy/move one string[16] in a DB to another DB place ! If a block...
Replies
5
Views
13,450
Would anybody like to have a look at the attatched source file and see if they can come up with a suggestion for what's wrong with it. Initially...
Replies
10
Views
5,196
Can somebody have a look at the appended code. I think I've got to the point where I'm seeing what I expect to see instead of what's really there...
Replies
12
Views
5,360
I've got a production line station which has two Cognex cameras in it to check that components are present and correctly orientated. The second...
Replies
7
Views
3,951
Back
Top Bottom