SASA Posted June 29, 2018 Report Posted June 29, 2018 Dear colleagues, I've one project where I need to read from TCP/IP port ASCII string from COGNEX Insight 7200 camera data. We are reading standard ASCII characters but also we have CROATIAN characters which are not represented in ASCII (ČĆĐŽŠ). I decided to use UNISTREAM 7" PLC for this purpose but I'm stucked with the way how to do this, I'm new to the UNISTREAM. I red in forum that we can use function COPY BUFFER TO TAG but when I do that I got ��. I can teach COGNEX camera to save font Ž as # for example, so if camera reads PŽ1234, it will send ASCII string P#1234 to PLC. At PLC side I need to convert # to Ž and then compile it to original state PŽ1234 and send it to SERVER. Can anyone help me with this ? Regards, Sasa Jovanic LOGOKOD d.o.o. Croatia
MVP 2023 Ausman Posted June 29, 2018 MVP 2023 Report Posted June 29, 2018 There is mention in the 7200 manual I quickly accessed online, of "In-Sight Explorer Software". Wondering if you can easily cure the source of the issue by changing a comms setting on the camera itself by using this software? cheers, Aus
SASA Posted June 30, 2018 Author Report Posted June 30, 2018 Dear Aus, I don't quite follow your idea ? By comms settings what do you mean? Sasa
MVP 2023 Ausman Posted July 1, 2018 MVP 2023 Report Posted July 1, 2018 Was simply wondering if there might be a setting within the camera itself to alter what comes out of it in the serial stream. Perhaps there is a particular internal setting that will give you a more conventional ASCII stream. And that program "In-Sight Explorer...." appears to be the one that lets you access the camera's innards/settings. If this is possible it will save a lot of trouble. cheers, Aus
SASA Posted July 2, 2018 Author Report Posted July 2, 2018 19 hours ago, Ausman said: Was simply wondering if there might be a setting within the camera itself to alter what comes out of it in the serial stream. Perhaps there is a particular internal setting that will give you a more conventional ASCII stream. And that program "In-Sight Explorer...." appears to be the one that lets you access the camera's innards/settings. If this is possible it will save a lot of trouble. cheers, Aus Dear Aus, Unfortunately it is not possible, INSIGHT only operates with ASCII 7 bit characters. that is why I'm trying to work around it. Sasa
Saragani Posted July 2, 2018 Report Posted July 2, 2018 The ASCII string that used by the UniStream is 8 bits ASCII. Making your camera convert Ž to # is wrong since # is mapped to characters that are below ASCII code 128. This means that you will not be able to distinguish between Ž and # because both will be converted to #. Can't the camera output Unicode? If it's only able to output ASCII, then are you sure it is 7 bit ASCII? Because then I cannot see how can you output any Croatian characters. (And I'm not seeing the point of outputting 7 bits ASCII, since each character still takes 1 byte, so the extra bit becomes pointless).
SASA Posted July 2, 2018 Author Report Posted July 2, 2018 10 hours ago, Saragani said: The ASCII string that used by the UniStream is 8 bits ASCII. Making your camera convert Ž to # is wrong since # is mapped to characters that are below ASCII code 128. This means that you will not be able to distinguish between Ž and # because both will be converted to #. Can't the camera output Unicode? If it's only able to output ASCII, then are you sure it is 7 bit ASCII? Because then I cannot see how can you output any Croatian characters. (And I'm not seeing the point of outputting 7 bits ASCII, since each character still takes 1 byte, so the extra bit becomes pointless). This is Cognex answer: OCR Max only supports the 7 Bit ASCII table. What can be done, is to "translate" Croatia characters into characters of the 7 Bit ASCII Area. In general you can teach the OCR-Tool every sign you want and tell it is a e.g Č as # Afterwards you can "decrypt" this translation in your PLC, in a script or somewhere else.
SASA Posted July 2, 2018 Author Report Posted July 2, 2018 10 hours ago, Saragani said: The ASCII string that used by the UniStream is 8 bits ASCII. Making your camera convert Ž to # is wrong since # is mapped to characters that are below ASCII code 128. This means that you will not be able to distinguish between Ž and # because both will be converted to #. Can't the camera output Unicode? If it's only able to output ASCII, then are you sure it is 7 bit ASCII? Because then I cannot see how can you output any Croatian characters. (And I'm not seeing the point of outputting 7 bits ASCII, since each character still takes 1 byte, so the extra bit becomes pointless). Hi Saragani, The project is to read car registration plates which has standard alpha numeric characters, there won't be #$&/,...that's why I can teach Croatian characters as suggested. I played little bit with Unistream 7" PLC and I'm stucked with TCP Buffer function where I convert Buffer to Tag (INT8) and then find & replace in INT8 ARRAY character / to hex value of letter Ž (8E). This works fine but I don't know how to convert Tag to buffer INT8 array ?
Saragani Posted July 3, 2018 Report Posted July 3, 2018 Can you upload an example project and tell me where (which rung) you are stuck at? I'm having trouble understanding what works fine and what's not.
SASA Posted July 3, 2018 Author Report Posted July 3, 2018 14 hours ago, Saragani said: Can you upload an example project and tell me where (which rung) you are stuck at? I'm having trouble understanding what works fine and what's not. Dear Sarangi, As mentioned I was playing with byte replacement but I don't know how to send array. In Rang 2 I Find & replace / with Ž integer. but I don't know how to send this array through TCP Server Tx, or how to do Copy Tag to Buffer of this Array. I can only do this with STRING but when I work with Strings I can't replace / with Ž character. I was testing this with Hercules (sending and receiving data over TCP). The program is little bit messy because I'm in testing phase, Sasa proba1.ulpr
Saragani Posted July 4, 2018 Report Posted July 4, 2018 Well, for start, I can assume that you want to replace more than one character, and not only / with Ž, and you repeat the Find and Replace in "BUFFER HEX Rx" data length times. Lets assume that your buffer length is N, the number of characters you want to replace are M. For each characters, you do N replaces, and the Find and Replace searches for the character in the input array, so in the worst case scenario, the Find and Replace goes over all the characters / array members on each iteration. This means that the complexity is N*N*M, which is O(N^3). I would do it differently. I would iterate on the "BUFFER HEX" using a loop (using Jump to Region), from index = 0 to Rx data length, and I would use Load From Array for reading the INT8 value from a specific index on the array. Then I would use a Lookup table in order to get the new INT8 value I need to place. By Lookup table, you can use a Data Table with 128 rows (The struct will contain INT8 member), or just an array, so on each index of that table / array, I place the correct value, for example, for the Letters A to Z and the numbers 0-9. I place their ASCII value, and for row number 47 (which is the ASCII of /, I place the value of 142, which is 0x8E, the ASCII value of Ž). And you can optimize the code, don't try readying the value from the Data Table, of the Value is from the range of A-Z and 0-9 (65-90 and 48-57), and if the Value you read from "BUFFER HEX" is 0, then stop iterating, since it's a Null (end of string). This code has a complexity of O(N) Furthermore, just like you used Copy Buffer to Tag, and placed "BUFFER HEX", then you can do the same thing with Copy Tag to Buffer. When you select "BUFFER HEX" in the "Copy tag to Buffer", then it automatically adds a [ since this tag input accepts both arrays and simple tags like INT8, so if you delete the last [, and press Enter, then it would accept the expression. // EDIT: I see that you are also repeating the find and replace on each cycle and you don't even want for the data to arrive. Here is an updated version of your project. proba1.ulpr
SASA Posted July 4, 2018 Author Report Posted July 4, 2018 2 hours ago, Saragani said: Well, for start, I can assume that you want to replace more than one character, and not only / with Ž, and you repeat the Find and Replace in "BUFFER HEX Rx" data length times. Lets assume that your buffer length is N, the number of characters you want to replace are M. For each characters, you do N replaces, and the Find and Replace searches for the character in the input array, so in the worst case scenario, the Find and Replace goes over all the characters / array members on each iteration. This means that the complexity is N*N*M, which is O(N^3). I would do it differently. I would iterate on the "BUFFER HEX" using a loop (using Jump to Region), from index = 0 to Rx data length, and I would use Load From Array for reading the INT8 value from a specific index on the array. Then I would use a Lookup table in order to get the new INT8 value I need to place. By Lookup table, you can use a Data Table with 128 rows (The struct will contain INT8 member), or just an array, so on each index of that table / array, I place the correct value, for example, for the Letters A to Z and the numbers 0-9. I place their ASCII value, and for row number 47 (which is the ASCII of /, I place the value of 142, which is 0x8E, the ASCII value of Ž). And you can optimize the code, don't try readying the value from the Data Table, of the Value is from the range of A-Z and 0-9 (65-90 and 48-57), and if the Value you read from "BUFFER HEX" is 0, then stop iterating, since it's a Null (end of string). This code has a complexity of O(N) Furthermore, just like you used Copy Buffer to Tag, and placed "BUFFER HEX", then you can do the same thing with Copy Tag to Buffer. When you select "BUFFER HEX" in the "Copy tag to Buffer", then it automatically adds a [ since this tag input accepts both arrays and simple tags like INT8, so if you delete the last [, and press Enter, then it would accept the expression. // EDIT: I see that you are also repeating the find and replace on each cycle and you don't even want for the data to arrive. Here is an updated version of your project. proba1.ulpr Dear Saragani, Thank you for your help. Frankly I'd never go that way you did I'll test the program right away. Sasa
SASA Posted July 4, 2018 Author Report Posted July 4, 2018 4 hours ago, Saragani said: Well, for start, I can assume that you want to replace more than one character, and not only / with Ž, and you repeat the Find and Replace in "BUFFER HEX Rx" data length times. Lets assume that your buffer length is N, the number of characters you want to replace are M. For each characters, you do N replaces, and the Find and Replace searches for the character in the input array, so in the worst case scenario, the Find and Replace goes over all the characters / array members on each iteration. This means that the complexity is N*N*M, which is O(N^3). I would do it differently. I would iterate on the "BUFFER HEX" using a loop (using Jump to Region), from index = 0 to Rx data length, and I would use Load From Array for reading the INT8 value from a specific index on the array. Then I would use a Lookup table in order to get the new INT8 value I need to place. By Lookup table, you can use a Data Table with 128 rows (The struct will contain INT8 member), or just an array, so on each index of that table / array, I place the correct value, for example, for the Letters A to Z and the numbers 0-9. I place their ASCII value, and for row number 47 (which is the ASCII of /, I place the value of 142, which is 0x8E, the ASCII value of Ž). And you can optimize the code, don't try readying the value from the Data Table, of the Value is from the range of A-Z and 0-9 (65-90 and 48-57), and if the Value you read from "BUFFER HEX" is 0, then stop iterating, since it's a Null (end of string). This code has a complexity of O(N) Furthermore, just like you used Copy Buffer to Tag, and placed "BUFFER HEX", then you can do the same thing with Copy Tag to Buffer. When you select "BUFFER HEX" in the "Copy tag to Buffer", then it automatically adds a [ since this tag input accepts both arrays and simple tags like INT8, so if you delete the last [, and press Enter, then it would accept the expression. // EDIT: I see that you are also repeating the find and replace on each cycle and you don't even want for the data to arrive. Here is an updated version of your project. proba1.ulpr Hi Saragani, The program works very nice. Thanks again ! Sasa
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now