|
First of all, to get you started, here is the pin designation[^] of an SPP (Standard Pareller Port) mode LPT.
As you can see from the schematic, by utilizing the DATA port, you are granted access to 8 bits of control information summing up to a total of 256 control possibilities.
Now, your task is to design the logic on how the motor is driven. The LPT can supply +5 V from each pin, and the maximum current is limited by the power source of the computer. As such, it is recommended to use the pin outputs only for TTL-level logic control. Consider the following example, with pins D0 - D7 being the data pins, and D0 being the least significant bit.
D7 D0 DEC
0 0 0 0 0 0 0 1 = 1 = Stop motor
0 0 0 0 0 0 1 1 = 3 = Low drive
0 0 0 0 0 1 1 1 = 5 = Medium drive
0 0 0 0 1 1 1 1 = 7 = High drive If this was your logic diagram, then you would require a 3-bit D/A converter to convert the digital word into analogue voltage. The idea is that you first have an on/off switch controlled purely by D0. Then, D1 - D3 are bridged into controlling an OP-AMP to do the conversion. You can find an example of a simple 3-bit DA-converter from this page[^].
As for the actual port control, in the IBM standard, the pareller port can be found from the IO space at address 0x378. Here[^] is a small example on how to write and read data from a pareller port under Microsoft Visual Studio. Note, however, that this method might not work under Windows 2000/NT/XP because their driver architecture is a bit different. See this article[^] under the CodeProject->System->Hardware programming.
Happy interfacing
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
If i use the logic circuit just u mention above but how the D/A converter can control the speed of dc motor? D/A converter can stand alone to control motor speed or need aid from the software!!!!
Thank You
|
|
|
|
|
The D/A converter cannot run the DC motor alone; it needs input signals to determine the output. These input signals (TTL-level) are provided by the pareller port's pins.
I won't start explaining in detail how the converter works here, that's a job for an electronics teacher. Instead, in a glance, let's say that the converter is able to convert a digital word into an analogue signal: the amplitude of the signal is determined by the digital input.
So, in the logic example, we had three digital pins, D1-D3. If you have a maximum input of +12 V DC for the converter, then an input of 111 would cause it to output +12V. The other levels of voltage can be directly calculated.
This means that depending on the output of the digital pins, the DC motor is fed with more voltage, thus resulting in greater RPM of the rotor. However, as I do not know how the motor is constructed, this might not be the correct approach. Some motors have seperate input pins for seperate drive levels, for example, feeding it 5V + 5V + 5V would result in full speed, where as 0V + 5V + 5V would stand for medium level drive. You must consult the motor's documentation and schematics for these details.
The basic idea is that whatever the way in which the motor is controlled, you MUST have some-sort of a voltage-level seperation between the pareller port and the motor. This means that you cannot feed the inputs of the motor from the pins directly. Doing so would break the port most certainly, and might even damage your computer seriously.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
To control the motor at high speed parallel port need to send the 0000 0111 to the converter. So i facing the another problem bcos parallel port is limited output port. When i want to control two set of the fan i not has enough output from the parallel port.... Actually i found the converter circuitry but this converter need 8 data port operate!!!
Thank You
|
|
|
|
|
deven chin wrote:
To control the motor at high speed parallel port need to send the 0000 0111 to the converter
Correct.
deven chin wrote:
When i want to control two set of the fan i not has enough output from the parallel port
Incorrect. You must have an ACTIVE D/A CONVERTER between the port and the motor. This means, in english, that all output power (voltage or current) from the converter comes from a different power source, such as a 12 V battery. You do not feed the motor directly with the power outputted from the pareller port, as this power amount is NOT ENOUGH, and taking out too much power (voltage or current) from the port will break it, and possibly even damage your motherboard.
Having an 8-bit output allows you to have a total of 256 different voltage levels, including no voltage. If you split it to half, 4-bit & 4-bit, you can still get up to 16 voltage levels. Heck, you could even split these two in half, having four 2-bit digital outputs, with each having a possible number of 4 voltage levels. Voltages like +0V, +4V, +8V and +12V, for example, depending on the bit sequence of the two bits. This would allow you, with 4 D/A converters, control up to four DC motors independently. I think that is more than enough.
So, once more: get yourself the schematics of a R2-2 D/A converter that utilizes an operational amplifier. If you have no other way, contact the local electronics shop and ask them for information. Tell them that you need an OP-AMP based D/A converter, they should understand. I won't start designing the schematic or the output control for you, because I don't do that kind of stuff free-of-charge.
If there is still something more you do not figure out, then place the question. But please, next time you write, do a complete grammar and typo-check on your post, and do not use abbreviations, no matter how busy you were. It is much easier to answer your posts when they are readable and easy to understand. Currently, your posts are pretty far from that.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I have tried to capture WM_POWERBROADCAST and all manner of system messages and API calls.
It seems these messages and API are all 'battery' related and power suspend-state related.
The UPS system service works fine and the 'messenger' service pops up a window when the UPS is running on battery power, and an event is logged to the Windows event log. However, a running application is just terminated seemingly without warning.
So, has anyone worked with the UPS service or some other drivers to be able to detect from their programs that an application is running on Windows that has just been toggled from the AC Power to the UPS Battery power?
Are there some links to this?
The best I came up with so far was some brief Linux code that directly monitored a few signals on the serial port, and I can do that if I have to, but I would rather let the rest of the system interact with the UPS as well.
|
|
|
|
|
Check out the WMI class, Win32_UninterruptiblePowerSupply .
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
If anyone uses a primitive windows frame... if you make the caption equal something like \nHello it will actually make a new line in the caption bar, I thought this was wierd cause it is acting like a static control...
If anyone wants to see this I could email a program that demonstrates the wierd effect.
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
Snyp wrote:
Actual Linux Penguins were harmed in the creation of this message.
poor penguins
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
But.. Isn't this the way it is supposed to work ? Naturally the caption area of the window is determined by the caption size, whether it had multiple lines, or a bigger font size/style. Wouldn't it look stupid if you used a huge font to draw the caption text then a minimalistic rectangle to represent the caption so that the font would clip out from it's region ?
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Well yes but the wierd thing is that the text gets cut off like half of it at least...
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
CMyDialog is a modal dialog invoked in CMyView, in CMyDialog, user can temporarily hide the dialog and go to CMyView window and use mouse to pick a point, then return to the dialog.
But how to implement the function gPickPoint() below,
CPoint gPickPoint()
{
CPoint pt;
// wait? loop? until user pick a point
return pt;
}
CMyView::OnBtnMyDialog()
{
CMyDialog dlg(this);
dlg.DoModal();
}
CMyDialog::OnBtnPickPoint()
{
CPoint pt;
CWnd *pFrameWnd = GetParent();
// hide dialog and go to view window
pFrameWnd->EnableWindow(TRUE);
ShowWindow(SW_HIDE);
pFrameWnd->SetFocus();
// waiting for user to pick a point from view
pt = gPickPoint();
// return from view window to dialog
ShowWindow(SW_SHOW);
SetFocus();
pFrameWnd->EnableWindow(FALSE);
EnableWindow(TRUE);
}
|
|
|
|
|
For the point-click handling, here's the design routine:
1. Use GetClienRect or GetWindowRect to get the view window's dimensions into a RECT structure. If using GetClientRect , remember to convert into screen coordinates.
2. Use ClipCursor to restrict the cursor into moving inside the defined RECT only. The cursor cannot leave this area now. Also, set a flag e.g. m_bCursorIsClipped to TRUE.
3. In the WM_LBUTTONDOWN handler of the view, check the flag value, and if it says that the cursor is clipped, then first send the point information to the dialog, then remove the clipping rectangle and show the dialog window again, hiding the main view. Lastly, set the flag to FALSE.
The clipping rectangle ensures that the user cannot do anything else on the frame window. He can use ALT+TAB to switch to other programs: in this case, you must handle this request (WM_KILLFOCUS ) and remove the clipping rectangle if it exists. You can re-set the clip in WM_SETFOCUS handler, if needed.
You should code a new user message for the view, called WM_USER_PICKPOINT , for example. Then in the dialog's button click handler, issue this message to the view window after hiding the dialog and showing the main frame. The handler for this message in the view window sets the cursor clipping region and the flag. The clipping region is removed and the flag nullified in the WM_LBUTTONDOWN handler of the view window, like I explained above.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Yes, it works.
Instead of restrict mouse within view's client area, I put patches for many toolbar or menu commands, and WM_CLOSE for main frame, to prevent user from running other command before this cmd finished.
But another little problem appears, CWinApp::OnIdle() ceased, which means ON_UPDATE_COMMAND_UI disabled. not sure why.
|
|
|
|
|
Hello,
How can I get the file size of a file using standard C++ library (not MFC)?
Thanks!!
Nachi
|
|
|
|
|
Do you mean, a function like _filelength ?
|
|
|
|
|
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream file;
int size = 0;
file.open("test.txt",ios::in); //Replace test.txt with file name
if(file.is_open())
{
file.seekp(0,ios::end); //Move position of stream to the end
size = file.tellp(); //Get position at end which tells size
file.close();
}
cout << "File size: " << size << endl;
return 0;
}
|
|
|
|
|
Hello!
GetFileSize() is WinAPI
|
|
|
|
|
My Access DB uses DD/MM/YYYY as do my text fields, but when I populate the list control (based on a code project sample) I get the format YYYY-MM-DD.
The offending line from FillData is
rgData = (LPSTR)rs->m_ppvData[nField];
Is there a directive I can give to OBDC to feed dates in as DD/MM/YYYY or should I be interpreting the contents of rgData?
Ger
|
|
|
|
|
You should not be assuming the date is in *any* format. A date is a date is a date, regardless of what format it is displayed in. If Access wants to display dates in DD/MM/YYYY format, fine. If you want to display dates in YYYY-MM-DD format, fine. For consistency, use the locale settings.
Ger Hayden wrote:
...but when I populate the list control (based on a code project sample) I get the format YYYY-MM-DD.
Check the Regional Settings applet in Control Panel.
Ger Hayden wrote:
The offending line from FillData is
rgData = (LPSTR)rs->m_ppvData[nField];
Which is meaningless since you have not provided the type of rgData , rs , m_ppvData , or nField .
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thanks David, Regional Settings are as specified in your reply. When I return to a proper modem line, I will elaborate more - am currenly on a mobile phone at 14.4bps so one must be brief
Ger
|
|
|
|
|
ded·i·ca·tion
n.
1. Catching up on CP posts using a mobile phone!
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thanks for the tips David. I side stepped the issue by trapping the column in a dedicated 'FillData' routine and re formatted them as required. However I now have an issue getting a ColeDateTime field to communicate with an ACCESS Date/Time field. I may well change the access field to an integer and use the .dt repesentation of the ColeDateTime field to interface.
Ger
|
|
|
|
|
I have a TV tuner with a crappy app that controls it and no scheduler to record shows. I would write my own app to schedule the startup of the crappy app and the ALT-R to begin record and again to stop it.
Unfortunately all I know is that I have to send the app a certain message. Any clues guys?
Thank you,
Andrei.
LATER UPDATE:
So I found you can use:
PostMessage(hwnd, WM_CHAR, WPARAM('^'), LPARAM(M)); for CTRL-M
But there appears 2 more questions in my mind:
a) How do you do it for ALT-R or ALT-F4? Any general rule?
b) How do you determine the handle of the window you want to send it to? Mine has "PCTV Vision" in the title. Any chance you have to use FindWindow?
TNX!
|
|
|
|
|
I like using Spy++ (part of the Visual Studio suite). It has several input methods - type the dialog name, 0x handle number, or select a cross-hair pointer and zap the window you want info on.
Johnny
|
|
|
|
|