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

More
8 years 2 months ago #116775 by andypugh

andypugh wrote: This adds an extra output that can be used with the message HAL component to say which gear should be selected. (using bitslice to convert the int to individual bits)


Actually, requiring bitslice is laziness on my part.
Code:
component GB_2speed; pin in bit spindle-enable-in; pin out bit spindle-enable-out; pin in float spindle-speed-in; pin out float motor-speed-out; pin in bit gear-high; pin in bit motor-high; pin in bit gear-A; pin in bit gear-B; pin in bit gear-C; pin in bit gear-D; pin in bit gear-E; pin out unsigned gear-required; pin out bit message[14]; license "gpl"; function _; ;; FUNCTION(_){ int actual, reqd; int i; // These need to be edited to suit the gearbox int speeds[15] = {0, 80, 125, 160, 215, 270, 360, 450, 595, 750, 1000, 1191, 1500, 2500, 1e99); int reqd_gear[15] = {0x0, 0x01, 0x21, 0x02, 0x22, 0x04, 0x24, 0x08, 0x28, 0x10, 0x48, 0x68, 0x50, 0x70, 0x0}; if (spindle_speed_in == 0) return; actual = (high_gear * 0x40 + motor-high * 0x20 + gear_A * 0x10 + gear_B * 0x08 + gear_C * 0x04 + gear_D * 0x02 + gear_E * 0x01); for (i = 0, spindle_speed_in > speeds[i] && i < 14; i++); gear_required = reqd_gear[i]; if (gear_required == actual && gear_required != 0x0){ // We are in the right gear spindle_enable_out = spindle_enable_in; motor_speed_out = speeds[13] * (spindle_speed_in / speeds[i]); message = 0; } else { int j; motor_speed_out = 0; spindle_enable_out = 0; for (j = 0; j < 13; j++) { message(j) = 0; } message(i) = 1; } }

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

More
8 years 2 months ago #116805 by tecno
Now this was a surprise as there are no email notifications on this subject.

Will have a look tomorrow and see if I can grasp this code, thanks Andy.

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

More
8 years 2 months ago - 8 years 2 months ago #116811 by andypugh
Again, done at work in Windows, so no guarantees of any sort.

Already spotted one error i have a comma where a semicolon belongs
for (i = 0; spindle_speed_in > speeds && i < 14; i++);
Last edit: 8 years 2 months ago by andypugh.

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

More
8 years 2 months ago #116817 by tecno

andypugh wrote: Again, done at work in Windows, so no guarantees of any sort.

Already spotted one error i have a comma where a semicolon belongs
for (i = 0; spindle_speed_in > speeds && i < 14; i++);


speeds && i < 14; i++);
Is above OK?

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

More
8 years 2 months ago #116838 by tecno
Halts in compile

bengt@debian:~/linuxcnc$ sudo halcompile --compile GB_2speed.comp
[sudo] password for bengt:
GB_2speed.comp:17:25: Array name contains no #: 'message'
> pin out bit message[14];
> ^
bengt@debian:~/linuxcnc$

Where in the compfile should a message be written and how?

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

More
8 years 2 months ago #116851 by andypugh

tecno wrote: GB_2speed.comp:17:25: Array name contains no #: 'message'
> pin out bit message[14];
> ^


That needs to be
pin out bit message-##[14]

Where in the compfile should a message be written and how?

"message" is an existing and separate HAL component.

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

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