12-07-2017 12:40 PM
Hi, I'm a physics professor, familiar with LabVIEW for experimental control and data acquisition for around 20 years.
We have been using Lego Mindstorms robots for over 10 years to have a fun team project at the end of our Electronics course. Students are supposed to design some sort of new sensor, and then have the robot respond to that sensor in some way. In the past, we were using the NXT bricks, and it was simple to read an analog voltage into the brick, and then proceed with programming in LabVIEW.
This year, we are using the EV3 robots for the first time, and I have gotten completely stuck at reading an analog voltage in using the EV3 bricks and LabVIEW. I know the pinouts of the cables connecting the brick to the sensors. I've tested the system with something simple like a voltage from a potentiometer going into the analog input pin -- this works immediately and easily in the Lego EV3 software. I can read either the raw or the scaled value.
However, I cannot figure out anyway in LabVIEW to do this same task.
I investigated the subVIs for the various forms of the polymorphic ReadSensor.vi, and mostly they seemed to use "Setup Sensor Port" coupled with "Read Generic Sensor". So I've set up a test vi just combining those two subVIs, but I don't get any reading. I thought that my problem must be that somehow I was not setting up the sensor port correctly, but I've tried all the options that I can see, and still I don't see any meaningful values coming out of the Read Generic Sensor vi. The raw value typically reads 0, but sometimes will flicker between 3 and 4, but with no apparent relationship to the voltage that I'm applying to the AI pin, so I think this is just noise of some sort.
Thanks for any suggestions.
12-08-2017 11:16 AM
Hi syl89,
First of all, my familiarity with the Lego platform is fairly low (perhaps some experts could chime in!). But it seems to me that if you are able to see noise, then the code is trying to read on some port. Have you tried connecting to a different AI pin to see if it is reading on a different pin / port?
12-10-2017 08:25 PM
Hi Jordans,
Thanks for your reply. I realized when I read your suggestion, that what I had written in the first place didn't make sense. I had written my post from memory, so I went back and checked my lab notebook.
I was getting occasional values of 3 and 4 for the raw values before I figured out how to actually connect to all of the pins correctly, and I think (bad notebook!) that I was using the EV3 software at that point.
After getting totally stuck and having no luck reading any meaningful signal on any of the pins, I fortunately found an informative YouTube video with a circuit shown to connect an analog voltage into the EV3, and even with a saved program in the EV3 software. This program works perfectly -- the analog voltage (controlled by a potentiometer) reads in (via pin 6) and displays on the front panel of the robot.
Changing absolutely nothing electronically, but just closing the EV3 software and opening LabVIEW instead, gives me no readings at all. Regardless of what settings I choose for the sensor setup, I get values of 0 from the raw and scaled outputs from the Read Generic Sensor vi.
Given that the analog voltage is easily read in using the EV3 software makes me believe that I have the pins correctly connected at this point. I just can't figure out how to make LabVIEW get that information from the sensor.
Thanks.
12-11-2017 09:58 AM
Good Morning syl89,
That makes sense. One thing I noticed in the code was that you are using the Setup Sensor Port VI in the while loop. This might be an issue because it would be trying to configure the port on each loop iteration. You could try setting up the sensor outside the loop and only having your read in the loop.
Have you run into this issues with other types of sensor bricks?
11-13-2018 06:39 PM
I'm having the same problem getting simple analog signals into the EV3 using LabVIEW. Has anyone had any luck with this?
11-13-2018 08:47 PM
I still have not figured it out, but I haven't been working on it since last Christmas.
I'm not glad you're having the problem, but I'm glad I'm not the only one! I wish the NI developers were paying attention to this issue -- it seems so basic. Why give the ability to read a voltage in the EV3 proprietary software which in general is less powerful, and not in LabVIEW, which seems to me where more people might like to use it.
Do you have any new info to add from your testing?