stepgen

More
10 Jul 2013 21:19 #36500 by BigJohnT
stepgen was created by BigJohnT
There was a suggestion on the IRC to increase the stepgen to 16 from the current 8 to be more inline with pid. I attempted to do this but ran into a problem. My modifications compile ok but only 10 stepgens show up. Any C experts or near experts can look at what I did and perhaps spot what I missed. The patch is based on master.

gnipsel.com/files/0001-increase-stepgen-to-16.patch

git.linuxcnc.org/gitweb?p=linuxcnc.git;a...hb=refs/heads/master

Thanks
JT

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

More
10 Jul 2013 21:53 #36506 by ArcEye
Replied by ArcEye on topic stepgen
Hi JT

+/*int step_type[MAX_CHAN] = { -1, -1, -1, -1, -1, -1, -1, -1, -1 };*/
+int step_type[MAX_CHAN] = { [0 ... MAX_CHAN-1] = -1 } ;


The method of array initialisation you first used is the C89 standard across all compilers

The method you then went for is peculiar to gcc and may require C99 to work

Try int step_type[] = { [0 ... MAX_CHAN-1] = -1 } ;
since you don't need to specify the array size when you are spelling it out in the initialiser

Otherwise I would stick with the old-fashioned method you used initially and then commented out.

regards

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

More
10 Jul 2013 22:05 #36510 by BigJohnT
Replied by BigJohnT on topic stepgen
I think it actually worked but as 10 is after 1 and not 9 I didn't see the pins with show pin.

I'll try your init line as well, thanks for the input. Jeff E mentioned that was a way that Seb had done it in another component.

JT

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

More
10 Jul 2013 22:17 - 10 Jul 2013 22:24 #36512 by ArcEye
Replied by ArcEye on topic stepgen
It should work as it is.

If you had a really big array all the same value, would be easier to memset() it after declaration, than write out all the initialisers.

I have given up using any of the newer array initialisation methods with Linuxcnc, because I keep getting bitten by the requirement for extra switches to the compiler
when they are compiled using comp.

The favourite one is ISO C90 forbids variable-size array so requires the -std=C99 switch, which comp does not use, so the code is not portable.

regards
Last edit: 10 Jul 2013 22:24 by ArcEye.

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

More
11 Jul 2013 00:19 #36522 by BigJohnT
Replied by BigJohnT on topic stepgen
I just tried
int step_type[] = { [0 ... MAX_CHAN-1] = -1 } ;

and that built and ran ok...

JT

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

More
11 Jul 2013 18:54 #36549 by andypugh
Replied by andypugh on topic stepgen

There was a suggestion on the IRC to increase the stepgen to 16 from the current 8 to be more inline with pid.


Why have a limit at all?

if there has to be a limit, then why not 18, for a 9-axis gantry configuration?

It is possibly to assign arrays at run-time in C (just slightly more troublesome) so there is no real reason to impose a limit.

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

More
11 Jul 2013 22:37 #36562 by BigJohnT
Replied by BigJohnT on topic stepgen

There was a suggestion on the IRC to increase the stepgen to 16 from the current 8 to be more inline with pid.


Why have a limit at all?

if there has to be a limit, then why not 18, for a 9-axis gantry configuration?

It is possibly to assign arrays at run-time in C (just slightly more troublesome) so there is no real reason to impose a limit.


That's beyond my guesspertice level in C... JT hands the baton off to Andy.

JT

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

More
11 Jul 2013 22:57 #36565 by ArcEye
Replied by ArcEye on topic stepgen

It is possibly to assign arrays at run-time in C (just slightly more troublesome) so there is no real reason to impose a limit.


The way the code is written at present, prevents unlimited arrays because it is parsing the commandline with RTAPI_MP_ARRAY_XXXX which requires a number as an argument to be already decided, hence the MAX_CHAN #define.

The way around this might be to have the first argument as the number of channels and then use that to assign the arrays for step_type and ctrl_type

I'll have a play and see what happens

regards

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

More
11 Jul 2013 23:11 #36567 by andypugh
Replied by andypugh on topic stepgen

The way the code is written at present, prevents unlimited arrays because it is parsing the commandline with RTAPI_MP_ARRAY_XXXX which requires a number as an argument to be already decided, hence the MAX_CHAN #define.


Ah, yes. And MP_STRING unhelpfully breaks at commas (I think) so we can't parse p,p,p,p,p,p as a string and just count entries.

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

More
12 Jul 2013 00:00 - 12 Jul 2013 00:03 #36571 by ArcEye
Replied by ArcEye on topic stepgen
Andy Pugh wrote:

Ah, yes. And MP_STRING unhelpfully breaks at commas (I think) so we can't parse p,p,p,p,p,p as a string and just count entries.


That is actually what I did, I used RTAI_MP_STRING to collect the params and used a : delimiter so I got a string (or at least I think I would have done)
Then parsed that for the number required, but could not use a variable to initialise arrays, so had to create arrays of pointers to hal_malloc'd data......

and then just thought why bother, it is miles simpler just to set MAX_CHAN to a number higher than we need and if that changes, increase it. :laugh:
Last edit: 12 Jul 2013 00:03 by ArcEye.

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

Time to create page: 0.163 seconds
Powered by Kunena Forum