SCOUG Logo


Next Meeting: Sat, TBD
Meeting Directions


Be a Member
Join SCOUG

Navigation:


Help with Searching

20 Most Recent Documents
Search Archives
Index by date, title, author, category.


Features:

Mr. Know-It-All
Ink
Download!










SCOUG:

Home

Email Lists

SIGs (Internet, General Interest, Programming, Network, more..)

Online Chats

Business

Past Presentations

Credits

Submissions

Contact SCOUG

Copyright SCOUG



warp expowest
Pictures from Sept. 1999

The views expressed in articles on this site are those of their authors.

warptech
SCOUG was there!


Copyright 1998-2024, Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.

The Southern California OS/2 User Group
USA

SCOUG-Programming Mailing List Archives

Return to [ 20 | May | 1999 ]

<< Previous Message << >> Next Message >>


Date: Thu, 20 May 1999 09:59:30 PDT
From: Steven Levine <steve53@earthlink.net >
Reply-To: scoug-programming@scoug.com
To: scoug-programming@scoug.com
Subject: SCOUG-Programming: #5

In <08256777.002356D8.00@svdatsmtpmta.beckman.com>, on 05/19/99
at 10:24 PM, "Benedict G Archer" said:

>But Steven, I've never written a driver in DOS,

OK, here's a sample. Other devices are more or less complex :). And,
don't bit about the hard coded 100uSec delay. I'll fix it someday.

>lasers, galvo-scanners, array sensors such as a linear diode array or
>ccd). The cards have been various, all with DOS drivers and usually with
>a library of functions (supplied with the card) linked into a C program

This is just wrappers. You still banging bits to and from the device.

Steven

--
-----------------------------------------------------------
Steven Levine MR2/ICE #10183
-----------------------------------------------------------
/*=== ADCInit: Initialize ADC ===*/

void ADCInit(BYTE idbRange)
{
outportb(ADC_BASE + 3, idbRange); // Init range

} // ADCInit

/*=== ADCRead: Read ADC channel ===*/

BOOL ADCRead(BYTE ibChan, short *psADCData)
{
USHORT c;
BYTE low;
BYTE high;
short sADData;
BOOL fOK;

outportb(ADC_BASE + 2, ibChan); // select A/D channel
for (c = 1; c < 25; c++)
; // wait 100 uSec for mux to settle - fixme to time

outportb(ADC_BASE + 1, 0); // start 12 bit conversion

while (inportb(ADC_BASE + 2) & ADC_BUSY && ++c < 500)
; // Wait for conversion to complete

fOK = c < 500; // False if conversion timeout

/* Read 12 bit ADC value
Data comes in normalized with MSB in bit 15 of data word
*/
low = inportb(ADC_BASE);
high = inportb(ADC_BASE + 1);
sADData = ((USHORT)high << 8) | low;
sADData -= 0x8000; // Remove offset
sADData = sADData >> 4; // Scale to 12 bits
*psADCData = sADData; // Stow

return fOK;

} // ADCRead

/*=== ADCReadStatus: Read ADC status word ===*/

BYTE ADCReadStatus(void)
{
return inportb(ADC_BASE + 2);

} // ADCReadStatus

=====================================================

To unsubscribe from this list, send an email message
to "steward@scoug.com". In the body of the message,
put the command "unsubscribe scoug-programming".

For problems, contact the list owner at
"rollin@scoug.com".

=====================================================


<< Previous Message << >> Next Message >>

Return to [ 20 | May | 1999 ]



The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA

Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.