07-24-2017 01:34 PM
Hello,
I have a digital potentiometer that I have got working with some arduino code, and I am now attempting to pass an int value to the arduino code through labview in order to control the resistance with a lab view dial. I am having trouble figuring out a way to do this, as VISA and LINX don't have a way (unless I missed something) to pass an integer. Could I potentially do this by converting a String (which I am able to send to the arduino through labview) into an integer?
Thanks,
J
07-24-2017 02:44 PM
What are the possible values of your integer? It is a U8, U16, or etc?
The simple way would be to use the Format Into String with the formation of "%d\n". The %d formats the number as a decimal number string and the \n is and End Of Line character. Send the result through the VISA Write. Then the Arduino can read the serial port until the \n and decode the read string into the number you want.
07-24-2017 03:16 PM
Well the program I have written so far essentially simulates a 128 turn potentiometer, and I currently have it changing between those values and running through a LED.
Is there an easy way to append those formatting tools onto a String with LabVIEW? I am currently using a Serial Write and Read program to attempt to send it to my arduino code.to be decoded back into an integer.
07-24-2017 08:20 PM
You apparently need to explore the pallets. There is a string pallette full of functions for manipulating strings.
07-25-2017 08:40 AM
09-12-2022 01:31 AM
I had the same question and your solution worked for me.
But I don't understand the mechanism that's happening. How does arduino read the string that is passed from labview and convert it into integer? Doesn't the Serial Port of Arduino read ASCII characters? It's so confusing, kindly clarify this.
Also, when I replace the Format into String function with the Type Cast function, it doesn't work, arduino doesn't take the input. Why is this so?
09-12-2022 01:48 AM
I had the same question and your solution worked for me.
But I don't understand the mechanism that's happening. How does arduino read the string that is passed from labview and convert it into integer? It's so confusing, kindly clarify this.
Also, when I replace the Format into String function with the Type Cast function, it doesn't work, arduino doesn't take the input. Why is this so?
09-12-2022 09:38 AM
@sarwatsarfaraz wrote:
Also, when I replace the Format into String function with the Type Cast function, it doesn't work, arduino doesn't take the input. Why is this so?
Because they do two totally different conversions. The Format Into String creates an ASCII-based text string that is human readable. The Type Cast just takes the raw data and states that its data type is a string, giving a raw/binary/hex value. It sounds like your Arduino is using the text string for its protocol.