Problems with gearchange component
- hardware_crash
- Topic Author
- Offline
- Premium Member
- Posts: 80
- Thank you received: 1
I wrote a little comp for a 9 gear gearswitch.
But it doesnt work as it should and i dont know if there is a possibility to check if the programm runs correctly ...
I have installed the "DEV" package and installed the comp with "comp --install gearswitch.comp " and there were no errors...
Is there a way to view the comp like in classicladder , where the active signals have a different color ?
Or any other way to see that the error is not in the programm ?
I connected the outputs of gearswitch.comp with the hal outputs like this :
net backGearMotor gearswitch.gearBitOUTBackGear => hm2_[HOSTMOT2](BOARD).0.gpio.081.out
is this correct?
I have attached the comp file, maybe I did something wrong...
best regards
Lukas
Please Log in or Create an account to join the conversation.
One thing I will suggest is making the state flag into an output pin, so you can monitor progress through the comp with halscope.
Silly question, but did you remember to addf the component to a thread, and start the thread?
Please Log in or Create an account to join the conversation.
- hardware_crash
- Topic Author
- Offline
- Premium Member
- Posts: 80
- Thank you received: 1
Yes i added it to the servo thread ..
maybe there is a problem when linking the comp files outputs direct to the mesa io pins ?
Please Log in or Create an account to join the conversation.
maybe there is a problem when linking the comp files outputs direct to the mesa io pins ?
No, that should be perfectly OK. How else would you do it?
Please Log in or Create an account to join the conversation.
- hardware_crash
- Topic Author
- Offline
- Premium Member
- Posts: 80
- Thank you received: 1
Please Log in or Create an account to join the conversation.
- hardware_crash
- Topic Author
- Offline
- Premium Member
- Posts: 80
- Thank you received: 1
static char GearSwitchSetBackGear(int gear, char setup) {
switch (gear) {
case 1: if ((gearBitINBackGearLeft) == TRUE) { // no matter wether it is setup or not
gearBitOUTBackGear = FALSE; // switch off motor
return TRUE;
}
if (setup) {
gearBitOUTReverse = FALSE; // Richtung des Motor
gearBitOUTBackGear = TRUE; // Motor einschalten
}
return FALSE; // Warten auf den Enschalter bis er TRUE wird
case 2: if (gearBitINBackGearCenter) { // Egal ob Setup gesetzt oder nicht , bei erreichen d. Enschalters abschalten
gearBitOUTBackGear = FALSE; // Motor ausschalten
return TRUE;
}
if (setup) {
if (gearBitINBackGearLeft){
gearBitOUTReverse = TRUE; // Richtung des Motor
gearBitOUTBackGear = TRUE; // Motor einschalten
}
if (gearBitINBackGearRight){
gearBitOUTReverse = FALSE; // Richtung des Motors
gearBitOUTBackGear = TRUE; // Motor einschalten
}
}
return FALSE; // Warten auf den Enschalter bis er TRUE wird
case 3: if (gearBitINBackGearRight) { // Egal ob Setup gesetzt oder nicht , bei erreichen d. Enschalters abschalten
gearBitOUTBackGear = FALSE; // Motor ausschalten
return TRUE;
}
if (setup) {
gearBitOUTReverse = TRUE; // Richtung des Motor
gearBitOUTBackGear = TRUE; // Motor einschalten
}
// fall through
default:
return FALSE; // Warten auf den Enschalter bis er TRUE wird
}
}
//
I get the error "Fault with vec=14...."
Anybody an idea ?
Please Log in or Create an account to join the conversation.
I get the error "Fault with vec=14...."
You may be using an unintialised pointer, or writing outside the bounds of an array.
It's hard to debug realtime code, especially using comp.
First it is probably worth looking at the intermediate C code that comp creates with no options.
The most likely problem is that you are using a variable name that is also used internally in the intermediate C. The most likely candidate is "setup". Try a different name for that variable.
Please Log in or Create an account to join the conversation.
- hardware_crash
- Topic Author
- Offline
- Premium Member
- Posts: 80
- Thank you received: 1
I have read that the comp acesses the pins via macros and there has to be the pointer for the macro ? is this correct ?
maybe there is my fault ?
Is there anybody who can test my comp ??
best regards
lukas
Please Log in or Create an account to join the conversation.
I have read that the comp acesses the pins via macros
Not quite. comp "macro substitutes" all the pin names, so that if you have
pin in bit bitpin
then there is a #define in the generated C something like
#define bitpin inst->bitpin[0]
(or something like that)
The problems come if you define a pin with the same name as one of the "internal" variables. "inst" is particularly bad.
If I was debugging your module (and I can't , I am working in Spain, and my computers are in the UK) then I would compile it the source with make, so that I could use
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...fs/heads/v2.5_branch
I think you need to look at the generated C and see if any variables get re-used, or any other semi-obvious problems.
Please Log in or Create an account to join the conversation.
- hardware_crash
- Topic Author
- Offline
- Premium Member
- Posts: 80
- Thank you received: 1
I tried this git.linuxcnc.org/gitweb?p=linuxcnc.git;a...fs/heads/v2.5_branch
But i can´t find the "fault.ko" module in the module directory or in any other place on the system ..
Do you know another way to see the faulty programm parts ?
BR,
Lukas
Ps i attached the compile gearswitch programm ...
Please Log in or Create an account to join the conversation.