LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Teensy 3.x with LabView & LIFA

(see http://pjrc.com/teensy/languages.html and http://pjrc.com/teensy/teensyduino.html for the software in addition to LV & LIFA)

Got the firmware to compile using Teensyduino v118 (rc4) and a modded AFMotor.h, but it doesn't appear to be working properly with the blink.vi.  The COM port won't initialize.  I can get the Teensy 2.0 to work. 

I'm looking for ideas. Hopefully some of the work can apply to LYNX later, but last I looked Teensy 2.0 wasn't supported on it yet, making LIFA seem like an easier starting point.

For the "Teensy 2.0" AFMotor.h, changes were mostly inspired by (aka copied from) Adafruit's mods to add Pic32 support, adding a test for which cpu was being compiled for and adding PWM lines to disable the function (like the 2.0).  Sorry about the formatting.  The forum doesn't seem setup for text languages.

****************** AFMotor.h as modded for Teensies

// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

// removed badly formatted text and attached a file instead - Mark

0 Kudos
Message 1 of 13
(11,319 Views)

Poked around, making sure there were no conflicts to COM ports.  Removed the Teensy driver and all of the 'stray' definitions in the Device Manager.  Reinstalled the Teensy driver.  Still fails to init the COM port.  Port settings (baud,etc) look ok. 

Is there an 'echo' I can send the LIFA firmware to see if the basic communication is working?  I'm looking for something really low level - "echo" from the command line or equivalent.  The Teensy 3.1 isn't bricked.  I can still write the blink firmware to it successfully.

Thanks, Mark

PS - I', playing with putty to attempt connecting to it.  If I understand 'echo.ino's function, if I open the port and type something, the Teensy should send it right back and putty will display it.  Oh, my!  Playing with serial ports after so many years away from dial-up modems...

0 Kudos
Message 2 of 13
(7,240 Views)

Default firmware rate is 115200.  Changed PC port and VISA to match and was able to connect to the port (Visa and Putty), but couldn't get the initial  Visa Clear in LIFA to work.

0 Kudos
Message 3 of 13
(7,240 Views)

It looks like you are getting the same error others were getting with Teensy 3.0 last December.  See the following thread.

Re: Error -1073807360 occurred at VISA Clear in LabVIEW Interface for Arduino

We never got Teensy 3.0 to work with LIFA.

However, you can use Teensy 3.1 with Labview. Attached  are a VI and zip file I used for testing.  Upload the sketch to Teensy 3.1 and use the VI to send a string to Teensy 3.1.  You should see the string being echoed back to the VI.   You can also run the AnalogReadSerial sketck that comes with Arduino and use the VI to red the analog data. 

hrh1818

Download All
0 Kudos
Message 4 of 13
(7,240 Views)

Saw those.  They works fine.  I'm not really looking to bit bang I2C thru USB using that interface.  That is, unless I misunderstand the functionality of the LIFA I2C palette. 

I've got the luxury of time to mess with it, learn something, and maybe make it work.  I've been using a USB8451 at a 'low level', but it's not something practicle outside a bench environment.  I'd prefer Teensy due to the form factor, etc, but I've got a couple Uno's laying around too.

This output from the compiler looks 'smokey'. Ring any fire bells? 

************************

C:\Users\Mark\AppData\Local\Temp\build1956113486934712470.tmp\LIFA_Base.cpp -o C:\Users\Mark\AppData\Local\Temp\build1956113486934712470.tmp\LIFA_Base.cpp.o LabVIEWInterface.ino: In function 'unsigned char checksum_Compute(unsigned char*)':
LabVIEWInterface.ino:720:27: warning: 'checksum' may be used uninitialized in this function [-Wmaybe-uninitialized]

Off to beat about and break things,

Mark

0 Kudos
Message 5 of 13
(7,240 Views)

Code snippet from LIFA_Base.cpp.  Enclosed.

**************

// Compute Packet Checksum
unsigned char checksum_Compute(unsigned char command[])
{
  unsigned char checksum;
  for (int i=0; i<(COMMANDLENGTH-1); i++)
  {
    checksum += command;
  }
  return checksum;
}

// Compute Packet Checksum And Test Against Included Checksum
int checksum_Test(unsigned char command[])
{
  unsigned char checksum = checksum_Compute(command);
  if(checksum == command[COMMANDLENGTH-1])
  {
    return 0;
  }
  else
  {
    return 1;
  }
}

Download All
0 Kudos
Message 6 of 13
(7,240 Views)

Hmmm...  Think I found something (plz excuse the one handed typing...).

Running the echo_string sketch above, I dug into the LabVIEW code a bit.  A VISA Clear contains a Serial Break.  Inside this is a VISA serial write of a 'empty string constant'.  The 'echo string' program duplicates the -1073807360 error behavior *IF* an 'empty string constant' is written into the VISA Serial Write vi.  When a 'string constant' with no content an nothing is returned (as expected) and no errors.  Probing the input wire shows the same data in both cases.  Of couse the question arises...

What's the diff between an 'empty string constant' and an empty string?  Once I know this, maybe the fix will be obvious.  I'm off to see if it's in the docs, but if someone knows, don't be shy.

<edit> A: Nothing.  Unless someone knows better.  I noticed inconsistent behavior of the echo.vi, so I'm going to see what that is...

Message was edited by: Mark.Randol - A to Q

Now I can repeatably duplicate that it's something breaks with the break terminated VISA Serial Write, not the string sent.  I'll beat on it some more...

0 Kudos
Message 7 of 13
(7,240 Views)

Hello Mark,

You may be intersted in the folowing excample. It shows LIFA is not required to use Labview with Teensy 3.1.

hrh1818

Attached are a script and VI for demonstrating the use of Labview with Teensy 3.1.  This demo does not use LIFA.   An example for reading data from analog input pin A0 and blinking a LED on digital pin 13 are in the demo.

Use a potentiometer to produce a test signal for this example.  Note the Teensy 3.1 ADC full scale range is 3.3 volts.  Whereas the full scale range for an Arduino Uno ADC is 5 volts.   Hence connect one side of the potentiometer to 3.3 volts, the other side to ground and the wiper to pin A0.  The LED on pin 13 is built into Teensy 3.1.

To use the demo unpack analogReadTest, compile the script and download the code to your Teensy 3.1.  Version 1.0.5 of the Arduino IDE with Teensyduino modifications is compatible with Teensy 3.1.  Note the serial port the Arduino IDE uses for downloading.

Test the sketch by using Arduino's Serial Monitor to send either an "a" or "b" to Teensy 3.1.  Do not include quotation marks with the character being sent. One analog reading will be returned to the serial monitor for each "a" sent to Teensy 3.1.  The on-off state of the LED will change each time "b" is sent to  Teensy 3.1.

For analog readings

  Open the VI

  Set Visa resource name to the COM port you used when uploading the sketch.

  Set Delay before read to 25 ms.

  Accept the default values for the other controls.

  Enter "a" in the string to write text box.

  Press the Labview Run button.

  You should see analog data in the read string box being updated once a second.

To blink the LED

Open the VI

  Set Visa resource name to the COM port you used when uploading the sketch.

  Set the read switch for the read string text bx to off.

  Accept the default values for the other controls.

  Enter "b" in the string to write text box.

  Press the Labview Run button.  You should see a LED blinking at a rate of 1 second on and 1 second off.

Download All
0 Kudos
Message 8 of 13
(7,240 Views)

Fair enough, but I'm interested in getting Teensy 3.x to work with LIFA (#4 + other stuff I won't bore everyone with).  After this works <fingers crossed>, then maybe on to trying with LINX. 

I've chased down the failure point in LabVIEW (#6), and now we're working on it over at the Teensy site (pjrc.com).  Paul's interested in giving it a look and a couple of us are supporting from the LabVIEW end.  I don't know the Teensy well, so I'm grateful Paul is willing to look.

BTW, not affiliated with NI, PJRC, etc except for using their 'stuff'.

0 Kudos
Message 9 of 13
(7,240 Views)

It's ALIVE!!!  Well, ok, it doesn't die on the VISA clear anymore.  For the teensyduino patch, go here. 

 

http://forum.pjrc.com/threads/25350-Teensy-3-1-Serial-Break

 

I think I've already posted the AFMotor changes I made to get the FW to compile.

 

LIFA is still bowing out with a 5003/5002 error.  I'm off to confirm where the issue is.

 

Message was edited by: Mark.Randol

Message 10 of 13
(7,240 Views)