USB Parallel Port and ADC11

Post general discussions on using our drivers to write your own software here
Post Reply
Bruce Cameron

USB Parallel Port and ADC11

Post by Bruce Cameron »

I am getting an error message from MEMMGR:

Attempt to lock unknown global
File adc11usb.c Line 614

This occurs for example if I try to run the sample ADC1132.xls with the port value edited to 101. I downloaded the driver today.

This appears to be the same as the acknowledged bug described in a number of postings more than one year ago. Technical staff were working on it and it was hoped the fault would be corrected "soon".

What is the current status? Have I overlooked something?

User avatar
markspencer
Site Admin
Site Admin
Posts: 598
Joined: Wed May 07, 2003 9:45 am

Post by markspencer »

Hi,

I am sorry to hear that you are experiencing problems. When using the ADC1132.xls with a USB to Parallel Port adapter you need to include three other functions run, ready and stop. These will look someting like this:


call adc11_run (1000, 0)

while adc11_ready() = 0
wend

call adc11_stop

The above will be placed after the adc11_set_interval call.

The prototypes have to be declared, details relating to the declarations, return types and arguments parameters can be found in the help manual.

Best regards,
Regards,

Mark Spencer

inschris
Active User
Active User
Posts: 13
Joined: Sun Oct 16, 2005 2:28 pm
Location: Capetown

USB Parallel Port and ADC11

Post by inschris »

Greetings all! Thread "USB Parallel Port and ADC11"
I too am trying to use the USB ADC11 (full-on USB, not parallel ADC11 w USB adapter) to collect data direct into Excel, having difficulty as described below. Will be grateful if anyone can give tips about this, eg, has bug referred to earlier in this thread been overcome?

OBSERVATIONS 10/08/2006
A) Running ADC1132_514e.xls in Win98SE, Excel 97 SR-2, w adc1132.dll dd. 15/6/06 in \winnt\system\ :
stepping thro macro GetAdc11 in ADC1132_514e.xls: got msg executing line:
Call adc11_get_times_and_values(times(), values(), 100):
Progrm has performed illegal oper'n, will be shut down. Details:
EXCEL caused an invalid page fault in
module at 0000:00180004.
Registers:
EAX=ffffffff CS=018f EIP=00180004 EFLGS=00010246
EBX=00180004 SS=0197 ESP=00180004 EBP=00180004
ECX=0062f5c8 DS=0197 ESI=00180004 FS=0faf
EDX=00180004 ES=0197 EDI=00180004 GS=0000
Bytes at CS:EIP:

Stack dump:

B) Running ADC1132_514e.xls in Win2000 SP4, Excel 97 SR-2, w adc1132.dll dd. 15/6/06 in \windows\system\ :
stepping thro macro GetAdc11 in ADC1132_514e.xls: At the same line, Excel and VBA IDE both closed without win2k's displaying any message. There may be a log somewhere.

CIRCUMSTANCES Here's the macro (I also attach the file):
' adc1132.xls from 5-14, edited by C Inskip Used w adc1132.dll from v5-14 modifd 15/6/06 in \winnt\system\
' Macro1 Macro
' Version 2.0
' Macro recorded 13Jul95 by Mike Green
' Updated for new drivers
'

Declare Function adc11_get_driver_version Lib "ADC1132.dll" () As Integer
' nxt line wks also As Boolean
Declare Function adc11_open_unit Lib "ADC1132.dll" (ByVal port As Integer, ByVal product As Integer) As Integer
Declare Function adc11_set_unit Lib "ADC1132.dll" (ByVal port As Integer) As Integer
Declare Sub adc11_close_unit Lib "ADC1132.dll" (ByVal port As Integer)

Declare Function adc11_get_unit_info Lib "ADC1132.dll" (ByVal s As String, ByVal lth As Integer, ByVal line_no As Integer, ByVal port As Integer) As Integer

Declare Sub adc11_set_do Lib "ADC1132.dll" (ByVal state As Integer)

Declare Function adc11_get_value Lib "ADC1132.dll" (ByVal channel As Integer) As Integer ' BYVAL OR BYREF?

Declare Sub adc11_set_trigger Lib "ADC1132.dll" (ByVal enabled As Integer, ByVal enable_auto As Integer, ByVal auto_ms As Integer, ByVal channel As Integer, ByVal falling As Integer, ByVal threshold As Integer, ByVal delay As Integer)
Declare Function adc11_set_interval Lib "ADC1132.dll" (ByVal us_for_block As Long, ByVal ideal_no_of_samples As Long, channels As Integer, ByVal No_of_channels As Integer) As Long
Declare Function adc11_get_values Lib "ADC1132.dll" (values As Integer, ByVal no_of_values As Long) As Long ' VBA DEFAULT IS BYREF
Declare Function adc11_get_times_and_values Lib "ADC1132.dll" (times() As Long, values() As Integer, ByVal no_of_values As Long) As Long ' VBA DEFAULT IS BYREF
' ADDN'S BY CI:
Declare Sub adc11_run Lib "ADC1132.dll" (ByVal no_of_values As Long, ByVal method As Integer)
' ?has to be Sub cos routine return: none and/or cos use is in Call, or has to be
Declare Function adc11_ready Lib "ADC1132.dll" () As Integer
Declare Sub adc11_stop Lib "ADC1132.dll" () ' Args none, returns none
' Declare Function adc11_open_usb_unit_async Lib "ADC1132.dll" (ByVal port As Integer, ByVal product As Integer) As Integer
Dim us As Long ' long integer for returns in microseconds
Dim vals As Long ' Long integer for no. of values; Function adc11_get_times_and_values is As Long

Dim times(100) As Long ' an array
Dim values(200) As Integer ' an array
Dim channels(22) As Integer ' an array This is ORIGNL; only 2 elements get values in present case
Dim s As String * 255 ' fixed length string
Public port As Integer
Public product As Integer

Function adc_to_mv(value As Integer) As Integer
adc_to_mv = value * 2500# / 1023
End Function


Sub GetAdc11()

' Open the ADC on LPT1
port = 101 ' declared above as integer
product = 111 ' declared above as integer
opened = adc11_open_unit(port, product) <> 0 ' Open ADC-10 driver IT'S A FUNCTION. TAKES TIME in w98SE
' but no delay needs to be put in in w2k
' opened = adc11_open_usb_unit_async(port, product) > 0 ' per help p adc11_open_usb_unit_async
If opened Then 'Check driver opened ok
Cells(17, "E").value = "ADC opened"
i = adc11_get_unit_info(s, 255, 1, port) ' IT'S A FUNCTION
Cells(18, "E").value = s
i = adc11_get_unit_info(s, 255, 2, port)
Cells(19, "E").value = s
i = adc11_get_unit_info(s, 255, 3, port)
Cells(20, "E").value = s
i = adc11_get_unit_info(s, 255, 4, port)
Cells(21, "E").value = s

' Enable trigger
' Auto trigger after 1 second
' Trigger on rising edge at 512 adc counts (512=1.25V) on channel 1
' No delay
Call adc11_set_trigger(True, True, 1000, 10, False, 512, 0) ' IT'S A SUB ! THERE'S NO SIGNAL ON CH 10
' Call adc11_set_trigger(False, True, 1000, 10, False, 512, 0) ' Args are all Integer

' Say that we want to take 100 readings in 20000us
' from channels 1 and 3
channels(0) = 1
channels(1) = 3
us = adc11_set_interval(10000, 100, channels(0), 2) ' IT'S A FN. ORIGNL: channels(0) indicates no. of dimns viz 1
' Args are ByVal Long, ByVal Long, default Integer, ByVal Integer Fn is as Long
Call adc11_run(100, 0) ' per PicoForum->General Software Disc'ns/USB Parallel Port and ADC11 (arcwebac\\1029.htm)
While adc11_ready() = 0
Wend
Call adc11_stop

' Get a block of 100 readings...
' we can call this routine repeatedly
' to get more blocks with the same settings
Call adc11_get_times_and_values(times(), values(), 100) ' had to chnge in Declare Fn to avoid ByRef arg mismatch
' VBA help: "CALL Stmt ... To pass a whole array to a procedure, use the array name followed by empty parentheses"

' Copy the data into the spreadsheet
For i = 0 To 99
Cells(i + 4, "A").value = times(i)
Cells(i + 4, "B").value = adc_to_mv(values(2 * i))
Cells(i + 4, "C").value = adc_to_mv(values(2 * i + 1))
Next i

' You can take a single reading from channel 3 like this...
i = adc11_get_value(1) ' arg is Integer
Cells(17, "g").value = adc_to_mv(CInt(i)) ' this w prev line wks
Else
Cells(7, "E").value = "Unable to open ADC"
End If

Call adc11_close_unit(port)

End Sub

EARLIER OBSERVATIONS:
Prior to introducing the lines
Call adc11_run(100, 0)
While adc11_ready() = 0
Wend
Call adc11_stop

I was getting same effects as reported by earlier contributor to this thread, at that same line:
Call adc11_get_times_and_values(times(), values(), 100)
namely:
---------------------------
MEMMGR
---------------------------
Attempt to lock unknown global
File \Picocvs\Pico\Prod\Adc11\Windrv\ADC11USB.c Line 1041
---------------------------
OK
---------------------------
then another msgbox:
---------------------------
MEMMGR
---------------------------
Attempt to lock global failed
File \Picocvs\Pico\Prod\Adc11\Windrv\ADC11USB.c Line 1041
---------------------------
OK
---------------------------
VBA then put up msgbox:
Runtime error 11 Division by 0

I chose Debug. After then clicking Stop debug, Excel and VBA IDE closed; if I click End, they shut down immediately. But after clicking Debug I can prevent this shutdown by commenting out the line
Call dc11_get_times_and_values etc ; then I can step thro the rest of the macro.

Michael
Advanced User
Advanced User
Posts: 656
Joined: Thu Jul 07, 2005 12:41 pm
Location: St Neots, Cambridgeshire

Post by Michael »

Hello,

The latest software release includes a new dll for the USB ADC11. This dll includes new function calls and will need to be downloaded to use.

The ready call has been fixed and now returns true when ready.

Please download and install.

Best regards,
Michael
Michael - Tech Support
Pico Technology
Web Support Forum

Post Reply