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

More
8 years 2 months ago #116044 by tecno
I have added following lines to HAL
Code:
# gearbox input signals # gearbox Hi/Lo net gearblocker.0.high-gear <= hm2_7i76e.0.7i76.0.0.input-15 # gearbox A - B - C - D - E net gearblocker.0.gear-A <= hm2_7i76e.0.7i76.0.0.input-10 net gearblocker.0.gear-B <= hm2_7i76e.0.7i76.0.0.input-11 net gearblocker.0.gear-C <= hm2_7i76e.0.7i76.0.0.input-12 net gearblocker.0.gear-D <= hm2_7i76e.0.7i76.0.0.input-13 net gearblocker.0.gear-E <= hm2_7i76e.0.7i76.0.0.input-14
Code:
loadrt gearblocker addf gearblocker.0 servo-thread

So how to do with following lines in COMP
Code:
component gearblocker; 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 float gear.#.min-speed[10]; pin in float gear.#.max-speed[10]; pin in float gear.#.ratio[10];

File Attachment:

File Name: cb_gearbox...8-14.hal
File Size:17.26 KB

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

More
8 years 2 months ago #116045 by rodw

tecno wrote: FUNCTION(_){
int i; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< delete this line ?


Yeh, you've done the right thing. It was just C politely telling you there was a variable that had not been used.
Warnings are basically telling you there is a problem that might be a problem but its not a fatal error so it will compile OK. Its best to eliminate them though as sometimes they can bite you.

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

More
8 years 2 months ago #116064 by tecno
Have together with *hakan* following changes in hal
Code:
net spindle-enable => gearblocker.0.spindle-enable-in net spindle-enable-2 <= gearblocker.0.spindle-enable-out => hm2_7i76e.0.7i76.0.0.spinena net spindle-vel-cmd-rpm-abs => gearblocker.0.spindle-speed-in net spindle-vel-cmd-rpm-abs-2 <= gearblocker.0.spindle-speed-out => hm2_7i76e.0.7i76.0.0.spinout

But how to get this that Andy describes is unclear.
And you might want "change up" and "change down" outputs too. Or an output to display the suggested gear.

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

More
8 years 2 months ago #116074 by Hakan
Hello Bengt,

I can show may thoughts here for anyone to see.

When the gearblocker finds the wrong gear is engaged: How to pop-up a warning? Or any other notification to tecno? It can of course be a silent, passive warning by just not starting the spindle. But a clear notification is better. Can that be made from hal? Or from the component?

I have made some tentative changes that could improve the component.

I don't use the code tag instead the red color to hilite.

component gearblocker;
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 out int wanted-gear;
pin in float gear.#.min-speed[10];
pin in float gear.#.max-speed[10];
pin in float gear.#.ratio[10];

pin in bit high-gear;
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;

license "gpl";
function _;

;;

FUNCTION(_){
int i;
int gear;
if (spindle_speed_in == 0) return;
switch (gear_A + gear_B * 2 + gear_C * 4 + gear_D * 8 + gear_E * 16 ) {
case 1: // Gear A
gear = (high_gear != 0) ? 1 : 6;
break;
case 2: // Gear B
gear = (high_gear != 0) ? 2 : 7;
break;
case 4: // Gear C
gear = (high_gear != 0) ? 3 : 8;
break;
case 1: // Gear D
gear = (high_gear != 0) ? 4 : 9;
break;
case 1: // Gear E
gear = (high_gear != 0) ? 5 : 10;
break;
case else: // gear selection is bitmasked to be able to spot double-engagement
gear = 0;
}

if (spindle_speed_in >= min_speed(gear) && spindle_speed_in <= max_speed(gear)) {
//RIGHT GEAR ENGAGED
motor_speed_out = spindle_speed_ * gear_ratio(gear);
spindle_enable_out = spindle_enable_in;
} else {
// WRONG GEAR ENGAGED, find a suitable gear
// Brute force search
wanted_gear = -1; // No suitable gear found
for (int i=0; i< 10; i++) {
if ( speed > min_speed(i) && speed <= max_speed(i) {
// First found suitable gear
wanted_gear = i;
break;
}
}

motor_speed_out = 0;
spindle_enable_out = 0;
}
}

If you integrate this into what you already have, you should be rather close.

Had to use () instead of brackets. Code tags with colors would be great :)

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

More
8 years 2 months ago #116075 by rodw
I'm not a fan of ever using for() loop in an interrupt service routine (which is what the servo-thread is).

It would be better to allow the servo-thread to do the looping in some way. It is far better off to use 10 cycles of the thread (which is only 0.01 second) than to hold up processing of all of the other components in the queue.

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

More
8 years 2 months ago #116076 by tecno
Hmmm does it really matter in this case as I can get nowhere until the right gear is in? Just asking as I am novice on programming.

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

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