Can I use a C shell script for my PLC stuff?

More
22 Feb 2012 14:59 #17935 by JR1050
Thanks again for your help.I have the turret up,indexing and stopping in the right spot.I need to get it to drop down and seat.I have not had much sucess using the timedelay component.Is there any one out there who has a good grasp of how it works? The manual page is not very descriptive....

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.

More
22 Feb 2012 15:14 #17936 by andypugh
JR1050 wrote:

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.

More
22 Feb 2012 16:32 #17941 by JR1050
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 ?Is timer in or char variable ot int? Thanks

Please Log in or Create an account to join the conversation.

More
22 Feb 2012 16:39 #17942 by ArcEye
Hi,

I have not had much success using the timedelay component..

The example of its use is in the header of the oracchanger.comp
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";
delaystart is set true when the motor is set into reverse to engage the pawl
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.

More
22 Feb 2012 17:05 #17943 by andypugh
JR1050 wrote:

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.

More
29 Feb 2012 14:26 #18203 by JR1050
A big thank you to Arceye and Andy.I finally got this thing workn and learned a few things along the way!!
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.

More
01 Mar 2012 11:58 #18232 by BigJohnT
On a Hardinge turret you have to time the magnet on the encoder to get it to stop correctly on the commanded tool. It is a very simple ladder logic to control the tool changer.

John

Please Log in or Create an account to join the conversation.

More
01 Mar 2012 13:49 #18234 by JR1050
Ive noticed several other folks have stopped it right on the commanded tool,I couldnt get it to land consistently,it would overshoot or under shoot.I suspect if I started with a machine that indexed correctly before the rebuild,it might stand a better chance.Adjusting all that mess with no real place to start is asking for trouble.I spent about 3 days trying to get it to land on the actual number.

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.

More
02 Mar 2012 00:32 - 02 Mar 2012 00:33 #18249 by BigJohnT
My CHNC is configured to home the X axis toward the operator (me) ie. away from the spindle or if your standing at the imaginary tail stock end the left side or positive X side.

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
Last edit: 02 Mar 2012 00:33 by BigJohnT.

Please Log in or Create an account to join the conversation.

More
02 Mar 2012 14:32 #18259 by JR1050
I have the HNC set to home to the same place,90% of the time it does,The other 10% it homes to the neg side.Ill look into it.

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.

Time to create page: 0.082 seconds
Powered by Kunena Forum