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.

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