• Advertisement

Archived

This topic is now archived and is closed to further replies.

Hardware interfacing...

This topic is 5717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am interested in learning how to write to the serial/com ports. Could someone point me in the right direction? Eg, what I would like to do for something simple, is maybe a computer controlled relay operator or something... is this possible without microchips? I hope it is, as I know all about resisters, capacitors, transisters, etc, and so I would be able to put together stuff myself, which is what I want to do, so can anyone help? CEO Plunder Studios

Share this post


Link to post
Share on other sites
Advertisement
Most pc hardware/assembly book combos cover writing to the serial/com ports. If you really want to get down and dirty, there is a book titled "Build your own universal computer interface" published by McGraw Hill. It shows how to build certain generic components and includes a sample assembly interface.

Share this post


Link to post
Share on other sites
hmmn... well I dont have the money for a book at the moment, im saving for the pezoild win32 book... is there any online info?
and yes, I did search google but did not come up with much useful info...

CEO Plunder Studios

Share this post


Link to post
Share on other sites
It''s easy to do in DOS : you just write to the proper memory address. It is *cough*harder*cough* in windows : you need to get the DDK and write a complete windows driver.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites
quote:
Original post by Fruny
It''s easy to do in DOS : you just write to the proper memory address. It is *cough*harder*cough* in windows : you need to get the DDK and write a complete windows driver.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]



So your telling me I have to know ASM? damn it!! I dont have time to learn that a the moment...


CEO Plunder Studios

Share this post


Link to post
Share on other sites
Unless you are doing something exotic you don''t need to write a device driver for serial communications in Win32 - there''s obviously a built-in driver. You can open a COM port and ReadFile/WriteFile from/to it, and there are functions for checking port status. This MSDN article describes the basics.

Share this post


Link to post
Share on other sites
Thanks man.
But is it possible to eg make an on/off switch using it, like the writen data would be feed into the base of a transister thereby switching it on... but then you would need to know currents and voltages that it sends/uses and stuff...

CEO Plunder Studios

Share this post


Link to post
Share on other sites
quote:

But is it possible to eg make an on/off switch using it, like the writen data would be feed into the base of a transister thereby switching it on...


Sure you can. But you''ll need additional external electronics in that case. The serial port uses a special transfer protocol, that synchronises the serialization of data bits. It also uses special oltages (-12V/+12V). You need an external decoder chip, that can be feed with commands through the serial bus. It''s not very complex, but I wouldn''t recommend it, if you are new to electronics.

If all you want to do is switch a transistor, then just take the parallel port. It''s much easier, you have 8 independend outputs, with standard TTL voltage (0V/5V). You can simply connect them to a transistor base (don''t forget the resistors, or you''ll kill your transistor) and switch stuff with it.

/ Yann

Share this post


Link to post
Share on other sites
quote:
Original post by Yann L
[quote]
If all you want to do is switch a transistor, then just take the parallel port. It''s much easier, you have 8 independend outputs, with standard TTL voltage (0V/5V). You can simply connect them to a transistor base (don''t forget the resistors, or you''ll kill your transistor) and switch stuff with it.

Cool, theres a guy on TA who said he had done something like this using the parrallel port, but hes never on. I didnt realize there was any difference between the two... I just didnt want to have to unplug my printer!
OK then, change of plan, info on parrallel port IO please



CEO Plunder Studios

Share this post


Link to post
Share on other sites
Yep, doing stuff like that using the parallel port is much easier. I can help you on the hardware/electronics side, but I have absolutely no idea on how to access the parallel port under Windows (I know it under DOS and Linux, but I guess that won''t help you very much )

/ Yann

Share this post


Link to post
Share on other sites
I wrote a controller using the parallel port for our 2nd year engineering project (miniature submarine)... The fact that the sub was powered in 220V made me extra careful not to fry my laptop

Soldering components is not fun.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites
heh, soldering isn''t too bad
Well I found a bit of info (lots of it regarding warnings, so ill probably pick up another internal card to use), but most of it was for pascal/delphi etc, I couldnt really find anything in regards to C++... but quite alot was sortof "theory" type stuff about it, but I still need more...

CEO Plunder Studios

Share this post


Link to post
Share on other sites
quote:

I wrote a controller using the parallel port for our 2nd year engineering project (miniature submarine)... The fact that the sub was powered in 220V made me extra careful not to fry my laptop


At uni I once had a project, where a 25kV circuit needed to be controlled by a computer (for a particle deflection coil). Now the computer was an extremly expensive (and brand new) SGI workstation... Guess how I felt, when it came to the first test... Fortunately it worked

elis-cool:
You should really be careful. If you work with low voltage components, then normally you can''t do too much harm (esp. to yourself). However, you can still seriously damage the parallel port signal drivers in your chipset, if you don''t respect their maximum drain current. So using a cheap separate interface card is definitely a good idea.

What exactly do you want to do (on the hardware side) ?

/ Yann

Share this post


Link to post
Share on other sites
I just want to muck around with it, eg Im not _really_ awesome or anything, I have taken an electronics course, and I just want to maybe put together some stuff that I can control with the comp eg, LED''s, maybe a little counter circut (eg with those 8 pin LED type things, like on Microwaves and stuff... I have put together a several-pcb boarded counter with them), which most of the processing would be done by the PC, like you enter a number and it displays it. And then maybe move on to hooking stuff up so I can control it via the PC, like lights and stuff, which is where I would most definatly be using a relay... eg more practical things

CEO Plunder Studios

Share this post


Link to post
Share on other sites
You will need to dig up an old hardware interface books. I know one of my books had info about it.... i think as PC underground... it is an old book published by Abacus or Databecker. I''ll post any info if I can dig it up.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Whe I do something, I go at it full speed.

Download and Memorize the Windows DDK. It will do you a lot of good! I know some really cool companies were hiring a while back, including professional sound recording equipment makers.


Share this post


Link to post
Share on other sites
Hi elis-cool,

I'm just working on controlling a relais via the serial port. If you want to do something like that without microchips, you have to control a single pin of the port which you use as output. In the case of the serial port, this could be the RTS (ready to send, pin 7 on a 9-pin port) or the DTR (data terminal ready, pin 4 on a 9-pin port). Signal ground is pin 5 on a 9-pin port. I use the DTR, but this is up to you. To set the DTR or RTS in Win32 environment, you need the Win32 API function SetCommState. I tried it out, it works. The voltage levels are -12V/+12V.
A drawback of the COM port is that you do not have a Vcc pin, so you can use the port only for sending signals, not for powering a circuit.

Hope that helps
blw

640 kByte of memory is all that any application should ever need
(Bill Gates 1981)

[edited by - blw on June 30, 2002 1:14:41 PM]

Share this post


Link to post
Share on other sites
Perhaps you''re interested in some code:

HANDLE hCom;
DCB dcb;
char *portname = "COM1";

// open handle for COM1
hCom = CreateFile(portname, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

if(hCom == INVALID_HANDLE_VALUE)
{
// some error handling
}
else
{
// read status of COM1
GetCommState(hCom, &dcb);

// set DTR high
dcb.fDtrControl=DTR_CONTROL_ENABLE;

// write new status to COM1
SetCommState(hCom, &dcb);
}

For another COM-port, just change portname. Switching DTR back to low is done by DTR_CONTROL_DISABLE. For the RTS pin, it works the same way.

Share this post


Link to post
Share on other sites

  • Advertisement