LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control PIC18F4550 via USB with LabWindows/CVI

Hello,
 
at first excuse my bad english, it´s not my native language :-).
 
I want to control a PIC18F4550 microcontroller with CVI. I want be able to switch 8 digital outputs an read 8 digital inputs. I own the sourcecode of the microcontroller an know witch messages I have to use to handle my device.
 
First I created a driver *.inf-file via NI Visa. This file works fine and my device is recognized in MAX.
The next step was programming the LabWindows program.
 
With the use of various functions in CVI, I am able to switch all my digital outputs.
 
Here is the code for swiching my outputs (just for example):
   viOpenDefaultRM (&SessionUSB);
    viFindRsrc (SessionUSB, "?*RAW", VI_NULL, VI_NULL, USBdevice);
    viOpen (SessionUSB, &USBdevice[0], VI_NULL, VI_NULL,
      &instr);
      
    viSetBuf (instr, VI_WRITE_BUF, 64);
    GetCtrlVal (panelHandle, PANEL_RD7LED10, &valueRD7);
   
    #define UPDATE_LED    0x32
        sendbuf[0] = UPDATE_LED;      // diese Befehle muss der PIC
         sendbuf[1] = 10;       // erhalten um die gewünschten
         sendbuf[2] = valueRD7;       // Ausgänge zu schalten
   
    viBufWrite (instr, sendbuf, 64, VI_NULL);
   
    viClose (SessionUSB);
 
 
 
 
 But reading the inputs doesn´t work. I get this error message:
sendbuf is a 64 bit array containing the messages the PIC needs to receive.
In receivebuf
 
 
0 Kudos
Message 1 of 2
(2,542 Views)
0 Kudos
Message 2 of 2
(2,535 Views)