Can I use a C shell script for my PLC stuff?
Im attemping this;
pin out bit timer_run; ///////timedelay.0.timer-run
case 2:///wait for the turret to seat
if((turret_pos_m)==(next_tool)&&(ls_turret_up)!=1)
{
tc_cond=3; //state of this plc
sl_turret_index=0; // turn off the index motor causing the turret to seat
timer_run=1; // wait for it to drop down
sl_turret_stop=0; //disengage the stop pin
}
break;
In hal
setp timedelay.0.on-delay 2
net run_timer timedelay.0.timer-run = timedelay.0.in( i think,i dont have the hal file infront of me)
This should work,but...it dont.I wrote the same function with if statements and got stuck in the same place,again any one have a detailed knowledge hoe the timedelay works.Thanks.
Please Log in or Create an account to join the conversation.
I have not had much sucess using the timedelay component..
I think it is a mistake to try to use that here.
timedelay simply sets an output pin high a fixed time after the input pin goes high. Feeding those pins into and out of your comp is a waste of time.
It makes a lot more sense to do it all inside your comp.
...
case 5:
timer = 0;
tc_cond = 6;
break;
case 6; // waiting
timer = timer + fperiod; //(or use timer += fperiod)
if (timer > 10) { // Not sure if this is seconds, nanoseconds, fortnights)
state = 7;
}
break;
case 7: // finished waiting..
...
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
The example of its use is in the header of the oracchanger.compI have not had much success using the timedelay component..
loadrt timedelay count=1
addf timedelay.0 servo-thread
# will wait 5 secs approx and turn motor off after reversing against stop
setp timedelay.0.on-delay 5
net delaystart timedelay.0.in <= oracchanger.delaystart
net delaydone timedelay.0.out => oracchanger.delaydone
.........
pin out bit delaystart = false "Starts timerdelay";
pin in bit delaydone =false "Signals timer finished";
When delaydone is positive the motor is shut off
I could have just used an inline timer, partly because I could not find a satisfactory definition of fperiod I decided to use a stock component.
The other reason was that using an external counter made it easy to continue to a idle state (progress_level 0) in the component and just turn off the motor when the delaydone signal comes back.
There is no 'right' way, just different paths leading to the same end
regards
Please Log in or Create an account to join the conversation.
I can do this,but I would like to know how this works,so question 1,fperiods,do I have to define this or does comp just know it when it see's it
"fperiod" is described in the comp docs under "Convenience macros"
linuxcnc.org/docs/html/hal_comp.html#r1_8
It is the floating point representation of the time since the function was last called, in seconds.
(you can also use "period" if you want it as nanoseconds in integer notation)
Your timer variable needs to be a double or float.
Please Log in or Create an account to join the conversation.
I couldnt get Andy's timer to work for me(mostly bescause I dont understand how it works!!!),I did however get the time delay component to work.
For any one who might be fighting with all the toolchange i/o,here are some things i found out;
After calling a tool with a t word(iocontrol.0.tool-prep-number),the register is set to zero and now
for comparing the toolchanger postion to the commanded tool,you have to use iocontrol.0.tool-number.
On a hardinge turret,you have to stop the tool one before the commanded tool(I had to do this on my Cincinatti also) due to the air motor overshooting.My guess is that an air motor is not accurate enough to used for postioning.Maybe a servo.
To compile your C file you have top run comp in the emc2 realtime directory like so sudo comp --install comp myfile.comp.It wont compile as the root user.To edit your file run sudo gedit as above.
Thanks again and I post a video of if shortly.Ive been making notes on what I had to do to get this to work along the way.Ill post them.
Please Log in or Create an account to join the conversation.
John
Please Log in or Create an account to join the conversation.
I have a Duplimatic turret on my Cincinatti(which has a Delta Tau on it) and it has to be stopped 1 before the commanded tool also,go figure.It uses a non servo AC motor.
The hardinge changes tools fast.The kool thing about a comp file is,it is easy to change....
When your CHNC homes,is home position for the X axis to the right or left in relation to the spindle face when the machine is veiwed from standing on the power cabinet end (tailstock end,it it had one)? Some times mine will home either way.Thanks
Please Log in or Create an account to join the conversation.
Under the far cover next to the turret is the encoder if you have not found it. Just loosen the screw that holds the magnet arm and move CW or CCW as needed to get the turret to stop in the correct place.
John
Please Log in or Create an account to join the conversation.
I messed around trying to get the turret to land on the exact spot every time,It would land about 50% of the time.There seems to be some lash in the worm that drives the encoder shaft.
It turned out to be much simpler to put the magnet right on top of the hall switch.It then over shoots the commanded tool,everytime .From there i wrote some code to subtract 1 from the commanded tool if the tool was not 1 or add 7 if the commanded tool was one.I put a 5/8 second delay for locking the turret down using the timedelay component.I also wrote some code to update the tool on start up,so EMC knows what tool is up with out a tool change and some error code to tell the operator if the turret isnt seated or if the wrong tool is up.Im very happy with the way the turret index's as of now.It is fast and in the 50 or so tool changes its doe,it hasnt missed one yet.
I am probably looking at the EMC from a different point of view then most .Ive been a toolmaker for 25 years and own a shop full of older,mostly American iron.Ive been gettn killed having old electronics repaired,not to mention the old contols,well,suck...being able to breath life into old machines is awesome.
The machines,however have to be safe.They need to have error messges,so the opperator can keep the machine running with out having to open a hal file or edit a comp file.
Again,thanks to everyone who helped me out so far.Ill get some pics/video up soon for any one who is interested.
Please Log in or Create an account to join the conversation.