Saving parameters after shut down
26 Dec 2012 12:31 #28038
by JR1050
Saving parameters after shut down was created by JR1050
I have a Cinci lathe that has a power chuck,tailstock and parts catcher, none of which have limit switches or sensors to indicate their position .On the original Acra 850 control the state was set by initializing the machine and storing the position of of the tailstock or chuck.The control tracked a "state " and stored its last state on powerdown.
I need to be able to do the same thing,how do I write directly to the hard drive to save the last state of a parameter so I dont have to manually set the state of each of these on every power up? My logic is written as comp's in C. Suggestions?
Thanks
I need to be able to do the same thing,how do I write directly to the hard drive to save the last state of a parameter so I dont have to manually set the state of each of these on every power up? My logic is written as comp's in C. Suggestions?
Thanks
Please Log in or Create an account to join the conversation.
27 Dec 2012 00:26 #28045
by ArcEye
Replied by ArcEye on topic Saving parameters after shut down
Hi
You probably need to expand a little upon what exactly you will be saving.
Lost me a bit as to what the 'state' consists of, if it cannot determine where the items are.
If your component is a userspace one, then you can just use the standard file functions from stdio.h, but I suspect the reason you ask is because it is a realtime component?
One easy way to side step the problems of accessing devices from a realtime module, would be to write a userspace component whose sole function is to read parameters at start up and write them to disc when signalled at close down.
You could then just connect the userspace to the realtime component, via suitable HAL pins for your data type, and have a signal pin to trigger a read or write.
regards
..............................none of which have limit switches or sensors to indicate their position
You probably need to expand a little upon what exactly you will be saving.
Lost me a bit as to what the 'state' consists of, if it cannot determine where the items are.
If your component is a userspace one, then you can just use the standard file functions from stdio.h, but I suspect the reason you ask is because it is a realtime component?
One easy way to side step the problems of accessing devices from a realtime module, would be to write a userspace component whose sole function is to read parameters at start up and write them to disc when signalled at close down.
You could then just connect the userspace to the realtime component, via suitable HAL pins for your data type, and have a signal pin to trigger a read or write.
regards
Please Log in or Create an account to join the conversation.
27 Dec 2012 01:11 #28048
by ArcEye
Replied by ArcEye on topic Saving parameters after shut down
This is an example of what I was talking about, it compiles OK but not tested.
(I have cast the float pin to float* from volatile real_t*, don't know how that will pass through fscanf,
if there are problems you could just use an intermediary float variable to receive it and then set the pin value from that )
(I have cast the float pin to float* from volatile real_t*, don't know how that will pass through fscanf,
if there are problems you could just use an intermediary float variable to receive it and then set the pin value from that )
component paramhelper;
pin in float invalue "Receives value to save";
pin out float outvalue "Sends value";
pin in bit readtrigger = 0 "signal to read from file";
pin in bit writetrigger = 0 "signal to write to file";
option singleton yes;
option userspace yes;
author "ArcEye";
license "GPL";
;;
#include <stdio.h> /* Standard input/output definitions */
#include <stdlib.h>
#include <stdint.h> /* Standard types */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <signal.h>
int done = 0;
void adios(int sig)
{
done = 1;
}
void user_mainloop(void)
{
char filepath[] = "~/emc2/param.sav";
int read = 0;
signal(SIGINT, adios);
signal(SIGTERM, adios);
while(!done)
{
usleep(500000);
FOR_ALL_INSTS()
{
if(readtrigger && !read) // only want to read once
{
FILE *fp;
fp = fopen(filepath, "r");
fscanf(fp, "%f", (float*)&outvalue);
read = 1;
}
else if(writetrigger)
{
FILE *fp;
fp = fopen(filepath, "w");
fprintf(fp, "%f", invalue);
}
}
}
exit(0);
}
The following user(s) said Thank You: JR1050
Please Log in or Create an account to join the conversation.
27 Dec 2012 01:49 #28051
by JR1050
Replied by JR1050 on topic Saving parameters after shut down
Thanks for the response. Let me see if i can explain.The chuck can be used to grab the part from the inside or the outside.It uses two solenoids to open or close the chuck.The chuck can be operated by a single foot switch or by mcodes.The control does not know whether the chuck is open or closed,so it gets a parameter,a bit,'" inside_chuck" or "outside_chuck" set. Right now im using a button to set the state of inside or outside,Id like to set it once and save the last known state.whether inside or outside,so on power up,the control knows the chuck is open(od grip) or closed(id grip).
You are correct,all of this is written as a realtime component.The userspace example is what I was looking for. Figuring machine logic is relatively easy,the c programming I know is from writing tool changers ,ect. Im kinda missing the how to use C part of using C for regular computer stuff,if any of that makes any sense!!!Thanks!!
You are correct,all of this is written as a realtime component.The userspace example is what I was looking for. Figuring machine logic is relatively easy,the c programming I know is from writing tool changers ,ect. Im kinda missing the how to use C part of using C for regular computer stuff,if any of that makes any sense!!!Thanks!!
Please Log in or Create an account to join the conversation.
27 Dec 2012 02:22 #28054
by ArcEye
Replied by ArcEye on topic Saving parameters after shut down
You're welcome
The example is back of an envelope stuff.
Occurred to me after posting that synchronising between a realtime and userspace component, it would probably be best to have a data-ready bit flag so that the realtime component knows that outvalue has been set to something meaningful .
Otherwise, unless you programmed a delay, it would send a read command and then immediately read the value of the pin which would probably still be 0 because it was being updated on a much slower thread.
regards
The example is back of an envelope stuff.
Occurred to me after posting that synchronising between a realtime and userspace component, it would probably be best to have a data-ready bit flag so that the realtime component knows that outvalue has been set to something meaningful .
Otherwise, unless you programmed a delay, it would send a read command and then immediately read the value of the pin which would probably still be 0 because it was being updated on a much slower thread.
regards
Please Log in or Create an account to join the conversation.
27 Dec 2012 04:19 #28059
by BigJohnT
Why not just have a selector switch for ID/OD chuck.
John
Replied by BigJohnT on topic Saving parameters after shut down
Thanks for the response. Let me see if i can explain.The chuck can be used to grab the part from the inside or the outside.It uses two solenoids to open or close the chuck.The chuck can be operated by a single foot switch or by mcodes.The control does not know whether the chuck is open or closed,so it gets a parameter,a bit,'" inside_chuck" or "outside_chuck" set. Right now im using a button to set the state of inside or outside,Id like to set it once and save the last known state.whether inside or outside,so on power up,the control knows the chuck is open(od grip) or closed(id grip).
Why not just have a selector switch for ID/OD chuck.
John
Please Log in or Create an account to join the conversation.
27 Dec 2012 06:03 #28064
by JR1050
Replied by JR1050 on topic Saving parameters after shut down
I could use a selector switch,but I will still have to initialize the control and make sure the chuck is matching the switch!! Right now Im using the cycle start button (when in manual mode),to write to a bit,but it is not saved at shut down.It would be much easier if everytime the chuck is opened or closed I set a bit and the bit is retained on shutdown.I also have a tailstock and parts catcher with the same issue,sooo....if it could be done with the lame Acra control,I can do it here!!!!
In all honesty,it would be nice to save the tool # in the turret and on a machine like say my Brown &Sharpe mill,which can have a tool in the spindle,a tool in the ready pocket and the tool pocket on the tool chain,saving what is where saves a bunch of hassle in the morning when firing the beast up.If you get the tools out of sync,it can a while to get them right. Saving them,like modern machines do is the way to go. Ill post the code I have so far.Thanks as usual!!
In all honesty,it would be nice to save the tool # in the turret and on a machine like say my Brown &Sharpe mill,which can have a tool in the spindle,a tool in the ready pocket and the tool pocket on the tool chain,saving what is where saves a bunch of hassle in the morning when firing the beast up.If you get the tools out of sync,it can a while to get them right. Saving them,like modern machines do is the way to go. Ill post the code I have so far.Thanks as usual!!
Please Log in or Create an account to join the conversation.
27 Dec 2012 06:10 #28065
by BigJohnT
Replied by BigJohnT on topic Saving parameters after shut down
One of the problems I see without sensors is getting out of sync if you do something with the power off. And your correct you can do almost anything in LinuxCNC. The thing that confuses me is if these devices are controlled with a contactor or solenoid in your G code would it not be prudent to set them as expected in the preamble?
John
John
Please Log in or Create an account to join the conversation.
27 Dec 2012 10:30 #28072
by JR1050
Replied by JR1050 on topic Saving parameters after shut down
Well,Im not sure these are g code type things,they really are misc machine functions.They can be controlled by mcode in MDI or in auto mode.In manual mode they are controlled by by buttons and switches.
Considering at the end of the day,after the last part is run,you leave the chuck open and the tailstock extended, and the normal position is chuck closed,tailstock back,the machine will be out of sync.My hardinge uses limit switches for everything,this machine,my Mori and my old Ikegai dont,they save the condition of the individual appendage as what it last was.I got the Ikegai confused once with the chuck,and it was a bear to get it right.
Considering at the end of the day,after the last part is run,you leave the chuck open and the tailstock extended, and the normal position is chuck closed,tailstock back,the machine will be out of sync.My hardinge uses limit switches for everything,this machine,my Mori and my old Ikegai dont,they save the condition of the individual appendage as what it last was.I got the Ikegai confused once with the chuck,and it was a bear to get it right.
Please Log in or Create an account to join the conversation.
12 May 2013 21:56 #33951
by mariusl
How would one signal the file to read or write at close down or startup?
Regards
Marius
www.bluearccnc.com
Replied by mariusl on topic Saving parameters after shut down
One easy way to side step the problems of accessing devices from a realtime module, would be to write a userspace component whose sole function is to read parameters at start up and write them to disc when signalled at close down.
You could then just connect the userspace to the realtime component, via suitable HAL pins for your data type, and have a signal pin to trigger a read or write.
How would one signal the file to read or write at close down or startup?
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.
Time to create page: 0.086 seconds