01-12-2009 03:19 AM
Hi everybody,
I have a little problem running a quickbasic programm in LabVIEW. In fact, I have some .exe files compiled with QuickBasic (I have the codes .bas) that make move a translation table via a com port. First I used directly the exe files to control the table but now I would like to modify directly in LabView the distance of the mouvement therefore write translate the .bas into a labview vi. I heard about LabBasic beta version but unfortunately it doesn't open com ports.
The real question is if somebody could help me tranlate my .bas file into a VI ??
The code is the following :
`Movement X 10 mm front
freq = 1000
horiz = -.15 `mm
vertic = 0 `mm
pasX = (horiz / 5) * 400
pasY = (vertic / 5) * 400
CLOSE
OPEN "com1:9600,n,8,1,RS,CS,DS,CD" FOR RANDOM AS #1
`axis selection
PRINT #1, "@03": GOSUB testerr ` @01=X ; @02=Y ; @03=XY
`commande de dplacement relatif: @0A pasX,freq,pasY,freq
PRINT #1, "@0A " + STR$(pasX) + "," + STR$(freq) + "," + STR$(pasY) + ","
+ STR$(freq): GOSUB testerr
GOTO fin
testerr: Q = TIMER
test: IF LOC(1) < 1 THEN A = TIMER: IF A - Q < 20 THEN GOTO test
IF A - Q > 20 THEN A$ = "CARTE ERREUR": GOTO test
A = 0: A$ = INPUT$(1, 1): IF A$ = "0" THEN RETURN
fin:
` PRINT "carte rpond :"; A$
CLOSE
END.
Thank you very much for your help !
01-12-2009 05:33 AM
Your code isn't too hard, and should be quite easily be ported to LabVIEW.
Here is a start where I set the names of the function to be used:
freq = 1000
horiz = -.15 `mm
vertic = 0 `mm
pasX = (horiz / 5) * 400
pasY = (vertic / 5) * 400
CLOSE
OPEN "com1:9600,n,8,1,RS,CS,DS,CD" FOR RANDOM AS #1 VISA Open
`axis selection
PRINT #1, "@03": GOSUB testerr ` @01=X ; @02=Y ; @03=XY Format into string, with visa write
`commande de dplacement relatif: @0A pasX,freq,pasY,freq
PRINT #1, "@0A " + STR$(pasX) + "," + STR$(freq) + "," + STR$(pasY) + "," Format into string, with visa write
+ STR$(freq): GOSUB testerr
GOTO fin
testerr: Q = TIMER
test: IF LOC(1) < 1 THEN A = TIMER: IF A - Q < 20 THEN GOTO test Some boolean comparison with a case structure
IF A - Q > 20 THEN A$ = "CARTE ERREUR": GOTO test Some boolean comparison with a case structure
A = 0: A$ = INPUT$(1, 1): IF A$ = "0" THEN RETURN
fin:
` PRINT "carte rpond :"; A$ Format into string
CLOSE
END.
The main task is to avoid locals, let all the data stay in the wires.
Only FP terminals needed:
01-12-2009 08:17 AM
Hello again,
I've been trying to build the vi as you told me but I haven't been able to do it. In fact, I didn't write the .bas programm and I don't know the qb language and I'm a LabView beginner...
I was hoping you could help a little more... Here is a picture of the vi I'm working on (i know it is very basic...) I don't know if the visa writing is correct, if I'm missing something... I'm really lost. And another question : the visa writing output is a number. How does that number become a movement or is it just an indicator and the table should move anyways??
Thank you again for your precious help
Chamo3000
01-12-2009 09:43 AM
It would have been better if you had attached the actual VI. That way someone would at least know what version of LabVIEW you have.
In any case, your Format Into String is not correct. You are missing a space after @0A and a couple of commas. Here is some code in LabVIEW 8.0 that you can try. I don't know if the strings need to be terminated. I've included some string constants that terminate with a CR and LF. If the original code does not work, you might want to try sending the CR and LF or just one of them.
I would also strongly suggest that you debug the com settings, serial cable, and commands in a program such as Hyperterminal before you try writing any code.
01-12-2009 10:08 AM
Hi,
Thank you for your taking the time... I actually have LabVIEW 8.0.
I didn't find the LabVIEW 8.0 code you talk about, I hope you could attach the vi again so I can take a look at it.
I will also try to debug the com settings as you said and keep trying.
01-12-2009 10:45 AM
01-13-2009 03:25 AM
Hi Dennis,
it didn't really work actually
..... thanks anyway
I'm going to keep trying and if someone has another suggestion please share it....
Thank you
01-13-2009 03:33 AM
Hi,
I noticed dennis made a copy error, the script states *400, Dennis wrote *1000 in the formula node.
Did you try both constants?
What is the response from the device?
What is the current state of your code?
Is it possible to get a sniffer to see what VB is actually sending (including end characters), maybe replace the Com-port with a file?
Ton
01-13-2009 09:31 AM
Sorry about the typo.
Here is the location for portmon. You can run this and capture the serial communication with the exe and compare it to the LabVIEW results.
From the quickbasic code listing and from I remember, it looks like the instrument requires ASCII so the code I posted should be close. You still have not said whether you tried Hyperterminal or not. Until you do and until you post back saying that it works or doesn't work with Hyperterminal, I don't know what anyone can do.