LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to convert C program ?

How can i convert a C code to run in LabView ?
i have the code but i dont want to use it with the compiler...
is there any way to enter this code and run from LV
btw. it use a transmit/recive function by serial port...

thanks for replay
0 Kudos
Message 1 of 11
(4,270 Views)
You can create a dll of your C code, and use the dll in labview
0 Kudos
Message 2 of 11
(4,260 Views)
There is also a Code Interface Node in the advanced pallette that can take your C code directly.  Go to Help>LabVIEW Bookshelf and read the "Using External Code in LabVIEW" pdf for more info.
LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 3 of 11
(4,233 Views)
Thank You All .....but i cant make it work.
all i want is to write a 1 byte to the serial with a few condition so...
start to walk around, ask question.....and yet, yok.
now, trying to load my C code (who work fine) to the LV and ......yok.
the mechine don't move.


0 Kudos
Message 4 of 11
(4,210 Views)
You had started a different thread on how to do this with LabVIEW and now you say here that it doesn't work. When you tried the LabVIEW code, do you get any error messages or error codes being generated? If so, what is the message or code? You should also attach the code you've written (both the LabVIEW and C) to let people try to determine what you've done wrong.
0 Kudos
Message 5 of 11
(4,204 Views)
Hi,
why don't you simply write your byte to the serial port using the Instrument I/O serial VI's. You'll find several examples in LabVIEW (help -> find examples: enter serial as keyword)
This should move your machine very soon...
Ciao,
Olli
0 Kudos
Message 6 of 11
(4,203 Views)
This is the CODE , it work fine in dos 😞
the user enter a numner 1-127 and send it by the serial port to the transmitter...
we search a reciver with the exact code and chang his stat, on\off...
all the data running on the power line...
some kind of a "smart home" device controled by the computer...

#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>

#define com 1  //use com1

void initCom(void)
{
    union REGS inregs, outregs;

    inregs.h.ah = 0;
    inregs.h.al = 0x43;
    inregs.x.dx = - 0;
    int86(0x14, &inregs, &outregs);
    delay(200);
}

void send(char data)
{
    union REGS inregs, outregs;

    inregs.h.ah = 1;
    inregs.h.al = data;
    inregs.x.dx = - 0;
    int86(0x14, &inregs, &outregs);
    delay(200);
}

char receve(void)
{
    union REGS inregs, outregs;
    while (1) {
        inregs.h.ah = 2;
        inregs.x.dx = - 0;
        int86(0x14, &inregs, &outregs);
        if (outregs.h.ah == 0)
            return(outregs.h.al);
    }
}



void main(void)
{              
   
    unsigned char status;
    char address [10];
    int index;

    clrscr();
    initCom(); 
    send('R');  
    send('S');  
    status = receve();
     printf("Status : %X \n", status);
    if (status == 0)
        printf("transmitter ready\n");
    else {
        printf("transmitter NOT ready\n");
        exit(1);
    }

    printf("enter code -->");
    scanf("%s",address);

    send('T');  








    for (index = 0; index < strlen(address); ++index)
        send(address[index]);
    send(';');

    do {
        send('S');  
        send(0xD);
        status = receve();
        /* printf("Status : %X \n", status); */
        if ((status & 0x80) > 0)
            printf("getting data\n");
        if ((status & 0x40) > 0)
            printf("sending data\n");


        if ((status & 0x20) > 0) {
            printf("I Did It\n");
            exit(1);
        }
    } while ((status != 1) && (status != 0));
    if (status == 1) printf("Unit On\n");
    if (status == 0) printf("Unit Off\n");
}

0 Kudos
Message 7 of 11
(4,196 Views)
Your C code may work fine in DOS, but have you ran it successfully in Windows?
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 8 of 11
(4,195 Views)


@AnalogKid2DigitalMan wrote:
Your C code may work fine in DOS, but have you ran it successfully in Windows?

NOP.
that is the reason i'm trying with LV....
didnt find the way to run it with all the sample over here...
0 Kudos
Message 9 of 11
(4,187 Views)
Hi
I suggest to try out a serial communication with your device using the VISA interactive control. Once this works you can continue in LabVIEW. I would NOT convert anything from C, just try out the readymade VI's. It's much easier.
Ciao,
olli

Message Edited by Olli on 12-29-2006 08:39 AM

0 Kudos
Message 10 of 11
(4,184 Views)