Shop OBEX P1 Docs P2 Docs Learn Events
LabView (2020+NXG) connection over serial port to FlexProp C code — Parallax Forums

LabView (2020+NXG) connection over serial port to FlexProp C code

RaymanRayman Posts: 13,897
edited 2021-06-22 12:03 in Propeller 2

Haven't used LabView in years, but on a whim am testing out connecting LabView NXG (community edition) to P2 over serial port. The code here shows how to make it work. But, LabView's VISA seems to be very possessive of the serial port. So far, it seems like the only way to make this work reliably is to flash the P2 with the code and then fire up LabView NXG. Trying to just load to RAM and then use LabView seems hit or miss for reasons I don't understand yet.

Fortunately, LabView NXG comes with an example, "VISA Serial Simple Query" that is very close to what was needed. One issue was that FlexProp C's serial receive functions echo back the input. So, to handle that, had to add an second serial receive block to get that (and then do nothing with it). This serial send and receive G code was then put in an infinite loop.

Anyway, here's the FlexProp C code and LabView G code that have the two talking.
I'm sure there's people out there better at this than me though!

Update: Got the regular version of Labview (2020) working with same P2 code, now attached as "ContinuousReadP2.zip".

Comments

  • I did this several years ago with the P1 also. Labview is wonderful for testing and some instrumentation but it's real-time modules are terribly expensive. I use Labjack modules for one of my testing systems. With it's analog abilities, the P2, should be a wonderful add-on for the Labview community. Had the P2 been available at the time, I definitely would have designed it in.

  • RaymanRayman Posts: 13,897

    Was looking up real time modules when I noticed a note saying NXG version is being effectively discontinued... Guess I made a mistake when I picked NXG over the regular version...

  • I've been using Labview community edition (free for noncommercial use) to talk to P2 running Taqoz forth, with success at 921600 baud. I put Taqoz into 'don't echo' but still have to receive and discard some replies. It works well, sending commands and receiving replies just as if from the terminal.

  • RaymanRayman Posts: 13,897

    @bob_g4bby Good to hear it works at that fast baud. The example I started from had a max of 230400 baud.

    I'm a bit bummed out about NXG... Looks like the main feature was that you can zoom in on things. Read a lot of complaints from people with high resolution monitors working with the regular Labview.

  • RaymanRayman Posts: 13,897

    It took some fumbling around but there is now a VI for the regular version of LabView (2020) in the top post.
    Started from the "Continuous Serial Write and Read" example and then modified to be like the NXG example.

    Something strange, if seeing it right, is that one must use the serial "bytes at port" function in order to make it work correctly.
    Reading from the port was all kinds of messed up before I added that in, then it worked perfectly.

  • RaymanRayman Posts: 13,897

    As as step toward controlling an 8dof robot with LabView, here's a VI that sends a slider value over serial to control the position of a hobby servo.

    Figured out that in order to get LabView's VISA to release the serial port, need to call Visa->Close function (the red button in this example)

Sign In or Register to comment.