Simple Flexport/Chicago Dial Indicator Data Acquisition Prog

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
cbey
Newbie
Posts: 5
Joined: Wed Oct 29, 2008 12:22 pm

Simple Flexport/Chicago Dial Indicator Data Acquisition Prog

Post by cbey »

I authored this simple code to fill the void for running data acquisition for linear length measurements using the

flexport. Note you'll need to have the flexport connected to either COM1 or COM2 (or you'll have to change your COM

designations to either 1 or 2) for the qbasic compiler to communicate with the Flexport. I'm sure the code could be

improved upon (i.e. the inclusion of graphics, etc.), but my goal was to send data to a text file to export into a

speadsheet program for graphing and analysis. I sincerely hope this helps someone else out there.

CLS
PRINT "FLEXPORT DATA ACQUISITION PROGRAM FOR USE WITH CHICAGO DIAL GUAGE INDICATOR"
INPUT "FILENAME (NAME.TXT)"; FILENAME$
INPUT "NUMBER OF SAMPLES"; SAMPLE
INPUT "SAMPLE RATE (SECONDS)"; RATE
OPEN "COM1:9600,n,8,1,CS,DS,RS" FOR RANDOM AS #1
OPEN FILENAME$ FOR OUTPUT AS #2
FOR Y = 1 TO SAMPLE
FOR X = 1 TO 3
WRITE #1, "!@R01" '
WRITE #1, "R01<CR>" 'COMMANDS TO THE FLEXPORT TO TAKE READING
WRITE #1, "R<CR>" '
NEXT X
INPUT #1, COUNT, READING, MODE$, ID, CR, LF
PRINT Y,DATE$, TIME$, READING, MODE$
PRINT #2, Y,DATE$, TIME$, READING, MODE$
CLOSE #1
LET SRATE=RATE*3600 'RATE IN SECONDS [WILL BE A FUNCTION OF CPU CLOCK SPEED TO CONVERT APPROPRIATE LENGTH TO

SECONDS OR MINUTES OR HOURS...]
' - CHANGE SAMPLE RATE INPUT TEXT ACCORDINGLY
FOR DELAY = 1 TO SRATE
NEXT DELAY
NEXT Y
END
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Ignorance is bliss!
Last edited by burger2227 on Thu Jul 02, 2009 6:59 pm, edited 1 time in total.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
cbey
Newbie
Posts: 5
Joined: Wed Oct 29, 2008 12:22 pm

REVISITED FLEXPORT FP-4U DATA ACQUISITION PROGRAM

Post by cbey »

I have revisited the original flexport gage interface data acquisition pogram I posted previously to include a real time plot display as well as the immediate creation of an excel file for plotting and data analaysis.

I wish to extend a special thanks to folks at MidwestFlex for the loaner flexport FP-4U to test the program on.

Typically the flexport can be used in conjunction with the Chicago Dial Indicator gage to measure the linear length and subsequent change in linear length of mortars and grout formulations.

Currently for many this is accomplished by taking periodic, manual readings. This manual method has many limitations, but primarily the lack datapoints overnight and during weekends. This program is provided as a facilitator for the utilization of the Flexport FP gage interfaces which when used in conjunction with the Chicago Dial Inidcator gages can allow automated data acquisition via a personal computer, hence "filling in the gaps" where reading were not previously taken.

The program currently provided was written in QBASIC due to it's ease in comprehension and modification, availability and negligible cost. That is not to say there aren't limitations to using QBASIC (i.e. imperfect timing). The aformention limitations are undoubtedly magnified due to my programming ability (or lack thereof), for which I apologize.

I do plan to post future versions in Visual C++.

It is my hope that this program will serve as guidance for those looking to utilize the gages and interfaces mentioned earlier, and perhaps to inspire others to adapt it for other purposes or to improve upon it.

CBey


CLS
CLEAR

'BASIC DATA AQCUISITION PROGRAM...
'INTENDED FOR THE FLEXPORT FP 4U IN DEFAULT CONFIGURATION
'IN CONJUNCTION WITH CHICAGO DIAL INDICATOR BG COMPARATOR GAGES
'PLEASE BE SURE TO DISABLE THE AUTO-OFF FUNCTION (INDICATED BY HOURGLASS) ON THE GAGE...
'BY PRESSING AND HOLDING "2ND" BUTTON UNTIL "2ND" APPEARS ON SCREEN, THEN PRESS "OFF" BUTTON...
'TO DISABLE AUTO OFF FUNCTION. THE HOURGLASS SHOULD DISAPPEAR
'ALSO BE CERTAIN TO DISABLE SCREENSAVER AND POWERSAVE FEATURES ON YOUR COMPUTER AS THEY WILL INTERRUPT READINGS
'THIS PROGRAM WAS WRITTEN IN QBASIC SO THE CODE WOULD BE EASY TO FOLLOW AND MODIFY AS WELL AS HAVING A READILY
'...AVAILABLE FREE COMPILER ONLINE

SCREEN 12'SOME MONITORS MAY NOT SUPPORT THIS SCREEN CONFIGURATION
INPUT "PLEASE ENTER A FILENAME TO RECORD YOUR MEASUREMENTS"; FILE$
INPUT "SAMPLING RATE IN SECONDS (I.E. ENTER 30 FOR EVERY 30 SECONDS)"; RATE
INPUT "TOTAL SAMPLING DURATION IN MINUTES"; SAMPLE
LET DURATION = SAMPLE * 60
LET READINGS = DURATION / RATE
ACTREAD = READINGS + 1
FILENAME$ = FILE$ + ".XLS"
OPEN "COM1:9600,N,8,1,CD,CS,DS,RS" FOR RANDOM AS #1
OPEN FILENAME$ FOR OUTPUT AS #2' CREATES EXCEL FILE FOR DATA
PRINT #2, "TIME(SEC)"; CHR$(9); "LLC1"; CHR$(9); "LLC2"; CHR$(9); "LLC3"; CHR$(9); "LLC4"; CHR$(9); "DATE";CHR$(9); "TIME"; CHR$(9); "CPU TIMER"'COLUMN HEADERS IN EXCEL SPREADSHEET..CONTINUATION OF PREVIOUS LINE

CLS
PRINT "PRESS 'Esc' TO STOP MEASUREMENTS..."'INTRO FOR INKEY BELOW ALLOWING ONE KEY TERMINATION OF MEASUREMENTS
VIEW PRINT 14 TO 15: LOCATE 15, 4: PRINT "0"
VIEW PRINT 3 TO 4: LOCATE 3, 3: PRINT "+5"
VIEW PRINT 26 TO 27: LOCATE 26, 3: PRINT "-5"
VIEW (500, 400)-(40, 40), , 1'ESTABLISHES VIEW WINDOW FOR GRAPH
WINDOW (0, -5)-(ACTREAD, 5)'ESTABLISHES SCALE FOR GRAPH
LINE (0, 0)-(ACTREAD, 0)'SETS 0 LINE FOR MONTORING EXPANSION OR SHRINKAGE
FOR X = 0 TO READINGS
Z = X * RATE
VIEW PRINT 29 TO 30
LOCATE 30, 15: PRINT DATE$, TIME$

'LLC1
WRITE #1, "!@R01"'COMMAND TO FLEXPORT CHANNEL 1 TO TAKE COMPARATOR READING
INPUT #1, A$, COUNT, LREADING1, MODE$, B$'ASSIGNMENT OF VARIABLES AND ACQUISITION OF READING
PSET (X, LREADING1)'GRAPHING DATA POINTS FOR LLC1
LINE STEP(0, 0)-STEP(.35, 0), 2
'LLC2 READING
WRITE #1, "!@R02"
INPUT #1, A$, COUNT, LREADING2, MODE$, B$
PSET (X, LREADING2)'GRAPHING DATA POINTS FOR LLC2
CIRCLE STEP(0, 0), .25, 3
'LLC3 READING
WRITE #1, "!@R03"
INPUT #1, A$, COUNT, LREADING3, MODE$, B$
PSET (X, LREADING3)'GRAPHING DATA POINTS FOR LLC3
LINE STEP(0, 0)-STEP(0, .25), 4
'LLC4 READING
WRITE #1, "!@R04"
INPUT #1, A$, COUNT, LREADING4, MODE$, B$
PSET (X, LREADING4)'GRAPHING DATA POINTS FOR LLC4
CIRCLE STEP(0, 0), .125

PRINT #2, Z; CHR$(9); LREADING1; CHR$(9); LREADING2; CHR$(9); LREADING3; CHR$(9); LREADING4; CHR$(9); DATE$;CHR$(9); TIME$; CHR$(9); TIMER',READING,MODE$ TO BE INCLUDED SENDS DATA TO COLUMNS IN EXCEL SPREADSHEET
VIEW PRINT 10 TO 15
COLOR 2
LOCATE 10, 65: PRINT "LLC1 "; USING "###.###"; LREADING1 'REALTIME DATA VIEW IN TXT
COLOR 3
LOCATE 11, 65: PRINT "LLC2 "; USING "###.###"; LREADING2
COLOR 4
LOCATE 12, 65: PRINT "LLC3 "; USING "###.###"; LREADING3
COLOR 7
LOCATE 13, 65: PRINT "LLC4 "; USING "###.###"; LREADING4
VIEW PRINT 29 TO 30

LOCATE 29, 45: PRINT "X="; Z

VIEW PRINT 16 TO 20
LOCATE 16, 65: PRINT FILENAME$
LOCATE 17, 65: PRINT "RATE"; RATE
LOCATE 18, 65: PRINT "DURATION"; SAMPLE
LOCATE 19, 65: PRINT "READINGS"; ACTREAD

IF X = READINGS THEN END ELSE
TIME = 804269 '(792055/SECOND) to (806807/SECOND) APPROXIMATELY WILL DEPEND ON CPU CLOCK SPEED AND TIME TO
'... EXECUTE INTERSTITIAL COMMANDS
IF INKEY$ = CHR$(27) THEN END ELSE
FOR J = 1 TO RATE
IF INKEY$ = CHR$(27) THEN END ELSE 'OPTIONAL INTENDED FOR LONG DURATION BETWEEN SAMPLES (OR USE CTRL + BREAK)
FOR t = 0 TO TIME
NEXT t
NEXT J
NEXT X






Programmers Area - QBasic Forum
Cbey (Programmer)0 replies29 Oct 08 (29 Oct 08)
Simple Flexport/Chicago Dial Indicator Data Acquisition Program
I authored this simple code to fill the void for running data acquisition for linear length measurements using the

flexport. Note you'll need to have the flexport connected to either COM1 or COM2 (or you'll have to change your COM

designations to either 1 or 2) for the qbasic compiler to communicate with the Flexport. I'm sure the code could be

improved upon (i.e. the inclusion of graphics, etc.), but my goal was to send data to a text file to export into a

speadsheet program for graphing and analysis. I sincerely hope this helps someone else out there.

CLS
PRINT "FLEXPORT DATA ACQUISITION PROGRAM FOR USE WITH CHICAGO DIAL GUAGE INDICATOR"
INPUT "FILENAME (NAME.TXT)"; FILENAME$
INPUT "NUMBER OF SAMPLES"; SAMPLE
INPUT "SAMPLE RATE (SECONDS)"; RATE
OPEN "COM1:9600,n,8,1,CS,DS,RS" FOR RANDOM AS #1
OPEN FILENAME$ FOR OUTPUT AS #2
FOR Y = 1 TO SAMPLE
FOR X = 1 TO 3
WRITE #1, "!@R01" '
WRITE #1, "R01<CR>" 'COMMANDS TO THE FLEXPORT TO TAKE READING
WRITE #1, "R<CR>" '
NEXT X
INPUT #1, COUNT, READING, MODE$, ID, CR, LF
PRINT Y,DATE$, TIME$, READING, MODE$
PRINT #2, Y,DATE$, TIME$, READING, MODE$
CLOSE #1
LET SRATE=RATE*3600 'RATE IN SECONDS [WILL BE A FUNCTION OF CPU CLOCK SPEED TO CONVERT APPROPRIATE LENGTH TO

SECONDS OR MINUTES OR HOURS...]
' - CHANGE SAMPLE RATE INPUT TEXT ACCORDINGLY
FOR DELAY = 1 TO SRATE
NEXT DELAY
NEXT Y
END
cbey
Newbie
Posts: 5
Joined: Wed Oct 29, 2008 12:22 pm

re: simple data acquisition...

Post by cbey »

burger2227 wrote:Ignorance is bliss!
Revisions and improvements are welcome!
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

I saw your posts but you never responded before.............

Post by burger2227 »

COM ports share the same IRQ address. COM 1 and 3 use the same IRQ. To swap the port addresses and keep the same IRQ, just swap the ports with the same IRQ! Below a routine swaps COM1 and COM3:"

Code: Select all

DEF SEG = 0 'DOS BIOS settings. QB will read COM1 with COM3 values
   COM1L% = PEEK(&H400): COM1H% = PEEK(&H401)  'COM1 port value   
   COM3L% = PEEK(&H404): COM3H% = PEEK(&H405)  'COM3 port values
   POKE &H400, COM3L%: POKE &H401, COM3H%    'change COM1 to COM3 settings
   POKE &H404, COM1L%: POKE &H405, COM1H%    'change COM3 to COM1 settings
DEF SEG         'reset to default memory segment"

'To swap COM2 and COM4, with the same IRQ, use the swap routine below:

DEF SEG = 0 'DOS BIOS settings. QB will read COM2 with COM4 values
   COM2L% = PEEK(&H402): COM2H% = PEEK(&H403)  'COM2 port values
   COM4L% = PEEK(&H406): COM4H% = PEEK(&H407)  'COM4 port values
   POKE &H402, COM4L%: POKE &H403, COM4H%    'change COM2 to COM4 settings
   POKE &H406, COM2L%: POKE &H407, COM2H%    'change COM4 to COM2 settings
DEF SEG         'reset to default memory segment

You should change the settings back after the program is done with the COM ports by running the procedure again.

NOTE: NT and XP machines may require PortTalk to work with ports!
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
cbey
Newbie
Posts: 5
Joined: Wed Oct 29, 2008 12:22 pm

Re: i saw your posts but you never responded before...

Post by cbey »

Thanks, burger2227 for the suggestions for swapping COM ports.
Post Reply