Sending a floating point through serial using VISA

how do I send a floating point number through a serial port to my microcontroller using VISA Write

I would recommend the Flatten To String because of being able to change the endiness.  Some systems want Big Endian while others want Little Endian.  It is best to specify.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • Sending float to arduino uno using VISA

    Hi guys,
    Basically i am trying to send a float to arduino uno.
    I use for that a string .I send at first its length  then i send the numbers.
    For the arduino side ,here is the code.I can see that the board Rx/tx leds blinks when i start the Vi.Unfortunately, the led which  doesn"t blink as it should be.
    Here is a quick look at my arduino code.
    void setup() {
    //Initialize serial and wait for port to open:
    Serial.begin(9600);
    pinMode(13,OUTPUT);
    // Serial.flush();
    // prints title with ending line break
    int i=0;
    int j=0;
    int longu=0;
    char data='F';
    String data2="";
    float val=0;
    int posVir=0;
    void loop()
    if (i==0)
    delay(10);
    data=Serial.read();
    longu=(int)data;
    while (j<longu+1)
    {data=Serial.read();
    data2=data2+data;
    delay(10);
    j=j+1;
    val=data2.toFloat();
    i=1;
    delay(50);
    if (val==22.5)
    digitalWrite(13,HIGH);
    delay(1000);
    digitalWrite(13,LOW);
    delay(1000);
    if (val==315)
    digitalWrite(13,HIGH);
    delay(4000);
    digitalWrite(13,LOW);
    delay(4000);
    val=0;
    Attachments:
    Sending data toarduino V2.vi ‏18 KB

    Basically a rehash of http://forums.ni.com/t5/LabVIEW/Synchronisation-with-arduino-and-Labview-using-visa/m-p/3110008

  • Send DAQ measurement results through serial ports

    Hi, All
    I use PCI-6034E for measurement. After DAQ gets data, I send them to another computer through serial port (com1). I write a Virtual C++ program, which calls NI-DAQ library functions to implement DAQ data sampling (multiple channel scan) and sends measurement data to another computer through serial port under request. DAQ data sampling and serial communication are implemented in two threads. They are running concurrently. They share a global memory for measurement data. The serial communication thread will do infinite wait and send data only when another computer sends a request through serial port.
    I met two problems. First, when I reduce the size of DAQ measurement buffers (piBuffer and halfpiBuffer, I us
    edouble buffer model), DAQ measurement is often interrupted by the message "[DAQ_DB_HalfReady] returned NI-DAQ warning 10846. Your application was unable to retrive data from the background acquisition buffer fast enough so the unretrieved data was overwritten with new data. ...". I want to get run time data so I need to reduce the buffers as small as possible. How can I solve it ? The second problem is that the serial port gets error data (nothing) from measurement computer sometimes, especially when DAQ initializes itself and finishes work. It looks like that there is a conflict between DAQ and serial port. Does anyone have similar experience about this? Any suggestion?
    Thank you in advance.
    Le Cai

    Le Cai,
    You are correct that the number of scans to read is equal to half of the buffer in double buffer mode. I was mistaken and referring to a standard (non double buffered) operation. However, you can increase the size of your buffer without affecting the period of your acquisition. A buffer of 60 is quite small and, as such, will be more prone to overflow errors. The rate is actually set through the DAQ_Rate() and DAQ_Start() functions. For more information on these functions and how to configure the scan rate, please see the NI-DAQ Function Reference Manual.
    NI-DAQ Function Reference Manual for PC Compatibles
    http://digital.ni.com/manuals.nsf/websearch/1630A0B68738B269862567C1007A2912?OpenDocument&node=132100_US
    A good place to start would be the example titled, "DAQdoubleBuf.c" which ships with the NI-DAQ driver. If you installed the examples for Visual C++ when you installed the NI-DAQ driver you should be able to find this example in the \Program Files\National Instruments\NI-DAQ\Examples\VisualC\AI folder on your computer. This example would be a good template as it is very close to what you are trying to do.
    If you observe that you only receive the overflow error when you are operating the two threads, thus ruling out the buffer size as being a potential problem, you may want to examine whether or not your second thread is placing a lengthy exclusion on your data buffer during the period when your first thread is trying to move the data. If your first thread has to wait during the half-buffer transfer this could easily cause the overflow, as the acquisition would be running but the transfer would be paused. Instead of placing a mutual exclusion around one piece of global memory you could try using a queue instead. A queue approach will allow you to pass the data from the first thread into a queue to be read, when convenient, by the second thread. In this method the first thread would never have to wait as the transfer would just be a handoff.
    Regards,
    Justin Britten
    Applications Engineer
    National Instruments

  • Sending Mail on iPhone (through iCloud) uses Apple ID?!

    When i try to send mail through iCloud.com, the sending email would be my iCloud email. However, when i send it through my iPhone, my Apple ID (@mac.com) is used. As such, the mail would not be successfully sent out. I cannot change the email used to send through iCloud.
    Thus, i am able to receive Emails into my iCloud Email Inbox but cannot send any mail out through my iPhone.
    I was wondering if anyone has similar issues or solutions to resolve this problem.

    I fooled around with the settings on the iPhone and was able to get it to send emails from @mac.com.  I think what I did was to go into "Settings" --> "Mail, Contacts, Calendars," and delete the iCloud account.  Then go back and re-add it.  When you send an email you should be able to select your mac.com address from the pulldown.
    My Apple ID was a mac.com address, so I don't know if that makes a difference.  I could always select mac.com from webmail but not the phone and that seems to have reset it.  Also, this was a couple of months back so my memory might not be completely accurate.

  • Sending Outlook Meeting Requests through Outlook using JSP?

    Hi all,
    I'm trying to develop a web application that's able to invoke the Create New Meeting Request dialog from the client's Outlook (they are using Outlook 2002/2003), and populate some data from server-side into the Meeting Request, so that users can customize the Request if necessary and send it out.
    Have looked at a few solutions as follows:
    1) HTML's mailto
    This is not good, coz the body can only accept plain text, whereas I need to be able to send HTML text (which Outlook can accept).
    2) Outlook View Control
    This was more hopeful, as I was able to invoke the new Meeting Request dialog. However still no way to send my data to the Meeting Request :-(
    Basically, what I need is to be able to send a customized Meeting Request through some means, like for example getting Outlook to do it like the above, or sending out via some Java APIs (do they exist?)
    Any ideas if the above is possible at all? Or if there are other ways to do this, other than relying on Outlook?
    I'm open to any suggestions, even commercial solutions, since I'm quite urgently in need of options.
    Note that I can't connect direct to Exchange (there are some solutions for doing that), because of some security issues which doesn't allow me to connect to the Exchange Server.
    Thanks in advance for any advice!

    Hi whartung,
    Thanks for the reply! Appreciate it.
    I think what you are suggesting is exactly what Outlook View Control is. Unfortunately, as I've mentioned, it seems that Microsoft did not give it sufficient controls to be able to pre-populate a new Meeting Request. You can only invoke the Outlook UI to create the Meeting Request, but there's no APIs to populate the new Meeting Request.
    Have however found a possible alternative in the meantime:
    Outlook supports iCalendar files which is a standard for calendaring information storage, and it is able to process a Meeting Request from an iCalendar file which contains details of the Meeting Request.
    So what I'm looking to do is this:
    1) Create the iCalendar file in the backend with Java.
    2) Send an email to the user(s) who is intended to receive the Meeting Request, with the iCalendar file attached.
    3) User clicks on the iCalendar file, which prompts them to process the Meeting Request.
    Somewhat indirect, but gets the Meeting Request across, and all the 3 steps are actually possible.
    Furthur to this, it opens up the possibility of sending Outllook Contacts (which supports iCard format) through similar mechanisms as well!

  • I can't send anything over 1024 bytes by using visa via TCPIP

    I am trying to use NI-VISA talk to instruments visa TCPIP. The problem is I can not send anything over 1024 bytes using viPrintf or viBufWrite call. A time out will be returned. I tried to use MAX to open a VISA session for my TCPIP device. If I put a string less than 1024 bytes in write buffer, it is fine. Anything longer than that will cause time out and some time the whole MAX crash.

    Hi Johnma,
    I suggest you check the specs on TCP/IP. I seem to remember a limit on the packet size. TCP is just the transport layer. Higher layers should handle the work of breaking packets into smaller sizes and tracking packet sequencing.
    I am relying on memory hear so please verify. (maybe the limit was 4096 and I am full of it).
    I also believe there was some discusion of a related topic recently on info-labview where Rolf did a good job explaining what was happening.
    Search for "Rolf" and "TCP" on Brian Renkins search engine.
    http://infolv.brianrenken.com/
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Want to use dotNet with teststand, but unsure how to send commands through serial port

    I have a loCom communication dll used to send and recieve commands through serial comunication for a particular product.  I the past they have used a LabVIEW wrapper to send and recieve commands, using this particular dll.  I would like to just use testStand for the DOTNET Dll.  I can get the commands, know the inputs and outputs required, however I can not figure out how to send the commands to the serial port.  Anyone have any exprience doing this in TesSTand?

    hallawt,
    With your .NET code module, you should be able to call it directly, most likely as a parameter in the .NET method.
    What are the inputs for the method you're trying to use?
    Also, could you clarify where you're starting to have problems in your project?
    Regards,
    Renée M
    Applications Engineer
    National Instruments

  • How can floating point division be faster than integer division?

    Hello,
    I don't know if this is a Java quirk, or if I am doing something wrong. Check out this code:
    public class TestApp
         public static void main(String args[])
              long lngOldTime;
              long lngNewTime;
              long lngTimeDiff;
              int Tmp;
              lngOldTime = System.currentTimeMillis();
              for( int A=1 ; A<=20000 ; A++)
                   for( int B=1 ; B<=20000 ; B++)
                        Tmp = A / B;
              lngNewTime = System.currentTimeMillis();
              lngTimeDiff = lngNewTime - lngOldTime;
              System.out.println(lngTimeDiff);
    }It reports that the division operations took 18,116 milliseconds.
    Now check out this code (integers replaced with doubles):
    public class TestApp
         public static void main(String args[])
              long lngOldTime;
              long lngNewTime;
              long lngTimeDiff;
              double Tmp;
              lngOldTime = System.currentTimeMillis();
              for( double A=1 ; A<=20000 ; A++)
                   for( double B=1 ; B<=20000 ; B++)
                        Tmp = A / B;
              lngNewTime = System.currentTimeMillis();
              lngTimeDiff = lngNewTime - lngOldTime;
              System.out.println(lngTimeDiff);
    }It runs in 11,276 milliseconds.
    How is it that the second code snippet could be so much faster than the first? I am using jdk1.4.2_04
    Thanks in advance!

    I'm afraid you missed several key points. I only used
    Longs for measuring the time (System.currentTimeMillis
    returns a long). Sorry you are correct I did miss that.
    However, even if I had, double is
    also a 64-bit data type - so technically that would
    have been a more fair test. The fact that 64-bit
    floating point divisions are faster than 32-bit
    integer divisions is what confuses me.
    Oh, just in case you're interested, using float's in
    that same snippet takes only 7,471 milliseconds to
    execute!Then the other explaination is that the Hotspot compiler is optimizing the floating point code to use the cpu floating point instructions but it is not optimizing the integer divide in the same way.

  • BigDecimal vs floating points...

    Hi all,
    I know its probably been asked amillion times before but I need to finally fully understand and get my head around the two.
    Firstly here are some bits I've been told by different people and read in different places (alot of people seem to think differently which is what confuses me):
    - I've read that if you are wanting precision for currency for example that floating point shouldnt be used because of its accuracy down to the fact it cant represent every decimal number.
    - The some people have told me that it doesnt matter and theres not much point ,ost the time in BigDecimal all you need to do is correct the floating point with formatting.
    - I've asked about this before but people just seem to give me a short answer to it but without actually explaining why or where they get it from, you cant just assume an answer based on nothing...
    I'm building some engineering software that has a general accuracy of 3 decmial places (millimeters from meters) and my first thought is that if currency at 2 decimal places requires BigDecimal then I surely require it (I cant afford to be missing off mm for every calculation, theres alot!) but the problem is this has resulted in me building pretty much the whole application with BigDecimal which you can probably imagine brings up thoughts about performance and memory uptake, I do calculations with BigDecimal, store data in BigDecimal and infact the only thing I do in double is the graphical display as the accuracy isnt so important.
    My last question is if this is an ok way to build an accurate application it makes me start to wonder why is floating points used more than BigDecimals, surely most numbers are required to be accurate in applications especially of an enterprise scale?
    Thanks,
    Ken

    MarksmanKen wrote:
    So your a big user of BigDecimal as well then? Thats good to know someone else thinks in similar ways, I was starting to feel like abit of an idiot for using them so extensively lolNot at all. The idiots are the people who use primitives rather than BigDecimal "because they're faster" even though they've never actually experienced any performance problems. Of course, there are lots of cases where the speed of a primitive is preferable, but on the whole those guys know perfectly well who they are and what they're doing.
    My program is very calculation heavy and I've not had any real performance issues yet but I was wondering if the performance gain would be significant enough while keeping the accuracy.Testing will show you the way. Don't let any "we tested this calculation a million times using primitives and the same one using BigDecimal, and it showed a remarkable 3 seconds quicker using primitives" sidetrack you, either. All that matters is that your actual production code is performant enough for your application. Generally speaking, anything involving currency will probably be better using BigDecimal, or, really, a Money class which happens to use BigDecimal under the covers. Quite why enterprise-targeted languages don't have some sort of native Money or Currency class out-of-the-box remains a mystery, to be honest.

  • Floating-point addition unit

    Hello All,
    I am very new to NI and I am looking for an example of floating-point addition unit. Basically, I am looking for some example to perform addition of two floating point number (single or double precision). -- just how to create floating-point addition unit using logical gates model (i.e. AND, OR, XOR, etc)
    Thank you!
    Leo
    Message Edited by smuStudent on 12-05-2005 11:51 PM

    Most (if not all) of us, when we want to do floating point math just put the Add function onto the block diagram. I would suggest you google for floating point gates or something similar. You can create subVIs that make up the basic functions such as a full adder and then link them together as needed.
    Attachments:
    Full Adder.JPG ‏9 KB

  • Serial Communicat​ion(CAN) of Floating Point Numbers

    Hi,
    I have ran into a situation were I need to use floating point numbers(IEEE Floating Standard) when communicating.   How can I send and recieve floating point numbers?  What converstions need to be made?  Is there a good resource on this?
    Thanks,
    Ken

    Hi K.,
    in automotive a lot of fractional values are exchanged via CAN communication, but still the CAN protocol is based on using integer numbers (of variable bit size)…
    We are thinking we need to use single SGL floats ... that require a higher resoultion and precision
    What is the needed resolution and "precision"? SGL transports 23 bits of mantissa: you can easily pack them into an I32 value!
    Lets make an example:
    I have a signal with a value range of 100…1000 and a resolution of 0.125. To send this over CAN I need to use 13 bits and scale the value with a gain of 0.125 and an offset of 100. Values will be send in an integer representation:
    msgdata value
    0 100
    500 162.5
    501 162.625
    1000 225
    5000 725
    7200 1000
     The formula to translate msgdata to value is easy: value := msgdata*gain+offset.
    Another example: the car I test at the moment sends it's current speed as 16 bit integer value with a range of 0…65532. The gain is 0.01 so speed translates to 0.00…655.32 km/h. The values 65533-65535 have special meanings to indicate errors…
    So again: What is your needed resolution and data range?
    Another option: send the SGL as it is: just 4 bytes. Receive those 4 bytes on your PC as I32/U32 and typecast them to SGL…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How to send images through PI using SOAP adapter

    hi,
    Can anybody tell me how to send images through PI using SOAP adapter.
    Regards ,
    Loveena

    Hi Loveena,
    only as attachments of a SOAP message.
    Regards,
    Udo

  • Is it possible to interface digital i/o modules using VISA serial?

    Hi,
          Iam using analog and digital modules from trycom for my project.I interface analog modules by modifying the sample code basic serial read and write given in LabVIEW examples.But i found difficulties in interfacing with the digital i/o modules.Is there any sample code forDigital I/O?Is it possible to interface the digital I/O using VISA serial?
    Please Mark the solution as accepted if your problem is solved and donate kudoes

    Also i found from the net that digital i/o modules can be communicate with Hyperterminal..Is it possible?
    Please Mark the solution as accepted if your problem is solved and donate kudoes

  • Can I create a java app for my palm zire 71 that uses floating point calc

    I am an eclipse user that is looking at studio creator 2 and was wondering if I could create a java app for my palm zire 71. I have read alot about no floating point support in midp... is that true for java on the palm? If so, how does one calculate with floats and doubles to do sqrt functions etc?
    Thanks in advance for your time
    Dean-O

    I looked at netbeans and it does not support floating points in midlets. Not good for palm app if no floating point ability. J2ME supports floating point but in netbeans... is uses midlets and there are no floating points. Now what does one do? Not that dreaded C++
    THanks in advance
    Dean-O

  • Has anybody used the Camera RAW filter on an OpenEXR, HDR or similar floating point color image?

    I often work on floating point images rendered out of 3ds Max, specifically OpenEXRs, and I have been lately using the Camera RAW filter to do some image adjustments. There is one problem though, the float image does not load correctly into Camera RAW. It looks slightly over-exposed when loaded and it is nearly impossible to get it back to "scratch". Is Camera RAW not fully float capable? Camera RAW is a drunkard compositor's dream when doing color corrections on a floating point image, especially an image rendered out of a 3D application such as 3ds Max or Maya. Any thoughts?
    Mark Kauffman
    Technical Lead of Project Visualization
    Parsons Brinckerhoff

    For what it's worth I have seen this going back a loooong time.  I've posted on the subject as well and have never gotten a solid answer.  It just appears as though Photoshop considers it "already open, so no need to open it twice".  I believe an uninitialized variable could be involved, since it's intermittent.
    I have found a couple of choices for workarounds or workflow changes...
    1.  You can save the first-opened document opened (e.g., as  a .PSD) somewhere.  Then reopening the raw file will always open a second document.
    2.  You could consider opening the raw file just once, duplicating it as a second layer, then use Camera Raw as a filter.  Obviously that doesn't avail Camera Raw of the raw data, but its usefulness depends on what you're trying to accomplish.
    -Noel

Maybe you are looking for