developing drivers for custom boards

More
04 Jul 2011 01:53 #11119 by btvpimill
developing drivers for custom boards was created by btvpimill
Couple of questions here. Now I know there are VERY good ready made boards out there, but wheres the fun in that?
first question : what interface?

I see EPP parallel port or ethernet . EPP seems a lot easier, but network based I/O feels like it would be nice in the long run. So is a network based I/O even feasible? Developing the I/O card for EPP is really easy, so maybe that needs to be first even if I go for the net based solution later.

second question: Drivers?

I assume a file written in comp is necessary, something simular to the file Andy made for the ISA card in another thread. I don't really want to do stepgen in the card, I really just need to have about 52 I/O on a single port.

So is there any detailed info on creating the comp file? I have read the link Andy pointed to, and I understand the file for the ISA card. I guess I am just looking for somewhere to start.

Third : How to structure the data?

By this I mean send a single address byte to my card followed by some number of data bytes? or an address byte for each data byte? Same question for reading the inputs.

I could use an existing driver for another card, but don't know where to find them.

Thanks in advance for any feedback :)

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

More
04 Jul 2011 10:33 #11124 by andypugh
Replied by andypugh on topic Re:developing drivers for custom boards
btvpimill wrote:

I see EPP parallel port or ethernet . EPP seems a lot easier, but network based I/O feels like it would be nice in the long run. So is a network based I/O even feasible?

Yes.
wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Etherlab

I assume a file written in comp is necessary,

It is possible that comp might be too limiting, and that you need to use normal C.

By this I mean send a single address byte to my card followed by some number of data bytes? or an address byte for each data byte? Same question for reading the inputs.

Or set up an address translation table at driver load time. This is an option in the Hostmot2 driver. You need to balance the overhead with the speed. if you will always be sending exactly 5 bytes, then yu might as well auto-address. If you will be sending data to 5 of a possible 50, then address then data makes sense. The address translation approach says "I will send the byte for address 2 then the byte for address 45 then the byte for address 12..."

I could use an existing driver for another card, but don't know where to find them.


Assuming you have the source: src/hal/drivers. look at ppmc and mesa_hostmot2.
git.linuxcnc.org/gitweb?p=emc2.git;a=blo...2d3b3d168576dd199aff
git.linuxcnc.org/gitweb?p=emc2.git;a=blo...2d3b3d168576dd199aff

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

More
04 Jul 2011 12:38 #11136 by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
Thanks Andy, lots of good stuff here. I think I will settle on a p-port approach, seems the most straight forward. Of course I have made the assumption USB is out of the question.

I think it makes sense to send a fixed number of bytes and read a fixed number. The numbers are TBD, but I am feeling like 5 sent and 4 read. For a whopping 9 byte transfer, I can't see any real value in trying to do random byte access.

I will study on the files posted and see if I can make sense of it.

First question I have is this: I see where 4 bytes get assembled into a 32 bit variable. Is this to make it possible to send the 4 bytes without an adress?

example:
variable = r0 + (r1<<8) + (r2 << 16) + (r3 <<24)
and if I want 5 bytes, will I just need to add +(r4<<32) ?

I guess the same would be true for reading if 4 bytes are read, they will come in as a 32bit variable?

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

More
04 Jul 2011 14:57 #11141 by andypugh
Replied by andypugh on topic Re:developing drivers for custom boards
btvpimill wrote:

variable = r0 + (r1<<8) + (r2 << 16) + (r3 <<24)
and if I want 5 bytes, will I just need to add +(r4<<32) ?

How many 8s in 32?

I guess the same would be true for reading if 4 bytes are read, they will come in as a 32bit variable?

It rather depends on the protocol. The parallel port is only 8 bits wide. I imagine you get the data in bytes, but it is possible that the low-level EPP drivers assemble into wider types. I have never looked.

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

More
04 Jul 2011 19:46 #11154 by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
next question:

with this command
outb(R0, base_addr);

how does the p-port know to strobe the address strobe or the data strobe?
for a P-port I would assume R0 is data and base_addr is 0x0378? (or whatever the p-port is at)

how many 8's are in 32?

why 5 of course :)

R0 = d0-d7
R1= d8-d15 data <<8
R2 = d16 - d23 data <<16
R3 = d24 - d31 data <<24
R4 = d32 - d40 data << 32

Ok, so I know there is only 4 8's in 32, but the first 8 don't count as I understand it. PLEASE correct me if I am wrong.

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

More
04 Jul 2011 20:40 #11156 by andypugh
Replied by andypugh on topic Re:developing drivers for custom boards
btvpimill wrote:

Ok, so I know there is only 4 8's in 32, but the first 8 don't count as I understand it. PLEASE correct me if I am wrong.

I might be misunderstanding the question, but you can only store 4 bytes in a 32-bit integer.
If you want to, you can store 8 bytes in a 64-bit integer, but that isn't a supported HAL pin type. Not that that necessarily matters.

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

More
04 Jul 2011 20:54 #11157 by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
Well thats the answer to the question I needed to ask but didn't. We can have 32 bit variables. so clearly 4 bytes is the answer. :) So I will work out the board to be like the PCL720, 32 out and 32 in.

I assume when the time comes, there is a way to transfer a spindle speed? a value from 0-200.

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

More
04 Jul 2011 20:57 #11158 by PCW
Replied by PCW on topic Re:developing drivers for custom boards
EPP address reads and writes are done at offset 3 from the port base address (so 0x37B) for a PP with 0x378 base address.

www.beyondlogic.org/epp/epp.htm is a good reference on EPP port operation

Perhaps the simplest addressing scheme on a EPP slave device is to write or clear a byte address pointer with address writes and increment that pointer on every data read/write

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

More
04 Jul 2011 21:33 #11160 by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
And yet another Doh! for me. I promise I am getting it. So for data, its base + 4. And clearly the in or out creates write line high or low.

Thanks PCW :)

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

More
11 Jul 2011 01:31 #11375 by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
I have modified Andy's pcl720.comp file, for what I think seems logical for an EPP driver. If someone doesn't mind looking it over to see if I have modified it properly that would be very nice. Assuming it seems correct, I have a question about using 2 cards (1 on each of 2 different ports). I think I need to create another set of pins, then somehow I need to use those for the read and writes of the second port. But I don't see where just yet.

To get this transition started, I am going to use my current cards set up on seperate ports. That way I don't have to create new hardware just yet. Once I am satisfied I understand what I am doing, I will convert to a single card for all my I/O needs.

File Attachment:

File Name: custepp.comp
File Size:2 KB
Attachments:

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

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