CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Communication PIC -USB-LABVIEW

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ad



Joined: 24 Mar 2015
Posts: 14

View user's profile Send private message

Communication PIC -USB-LABVIEW
PostPosted: Wed Sep 23, 2015 2:03 pm     Reply with quote

Welcome, I have a problem with my project. I have 4 parameters you want to be displayed in the LabVIEW. As I have now only the first is displayed. How should I do it to see all four? This is the code that I have.
Code:

main(){
while(1){
usb_task();
if (usb_habilitado && usb_enumerated() && usb_attached()){
        out_data[0]=TC;  //Temperatura motor
        out_data[1]=p;   //Nivel comb
        out_data[2]=RPM;//RPM
        out_data[3]=VEL;//vel
        usb_put_packet(1,out_data,1,USB_DTS_TOGGLE);
        if (usb_kbhit(1)){
           usb_get_packet(1,in_data,1);
        }
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 23, 2015 6:28 pm     Reply with quote

So Labview, or some aspect of it, is a terminal program, and you're
sending bytes to it via USB CDC. I can surmise that much from your code.

The next thing I look at is this. You've got four bytes that you want to
send via the usb_put_packet() function:
Quote:
out_data[0]=TC; //Temperatura motor
out_data[1]=p; //Nivel comb
out_data[2]=RPM;//RPM
out_data[3]=VEL;//vel
usb_put_packet(1,out_data,1,USB_DTS_TOGGLE);

I look at the definition of usb_put_packet() in the USB-related driver and
example files in the CCS compiler directory. The 3rd parameter is 'len'.
Quote:
int1 usb_put_packet(unsigned int8 endpoint, unsigned int8 * ptr, unsigned int16 len, USB_DTS_BIT tgl)

I can't find any explicit statement by CCS in their files as to what 'len' is.
My guess is that it's a byte count.

I do find this statement,
Quote:

Normally this program sends and receives 2 bytes. These
sizes can be changed with USB_CONFIG_HID_TX_SIZE and
USB_CONFIG_HID_RX_SIZE.

and this code:
Quote:
if (usb_put_packet(USB_HID_ENDPOINT, out_data, USB_CONFIG_HID_TX_SIZE, USB_DTS_TOGGLE))

So it's a byte count. So your problem is that you want to send 4 bytes
but you have 'len' set to 1. Change it to 4 as shown below and see what happens:
Quote:
usb_put_packet(1, out_data, 4, USB_DTS_TOGGLE);
ad



Joined: 24 Mar 2015
Posts: 14

View user's profile Send private message

PostPosted: Fri Sep 25, 2015 5:17 am     Reply with quote

When I send 1 byte in the LABVIEW the parameter is displayed in the LABVIEW, but when I send 4 byte, the parameters are overlap in the LABVIEW. I have a keyboard through which selected parameters .

This is my code:


Code:

//USB
#define USB_HID_DEVICE  TRUE                    //Se activa la comunicacion USB_HID
#define USB_EP1_TX_ENABLE  USB_ENABLE_BULK //Activa EP1 para la entrada de transferencias ***INTERRUPT/BULK
#define USB_EP1_TX_SIZE    8                    //Envio de 8 bytes
#define USB_EP1_RX_ENABLE  USB_ENABLE_BULK //Activa EP1 para la salida de transferencias ***INTERRUPT/BULK
#define USB_EP1_RX_SIZE    8                    //Recepcion de 8 bytes
#define USB_CON_SENSE_PIN PIN_B2
#define LED1 PIN_B3                             //LED VERDE

main(){
while(1){
usb_task();
if (usb_habilitado && usb_enumerated() && usb_attached()){
        out_data[0]=TC;  //Temperatura motor
        out_data[1]=p;   //Nivel comb
        out_data[2]=RPM;//RPM
        out_data[3]=VEL;//vel
        usb_put_packet(1,out_data,1,USB_DTS_TOGGLE);
        if (usb_kbhit(1)){
           usb_get_packet(1,in_data,4);
        }
}
}
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Fri Sep 25, 2015 9:33 am     Reply with quote

Hi,

This now sounds like a Labview issue to me! I don't use Labview, but I do a lot of development with embedded PIC systems that pass data to desktop applications. The remote application must receive the individual data bytes and treat them uniquely in some way. It sounds like your Labview application is *not* doing this correctly!
_________________
John

If it's worth doing, it's worth doing in real hardware!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group