Aggrivated with Interfacing Labview to BS2
rage404
Posts: 17
Hey all,
I've been working on using Labview with the BS2. I want to click a button in labview and run a program on the BS2. Has anyone created a program that can perform this task? All i want is to flash a led.
High 2
Pause 500
Low 2
pause 500
Instigated by some input·from labview.
If I could get this to work it seems like i could figure all the more complicated stuff out.
I am a mechanical engineer so if you are gracious enough to help me out I would appretiate it if it were lower level explanation, else I will just be more confused and aggrivated
Jeff
Post Edited (rage404) : 2/2/2009 3:38:18 AM GMT
I've been working on using Labview with the BS2. I want to click a button in labview and run a program on the BS2. Has anyone created a program that can perform this task? All i want is to flash a led.
High 2
Pause 500
Low 2
pause 500
Instigated by some input·from labview.
If I could get this to work it seems like i could figure all the more complicated stuff out.
I am a mechanical engineer so if you are gracious enough to help me out I would appretiate it if it were lower level explanation, else I will just be more confused and aggrivated
Jeff
Post Edited (rage404) : 2/2/2009 3:38:18 AM GMT
Comments
I am communicating between my computer and the BS2 by means of a serial cable. I am looking to use the serin serout commands. My program may be working since I can use the debug terminal to activate my LED blink.
It seems that the issue is with LabVIEW. How can I get it to recognize a usb to serial adapter?
Any labview experts out there?
Jeff
http://www.parallax.com/dl/sw/labviewbs2.pdf
Please advise as to your progress.
This is an issue with LabVIEW. I'm not sure why but it does not want to recognize the com port that is connected to my BS2 and I get error messages.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
While using it I learned that most of the time serial communications did not work it was either the protocol in Labview and the target were not set the same (speed, parity, stop bits, etc), or the target was expecting an acknowledgment character.
Also, always start at a very low speed to get it to work, then ramp up until it fails. Use a speed somewhat less than the max.
Sorry I can't contribute more-I wish I was still developing with Labview, it is fun and nice that you don't have to deal with dll's and deployment issues.
Running the below program I get the desired result.
To test this run the bellow program with an LED hooked in series to a resistor from pin 1 to Vdd.
Once the debug terminal appears enter Axxxx into the white input area, LED on pin 2 flashes. entering Bxxxx makes led on pin 1 flash.
This is exactley what I want from my program.
I want to accomplish the same thing using labview as a front panel. Entering text into the basic serial read write program returns no results.
Using the measurment and automation program and exploring the appropriate com port allows me to access a test connection section. In this area I can get a response only if I enter my comman twice. Does anyone have an explanation for this?
stamp program
' {$STAMP BS2}
baudmode CON 84 'serial code to set baudrate (pg.321, BASIC Stamp® Manual)
'For pin 16 (noninverted): 9600=>84, 19200=>32, 38400=>6
'For pins 0-15 (inverted): 9600=>16468, 19200=>16416, 38400=>16390
comm VAR Byte(3) 'command data char
val VAR Word 'command value
comm(2) = 0
'LabVIEW command I/O loop
top:
DEBUG CLS, "enter a string of 5 digits starting with an a or d", CR
SERIN 16,baudmode,[noparse][[/noparse]STR comm\2, DEC3 val] 'get command and value
'Signal Data Received...always a 2 char command plus 3 digits
IF comm(0)="A" OR comm(0)="a" THEN A
IF comm(0)="D" OR comm(0)="d" THEN D
GOTO top
A:
HIGH 2
PAUSE 500
LOW 2
PAUSE 500
SEROUT 16,baudmode,[noparse][[/noparse]"AA ", DEC3 val, CR]
GOTO top
HIGH 1
PAUSE 500
LOW 1
PAUSE 500
SEROUT 16,baudmode,[noparse][[/noparse]"BB ", DEC3 val, CR]
GOTO top
From PBASIC Help regarding SERIN:
Decimal Formatter Specifics
The decimal formatter is designed to seek out text that represents decimal numbers. The characters that represent decimal numbers are the characters "0" through "9". Once the SERIN command is asked to use the decimal formatter for a particular variable, it monitors the incoming serial data, looking for the first decimal character. Once it finds the first decimal character, it will continue looking for more (accumulating the entire multi-digit number) until it finds a non-decimal numeric character. Keep in mind that it will not finish until it finds at least one decimal character followed by at least one non-decimal character.
·
P16 is the programming port·with a line driver and the baud should be 9600 inverted which is 16468.
Also P16 echoes all data it receives back to the PC which can·sit in the PC's serial buffer and get mixed in with your next transmission, best if you can give an·"emptybuffer" instruction before sending data·each time. The suggestion of a terminating CR or null character can only be a good thing .
Apart from that the BS2 stuff you have looks good to me.
Jeff T
Jeff T.
EDIT this all needs to be done at the LabView end the Stamp code looks fine.
PBasic·code development time = 20 min
cost = $0
Labview painstaking trial and error = 4 days
Cost = $4000 for a commercial license. (I'm glad I didn't pay that.)
So here are some questions I hope will get me all straightened out.
How many bits does a letter require?(2)?
How can labview read my stamp and return the value I entered when my stamp is powered off?
Has anyone else been able to sucessfully communicate with labview to a BS2?