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

More
23 Jan 2012 14:28 #17051 by JR1050
I have a Hardinge HNC lathe that is 90% done.I realize I can use Classic ladder,a Comp component or a Python userspace script for plc coding.I have no desire to ladder program,so can I simply write my plc stuff as a C shell script and call it as a user space com[onent? Thanks.

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

More
23 Jan 2012 16:45 #17058 by andypugh
JR1050 wrote:

can I simply write my plc stuff as a C shell script and call it as a user space com[onent? Thanks.

I am not sure what you mean by "C shell script", but it is relatively easy to write it in comp then compile as a user-space component.
linuxcnc.org/docs/html/hal_comp.html
I have never written a userspace component, but as far as I can see the only difference is that you load them with loadusr rather than loadrt in the HAL file, and that you put "option userspace yes" in the .comp file.

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

More
23 Jan 2012 17:05 #17059 by ArcEye
Hi

As Andy says, userspace component is probably the way to go.

All you need to write is the C routine that does the actual job required, comp will add all the stuff to enable it to be loaded from a .hal file and have visible hal pins etc

In its simplest form, the userspace component just needs void user_mainloop(void) after the pin declarations, options etc..

user_mainloop can just contain a while(1){ } loop which does whatever you want it to each time it is polled.

All the normal C libraries are available, so it is far easier to write than a real time component in many ways.

regards

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

More
24 Jan 2012 00:38 #17074 by cmorley
Userspace program for a PLC?

PLC stuff is usually realtime.

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

More
24 Jan 2012 01:08 #17076 by BigJohnT
JR1050 wrote:

I have a Hardinge HNC lathe that is 90% done.I realize I can use Classic ladder,a Comp component or a Python userspace script for plc coding.I have no desire to ladder program,so can I simply write my plc stuff as a C shell script and call it as a user space component? Thanks.


What exactly are you needing to do? Tool change in classicladder is done and on my web site for my CHNC which I think is the same as the HNC as far as the turret goes.

John

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

More
24 Jan 2012 05:14 #17081 by JR1050
My initial idea was to write an executable shell script in the c shell( csh,like bash or ksh).It seemed like it might be easier than Comp and considering Python scripts work as user space components,it mighta been worth a shot.I have some previous retrofit experience with Delta Tau and I wrote two PLC programs for a Cincinatti lathe.One was estop,error messages and button functions,the other for the Duplimatic turret.DT scans for changes in i/o states and acts on the changes accordingly.I was thinking about just writing one long file with my turret,estop logic,fault conditions ect.Right now Im using some and/or functions to get things up and going.

I do appreciate that the HNC turret logic has been figured out and shared.Im a glutten for punishment and was gonna have a go at it myself,just for the learning experience.Im not hot on ladder programming and Classic ladder runs in userspace anyway.I was thinking about putting a reverseable two way solinoid on the lathe so the turret would be bi directional.

Thanks for all the input,I started writing the C component and will post some snippets...its a first and Im sure Im gonna get stuck!!.I posted some pics.....


if I can be of any help to any one,please ask!!!
Attachments:

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

Time to create page: 0.119 seconds
Powered by Kunena Forum