LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic Stamp 2 MicroController

I am currently working on a project that involves using a Basic Stamp 2 microcontroller that was purchased through Parallax.com.  We currently have the uController connected with our laptops using a USB to Serial converter and are able to achieve proper communication with the example LabVIEW code provided through parallax.com.  We loaded the Basic Stamp Editor code that I attached below  and ran the LabVIEW program (also attached).  The problem that we are running into is that we need to have the ability to read and write to each pin.  We need to set a specific pin HIGH depending on the user input. (Ex. User selects Pin 3 to set HIGH or LOW)  The program that was loaded from the basic stamp editor just echos the user input.  We are beginners with the software so we are not sure what part has to be changed in order to get it working.

 

If there is any more information that is needed please let us know! We are nearly 4 weeks until our due date =/

Download All
0 Kudos
Message 1 of 11
(4,278 Views)

Specific control line states can be read by using a VISA property node.  Go to the Instrument I/O palette, then VISA >> Advanced.  Select the property node function, left click on it, and go to Serial Settings >> Modem Line Settings.  You should be able to select a specific control line this way.

0 Kudos
Message 2 of 11
(4,248 Views)

Hi,

Looking at your stamp code, it is only programmed to drive one output pin and one input pin.  Your serial protocol needs to be expanded to allow you to set pin and state, currently you only send state.  You could just copy the code down and change the DO command to O1, O2 etc.

Also, the labview code you have is not too good.  There is no while loop.  Are you just running the code once or using the run continuous button?  Run continuous is very bad as you are continuously opening and closing the com port.  You should move the serial port open and close functions outside of the loop.  This will require you to move the open and close code out of the subvi.  If the code is user interface driven then you should use an event structure within your main loop.  If you are not using an event structure you must put a small wait inside the loop or your code could use 100% CPU and lock up your PC.

Search the labview examples for ways to code your application.

Good luck,

Michael

0 Kudos
Message 3 of 11
(4,231 Views)

Hey Rivers,

 

I understand what you mean but exactly which section of the code should I copy down and which DO and I am I switching?  Do I switch every DO or just this section:

 

DO:
    Dout=val      'Set digital output
    SEROUT 16,baudmode,["DO ", DEC3 Dout, CR]   'Send response
  GOTO top

I apologize that I dont have more experience with writing code. =/

0 Kudos
Message 4 of 11
(4,215 Views)

do you need analogue in and out as well as digital in and out or are you just doing some of them?

0 Kudos
Message 5 of 11
(4,211 Views)

Also, if I fix the LabVIEW program that I posted, will I be able to write a pin HIGH and LOW with it?  It states "Write Sting" and I wasn't sure if this is where I would write "HIGH 1"

0 Kudos
Message 6 of 11
(4,209 Views)

I only need a Digital in and out.....we are using the stamp to send 5V to a circuit of LED lights and we also need to read voltages from a motion sensor

0 Kudos
Message 7 of 11
(4,207 Views)

so you change the command set from AI AO DI DO to A1 A2 to read analogue in  O1 O2 to write to digital out and I1 I2 to read digital ins.  this keeps your code simple.  check out the modified stamp code.  It is only a guess because I have not used basic stamp before!

0 Kudos
Message 8 of 11
(4,201 Views)

I'm still trying to get it to build becuase not all of the variables are defined.  Still having trouble doing that

 

0 Kudos
Message 9 of 11
(4,189 Views)

I got the code to compile and tried it out in LabVIEW, it is still an echo of the input

0 Kudos
Message 10 of 11
(4,178 Views)