Does anyone know of any online tutorials about using PCI input/output ports? I've got an upcomming application, so I've deceided to update my old ISA boards to something current. I know they work differntly (not just simple IN and OUT anymore) and need some practical info. Thanks.
Ralph Brown -RBPCI- I'll add more when I find them, but this one includes a lot of data files for different implementations.
to bad I can't attach my books in my "Developing Windows NT Device Drivers" they deal with this profoundly. I just checked. It's a lot of info :-/ ISBN 0-201-69590-1 if that helps you a bit more Ernie
what you mean exactly with pci io ports?, a) pci bus configuration ports (0cf8h-0cffh) or b) pci board memory access.. using a* is incompatible with some boards, you should prefere HalGet(Set)BusData .. i have sample asm kernel driver source for searching a pci board, accessing pci memory space, allocating/preparing/locking user/kernel-mode memory for pci-dma access.. if that's what you need.. k
I'm currently planning out some control routines for a PCI-DIO48H/CTR15 IO board. This board emulated 2 8255 24 bit IO ports, and also 5 8254 tripple counter timers. I've sucessfully bit banged these devices when they were living on the ISA bus, but now that they are shifting over to the PCI bus life is more complicated. Basically, these devices just look like a collection of byte sized IO ports to the system. It's getting thru the PCI layers that I don't know how to do.
Thats a toy to be had.. :) Too bad its not Christmas, because a student's wages cant afford it.. Ernie, im currious, I take it you are writing your own software rather than what they would provide, the board seems to be simply I/O with no hardware interupts etc for each port. How do you pan to 'poll' them in windows for for changing inputs?? This could be a 'no-brainer' type question, but im novice to such work. :rolleyes: NaN
Nan, The only stoopid questions are the ones you never ask. Professionally, I'm an electrical engineer. I do lots of things as such, but my favorite has always been automating process control, usually in the form of an automatic test stations. Mostly I've worked in companies that make hybrids, which you can think of as semi-custom analog or digital ICs. Each must have a special test stand so it can be tried out, it's performance measured to some specfication to insure it works. This can be a tedious process, making precision measurements over and over. It's something I can't do for even an hour without going bonkers. Give this task to someone for 8 hours a day, day after day, and it's understandable that you just can't trust what they do. In steps a computer. Test stands like this are rather simple to impliment and program (well, for me they are, since I speak both electronics and code). You have a fixed series of tests to perform, with a single output that is either GOOD or BAD. Usually, every test follows this pattern: Output a byte pattern to a board that can output this information as logic levels on pins to OUTSIDE the computer. Then these voltage levels can be used to drive say relays (1 relay per bit) to set a particular condition to drive the device being tested. Then, you need make a reading. Usually this is some voltage out of the device. Traditionally, I'd use a digital voltmeter that has an IEEE-488 bus port in it. This bus can be used to get that reading back to the computer. On a really cheap Fluke DVM (it's $1k, cheap is a relative thing when it's not your own pocketbook), I can get about 1 reading a second, so a 12 test step acceptance test can be completed in 6 seconds. And that's even using Visual Basic as the test language! A human would be lucky to do the same tests in under a minute. The new trend in taking measurements is to forget the seperate meter, cable, IEEE-488 cable bus, and drop all that junk into another PCI card. Such cards can take DC measurements on up to 64 channels (different signals) up to about 1,000,000 times a sec. Reading this fast mean you can thus digitally sample an AC wave, even use the computer as an oscilloscope. National Instruments (NI.com) Takes this a step further in providing a TRULY visual programming language based on it's boards. I saw a demonstration once where the operator pulled up icons of equipment installed on the PC, drew some lines between them, and 'programmed' a feedback control loop without writing any code at all! Just connecting the dots to spec a process or control flow. And it generated C code when he was done. Oh, and what an I doing with the computer now? I'm making precision sized bubbles in a water filled tube. The Counter Timer board is so I can precisely gate on a air value (we found one with a millisec responce time). That board I mentioned can cut up a microsec 10 times, so it's quite fast enough. Bubbles? At my current job we make bubble detectors (something of prime importance if the fluid is blood and being pumped into someone's body), and need some way to scan for the size bubbles we really detect.
Ernie, I have code that accesses the PCI Bus from Windows. You can read and write to the PCI addresses and get a list of devices and some other things. It is very very cool. There is no source code to the DLL but I do have binaries. I have an import library, DLL, and some header files. It also came with a VXD file for Windows 95/98 access, and a SYS (WDM?) file for Windows NT4/2000/ME but it appears that they aren't really need (??). Found it in a German magazine on a Russian site. I have all the files saved on my system at work so I can upload them to my work page and everyone can download them. I don't know if you will get anywhere with them since no examples are with the code.. just the import library and the header files. I'll be at work on Friday, April 27th. I can upload them then. Best of luck, Devin.
Ernie, Thanks for the heads-up! I got a good feeling for what your up to, but Im still wondering how you plan to actually have windows Ring3 poll Ring0 continuously (im assuming PCI is ring 0, my knowledge of CPU hardware is dated to ISA). Well, I guess the board might have a buffer of sorts and can send 'chunks' of data back when ring3 'asks'. The reason im interested is because i want to be in just the same thing, i have simular ambitions with ASM and work. Except my assembly experience with Windows is still 'novice' for such work. Im presently finishing my 6'th year of post-secondary Electrical Education (3 yr Electrical Control System Technology, and 3/4 years Electrical Engineering). University is a MAJOR let down, all theory and nothing to call your own :(. In college i learned and built alot of both analog and discrete control systems for responce/stability/etc. However we always had to program our interfaces in DOS (if we had to). The problem i found after graduating is 1) your in university now, so you're not suppost to know this stuff till 4th year, and 2) I was simply re-inventing the wheel every time i wanted to use a computer to control hardware. So, being a broke student I found myself at Iczelion's door step, trying to learn VxD's. I quickly realized, knowing ASM is one thing, but the actual windows 'technology' is another. Im now in a position where i feel ready to give it another stab, and am very currious of 'methods' that have been 'tried-tested-and-true' for contolling information in and out of a cpu. It dawned on me a while ago that the windows message loop system doesnt lend to well for reliable "pseudo-polling" of inputs, so interupts must be the alternative. Which is why i am curious of how you plan to work with your board's many inputs on one port. Really any info that you feel relivent is all im currious in, don't need miles of code to give me a good idea to work off of :) Basically, if you wanted to use your card as a digital oscilloscope, on one of the inputs, how do you get around the message loop, and still keep your data's integrity (asside from building RAM buffers on the recieving hardware). Anywho, this has become quite long, i dont want to bore either, so i will stop while i still think im ahead. :) NaN
How would I make a Wintel platform into an oscilloscope? Simple. I'd buy the fastest analog to digital converter board with the highest number of bits resolution. Then I'd buy it's software driver and run that. It's one of the few cases where the bloatware is probably gonna be just as fast, and probably more stable, then anything I could do. As to how I'd guess they do it.... The problem is half hardware, half software. If you've ever used a digital oscilloscope you've seen the problem being solved. In a Wintel solution, the board will probably have it's own trigger, ie, it generates some internal signal that waveform A has crossed some threshold voltage in the proper direction (perhaps it even has a more advanced trigger). That trigger will be sent as a hardware interupt to the PC. Right away we're talking some VxD to drive the board. Windows is anything but a real time perating system. There can be a significant, variable delay from an interupt being generated and when it's handled. Thus, the scope board will need to have it's own RAM buffer to catch samples. During the measurement the board and the PC have to cooperate so the PC can read out this buffer and save it in memory (or file, etc), probably thru DMA or such. When finished, you have an array of sample values in memory, and the VxD will send a single FINISHED message to the controlling program. This may come as either a PostMessage message, or in the OCX case as an event. Either way, the application gets a single message "YOU GOT DATA" and it can then go ahead and do any processing it needs. Personally, I've only used the "old style" digital scope, the ones where the scope itself does most of the processing. I could set the scope up (volts per division, timebase, etc), set the trigger, then poll it for it being complete. Then I could issue commands to make measurements such as RMS voltage, frequency, max value, etc. These messages are sent over the IEEE-488 bus. This card on the PC needs a VxD driver, I'd use the one that came with the board. To my application, it looked like any other DLL, I'd invoke methods with strings as parameters to issue commands. Or pass variables byref to read out information. If you want to play with activly controlling stuff, I'll look around for a IO card for you. I once found a very inexpensive 8255 ISA card (3 bytes you can use as IN or OUT ports). It was around $60 USD, and will let you play and play with disturbing the world from your PC.
Thanx again for the heads up... I guess your write with digital-oscilloscope, Even when it appears real-time there must be some lag an buffering going on behind the screens... I think i might look into such a card... I was hoping i could simply build a small hardware card and get away with it cheaply (learned alot of hardware in college), but if they are as cheap as you saying then the cost may outweight the design time/frustration of the alternate. Anyways, thank you for the conversation, and goodluck with your PCI problems :) I will check out NI.com and see what i find, NaN
Ernie, I suppose your quite aware that your computer more than likely has 4 16bit A/D converters on board, right! Your game ports! Usually a game port will have four axis in which is an analogue value, usually set by a potentiometer on each axis of the controller (joystick). This game ports can be polled more than 30 times a second (Not that you'd want to if your collecting days of information!) and provide a 16 bit value inside. Very easy to use, very inexpensive. As for the I/O, no matter whether you have PCI/ISA bus, you can access the reserved address of any device using standard In/Out so long as your running in Win9x or DOS (Or 3.xx for that matter). Once you get to WinNT and Win2K things get more complicated. If this is a continious job application, you should build yourself a data logger. In case your not sure what it is externally or for those others reading, you set up a small circuit with a microcontroller and an A/D converter with an EEPROM, and a serial port. The microcontroller does all the work (Polling and reading values, etc...) then when your done the job you just read in the EEMPROM through the serial port. This is often done using A BasicStamp for it's availability and simplicity (You could program the thing the same night you get it, it's so easy to learn) If you are interested in more info you can email me. Otherwise good luck with your other options! See ya, Ben
Hmmm the game ports use a 555 timer and some resistor (for axis) to determine joystick position by reading the time period betwwe 2 oscilations of the 555 chip.... A VERY cheap and SLOW and UNPRECISE A/D...30times a second is about 30 Hertz... any decent Osciloscope has a range of 10 Mega Hertz (audio only) or 1GigaHertz RF/Digitl...but a 2-5Gigahertz one will do better today :) So Ernie will better stick with his fast A/D board...if he want to have any chance to make a digital Osciloscope... Main problems will be: 1.Speed of A/D conversion 2.Memory for the Samples 1Giga/second top speed ? 3.Trigger electronics that must also be controled by software 4.Win is NOT an REAL TIME OS :(
... and besides being a slow and dirty analog to digital converter, I can already hear the laughter when I try to prove it's calibrated to some source traceable to a National Standards Institute. "But I *swear* it's a good thing!" I'm not just playing a game here, I'm testing life-critical medical equipment. That demands stable, accurate, calibrated readings.
Ernie and all others. I have uploaded the file to the web. It is at: http://www.nutrend.com/tskb/drivers/hwdev.zip Hardware Development Libs I don't know if it will help you since it may be pirated or free. If you are going to release your software as free then I doubt there is a problem. If you are going for a full on commercial application then I highly suggest you look at WinDriver by Jungo (www.jungo.com) Take a look at it and see if this is what you need.
Ernie, if PCI-DIO48H/CTR15 io ports are really io ports, you can communicate via in-out opcodes (if you are using nt, you should switch to ring0), but if these ports are memory mapped io ports, you must write a driver and call mmmapiospace to translate port address to virtual adress.. in both cases, it's not difficult if you dont plan to write a bill gates certified driver for this card.. but before starting to write something, you must know what kind of io ports you have ; if device manager shows input/output range xxxx-xxxx , you have io ports ; if it shows Memory Range xxxxxxxx - xxxxxxxx you have memory mapped registers.. if case1 and win98 : you can continue your life with IN-OUT case1 and nt : IN-OUT + kernel driver case2 and 98 : vxd(MAPPHYSTOLINEAR) or ring0trick+MAPPHYSTOLINEAR case2 and nt : kernel driver(mmmapiospace) (i have source (asm) for all cases.. i can send you when you need) k
Here's the little I know about this board (from the Userís Manual): "The PCI-DIO48H/CTR15 uses eight standard I/O addresses for the two 8255 emulations, 20 addresses for the five 82C54s (4 each) as well as the addresses required for Plug-and-Play operation. The addresses are allocated by the PCI plug & play procedure and may not be modified. A word of warning: Direct writes to the addresses simply by reference to the base address of the PCI-DIO48H/CTR15 I/O registers is not advised. Since the addresses assigned by the PCI plug & play software are not under your control, there is no way to guarantee that your program will run in any other computer. Not only that, but if you install another PCI board in a computer after the PCI-DIO48H/CTR15 addresses have been assigned, those addresses may be moved by the plug & play software when the second board is installed. It is best to use a library such as Universal Library or a application such as SoftWIRE to make measurements with your board." So it sounds like standard IO (IN and OUT) stuff thru the PCI. And we're gonna use W98. So any info you can send is appreciated. However, their Universal Library is only 50 bucks, and I will be buying that with the card. If it saves me a day, it's worth it.
Hey I don't know if your interested. But for the sake of you people knowing. I was told the "best" way to do this with the best result is to use BeOS as the OS (www.be.com) and program your own program. It's a realtime OS and has API for accessing PCI function directly. Very neat! The only downfall is that the OS was designed to be programmed 100% in OOP C++, so it's tricky with ASM, but if you know C++ you could build your app in that. (The OS is very neat too!) See ya, Ben
OOP in asm, what a novel concept. Maybe someone should work on how to do that.....
Anyway, I'd get tossed out if I suggested changing OSes. As it stands now, my boss is INSISTING I develope the test program in (would you believe) Microsoft Access !!!!
Yep, the Database program. He claims he did it once and it worked. Mind you, I spent the last 12 years developing production test stations.
I'll resign before I do that.
But windows is just find for this sort of work anyway.