Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] C# USB transmit error

Status
Not open for further replies.
Please zip and post the original untouched VC# project and mention which version of Visual Studio has to be used to open the file. I tried opening in VS 2008, VS 2010, VS 2012, VS 2013 and VS 2015 but they don't show the Windows Form of the project.

Edit: It opened in VS 2010.

Make this small change and see if it works.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
private void btnReceive_Click(object sender, EventArgs e)
        {
            int i=0, j=0, k=0;
            byte[] data = new byte [64];
            byte[] str = new byte [64];
            data = dev.Receive();
            if (data != null)
            {
                txtReceive.Text = System.Text.Encoding.ASCII.GetString(data);
            }
            
        }

 
Last edited:
It worked for me. I will modify the mikroC project file and post it here. I will also modify the VC# app so that it displays the data as soon as it receives it.
 

Attachments

  • sim ss.png
    sim ss.png
    20.8 KB · Views: 79
  • PIC USB C#.rar
    928 KB · Views: 86
Dear Sir,

I mean that at the second time when I sent the information to MCU, the data including that information VC# received. Like this
problem1.PNG
 

After VC# app receives data and displays it try to clear the buffer (data buffer) used for USB HID reception. Also clear the buffers used in mikroC code after each USB HID communication.
 
Last edited:
Dear Sir,

I will try it later. Today and tomorrow I have important examinations :bang:.
 

I tried to use Zedgraph software to plot signal received from MCU. But I think my working exist some limitations.
It is have a problem when I sent data at the second time Sir.
For example, the first time I send "BiNa" and LCD displayed perfectly on screen but the second time when I send "1" so LCD displays "1iNa" that mean the readbuff[] is still contain the old values.
Graph problem.png
In MikroC, LCD before printing a new value to LCD clear the LCD line by using
Code:
LCD_Out(1,1,"                ")
It is not work in my case.
 

Also clear the buffers in VC# app after data is sent and after data is received and processed.
 
I don't still fix it Sir.
I MikroC I use this
Code:
Lcd_Cmd(_LCD_CLEAR);
   readbuff[0] = 0;
   str[0] = 0;
In VC# I use these code
Code:
EnviarDadosUSB(DataWrite);    //Send to Microcontroller the USB Buffer 
            DataWrite[63] = (byte)0;    ////any byte Data (0 ~ 63)
 

You are not clearing all the elements of the buffers. Use a loop and clear the complete buffers.
 
Everything work well in the simulation file (send data from my PC to PIC18F4550) but when I try to connect RFID Reader when MCU C8051F430 interface with USB block. I cannot send any data although my firmware can detect this USB device.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top