developing drivers for custom boards

More
26 Mar 2013 00:41 #31868 by btvpimill
Thanks Andy, that makes a lot more sense to me now. At this point the count function is only there because of borrowed code from you or another driver. I actually only have a need for 1 card connected to it at this time (my card can drive 10 steppers), but I do like the idea of more than 1.

Currently I have some conversation happening between hal and my card. I am getting some data from hal, and hal is getting some back. Best of all, nothing is locking up yet :)
I have some buffer issues in my card right now, but I am sure that is something dumb and I will sort it out quickly.

Once I sort that out, I will be back with more questions like how can I pass some arguments to extra setup for card configure (I think just like ioaddr is passed), and how do I pass a pin that is not a bit?
I want my byte3 to actually be a spindle speed between 0-255. I am sure that is trivial to all but me.

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

More
26 Mar 2013 05:10 #31879 by btvpimill
Buffer issues fixed!!! I can now send and receive 4 bytes of data.

Thanks to all (Andy,Peter,John, and more) who have held my hand and gotten me this far


On to the next things - in my extra setup, I want to send some config data. I would like to pass it from config.hal, but not sure how to do that.
also need to work out how to have 1 of the bytes be my spindle speed.

Any help for this??

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

More
26 Mar 2013 06:06 #31880 by andypugh

On to the next things - in my extra setup, I want to send some config data. I would like to pass it from config.hal, but not sure how to do that.

I am not even sure what you mean.

also need to work out how to have 1 of the bytes be my spindle speed

That's easier.
Create a float pin and a float scale parameter.
Mutiply the pin value by 256 then divide by the scale into a byte, then send the byte.
The following user(s) said Thank You: btvpimill

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

More
26 Mar 2013 06:29 #31881 by btvpimill
for instance, I want to send 3 bytes to my card but only when Linuxcnc is started. this will be step size info and what drives will be used. So in my hal file I want something like this:
steps=0xff,0xc2
drives=0xff

similar to how we have
ioaddr=0x378

then in my extra_setup I want to have:
outb(steps[0],base_addr+4)
outb(steps[1],base_addr+4)
outb(drives,base_addr+4)

I hope this makes more sense. I will chew on the spindle part and see what I can do.

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

More
26 Mar 2013 06:40 - 26 Mar 2013 06:40 #31882 by andypugh

for instance, I want to send 3 bytes to my card but only when Linuxcnc is started. this will be step size info and what drives will be used. So in my hal file I want something like this:
steps=0xff,0xc2
drives=0xff

similar to how we have
ioaddr=0x378


The code that does this is:
static int ioaddr[MAX_CHAN] = {-1, -1, -1, -1, -1, -1, -1, -1};
RTAPI_MP_ARRAY_INT(ioaddr, MAX_CHAN, "Base addresses")
You need to add
static int steps
RTAPI_MP_ARRAY_INT(steps, MAX_CHAN, "some comment here")
And the same for drives (possibly).
You can then index into the arrays with the extra_arg as required to get the data.

To add some auto-documentation use something similar to your current:
modparam dummy ioaddr """Base address of card. Separate each card base address
with a comma but no space to load more than one card. eg
loadrt custepp ioaddr=0x378,0xdf00. use 0xNNN to define addresses in Hex""";
There is some support in "comp" for modparams, but only integers (and it is undocumented, and may not work). This example uses "dummy" to create only the documentation, and then the actual modparam is created with the RTAPI_MP_ARRAY_XXXX macros.
Last edit: 26 Mar 2013 06:40 by andypugh.
The following user(s) said Thank You: btvpimill

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

More
26 Mar 2013 06:54 #31883 by btvpimill
Well it doesn't even have to be an array, but I will give it a whirl tomorrow when I get to work. it could be a 3 byte array and just need 1 variable that way:
cardconfig=0x23,0x45,0xff
for instance.

I will look for this extra_arg to see what this is.

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

More
26 Mar 2013 07:14 #31884 by andypugh

Well it doesn't even have to be an array, but I will give it a whirl tomorrow when I get to work. it could be a 3 byte array and just need 1 variable that way:


You tend to have one argument for every Instance of the component.
Comp rather hides this complexity from you.

I will look for this extra_arg to see what this is.

"extra_arg" is a variable that you can use in EXTRA_SETUP to get the index of the current instance.
The code in EXTRA_SETUP is called once for each instance of the component.
Typically you would need to look at ioaddr[extra_arg] to make sure that the setup data for each instance of the component was sent to the correct card port.
And the same for any other modparams that you use.

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

More
26 Mar 2013 07:35 #31885 by btvpimill
thank you ahead of time for you patience, I think I either don't understand, haven't explained it correctly, or am trying to use the tools wrong. Prolly all 3

My card will send step/dir signals to as many as 10 drive cards. (linuxcnc can control 9 and 1 slave or any variation)
the step size is programmable per drive (ie microstepping half,fourth,eighth,or sixteenth)
in a given machine configuration, I may want to only use 5 drives with 2 at eighth step and 3 at quarter step

So there would only need to be 1 instance of the comp, but in the extra_setup I thought I could send the data needed for the step size and drive enables. Now this enable is not to be confused with the regular amp_enable pin, that will be used to turn all the enabled drives on.(in above example that would be 5)

This data only needs to be sent once when axis is started hence my idea to use the extra_setup section. So my question is how to get that data from hal file to comp so the comp file is generic to my card.

I hope this makes sense, and maybe this is what you answered. So then I just do not fully understand yet and need to play to see the results.

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

More
26 Mar 2013 07:50 #31886 by andypugh

This data only needs to be sent once when axis is started hence my idea to use the extra_setup section. So my question is how to get that data from hal file to comp so the comp file is generic to my card.

Send it as a modparam, as discussed.
How you encode it is entirely up to you.

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

More
26 Mar 2013 23:15 #31930 by btvpimill
So far I have my array working to pass some values (12 in all) that get sent to my card. This is FUN STUFF!!!

Now, in my clueless way, I seem to have almost filled my 4G HDD. I can only assume this is from my blantent use of RTAPI_PRINT running in a thread. So anybody know where this is stored and how to get rid of it?

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

Moderators: PCWjmelson
Time to create page: 0.110 seconds
Powered by Kunena Forum