Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read from flle
#1
Hi,

What would be the best way to read the contents of a txt file and use it on my system?

I'm already saving in a .txt the last commanded position of a Motor, and at my controller startup (in case of a reboot) I would like to set Motor[i].HomePos as the value saved in the file.
Reply
#2
If you are trying to just read PMAC commands, you can issue the Linux command "gpascii -i/<filepath>"

So if you have a text file named "Commands.txt" loaded into the "Documentation" folder of your project (already downloaded onto PMAC), you could issue in the terminal:

system gpascii -i/var/ftp/usrflash/Project/Documentation/Commands.txt

Note that issuing this from a PLC or Motion Program would use the "system" command and require quotation marks, though the above syntax should work in the terminal.



Depending on what the parameters are, you could also look into using "pp_custom_save.tpl" along with the "fsave" and "fload" commands--so if you wanted to back up Motor[1].JogSpeed, you would:

1. Put "Motor[1].JogSpeed" into "pp_custom_save.tpl", then download the project
2. Set Motor[1].JogSpeed to the desired value
3. Issue "fsave"
4. Do other tasks, including possibly changing the jog speed or power cycling the PMAC
5. Issue "fload" to re-load the saved values




Now, if you need to parse the text file (ie, if it isn't formatted properly to be directly issued to PMAC), then you would likely need a custom C Application that could parse it and issue the correct commands, but that would be a different task.
Reply
#3
Thanks, AAnikstein!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)