06-29-2012 09:52 AM
I have used the Arduino Environment to set Analog pins HIGH and LOW by setting pins 14-19 (A0-A5) as outputs (pinmode). However, I have tried to use SetDigitalPinMode and I can't get the analog pin to respond. I am using an Arduino Nano v3.0 and Labview 2010. I have read that people have successfully done this with the Mega. Is it possible to do?
Solved! Go to Solution.
07-03-2012 02:09 PM
I'm in a similar situation. I saw on the arduino website that it should be possible: http://arduino.cc/en/Tutorial/AnalogInputPins, but I too can't get the analog pin to respond when I try to do this through LabView. Any suggestions?
07-03-2012 02:23 PM
Hello swplainview,
It is possible to use the Analog Pins 0-5 as Digital Outputs. Anyone questioning the possibility can refer to the Arduino Reference page or input the following code onto their Nano and observe that it works.
int ledPin = 14; // LED connected to Analog Pin 0 (A0)
void setup()
{
pinMode(ledPin, OUTPUT); // sets the Analog Pin as Output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
However, in order to do this using LIFA, if I am not mistaken, you would need to use the VI SetDigitalPinMode and the pins number would either be 14 (continuing from where the actual digital pins leave off at - 13) or some other number. I have tried a very large variety and had zero success. Below is a screen shot of something I have tried.
I have tried other methods, but still I am not able to set the analog pins high (5V) which I have used a multimeter to test.
Please, any suggestions would be greatly appreciated.
Nat
07-04-2012 01:06 AM
Do you get any errors in LabVIEW? Note that you can't read a pin that has been set as output.
If that Arduino code actually does work then I would suggest creating custom LabVIEW functions in the firmware and in LabVIEW to issue these commands individually.
Also, I notice on the Arduino website that is says the nano has 14 digital pins but there are only 13 broken out on the board. Are you sure the value of A0 is 14? I wasn't able to find it's value.
07-09-2012 07:56 AM
I do not receive any errors in LabVIEW.
Also, the reading of the digital pins when set to output works and will return either a 1 or 0 depending on the state of the pin (I have verified this by toggling the pin, measuring the voltage on the specific pin, and comparing it to the indicator in LabVIEW). I am assuming that if it works for the actual digital pins then it should work for the analog pins when configured as digital outputs.
The arduino code does work and the Arduino reference page notes that the analog pins 0-5 can be used as digital outputs (A6 and A7 are input only).
The Nano does have 14 digital pins. However, pins D0 and D1 are used for Rx and Tx.
As far as what the actual digital pin value would be for the analog pins I am not sure as it is not mentioned anywhere online. However, when reading some of the forums on here I have seen that on the Mega they just use the actual pin number as denoted on the spec sheet. I have tried several different combinations - refering to A0 as 14 (D13 is the last actual digital pin and in LIFA is 13) and also as the actual pin number - 19. I have also tried many values above and below the discussed range with no success.
It can be done on the Mega so I would assume that there is something simple that I am missing.
07-09-2012 06:19 PM
I totally forgot that the pins numbers are zero based. That's why I questioned the 14 but that's all cleared up now.
07-14-2012 01:20 PM
Modify the following VI to enable the use of A0-A5 as general purpose I/O pins:
C:\Program Files (x86)\National Instruments\LabVIEW 2011\vi.lib\LabVIEW Interface for Arduino\Utility\Check For Pin Out Of Range.vi
In the "Uno, default" -> "Digital" case, change the "Num Pins" constant to a value of 20. Save the file.
This hack seems to be working fine, however I cannot guarantee new bugs will not be introduced.
Carey