I am looking for a way to write values to Fanuc variables (i.e. local variable #1) on a Fanuc 21i or 31i controller from my PC. Currently, I am connected via the serial RS 232 port but I can invest in additional hardware or controller add-ons if necessary.
Are you wanting to do this while a program is running on the machine? If so, its not going to happen without modification to the PMC. If you're going to be setting the Variables whilst the machine is not operating another program, it can be done simply by creating a program with the code for whatever Variables you want to set in the form of:
#1 = 11111
#2 = 22222
However, as these are local Variables, if you terminated the PC Program with M30, this will Reset the Local Variables back to Empty (Null). You could call the program you want to run for your part manufacture, as a Subprogram that is called by a Subprogram Call Block sent from the PC, but if the Variables being set are to be used in the Subprogram, you would have to use Common Variables, or pass the Local Variable values via a Macro Call Block (G65).
A better explanation of your goal is required.
sending a program to the control via DNC with the control mode set to Auto/Memory