gearchange with DC motor (3 gears) halcompile problems

More
09 Jan 2022 15:51 - 12 Jan 2022 19:05 #231250 by Wieser
Hello everyone,
I am trying to get the gearchange on my Hermle to happen automatically.
It has 4 gear positions controlled by a 12V DC motor.
0
40-690
691-1980
1981-6000
Each position has a micro switch. To change gear the motor has turn in the appropriate direction (it can`t make a full turn). Also while changing gears, the spindle oscillates at 5Hz at a slow speed.  
At first i thought about realizing the gearchange in classiclader, but in other threads it was pointed out that it can only handle integers. So the gearchange would be possible, but the scaling of the PWM signal for the spindle drive (+-10V) can´t happen there (and the result would be messy).
So I looked around and found some modified versions of gearchange.comp by andypugh. I´ve had no experience with HAL components, so I started reading about them. I understand the basic structure now and I have compiled an example component (and3.comp). But that’s it.

From what I have seen, all these components work with clutches to engage and disengage gears.  

I also looked at RotarySMPs gearchange code for the Maho, but I don´t understand a thing. 

My thoughts on a custom component:
-it must not do anything when the spindle is turning (spindle at speed signal or PWM output !=0)
-it needs to read the speed command and check if it’s in the right range (first if else if loop)
-if the range is correct, scale the output speed command accordingly and exit-if in the wrong range, create 5Hz signal and move DC motor in the right direction until the according switch goes on (and change PWM scale)(Second if else if loop)
-also set the PWM scaling to 0 to prevent spindle movement
 
But here’s a problem I can´t figure out:
I only want the gearchange if spindle speed is 0. but as soon as I try to change the gear and create the 5Hz signal, the spindle speed isn´t 0 anymore. So the gearchange would stop?!
Also it should not react to spindle speed override poti.  

Do you think this is the right way to go about this?Can you think of comps that roughly fit my needs, so i can fiddle with them? 
Attached is a picture of the gear schematic and motor control. 



 
Attachments:
Last edit: 12 Jan 2022 19:05 by Wieser.

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

More
12 Jan 2022 19:10 - 12 Jan 2022 19:13 #231586 by Wieser
After reading some more I cobbled together a custom component.

 

File Attachment:

File Name: gearchangehermle.comp
File Size:3 KB


When using halcompile I got a huge list of errors at first. Now I am down to a few lines, but can't figure out where the problem is.
Does anyone know what causes this error?
linux@debian:~/linuxcnc/src/hal/components$ sudo halcompile --install gearchangehermle.comp Compiling realtime gearchangehermle.c gearchangehermle.comp: In function ‘_’: gearchangehermle.comp:139:12: error: invalid storage class for function ‘__comp_get_data_size’ 

Full Error message:
 

File Attachment:

File Name: error2.txt
File Size:1 KB
Attachments:
Last edit: 12 Jan 2022 19:13 by Wieser.

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

More
12 Jan 2022 20:05 #231599 by db1981
I am missing the last bracket } for the whole function, and one } for the first if statement in line 37-39 .
The following user(s) said Thank You: Wieser

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

More
12 Jan 2022 20:27 #231605 by Wieser
Thanks alot! It did compile after adding those two brackets.
I will try if it works tomorrow or on the weekend.

How did you find that errors? Just reading over it or is there a programm you can check your code with?

I did write it on my windows PC in Notepad++ because I am not used to linux.

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

More
12 Jan 2022 22:29 #231621 by db1981
Because of that Assembler and C are my native languages,
on that few lines, my eyes triggers alarm....


You can use an IDE Envirionment like Eclipse or any better editor.
In notepad++ do a doubleklick in the left down corner (plain text / reiner text) an change it C, then you will have source code highligthing and optical bracket support.
The following user(s) said Thank You: Wieser

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

More
01 Jan 2023 00:04 - 01 Jan 2023 00:12 #260686 by Alexandrion
Hi,

Have you tested your component? I try to retrofit a similar machine Hermle UWF 851.

Thanks!
Attachments:
Last edit: 01 Jan 2023 00:12 by Alexandrion.

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

More
03 Jan 2023 18:59 - 04 Jan 2023 22:48 #260864 by Alexandrion
I used your component as a starter and I modified it for my needs. At the moment this is work in progress and I plan to post the final version when it is finished and tested.
For now the switch logic and the short circuit delay seems to work, but I tested them only in Halshow. I still don't know how I will make use of the speed output, and if the spindle twitch is working.
Suggestions are welcomed. 

File Attachment:

File Name: hermle_uwf...box.comp
File Size:6 KB


PS. How can I read the value of  the programmed S gcode(ex. S1000M3)?  Now it reads spindle-vel-cmd-rpm but that means that my component will try to make a gear change to neutral every time I hit spindle stop. The programmed S value is also immune to the spindle override, which is one of the requirements. Thanks!

PPS. After a bit o research and mental gymnastics I came to the conclusion that is easier to remap two M codes (ex. M100/M101) to communicate with HAL to set a pin to
neutral = true/false. I will use this as guide for remapping . After this, if the component will see neutral = false and speed input 0 it will do nothing. If am am already in a gear and neutral = true , it will move to neutral position on the switch.
Attachments:
Last edit: 04 Jan 2023 22:48 by Alexandrion.

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

More
08 Jan 2023 23:21 - 08 Jan 2023 23:40 #261310 by Alexandrion
Hi all,

I managed to test the gearbox component on the machine and everything went well. At the moment the machine does homing correctly and is able to switch gears. For those interested in what I have done so far you can find the config files in the attachment.

One more safety feature I want to make is to stop power to the dc motors in case the gears somehow fails to mesh in a given time. ex 5 seconds, to prevent motor overheating and damage.

If you have any questions or suggestions let me know.

Kind regards,
Alex

File Attachment:

File Name: hermle_uwf...-08.comp
File Size:8 KB
Attachments:
Last edit: 08 Jan 2023 23:40 by Alexandrion.
The following user(s) said Thank You: tommylight, Wieser

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

More
27 Feb 2024 21:18 #294646 by Wieser
Hi Alex.
Nice to see that you could use this as a base for your machine. I basically abandoned my conversion for the last two years, but since December I started finishing it. 

It is strange that your gearbox will shift to neutral gear after spindle stop command, mine does not do that. But to investigate this, I would first need to rethink myself into the code...

Regarding your 5 sec timer: What i found during the use with the siemens control was, that it would fail to shift or "overshift" and get lost quite often.
When shifting with this component it all goes flawless, so I don’t think its necessary, but of course it would be nice to have.

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

More
25 Mar 2024 23:31 #296784 by Alexandrion
Hi Wieser,

I managed to finish my machine and now I have almost 5 months working with it. In the end I used the S remap route for gear selection because this allowed me to switch gears without having to start the spindle, just like in the original control. You can find my configuration in the attached and if you have any questions let me know.

Some things you may find interesting in my configuration:
1. Automatic lubrication based on distance traveled (just in auto mode, no jog)
2. Automatic gear selection based on S remap
3. Spindle orient and spindle pid tunning based on selected gear
4. Automatic tool changer based on carousel component, M6 remap and subroutines
5. Classic ladder for auto feed (like in the original control)
6. Implementation of xhc-whb04b-6 pendant
7. Different acceleration and deceleration ramp (useful for rapid breaking in tapping, otherwise rigid tapping tend to overshoot the desired depth)
8. Use of potentiometers for feed and rapid override.
9. Use of macros in the macro bar of gmmocapy (some with pictures)

Sure there is a lot of room for improvement but it can be used as a reference.

Kind regards,
Alex
Attachments:

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

Moderators: piasdom
Time to create page: 0.165 seconds
Powered by Kunena Forum