LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Quick basic to labview

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 d‚placement 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 r‚pond :"; A$
CLOSE
END.

 

 

Thank you very much for your help !

0 Kudos
Message 1 of 9
(4,500 Views)

adf

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 d‚placement 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 r‚pond :"; 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:

  •  freq
  • horiz
  • vertic
  • Comm-port
  • Output (A$)

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 2 of 9
(4,480 Views)

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

0 Kudos
Message 3 of 9
(4,452 Views)

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.

 

 

Message 4 of 9
(4,432 Views)

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.

0 Kudos
Message 5 of 9
(4,413 Views)
Sorry. I don't know how the attachment got lost. Here it is again.
Message 6 of 9
(4,401 Views)

Hi Dennis,

it didn't really work actually Smiley Sad ..... thanks anyway

 

I'm going to keep trying and if someone has another suggestion please share it....

 

Thank you

0 Kudos
Message 7 of 9
(4,349 Views)

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

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 8 of 9
(4,346 Views)

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.

0 Kudos
Message 9 of 9
(4,305 Views)