changing Hal parameters

More
10 Jul 2021 19:21 #214210 by anfänger
Hi,

I use a bash script for gear change and was kind of lazy. I have 12 manual selectable gears and a two clutches (1.1 and 1:1.6 gear reduction) I can use. So it is more or less a two stage gearbox. I use one gear change module for the clutches and set the parameters with a bash script / MCode. In Hal everything looks fine the parameters are changed. BUT when I tested it with the machine running it looks like the initial parameters are used.
 For example on startup the min_speed_2 parameter is set to 1600 I change gear and the in Halshow min_speed_2 parameter is now 72 as it should be for this gear when I try to run the spindle now at 80 rpm the output is still 1600

is there a way to get the parameters updated or a neat way to work with a two stage gearbox?

thanks Patrick
 

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

More
11 Jul 2021 06:17 #214230 by Aciera
Replied by Aciera on topic changing Hal parameters
Can you post your script / MCode?

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

More
11 Jul 2021 06:52 - 11 Jul 2021 06:55 #214234 by anfänger
Replied by anfänger on topic changing Hal parameters
yea sure  this is the script where I change the parameters. In Halshow I see that they are updated but the module still works with the initial parameters.

#!/bin/sh
#set clutch 2
P=$1
Q=$2

gearnr=${P%.*}
echo $gearnr
if [ $gearnr = 1 ]; then
#    set -- $(halcmd -s getp  gearchange.0.max1)
    max=1400
    halcmd setp gearchange.0.max1 $max
    acc=1400
    halcmd setp gearchange.0.acc1 $acc
    min=1000
    halcmd setp gearchange.0.min1 $min
    scale=1.6
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 2 ]; then
    max=500
    halcmd setp gearchange.0.max1 $max
    acc=500
    halcmd setp gearchange.0.acc1 $acc
    min=357
    halcmd setp gearchange.0.min1 $min
    scale=4.48
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 3 ]; then
    max=710
    halcmd setp gearchange.0.max1 $max
    acc=710
    halcmd setp gearchange.0.acc1 $acc
    min=507
    halcmd setp gearchange.0.min1 $min
    scale=3.15493
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 4 ]; then
    max=1000
    halcmd setp gearchange.0.max1 $max
    acc=1000
    halcmd setp gearchange.0.acc1 $acc
    min=714
    halcmd setp gearchange.0.min1 $min
    scale=2.24
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 5 ]; then
    max=355
    halcmd setp gearchange.0.max1 $max
    acc=355
    halcmd setp gearchange.0.acc1 $acc
    min=253
    halcmd setp gearchange.0.min1 $min
    scale=6.309859
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 6 ]; then
    max=128
    halcmd setp gearchange.0.max1 $max
    acc=128
    halcmd setp gearchange.0.acc1 $acc
    min=91
    halcmd setp gearchange.0.min1 $min
    scale=17.5
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 7 ]; then
    max=180
    halcmd setp gearchange.0.max1 $max
    acc=180
    halcmd setp gearchange.0.acc1 $acc
    min=128
    halcmd setp gearchange.0.min1 $min
    scale=12.44444
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 8 ]; then
    max=250
    halcmd setp gearchange.0.max1 $max
    acc=250
    halcmd setp gearchange.0.acc1 $acc
    min=178
    halcmd setp gearchange.0.min1 $min
    scale=8.96
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 9 ]; then
    max=80
    halcmd setp gearchange.0.max1 $max
    acc=80
    halcmd setp gearchange.0.acc1 $acc
    min=57
    halcmd setp gearchange.0.min1 $min
    scale=28
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 10 ]; then
    max=31.5
    halcmd setp gearchange.0.max1 $max
    acc=31.5
    halcmd setp gearchange.0.acc1 $acc
    min=22
    halcmd setp gearchange.0.min1 $min
    scale=71.11111
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 11 ]; then
    max=45
    halcmd setp gearchange.0.max1 $max
    acc=45
    halcmd setp gearchange.0.acc1 $acc
    min=32
    halcmd setp gearchange.0.min1 $min
    scale=49.77778
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi
#
if [ $gearnr = 12 ]; then
    max=63
    halcmd setp gearchange.0.max1 $max
    acc=63
    halcmd setp gearchange.0.acc1 $acc
    min=45
    halcmd setp gearchange.0.min1 $min
    scale=35.55556
    halcmd setp gearchange.0.scale1 $scale
    max=$(echo "$max*1.6" | bc)
    halcmd setp gearchange.0.max2 $max
    acc=$(echo "$acc*1.6" | bc)
    halcmd setp gearchange.0.acc2 $acc
    min=$(echo "$min*1.6" | bc)
    halcmd setp gearchange.0.min2 $min
    scale=$(echo "scale=5; $scale/1.6" | bc)
    halcmd setp gearchange.0.scale2 $scale
fi

exit 0
Last edit: 11 Jul 2021 06:55 by anfänger.

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

More
11 Jul 2021 16:07 #214278 by anfänger
Replied by anfänger on topic changing Hal parameters
I took the long route and set up all 24 gears in gear change and changed my M codes.

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

More
11 Jul 2021 17:30 #214299 by Aciera
Replied by Aciera on topic changing Hal parameters
It's a long shot but sometimes a forced synch helps:

M66 E0 L0

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

More
11 Jul 2021 22:09 - 11 Jul 2021 22:12 #214330 by Grotius
Replied by Grotius on topic changing Hal parameters
Hi,

If your module isn't updating, maybe create a thread.

    halcmd loadrt threads name1=gear-thread
    halcmd loadrt yourgearmodule
    halcmd addf update gear-thread

Then in your component add function declaration:
static void update();

Add function eof:
static void update()
{
    // here your code to update or initialize the values.
}

If you don't know how to. Then you can post your component source file.


  
 
Last edit: 11 Jul 2021 22:12 by Grotius.
The following user(s) said Thank You: anfänger

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

Time to create page: 0.076 seconds
Powered by Kunena Forum