Quantcast

Maximum PC

It is currently Mon Sep 22, 2014 7:12 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: OK, So I Want to Write Device Drivers. Where Do I Start?
PostPosted: Tue Nov 13, 2007 5:59 am 
8086
8086

Joined: Tue Jul 03, 2007 8:06 am
Posts: 67
OK, So I Want to Write Device Drivers. Where Do I Start?

I’ve had this interest in robots and animatronics. After seeing Gary Willett’s creation, I am more excited and frustrated than ever. It seems that I can’t get there from where I am. However I’m willing to learn.

By using a pc, just how do you control something? I figure you will have some sort of caballing or link to the thing to be controlled. But on the pc side you need drivers to run the device at the other end. I figure there aren’t many interested in this but I’ll ask anyway.

I want to learn how to write device drivers for the stuff I want to build. I was thinking about starting with very cheep stuff at hand. Like controlling the read write heads of old floppy drives. Floppy drives come in USB versions that may help here. The in, out motion can be leveraged to move stuff (small stuff).

Back to the drivers:
Just where should I start?
What language are most device drivers written for Windo$? I assume there are books to learn the language.
Are there books that a beginner can read to get started writing drivers?
To help in what causes what to happen, how does one un-compile a driver so it can be read?

Help any one?


Top
  Profile  
 
 Post subject:
PostPosted: Tue Nov 13, 2007 9:26 am 
Thunderbird
Thunderbird
User avatar

Joined: Tue Nov 14, 2006 7:08 am
Posts: 843
Location: Texas
Quote:
OK, So I Want to Write Device Drivers. Where Do I Start?


Here are some basics


Quote:
It seems that I can’t get there from where I am.


Why do say that? Where are you at (as far as knowledge of the subject)? If your at the beginning thats perfectly fine, I am just asking because I don't have any experience with the software side (which I do understand is half of what you getting at) but, I do know you will need to have a LOT of knowledge with the componants that your are controlling. If you into robotics, one of the most FUNDAMENTAL things you can learn are stepper motors, and how to control them. It is a great place to get started, and you can get stepper motors very cheap. I would highly suggest becoming familiar with an integrated circuit known as a 555 timer. The controling behind robotics is basically done using microcontrolers, the more complex the design and motion, the more complex the controller. However, I think a 555 timer, which can be used to directly control a stepper motor, is the best place to start. Here is the thing though, you need to understand RC time constants (which are actually very easy) to understand 555 timers. In order to understand RC time constants, you will need to understand the most fundamental peices in electronics, which are resistors, capacitors, and inductors. Inductors are not in RC, but, they are still one of the fundamentals. What I am getting at here, is I beleive you need to understand a great deal about electronics if you really want to persue this idea.

I myself have a great interest in this, but the majority of it in the hardware side of it.

Quote:
Floppy drives come in USB versions that may help here. The in, out motion can be leveraged to move stuff (small stuff).


You should take one a part some time, I beleive that it uses a very simple stepper motor.

Quote:
Back to the drivers:
Just where should I start?
What language are most device drivers written for Windo$? I assume there are books to learn the language.
Are there books that a beginner can read to get started writing drivers?
To help in what causes what to happen, how does one un-compile a driver so it can be read?


edit* Here is another good link

Gives a basic program that runs in Windows, which controls a stepper motor through a parallel port.


Top
  Profile  
 
 Post subject:
PostPosted: Tue Nov 13, 2007 10:54 am 
8086
8086

Joined: Tue Jul 03, 2007 8:06 am
Posts: 67
Quote:
Where are you at (as far as knowledge of the subject)? If your at the beginning thats perfectly fine, I am just asking because I don't have any experience with the software side (which I do understand is half of what you getting at) but, I do know you will need to have a LOT of knowledge with the components that your are controlling.

I use to program in Cobol & Fortran (and some other DEC languages) for over 10 years but that was some 10 years ago. Before that I did a couple years of debugging boards for military computers.

I can make the computer maintain a general ledger or payroll using Cobol and I can build a circuit using IC chips, resistors, capacitors and relays (I can read a resistor, circuit diagrams).

What I don’t understand is how to get the signals in and out of a computer where the stepping motor does what the program requires and the program knows what the sensors around the motor is sensing. I figure there are some sort of pulses but what?

Yes, I am very new at this part but have sufficient background and interest to get going.

Quote:
You should take one a part some time, I believe that it uses a very simple stepper motor.


That is why I wanted to start there. Also, I figure most of the voltage regulators and support circuits are already on the board of the floppy. A cheep place t o start.

Is the language to start with C, C++, C# or something else?
Where do I go to find out what to do to get a floppy stepping motor to do my bidding at the program level?

I think a good first step is to get the floppy head to go in and out when I push or pull my mouse. Sort of zip zup (in out).

Next, have something on the screen tell me the relative position of the head so the value changes as I push my mouse.

Then, maybe have the drive motor that turns the floppy start turning when I click the left mouse button.

That would be a great start.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Nov 14, 2007 7:44 am 
Thunderbird
Thunderbird
User avatar

Joined: Tue Nov 14, 2006 7:08 am
Posts: 843
Location: Texas
Quote:
I use to program in Cobol & Fortran (and some other DEC languages) for over 10 years but that was some 10 years ago. Before that I did a couple years of debugging boards for military computers.


This is great, as these can actually be used to program code for the controls, as well as C++ (which is the only thing I really have experience with), and if you choose to use C++, it will be a lot easier, having a programming background.

Quote:
What I don’t understand is how to get the signals in and out of a computer where the stepping motor does what the program requires and the program knows what the sensors around the motor is sensing. I figure there are some sort of pulses but what?




Using a parallel port as an example, the parallel port has the d2-d9 output data pins, which produces bit outputs. The same bits are what would be used to control an integrated circuit, this integrated circuit then runs the coils (number depends on your pole number in the motor).

SO from a conceptual point of view:

1. C++/Fortran/COBOL: initial code - human commands to computer language commands

C++ (for example) compiles and breaks down to an assembly language, a language that can be converted to bits

2. Assembly language-computer to lower level language that can be ouput through the form of bits, output is parallel port

3. HCs12 Microcontroller, or a more simple device like the ULN2003 (just one example) decodes these bits and produces the correct pulses from its outputs, has its own internal timing.

Now, you want to program the driver for the C++ (or related code), or you want to write the entire control program itself?
A program like this for example: here

I have no clue how C++ would handle calling to a driver, or what ever it does exactly.

My question is, are you wanting to write the drivers because you really have interest in wrting the drivers, or are you are just concerned with controlling the stepper? I ask becasue there are programs that are already written for this type of thing. They wouldn't be written for a specific floppy drive, but they are designed for X-pole stepper motors. You would then buy or pull a motor from the floppy, get the corresponding logic chip or microcontroller for x-amount of poles, and then program that.

My thing is, if your getting into controls, which is all robotics is, if your are basing everything your starting to learn on floppy drives to control the motors, your not really learning to control a motor, your learning to contol a floppy drive, and ITS compnants; which are then used to control the motors.

I hope what I am trying to explain is clear, if not let me know.

As far as that conceptual outline I posted above, I will post in the programing forum to make sure that is correct.

DO you see my point about controlling the floppy drive though? I hope that made sense.

IF you strictly are just wanting to write the drivers themselves, here is a link to the basics of doing that within a Linux environment. this link gives a great over-view from one end to the other


Top
  Profile  
 
 Post subject:
PostPosted: Wed Nov 14, 2007 11:36 am 
8086
8086

Joined: Tue Jul 03, 2007 8:06 am
Posts: 67
reklaw wrote:
Quote:
My question is, are you wanting to write the drivers because you really have interest in writing the drivers, or are you are just concerned with controlling the stepper? I ask because there are programs that are already written for this type of thing. They wouldn't be written for a specific floppy drive, but they are designed for X-pole stepper motors. You would then buy or pull a motor from the floppy, get the corresponding logic chip or microcontroller for x-amount of poles, and then program that.



Thanks for all of this information and your help here.

My ultimate goal is to control stepper motors. Being a new-be, I figured that the stepper motor in the floppy drives were easy to find and maybe easy to convert to my use. I also thought that some of the circuits I may need are already on the floppy controller board. All of the same goes for CD ROMs. I was looking a floppies as spare and cheap parts.

I saw where I can buy the software and buy interfaces cards (which may be easer and cheaper) but one of the reasons I want to do this is to learn the ins and outs of this part of computing. Right now, I’ll take the hard way.

Question to you. You mentioned that you use the Parallel port; some of these articles talk about the serial port is the one to use. However the newer laptop computers are coming out with only USB 2.0. Should I start with USB? Is this harder or easer or nether?


Top
  Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 8:23 am 
Thunderbird
Thunderbird
User avatar

Joined: Tue Nov 14, 2006 7:08 am
Posts: 843
Location: Texas
Quote:
Question to you. You mentioned that you use the Parallel port; some of these articles talk about the serial port is the one to use. However the newer laptop computers are coming out with only USB 2.0. Should I start with USB? Is this harder or easer or nether?


Yes you can use USB for microcontrollers, or others as well. There are several different interfaces that can be made for microcontrollers, it will have to made by you though, or purchased to fit the specific microcontroller.

I would HIGHLY suggest just using the x-pole motor, however you can get one (pulling one from a floppy) and then find a cheap PIC microcontroller to learn how to run this from within the operating system's environment. This will be the equivalent of running the floppy from the computer, and a lot easier - IMHO. You can write the program, run the code and output to the appropriate interface i.e. USB, serial or parallel, then that will run the floppy's motor through the microcontroller. The principle will be same, but the operation will be easier, and a lot more applicable to robotics this way. THis will still be the same as running the floppy as a whole device, because that floppy has its own microcontroller anyway, and you have figure out what type it is, and how it operates, its pin configuration etc... in order to issue these commands from the Windows interface.

Does this make sense?


Have you had a chance to download and try that compiler yet?


Top
  Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 12:31 pm 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
Since linux is open source, one approach would be to start looking at the source code for devices similar to those for which you would like to write drivers.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 2:45 pm 
Thunderbird
Thunderbird
User avatar

Joined: Tue Nov 14, 2006 7:08 am
Posts: 843
Location: Texas
Jipstyle wrote:
Since linux is open source, one approach would be to start looking at the source code for devices similar to those for which you would like to write drivers.


Good idea there Jip.


@Bill:

I have two files one of which is a .cpp file that I mentioned to you earlier.

Here is the REALLY BASIC coil driver, something to get started with anyway.



Code:

#include <stdio.h>
#include <conio.h>
#include <avr/io.h>

void Delay(int n)

{
    int j,i;
    for (j = 1; j <= n; j++)

{
    for (i = 1; i <= n; i++);
    }

}

void main(void)
{
outb(DDRB, 0xFF);
PORTB = (1<<0);
while(1)
{
sbi(PORTB, 2); Delay(100); 
cbi(PORTB, 2); Delay(100);
}
}



I *think* this will give you a pulse from pin 2, I hope it will work with Turbo.

I am not sure what the library <conio.h> is though.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group