VCP example from ME(LibStock)
VCP example from ME(LibStock)
In the example of VCP from ME(Libstock),colud anyone please help, how is the data stored and how do I retrieve the data and display it through LCD/GLCD.
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: VCP example from ME(LibStock)
Hi,
Please, can you explain me a little bit more your question?
You want to use Virtual COM Port example from USB Device Library from LibStock:
http://www.libstock.com/projects/view/5 ... ce-library
The examples are written for PIC18F4550 and PIC18F87J50, but you can adjust them for the microcontroller that you use with the help of the appropriate datasheet.
Best regards,
Marina
Please, can you explain me a little bit more your question?
You want to use Virtual COM Port example from USB Device Library from LibStock:
http://www.libstock.com/projects/view/5 ... ce-library
The examples are written for PIC18F4550 and PIC18F87J50, but you can adjust them for the microcontroller that you use with the help of the appropriate datasheet.
Best regards,
Marina
Re: VCP example from ME(LibStock)
Thank you,marina.petrovic
I want to display in GLCD the value, what i was send in USART.
I want to display in GLCD the value, what i was send in USART.
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: VCP example from ME(LibStock)
Hi,
You can adjust the example from LibStock with help of the simple GLCD example from compiler.
You can see in the Virtual COM Port example we used variable buffer for receive buffer where received data is stored.
Also, if you use some other microcontroller or hardware you need to adjust the example to work with your hardware with the help of appropriate datasheet.
Best regards,
Marina
You can adjust the example from LibStock with help of the simple GLCD example from compiler.
You can see in the Virtual COM Port example we used variable buffer for receive buffer where received data is stored.
Also, if you use some other microcontroller or hardware you need to adjust the example to work with your hardware with the help of appropriate datasheet.
Best regards,
Marina
Re: VCP example from ME(LibStock)
Thank you,
I have try this program,
the value that i send in USART,is not display in glcd. But he different value have be display.
I have try this program,
Code: Select all
#include <stdint.h>
int i,x;
// Buffer of 64 bytes
char buffer[64] absolute 0x500;
char read[9];
// Glcd module connections
char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at LATB0_bit;
sbit GLCD_CS2 at LATB1_bit;
sbit GLCD_RS at LATB2_bit;
sbit GLCD_RW at LATB3_bit;
sbit GLCD_EN at LATB4_bit;
sbit GLCD_RST at LATB5_bit;
sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction at TRISB2_bit;
sbit GLCD_RW_Direction at TRISB3_bit;
sbit GLCD_EN_Direction at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections
// USB interrupt service routine
void interrupt(){
// Call library interrupt handler routine
USBDev_IntHandler();
}
void USBDev_CDCParamsChanged(){
}
extern const uint8_t _USB_CDC_BULK_EP_IN; // Data interface IN endpoint
extern const uint8_t _USB_CDC_BULK_EP_OUT; // Data interface OUT endpoint
uint8_t dataReceived = 0;
uint16_t dataReceivedSize;
void USBDev_CDCDataReceived(uint16_t size){
dataReceived = 1;
dataReceivedSize = size;
}
void display(){
Glcd_Fill(0x00); // Clear Glcd
Glcd_Set_Font(Character8x7, 8, 7, 32); // Change font
x=buffer[(10)];
IntToStr(x,read);
Glcd_Write_Text(read, 5, 0, 2); // Write string
Delay_ms(2000);
}
void main(void){
Glcd_Init();
ADCON1 |= 0x0F; // Configure all ports with analog function as digital
CMCON |= 7; // Disable comparators
// Initialize CDC Class
USBDev_CDCInit();
// Initialize USB device module
USBDev_Init();
// Enable USB device interrupt
IPEN_bit = 1;
USBIP_bit = 1;
USBIE_bit = 1;
GIEH_bit = 1;
// Wait until device is configured (enumeration is successfully finished)
while(USBDev_GetDeviceState() != _USB_DEV_STATE_CONFIGURED)
;
// Set receive buffer where received data is stored
USBDev_CDCSetReceiveBuffer(buffer);
// Infinite loop
while(1){
if(dataReceived == 1){
dataReceived = 0;
// Send back received packet
USBDev_CDCSendData(buffer, dataReceivedSize);
// Prepare receive buffer
USBDev_CDCSetReceiveBuffer(buffer);
} display();
}
}
the value that i send in USART,is not display in glcd. But he different value have be display.
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: VCP example from ME(LibStock)
Hi,
Please, can you tell me which value you have displayed on the GLCD and which are you expecting?
Also, please, take a look at compiler Help file:
mikroC PRO for PIC Libraries -> Hardware Libraries -> Graphic Lcd Library
Glcd_Write_Text() routine prints text on GLCD - "text" parameter (text to be written) is char * :
Prototype: void Glcd_Write_Text(char *text, unsigned short x_pos, unsigned short page_num, unsigned short color);
Best regards,
Marina
Please, can you tell me which value you have displayed on the GLCD and which are you expecting?
Also, please, take a look at compiler Help file:
mikroC PRO for PIC Libraries -> Hardware Libraries -> Graphic Lcd Library
Glcd_Write_Text() routine prints text on GLCD - "text" parameter (text to be written) is char * :
Prototype: void Glcd_Write_Text(char *text, unsigned short x_pos, unsigned short page_num, unsigned short color);
Best regards,
Marina
Re: VCP example from ME(LibStock)
Thanks marina,
This is the print screen from USART tool.
The value display in GLCD is 59. How I want to display the same value at USART terminal at GLCD.
please help
This is the print screen from USART tool.
The value display in GLCD is 59. How I want to display the same value at USART terminal at GLCD.
please help
- Attachments
-
- usart.png (73.19 KiB) Viewed 9045 times
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: VCP example from ME(LibStock)
Hi,
Hexadecimal 0x31 is ASCII "1" that you actually sent (set data format in USART Terminal) - decimal value 49.
You can use Glcd_Write_Char() or Glcd_Write_Text() routine, depends do you want to display char or text on the screen.
You can take a look at simple GLCD example from compiler:
...\mikroC PRO for PIC\Examples\Development Systems\EASYPIC7\Glcd
You can send ASCII value of the decimal value 59 -> ASCII (59) = ";".
Of course, you can use routines from Conversions Library:
mikroC PRO for PIC Libraries -> Miscellaneous Libraries -> Conversions Library
Best regards,
Marina
Hexadecimal 0x31 is ASCII "1" that you actually sent (set data format in USART Terminal) - decimal value 49.
You can use Glcd_Write_Char() or Glcd_Write_Text() routine, depends do you want to display char or text on the screen.
You can take a look at simple GLCD example from compiler:
...\mikroC PRO for PIC\Examples\Development Systems\EASYPIC7\Glcd
You can send ASCII value of the decimal value 59 -> ASCII (59) = ";".
Of course, you can use routines from Conversions Library:
mikroC PRO for PIC Libraries -> Miscellaneous Libraries -> Conversions Library
Best regards,
Marina
Re: VCP example from ME(LibStock)
Tq,marina.
I managed to read the data but now i have new problem,How can I send my data to the buffer and to the other microcontroller.below is the codes that i modify but i did not manage to send data from adc reading.
I managed to read the data but now i have new problem,How can I send my data to the buffer and to the other microcontroller.below is the codes that i modify but i did not manage to send data from adc reading.
Code: Select all
/*
* Project name:
Virtual COM Port Demo
* Description
Example showing usage USB CDC device that functions as a generic virtual
COM port. The example echoes data sent via USART terminal.
* Test configuration:
MCU: P18F4550
dev.board: EasyPIC v7 Connectivity
http://www.mikroe.com/easypic/
Oscillator: HS-PLL, 48.000MHz
Ext. Modules: None.
SW: mikroC PRO for PIC
http://www.mikroe.com/mikroc/pic/
Notes: Example uses CDC Driver included in Windows. An .inf file
is supplied with the example in order to match the driver
with this device (user must guide driver installation
wizard to the VCPDriver folder).
*/
#include <stdint.h>
int in=0,out=0,count,state=0,i,x;
// Buffer of 64 bytes
char buffer[4] absolute 0x500;
char read[9];
// Glcd module connections
char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at LATB0_bit;
sbit GLCD_CS2 at LATB1_bit;
sbit GLCD_RS at LATB2_bit;
sbit GLCD_RW at LATB3_bit;
sbit GLCD_EN at LATB4_bit;
sbit GLCD_RST at LATB5_bit;
sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction at TRISB2_bit;
sbit GLCD_RW_Direction at TRISB3_bit;
sbit GLCD_EN_Direction at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections
// USB interrupt service routine
void interrupt(){
// Call library interrupt handler routine
USBDev_IntHandler();
}
void USBDev_CDCParamsChanged(){
}
extern const uint8_t _USB_CDC_BULK_EP_IN; // Data interface IN endpoint
extern const uint8_t _USB_CDC_BULK_EP_OUT; // Data interface OUT endpoint
uint8_t dataReceived = 0;
uint16_t dataReceivedSize;
void USBDev_CDCDataReceived(uint16_t size){
dataReceived = 1;
dataReceivedSize = size;
}
void display(){
if (state==1){
Glcd_Fill(0x00); // Clear Glcd
Glcd_Set_Font(Character8x7, 8, 7, 32); // Change font
x=buffer[0];
IntToStr(x,read);
Glcd_Write_text(read, 5, 0, 2);
x=buffer[1];
IntToStr(x,read);
Glcd_Write_text(read, 67, 0, 2);
x=buffer[2];
IntToStr(x,read);
Glcd_Write_text(read, 5, 1, 2); // Write string
IntToStr(in,read);
Glcd_Write_text(read, 5, 2, 2);
IntToStr(out,read);
Glcd_Write_text(read, 5, 3, 2);
state=0;}
}
void main(void){
Glcd_Init();
ADCON1 |= 0x0D; // Configure all ports with analog function as digital
CMCON |= 7; // Disable comparators
PORTA=0;
TRISA=0x03;
// Initialize CDC Class
USBDev_CDCInit();
// Initialize USB device module
USBDev_Init();
// Enable USB device interrupt
IPEN_bit = 1;
USBIP_bit = 1;
USBIE_bit = 1;
GIEH_bit = 1;
// Wait until device is configured (enumeration is successfully finished)
while(USBDev_GetDeviceState() != _USB_DEV_STATE_CONFIGURED)
;
// Set receive buffer where received data is stored
USBDev_CDCSetReceiveBuffer(buffer);
// Infinite loop
while(1){
count=count+1;
if(count==1){state=1;}
if (count >=10000){count=0;}
in=ADC_READ(0);
out=ADC_Read(1);
if(dataReceived == 1){
dataReceived = 0;
buffer[(0)]=(char)in;
buffer[(1)]=(char)out;
USBDev_CDCSendData(buffer, 4);
// Prepare receive buffer
USBDev_CDCSetReceiveBuffer(buffer);
} display();
}
}
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: VCP example from ME(LibStock)
Hi,
Please, can you explain me a little bit more what you need to do?
You said that you need to send data to the other microcontroller (what you want to use)?
Best regards,
Marina
Please, can you explain me a little bit more what you need to do?
You said that you need to send data to the other microcontroller (what you want to use)?
Best regards,
Marina
Re: VCP example from ME(LibStock)
Thanks marina,
i need to send data read from ADC channel(pic18F4550) to matlab/simulink using USB (vcp).
i need to know what code to write to buffer and send it through VCP.
please help
i need to send data read from ADC channel(pic18F4550) to matlab/simulink using USB (vcp).
i need to know what code to write to buffer and send it through VCP.
please help
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: VCP example from ME(LibStock)
Hi,
Unfortunately, I am not able to help you with the MATLAB/Simulink project,
you need to write your own example/project.
Also, you can search our forum and LibStock Website to see whether some of our users posted their projects that can help you.
Best regards,
Marina
Unfortunately, I am not able to help you with the MATLAB/Simulink project,
you need to write your own example/project.
Also, you can search our forum and LibStock Website to see whether some of our users posted their projects that can help you.
Best regards,
Marina
Re: VCP example from ME(LibStock)
Hi,
I am using windows10 and vcp example doesn't work here. (it was working in win7) i guess there are some problem.
I am using windows10 and vcp example doesn't work here. (it was working in win7) i guess there are some problem.
- viktor.milovanovic
- Posts: 240
- Joined: 08 Jun 2015 10:09
Re: VCP example from ME(LibStock)
Hello,
Which MCU are you using?
Please note that win10 has been out for a short period of time, so we could not manage to test everything.
We are doing our best to run tests and see how our products will react to win10.
Best regards,
Viktor Milovanovic
Which MCU are you using?
Please note that win10 has been out for a short period of time, so we could not manage to test everything.
We are doing our best to run tests and see how our products will react to win10.
Best regards,
Viktor Milovanovic
Re: VCP example from ME(LibStock)
I am using pic18f14k50