Can I use a C shell script for my PLC stuff?
GOT iT. I was trying to run this from the usr/bin ect directory.When I put it in the home folder with the other machine specific fiies and ran "sudo comp buttonlogic.comp",it ran.
DUHHHH
Good job you found that, I doubt we would ever have guessed that it was a rights problem.
Please Log in or Create an account to join the conversation.
jr1050@jr1050-desktop:/usr/realtime-2.6.32-122-rtai/modules/emc2$ sudo comp --install buttonlogic.c
make -C /usr/src/linux-headers-2.6.32-122-rtai SUBDIRS=`pwd` CC=gcc V=0 -o /Module.symvers modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-122-rtai'
CC [M] /tmp/tmp9VDHL7/buttonlogic.o
buttonlogic.comp: In function ‘_’:
buttonlogic.comp:101: error: invalid storage class for function ‘get_data_size’
buttonlogic.comp:101: warning: ISO C90 forbids mixed declarations and code
buttonlogic.comp:101: error: expected declaration or statement at end of input
buttonlogic.comp:101: error: expected declaration or statement at end of input
buttonlogic.comp:101: error: expected declaration or statement at end of input
buttonlogic.comp:101: error: expected declaration or statement at end of input
buttonlogic.comp:101: error: expected declaration or statement at end of input
buttonlogic.comp:101: error: expected declaration or statement at end of input
buttonlogic.comp:101: error: expected declaration or statement at end of input
buttonlogic.comp:101: error: expected declaration or statement at end of input
make[2]: *** [/tmp/tmp9VDHL7/buttonlogic.o] Error 1
make[1]: *** [_module_/tmp/tmp9VDHL7] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-122-rtai'
make: *** [modules] Error 2
Thisi appears to be a an error in the .c file that the pre processor ran.I attahced the .c file any suggestions?Thanks....its late.
Please Log in or Create an account to join the conversation.
Your curly brackets are all over the place, most of them are not needed and some are before conditional if() statements which is wrong
If you use the indenting style in the attached amended version, it is much easier to match them up correctly.
It now compiles fine on my system with comp --compile buttonlogic.c
comp processes the .comp file and outputs a C file, but it does not test it at all, so you don't get C errors until you run it through gcc.
regards
Please Log in or Create an account to join the conversation.
What is on line 101 of the C?buttonlogic.comp:101: error: invalid storage class for function ‘get_data_size’
I suspect that your use of all-caps for pin names might cause problems. I would not be at all surprised to find that MDI_MODE is being macro-substituted at compile-time into quite a different string.
C-convention is that all-caps words are macros. Also the LinuxCNC standard for pin names is all lower case and hyphens rather than underscores. (it is not a well adhered-to standard)
I suspect that one order of your pin names are #defined in one of you #includes. In some IDEs you can right -click to find the definition to check.
Please Log in or Create an account to join the conversation.
This is a piece of my hal file.It works.The button changes state when pushed.
net PB_CYL_START hm2_5i20.0.gpio.049.in_not
I have also assigned the modes of operation to the following names
net AUTO_MODE halui.mode.is-auto
net MDI_MODE halui.mode.is-mdi
net MAN_MODE halui.mode.is-manual
net PROG_RUN_OK halui.program.run
net PROG_RESUME halui.program.resume
net FEED_HOLD halui.program.pause
In the declaretion section of my first comp file(which at this time is named buttonlogic.comp)which is the logic for that pushbutton,I have this..
pin in bit PB_CYL_START;
And in the same file I am attempting to use the bit like so
if(((PB_CYL_START)==1)&&((AUTO_MODE)==1||(MDI_MODE)==1))
RUN_PROGRAM=1;
I have seen some example comp files that attached an extra name at the end of the pin in a fashion like this.
net PB_CYL_START hm2_5i20.0.gpio.049.in_not=pbclystart.buttonlogic
Can I use the original name that is in my hal file ,that is actually attached to the physical pins as I already have or must I follow the convention above and add a second name for the comp file.I plan on elimenateing all the uppercase and underscores.Would I be correct in guessing if the second name is needed it must be followed by .name of the comp file?Thanks again.
Please Log in or Create an account to join the conversation.
This might not be doing what you want. This creates a HAL "signal" called AUTO_MODE, but that is not the same as the AUTO_MODE "pin" that is created by your .comp component, which is called buttonlogic.0.AUTO_MODE.net AUTO_MODE halui.mode.is-auto
This will create a HAL "pin" called buttonlogic.0.PB_CYL_START, to use that in your HAL file you will need something like:In the declaretion section of my first comp file(which at this time is named buttonlogic.comp)which is the logic for that pushbutton,I have this..
pin in bit PB_CYL_START;
net pb_cyl_start_signal buttonlogic.0.PB_CYL_START <= hm2_5i20.gpio.049.in_not
This creates a HAL "signal" called pb_cyl_start_signal (you can use any name you like) which follows the value of the output pin to which it is assigned (hm2_5i20.gpio......) and writes that value to any input pin to which it shares a "net" command, in this case buttonlogic.0.PB_CYL_START.
I am confused when you say "in the same file". The line above is C / .comp syntax, but "net" commands are HAL file syntax.And in the same file I am attempting to use the bit like so
if(((PB_CYL_START)==1)&&((AUTO_MODE)==1||(MDI_MODE)==1))
RUN_PROGRAM=1;
I think that the logic above belongs in your .comp file, and the HAL file should just be "net"-ing the RUN_PROGRAM HAL pin to a physical output pin.
You _can_ do that sort of logic in HAL, but that involves netting together a bunch of and2 and or2 HAL components (which are written in .comp)
Incidentally, that line would work just as well as:
if (PB_CYL_START && (AUTO_MODE || MDI_MODE )) RUN_PROGRAM=1;
In fact this is better, as "TRUE" parport pins in HAL simply have a non-zero value, not necessarily 1. (hm2 gpio pins are always 1 == true, though)
Please Log in or Create an account to join the conversation.
Id say the manual needs a section that says "pin in bit blah_blah" will create a signal(name?) in your .comp file called "0.blah_blah' and to make this name actually do something it has to be tied to a real pin(name,signal?) like so ,net but_blah mycompfileblah.0.blah_blah=hm2_5i20.gpio.049.in_not in your .hal file.
Again,a huge thanks for your help,hopefully I understand this correctly,Im sure Ill have a few more before its all over...
Please Log in or Create an account to join the conversation.
I'll work on that.
John
Please Log in or Create an account to join the conversation.
jr1050@jr1050-desktop:/usr/realtime-2.6.32-122-rtai/modules/emc2$ sudo comp --install coolant.comp
[sudo] password for jr1050:
make -C /usr/src/linux-headers-2.6.32-122-rtai SUBDIRS=`pwd` CC=gcc V=0 -o /Module.symvers modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-122-rtai'
CC [M] /tmp/tmp0lP5aI/coolant.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "hal_init" [/tmp/tmp0lP5aI/coolant.ko] undefined!
WARNING: "rtapi_print_msg" [/tmp/tmp0lP5aI/coolant.ko] undefined!
WARNING: "hal_exit" [/tmp/tmp0lP5aI/coolant.ko] undefined!
WARNING: "hal_export_funct" [/tmp/tmp0lP5aI/coolant.ko] undefined!
WARNING: "hal_malloc" [/tmp/tmp0lP5aI/coolant.ko] undefined!
WARNING: "hal_pin_bit_newf" [/tmp/tmp0lP5aI/coolant.ko] undefined!
WARNING: "rtapi_snprintf" [/tmp/tmp0lP5aI/coolant.ko] undefined!
WARNING: "hal_ready" [/tmp/tmp0lP5aI/coolant.ko] undefined!
CC /tmp/tmp0lP5aI/coolant.mod.o
LD [M] /tmp/tmp0lP5aI/coolant.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-122-rtai'
cp coolant.ko /usr/realtime-2.6.32-122-rtai/modules/emc2/
I do have a coolant .ko file and the pins show in hal show.My inputs show change of state(when the coolant button is pushed,coolant.0.pb_cool_on go high),but I have no change to my output bit,so consequently, have actual output to the machine.
Below is the small file i am trying to run
component coolant;
pin in bit pb_cool_on;
pin out bit cl_idod_clnt;
variable bool run_program;
variable bool cs_coolant_on;
variable bool cs_coolant_off;
variable bool collet_clsd;
variable bool collet_opn;
function _ nofp;
license "gpl";
;;
FUNCTION(_)
{
//coolant on button///
if((pb_cool_on)==1)
{
cl_idod_clnt=1;
cs_coolant_on=1;
}
}
Here is my hal file.
are the errors that are showing up at install time causing my output not to function or am I missing something else?Thanks as always...
Please Log in or Create an account to join the conversation.
Probably not, they seem to always appear.are the errors that are showing up at install time causing my output not to function or am I missing something else?
It looks like it ought to work. Are you not seeing the pin change on the Mesa card, or isn't it changing in HAL either?
I doubt this is the problem, but use
if(pb_cool_on)
rather than
if((pb_cool_on)==1)
As there is no guarantee that a "true" bit value is 1, it is merely any non-zero value.
Please Log in or Create an account to join the conversation.