Problems with gearchange component

More
06 Sep 2012 12:26 - 06 Sep 2012 12:29 #23969 by hardware_crash
Hey guys,

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

File Attachment:

File Name: gearswitch.comp
File Size:11 KB
Attachments:
Last edit: 06 Sep 2012 12:29 by hardware_crash.

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

More
06 Sep 2012 12:33 #23973 by andypugh
I am nowhere near my LinuxCNC machines at the moment, so can't check the component.

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.

More
06 Sep 2012 12:50 #23974 by hardware_crash
dear andy,

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 ?

:dry:

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

More
06 Sep 2012 13:55 #23977 by andypugh
hardware_crash wrote:

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.

More
06 Sep 2012 14:30 #23981 by hardware_crash
Don´t know i was just thinking :laugh:

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

More
06 Sep 2012 20:53 #23988 by hardware_crash
Seems like there is an error while calling the part which sets the Motor to the sellected position:

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.

More
06 Sep 2012 21:15 #23989 by andypugh
hardware_crash wrote:

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.

More
06 Sep 2012 21:34 - 06 Sep 2012 21:36 #23991 by hardware_crash
hey andy,

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
Last edit: 06 Sep 2012 21:36 by hardware_crash.

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

More
06 Sep 2012 21:49 #23993 by andypugh
hardware_crash wrote:

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.

More
07 Sep 2012 11:58 - 07 Sep 2012 12:01 #24011 by hardware_crash
hey andy,

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 ...

File Attachment:

File Name: gearswitch.c
File Size:18 KB
Attachments:
Last edit: 07 Sep 2012 12:01 by hardware_crash.

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

Time to create page: 0.158 seconds
Powered by Kunena Forum