How to update Parameters at run time

More
22 Jun 2015 02:06 #60040 by micknucam
Hello
This is the first time i have asked a question i am really stuck.
On my lathe i have implemented a rotary switch and some logic to select the Parameters required to select the different pulley ratios. The hardware i am using is Messa 5i25 and the 7i76 with the digital pot connected to a VFD 0-10 V input.

The setup info in the HAL File
addf mux-gen.00 servo-thread
addf gearbox.0 servo-thread

# external output signals

setp mux-gen.00.in-float-00 2300.0 These Numbers are for testing at the moment
setp mux-gen.00.in-float-01 2401.1
setp mux-gen.00.in-float-02 2502.2
setp mux-gen.00.in-float-03 2603.3

net gear0 hm2_5i25.0.7i76.0.0.input-02
net gear1 hm2_5i25.0.7i76.0.0.input-03 or2.0.in0
net gear2 hm2_5i25.0.7i76.0.0.input-04 or2.0.in1 or2.1.in1
net gear3 hm2_5i25.0.7i76.0.0.input-05 or2.1.in0

net speed1 mux-gen.00.sel-bit-00 <= or2.0.out
net speed2 mux-gen.00.sel-bit-01 <= or2.1.out

net newscale gearbox.0.in mux-gen.00.out-float

I have made a C component with a rw parameter in it thinking it could be used

component gearbox "to select new pulley ratios";
pin in float in;
pin out float out;
param rw float newpulley;
function _;
license "GPL";
;;
newpulley = in;
out = newpulley;

This is the way i would set the parameters up in the HAL file for the digital pot
setp hm2_5i25.0.7i76.0.0.spinout-minlim -2300
setp hm2_5i25.0.7i76.0.0.spinout-maxlim 2300
setp hm2_5i25.0.7i76.0.0.spinout-scalemax 2300

I thought i may be able to do this but still get an error message
setp hm2_5i25.0.7i76.0.0.spinout-scalemax gearbox.0.newpulley

Error Message
my_test2.hal:116: value 'gearbox.0.newpulley' invalid for float

I have checked everything can someone please tell me what i need to do ! if this is at all possible

Thanks
Mike

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

More
22 Jun 2015 13:27 - 22 Jun 2015 15:05 #60050 by ArcEye

I thought i may be able to do this but still get an error message
setp hm2_5i25.0.7i76.0.0.spinout-scalemax gearbox.0.newpulley

Error Message
my_test2.hal:116: value 'gearbox.0.newpulley' invalid for float


setp sets a pin to a numerical value, you cannot use another pin as that value.

EDIT
On checking found hm2_5i25.0.7i76.0.0.spinout-xxxx are params not pins
so my original answer won't work.

params are really an unnecessary anachronism, now that pins can have a non-default value at creation
and can cause lots of problems as you have found

What I did on my lathe with a pulley driven spindle, was to set up a user M code which passed the relevant value to set a param.
Since the belts have to be set manually with the spindle off anyway, it is just a case of using M131 3 say in the MDI box to set pulley ratios for position 3
or just have that code in the start of the program
#!/bin/bash

## sets scale gain to make output speed accurate
## for each of 4 pulley settings

if [ ! $# -ge 1 ]; then
  echo "Usage: M131 n - where n is speed range 1 - 4"
  exit 1
fi

float=$1
int=${float/\.*}

case $int in

    1 ) halcmd setp scale.0.gain 0.595;;
#       accurate at 1200 in M4 for turning

    2 ) halcmd setp scale.0.gain 1.16;;
#       accurate at 600 in M4 for turning

    3 ) halcmd setp scale.0.gain 2.175;;
#       accurate at 300 in M3 for threading

    4 ) halcmd setp scale.0.gain 4.3;;
#       accurate at 150 in M3 for threading
esac

exit 0

I could have done it via a button, but my screen is cluttered enough.

regards
Last edit: 22 Jun 2015 15:05 by ArcEye.

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

More
22 Jun 2015 22:08 #60062 by micknucam
Thanks ArcEye for taking the time to sort the problem out !! I did have a good go at it had tried the net command and it's like you said !! Have managed to write a Mcode script and can change the parameters using that will sort some buttons out on my gui !! But would just like to have come a long way since January this year the Mesa cards are brilliant !! This problem has made me look at the c components and will use one for the lathe tool changer we have built !! Have added a picture of my lathe so far thought putting all in one place was a good idea but it's massive !!!!

Thanks

Mike
Attachments:

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

More
24 Jun 2015 14:58 #60108 by ArcEye
Thats the problem with getting everything together and working, you just want to use it, not spend time making everything tidy!

Most of the pictures I have seen of 3D printers look like explosions in spaghetti factories,
the builder got right to the bit where it worked and then left all the wires etc exactly where they were :laugh:

I am sure you will be able to squeeze it all up enough to fit in the filing cabinet under the lathe, where you can close the door and forget about it.

regards

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

Time to create page: 0.067 seconds
Powered by Kunena Forum