Sign in to follow this  
Followers 0
Tito&Earl

ASCII Text File on Mem Card to CPU Memory

6 posts in this topic

Hello All, I was wondering if I could get some help. The project I am working on: 1- Takes a file (will be either .txt or .CSV) from our network and transfers it to the CF memory card in a CJ2H via FTP. 2- From there I want to read the ASCII text characters and get them into the PLC. 3- An NS touchscreen will display the information 4- Upon user acceptance/acknowledgment, this information will be sent to a Domino Inkjet printer via RS232 and also to two Cognex vision cameras via Ethernet/IP. Where I am getting hung up is item 2...getting the ASCII text characters into the PLC. Example text string in the file: NE0457,1769-09 If the string was simply numbers (HEX) I'd have no problem using FREAD. From what I've been able to find searching around the forum it appears that the data would have to first be converted from ASCII text to HEX ASCII code in order to get it into the PLC memory. Anyone have any sugguestions or links to help direct me into the right direction? -Thanks! Edited by Tito&Earl

Share this post


Link to post
Share on other sites
I am mobile right now, so don't have access to manuals etc to confirm. But, converting ASCII to no's is relatively easy, you just need to make sure that the file you reading is in the correct format. This means that your file would have to be converted to ASCII first. When I get back online with PC, I should be able to post more.

Share this post


Link to post
Share on other sites
Ok, you can use the NUM/4/8/16 instructions to convert ASCII data to a number. You will have to ensure that all the digits of the data you are converting are actuall ASCII no's also. Also, your data on your CF would have to be represented as ASCII characters.. ie. 3056 would have to be 33303536 (I think, I have not tested this, so cannot confirm...)

Share this post


Link to post
Share on other sites
Thanks for the reply. Sorry I totally messed up my post. The text or CSV file contains alphanumeric characters (e.g. NE0457,1769-09). I was wondering if there is any other way to read in this text string without first converting the file contents to ASCII code or is there a means for the PLC to convert the text string into ASCII? I edited the original post to correct it. Thanks again any help. Edited by Tito&Earl

Share this post


Link to post
Share on other sites
Not sure, would have to do some testing with reading of file contents to see what format appears in the PLC. What testing have you done, with what results? ie, what were the contents of the file, & what appeared in the PLC memory area?

Share this post


Link to post
Share on other sites
I first tried FREAD but it would error flag if any of the characters were non HEX (anything not 0-9 or A-F). Anything HEX it would read in just fine exactly how it was in the file. I started messing around with the Read CSV function block but again it would error flag. Haven't got to really dive into the function blocks as I am off all this week and I haven't been able to find anything to do what I need. Seems as though I am going to have to have the contents of the file be be converted to ASCII code/Hex in order for the PLC to read it in. Was hoping there was another way. Hopefully our AS400 system will be able to generate the file in ASCII code/HEX instead of alphanumeric if all else fails.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0