Help needed to get my 7i76E + 7i85S + 7i73 on my mill going.

More
8 years 2 months ago #116243 by tecno
So down in my shop and trying to install linuxcnc-dev but no-go in my Mint installation. Need to get my comp file working.

Any clues what can be wrong?

sudo apt-get install linuxcnc-dev is what I try to use

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

More
8 years 2 months ago #116246 by tecno
Hmmm appears o be installed but again errors

bengt@CombiMll ~/linuxcnc/configs/CM_GEARBOX $ sudo halcompile --compile gearbox3.comp
Traceback (most recent call last):
File "/usr/bin/halcompile", line 1353, in <module>
main()
File "/usr/bin/halcompile", line 1322, in main
process(f, mode, outfile)
File "/usr/bin/halcompile", line 1192, in process
a, b = parse(filename)
File "/usr/bin/halcompile", line 417, in parse
a, b = f.split("\n;;\n", 1)
ValueError: need more than 1 value to unpack


Can you guys see what is wrong in the comp file

File Attachment:

File Name: gearbox3.comp
File Size:1.67 KB


Cheers
Bengt

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

More
8 years 2 months ago #116276 by tecno
Some progress, fixed some typos and now it complaints about this on line 12. We are making progress

pin out int wantedgear "Shift to this gear if told so";

Something with int
Code:
component gearbox3 "LinuxCNC HAL component for Tecno's gearbox"; author "Rod Webster Håkan Båstedt"; pin in bit input_a "input a"; pin in bit input_b "input b"; pin in bit input_c "input c"; pin in bit input_d "input d"; pin in bit input_e "input e"; pin in bit higear "true if in high gear"; pin in float speed "Spindle speed in RPM as in Sxxx"; pin out bit gearshift "Need to shift gear, true if high"; pin out int wantedgear "Shift to this gear if told so"; pin out float speedratio "max RPM for machine divided by maximum RPM for gear"; param rw float maxrpm "maximum RPM for machine"; function _; license "GPL"; ;; #include <rtapi_math.h> FUNCTION(_) { static double speeds[7][2] = { { 160.0, 80.0} { 270.0, 160.0}, { 450.0, 270.0}, { 750.0, 450.0}, {1250.0, 750.0}, {1500.0, 1250.0}, {2500.0, 1500.0}, }; // Gears are number from 1 (lowest) to 7 // Check which gear to use with this speed Sxxx int geartouse = -1; for (int i=0; i<7; i++) { if (speed <= speeds[i][0] && speed > speeds[i][1]) geartouse = i+1; } // Which gear is engaged int gearengaged = 1*input_a + 2*input_b + 3*input_c + 4*inpud_d + 5*input_e + 5*higear; if (geartouse == gearengaged) { // Everything ok gearshift = 0; wantedgear = gearengaged; speedratio = speed/speeds[gearenaged-1][0]; } else { // Should change gear gearshift = 1; wantedgear = geartouse; speedratio = speed/speeds[geartouse-1][0]; } }

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

More
8 years 2 months ago - 8 years 2 months ago #116283 by Hakan
I also want to claim the holiday reason :)
I think it is the "int" that is wrong, There seems to be no such datatype for hal pins.
Either "s32" or "u32" for signed or unsigned integer.
Chose "s32" so you can have -1 for "no suitable gear found".

Regarding the gear calculation. The one-line way doesn't add any
failure protection. If that is important, you need to expand on that.
Andy's way may be better. You have to see and judge what is important
for you.
Last edit: 8 years 2 months ago by Hakan.

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

More
8 years 2 months ago #116288 by tecno
No worries here Håkan, I appreciate all the help I can get. Made some progress now for loop error.

File Attachment:

File Name: gearbox3_2...-19.comp
File Size:1.61 KB

Code:
bengt@debian:~/linuxcnc/configs/sim.gmoccapy$ halcompile --install gearbox3.compmake KBUILD_EXTRA_SYMBOLS=/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc/Module.symvers -C /usr/src/linux-headers-3.4-9-rtai-686-pae SUBDIRS=`pwd` CC=gcc V=0 modules make[1]: Entering directory `/usr/src/linux-headers-3.4-9-rtai-686-pae' CC [M] /tmp/tmpxFPQ1m/gearbox3.o gearbox3.comp: In function ‘_’: gearbox3.comp:39:5: error: ‘for’ loop initial declarations are only allowed in C99 mode gearbox3.comp:39:5: note: use option -std=c99 or -std=gnu99 to compile your code gearbox3.comp:45:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] gearbox3.comp:50:33: error: ‘gearenaged’ undeclared (first use in this function) gearbox3.comp:50:33: note: each undeclared identifier is reported only once for each function it appears in make[4]: *** [/tmp/tmpxFPQ1m/gearbox3.o] Fel 1 make[3]: *** [_module_/tmp/tmpxFPQ1m] Fel 2 make[2]: *** [sub-make] Fel 2 make[1]: *** [all] Fel 2 make[1]: Leaving directory `/usr/src/linux-headers-3.4-9-rtai-686-pae' make: *** [modules] Fel 2 bengt@debian:~/linuxcnc/configs/sim.gmoccapy$

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

More
8 years 2 months ago - 8 years 2 months ago #116290 by rodw
Its best practice to define variables at the head of the function. The exception might be if you have a low memory environment.
I don't think the halcompile environment likes a definition of the loop variable in the for statement. Also you are mixing types by assigning an int (geartouse) to a long (eg. S32) so try this:
Code:
FUNCTION(_) { static double speeds[7][2] = { { 160.0, 80.0}, { 270.0, 160.0}, { 450.0, 270.0}, { 750.0, 450.0}, {1250.0, 750.0}, {1500.0, 1250.0}, {2500.0, 1500.0}, }; // Gears are number from 1 (lowest) to 7 // Check which gear to use with this speed Sxxx long geartouse = -1; int i; for (i=0; i<7; i++) { if (speed <= speeds[i][0] && speed > speeds[i][1]) geartouse = (long) i+1L; } // Which gear is engaged int gearengaged = 1*input_a + 2*input_b + 3*input_c + 4*input_d + 5*input_e + 5*higear; if (geartouse == gearengaged) { // Everything ok gearshift = 0; wantedgear = gearengaged; speedratio = speed/speeds[gearenaged-1][0]; } else { // Should change gear gearshift = 1; wantedgear = geartouse; speedratio = speed/speeds[(int)geartouse-1][0]; } }

I'm not sure if halcompile will like 1L which signifies 1 is a long type. If it complains, try "(long) 1" instead

OOPS just edited as an explicit typedef is required on the line where speedratio is defined.
Last edit: 8 years 2 months ago by rodw. Reason: OOPS just edited as an explicit typedef is required on the line where speedratio is defined.

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

Moderators: cmorley
Time to create page: 0.473 seconds
Powered by Kunena Forum