Using an example to learn from

More
22 Oct 2017 08:11 - 22 Oct 2017 08:20 #100624 by Nitram
Hello.

Rather than just getting a "result" I would like to use this situation to learn more about HAL programming.

I am using gmocchapy, I've got the spindle at sped LED going and would like to get the spindle bar going. This all occurs via the custom post gui hal folder, which is where both pieces of code (spindle at speed (working) and spindle bar (not working)) live.

From HAL meter the only feedback on spindle speed is spindle-vel-fb-rps.
Given this I thought it would be a good learning exercise for me to try to get it working with a hal function to multiply that (rps) output by 60, get rpm and then net that to the gmoccapy halui pin for the spindle bar.

So this is what I tried:

#Spindle feedback bar

addf mult2.3 servo-thread # I already have 3 other mult2 functions in HAL ie 0 to 2
setp mult2.3.in1 60.0 # set the multiplier to 60 to achiive rps to rpm
net spindle-vel-fb-rps mult2.3.in1 60.0 => mult2.harry.in1 #calling the result harry so it stands out for debug
net mult2.harry.out => gmoccapy.spindle_feedback_bar #trying to output the result to the gmoccapy halui pin for the bar

I believe my problem is that I don't know how to create the resultant parameter "harry" correctly.
I'm sure this error is about as basic as it gets, and so I really want to use this a stepping stone to learn with.

I've attached the two files for context.

Any help appreciated, especially a brief global explanation would be most helpful, as I think that would set a foundation to learn from.

Many thanks,
Marty.
Attachments:
Last edit: 22 Oct 2017 08:20 by Nitram.

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

More
22 Oct 2017 12:14 #100628 by raglanlittlejohn
A few ideas, may be nonsense as still learning.

net spindle-vel-fb-rps mult2.3.in1 60.0 => mult2.harry.in1 #calling the result harry so it stands out for debug

spindle-vel-fb-rps is an existing signal, so only needs "netting" to the input pin of mult2.3

Would expect something like,

net spindle-vel-fb-rps => mult2.3.in0
net Harry mult2.3.out => gmoccapy.spindle_feedback_bar

this assumes "gmoccapy.spindle_feedback_bar" is the pin to send the multiplied speed to. Harry is the arbitrary name for the signal.

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

More
23 Oct 2017 10:42 #100664 by Nitram
Thanks very much for getting back to me on this.
I have tried the code you write and the syntax works correctly.
Seeing it work and grasping the correct syntax has been very enlightening.
Thanks again!
Cheers,
Marty.

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

More
24 Oct 2017 23:27 #100761 by andypugh
The first thing after "net" is always a signal name. You can choose any signal name.
After the signal name you can have one or more HAL pins.
You can use the same signal name on more than one line, and in more than one file.
And pins that share the same signal will take the same value.
Only one of the pins connected to any one signal can be an output (writer) pin.
Note that physical inputs are HAL output pins and physical outputs are HAL input pins.

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

More
01 Nov 2017 09:30 #101112 by Nitram
Hi Andy.

We spoke in another thread about a limit2 on my spindle to stop belt slip/squeal during the instantaneous direction change at the bottom of the G33.1 (via a user M code to be called together with the G33.1 via the CAM processor).

I think an easier option would be to simply put a time delay in line with the signal to M4. Rigid tap is the only cycle which has such an aggressive spindle reversal. If I can delay the harsh change from the M4 to the M3 within the G33.1 cycle, I think that would give the spindle the half second or so necessary to significantly reduce or even stop the RPM at the point where M4 is commanded.

I have taken on-board your earlier message, but I am still getting my head around the correct syntax to achieve this. I have written the HAL as I would have thought was correct or hopefully very close. I have also put some colored arrows into the proposed hal to highlight my rationale. For some reason, the syntax is not clicking quite right just yet...

Any help would be appreciated, again by doing this I hope I can better get my head around the generic syntax.

With thanks,
Marty.
Attachments:

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

More
02 Nov 2017 10:02 #101182 by Nitram
Hi Andy,

Just thought I'd let you know, I got the syntax right and got the timer working. I put a 0.15 sec pause on the M4 which made all the difference in taming the G33.1 reversal process.

Thanks for your ongoing help!
Kind regards,
Marty.

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

Time to create page: 0.101 seconds
Powered by Kunena Forum