Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Pc parallel port pwm output

Status
Not open for further replies.

Milan-Sr

Newbie level 4
Joined
Oct 2, 2004
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Serbia
Activity points
80
pwm parallel port

Hi,
Need help!
I want to use parallel port as a PWM output.
Those are my questions
1.How can I make it the easiest way
2.What is the frequency and resolution I can expect from PC parallel port

Thanks Milan
 

leomecma

Full Member level 5
Joined
Jun 17, 2005
Messages
242
Helped
14
Reputation
28
Reaction score
1
Trophy points
1,298
Location
Brasil
Activity points
3,917
parallel port pwm

Using timer components of Delphi or C++ Builder, and using thread to do others jobs or using external reference. Windows don't give great accuracy timer, then if you need it very accurate use an external hardware clock reference (on input pin) and set your threads in tpHighest mode. This mode can stop others programs and mouse/keyboard, but for very accurate PWM(only for PC with high processors) I don't know other form.

In C++ use this for access the port:

//Register address of LPT1
#define Porta_Dados 0x378 //Output port
#define Porta_Estados 0x379 //Input port
#define Porta_Controle 0x37a //Control port

//---------------------------------------------------------------------------
void OutPortB( unsigned int Endereco, unsigned int Dado)
{
_DX = Endereco;
_AX = Dado;
//Begin assembly block
asm{

//Write AL Byte on port number DX
out dx, al

}
}

//---------------------------------------------------------------------------
unsigned int InPortB (unsigned int Endereco)
{
_DX = Endereco;

asm{
in al, dx
mov ah, 0x00
}
//Return port value
return (_AX);
}
//---------------------------------------------------------------------------


leomecma
 

Pinczakko

Full Member level 2
Joined
Jul 29, 2004
Messages
138
Helped
13
Reputation
26
Reaction score
0
Trophy points
1,296
Location
Taka Bonerate National Park, Indonesia
Activity points
1,592
pwm on parallel port

you also have to consider the current level of the parallel port on your PC. You might need a current-amplifier circuit to amplify the output from the PC. I've made a simple stepper motor control software a few years ago, and indeed I need to add a current-amplifier to interface with the stepper motor from PC parallel port. The architecture of as follows:

windows:
GUI (win32 API in C )<--> device driver (self made/quick hack) <-->parallel port -->current-amplifier --> stepper motor

linux:
console_app <--> linux port_IO <-->parallel port -->current-amplifier --> stepper motor
 

coldnuke

Newbie level 5
Joined
Oct 3, 2005
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,370
parallel to pwm

could u explain the code u posted a bit more coz can't understand it.


i was working on a same problem, to acess LPT port on XP or win32 OS. it resteced me to write directly.outport and in port were disabled.

so kindly explain
 

BigFreddy

Newbie level 4
Joined
Oct 1, 2005
Messages
7
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,283
Activity points
1,348
pwm parallel port c++

You need a driver to perform any port i/o operations under Windows NT/2000/XP.
Take a look at port i/o toolkits like TVicLPT or similar (winio, ntport, TVicPort and so on).
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,310
Reputation
4,622
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,416
parallel port to pwm

Instead of parallel port, have you considerd using serial port?
It is much, much easier and accurate as the PWM is generated by a hardware specially design for this purpose ..
All what you need to do is to select a microcontroller (planty to choose from) with single(multi)-channel PWM module and a UART to communicate with a PC ..
Regards,
IanP
 

Pinczakko

Full Member level 2
Joined
Jul 29, 2004
Messages
138
Helped
13
Reputation
26
Reaction score
0
Trophy points
1,296
Location
Taka Bonerate National Park, Indonesia
Activity points
1,592
pwm pc

IanP said:
Instead of parallel port, have you considerd using serial port?
It is much, much easier and accurate as the PWM is generated by a hardware specially design for this purpose ..
All what you need to do is to select a microcontroller (planty to choose from) with single(multi)-channel PWM module and a UART to communicate with a PC ..
Regards,
IanP

yeah, I also thought this is a better solution. This will also ease you in the software side ;).

You can just use Visual Basic (instead of building custom drivers) and MSCOMM32 ocx (activeX control) to interface with the hardware by using RS-232. Much simler and easier to debug.

greetz,

Pinczakko
 

steevo4321

Newbie level 1
Joined
Dec 3, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
Interesting. i'm also trying to do PWM controlled through the serial port, but this project will involve 3-phase positioning of a servo motor. so I decided to try a propeller chip because of the 8 cogs can thread the tasks at hand, also each cog can be sync. to the clock pulses, so i figured use one cog for serial communications of, say, X, Y, Z positions, and others to coordinate delta positions and bit generation calculations. I just hope 80Mhz will get the job done in propeller assembly. I need three axis's(9 phases from 18 ports of pwm - > 9 I/O ports at a time) and a spindle control, with some sort of encoder to track positions. any suggestions or ideas??
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top