ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make the interface between the pic and the labview via usb

how to make the interface between the pic and the labview via usb ?? 

how to send 1 logic in the aprropriate bit via usb to the pic ??

0 Kudos
Message 1 of 5
(6,420 Views)

Hello Karkar,

 

I'm sorry I'm not familiar with "pic", which NI device are you using ?

 

Could you develop the requirements of your project ?

 

Thanks

0 Kudos
Message 2 of 5
(6,407 Views)
0 Kudos
Message 3 of 5
(6,403 Views)

thinx for the replies i'm using a microcontroller 18f4550, and this is my program in mikroc , i want to use the Ni VISA usb driver to developp my application 

my problem how to send to microcontroller 1 logic in the appropriate bit

#include"USBdsc.c"

unsigned char read_buff[64] absolute 0x500;
unsigned char write_buff[64] absolute 0x540;

GET_Digital_Data();
GET_Analog_Data();
LCD_Write();

void interrupt(){
USB_Interrupt_Proc(); // USB servicing is done inside the interrupt
}

void main(){
CMCON = 0x07; // Disable comparators
TRISD=0x00; TRISB=0xFF; PORTD=0x00; TRISE=0x0F;

HID_Enable(&read_buff,&write_buff); // Enable HID communication

while(1){
//Read From USB
HID_Read();
PORTD=read_buff[0];
LCD_Write();
//Write To USB
GET_Digital_Data();
GET_Analog_Data();
HID_Write(&write_buff,17); 
delay_ms(1);
//End Communication
if(!RE3_bit)HID_disable();
}
}

GET_Analog_Data(){ //ADC is 10 bit resloution
write_buff[0] = ADC_Read(0); //Read First 8 Bit(1Byte)
write_buff[1] = ADC_Read(0)>>8; //Read Last 2 Bit(2Byte)

write_buff[2] = ADC_Read(1);
write_buff[3] = ADC_Read(1)>>8;

write_buff[4] = ADC_Read(2);
write_buff[5] = ADC_Read(2)>>8;

write_buff[6] = ADC_Read(3);
write_buff[7] = ADC_Read(3)>>8;

write_buff[8] = ADC_Read(4);
write_buff[9] = ADC_Read(4)>>8;

write_buff[10]= ADC_Read(5);
write_buff[11]= ADC_Read(5)>>8;

write_buff[12]= ADC_Read(6);
write_buff[13]= ADC_Read(6)>>8;

write_buff[14]= ADC_Read(7);
write_buff[15]= ADC_Read(7)>>8;
}

GET_Digital_Data(){ //Binary Represntation of Switches Value
write_buff[16]= PORTB ; //0->255 decimal Value(1 Byte)
}

 
 
0 Kudos
Message 4 of 5
(6,380 Views)