Author Topic: PIC32 USB to PC Job  (Read 5043 times)

0 Members and 1 Guest are viewing this topic.

Offline dpadam450Topic starter

  • Newbie
  • Posts: 5
  • Country: us
PIC32 USB to PC Job
« on: April 27, 2023, 07:53:04 pm »
Man what an annoying headache MPLAB and Microchip are for providing any tutorials or documentation. I'm aware of Harmony but I can't even start a fresh install and click on a USB example to get it to compile. I also do not see any included applications on the PC side to communicate as a full hands on tutorial from start to finish.

Willing to pay someone that can get me a working USB example communicating with a PC. I want the Windows PC app in a c or cpp file. I have PIC32MX120, PIC32MX220, and PIC32MX250. Any of these working example are fine.

Thanks.
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2231
  • Country: gb
Re: PIC32 USB to PC Job
« Reply #1 on: April 27, 2023, 08:04:02 pm »
M-Stack is nicer than Microchips code IMHO.
The examples are ready to use, compile and run.
The cdc_acm works and gives you a standard comport on the PC, no drivers required.
https://github.com/signal11/m-stack
 

Offline dpadam450Topic starter

  • Newbie
  • Posts: 5
  • Country: us
Re: PIC32 USB to PC Job
« Reply #2 on: April 28, 2023, 01:16:23 am »
I copied the cdc_acm as suggested. m-stack is giving me this. Reading the code I can take a guess but not 100% sure. I'll poke at some params and see if it works.

MAX_LUNS_PER_INTERFACE I assume would just be = 1 if its a slave device? If you have a working one I'd still pay you for it.
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2231
  • Country: gb
Re: PIC32 USB to PC Job
« Reply #3 on: April 30, 2023, 07:53:10 pm »
You need to download the whole repository and compile without changing the project structure. The apps include files from the usb folder, etc.
 

Offline dpadam450Topic starter

  • Newbie
  • Posts: 5
  • Country: us
Re: PIC32 USB to PC Job
« Reply #4 on: April 30, 2023, 11:29:22 pm »
Per the m-stack owners own message, you have to modify the code which is all good, I just don't want what params to set just yet. I didn't get go fruther just yet but will at some point.

"To create a new project, perform the following steps:
1. Create a new project with MPLAB X.
2. Copy and add the usb/ directory as a subdirectory of your project.
3. Add the usb/include directory to the include path of your project. (Note
   that the include paths are relative to the Makefile.  If you set up your
   project like the examples, with an MPLAB.X/ subdirectory, you'll need to
   add an additional ../ to the beginning of the include path).
4. Add . to the include path of your project (same note from #3 applies).
5. Copy a usb_config.h and a usb_descriptors.c file from one of the example
   projects into your main project directory.
6. Modify usb_config.h to match your desired device configuration.
7. Modify usb_descriptors.c to match your device configuration.
8. If you're using a PIC16F/18F platform, add an interrupt handler similar
   to one of the examples.
9. Reference main.c in one of the examples, and the Doxygen-generated
   documentation to add your application logic.
10. Make sure to configure the MCU for your board (__CONFIG registers, etc.)."
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2231
  • Country: gb
Re: PIC32 USB to PC Job
« Reply #5 on: May 01, 2023, 09:13:12 am »
Regarding the wider project...

(1) What programming language do you plan to use for the PC software? Or perhaps you have an application already?

(2) Does your PC application need to be cross-platform? Linux, Windows, Mac...or just one of those?

(3) Given the MCUs you mention use USB Full Speed, I assume that max transfer rate of a few megabits/second is enough?

(4) The two simplest ways for USB connection to an mcu are (a) COMport (b) custom USB device using libusb on the PC side. If a COMport is suitable for you, it's probably the simplest to start with. COMport OK with you?
 

Offline dpadam450Topic starter

  • Newbie
  • Posts: 5
  • Country: us
Re: PIC32 USB to PC Job
« Reply #6 on: May 02, 2023, 12:00:55 am »
C++ Windows only.  I only need to send like 12 bytes 0.5 to 1ms.  I'm assuming COM is fine from what I've read. Nothing complicated.
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2231
  • Country: gb
Re: PIC32 USB to PC Job
« Reply #7 on: May 02, 2023, 10:57:19 am »
If comport is fine for you, then you have the option to just use a USB to serial (uart) converter IC, such FTDI FT230X or something similar.
This might be better for you since you don't need to deal with USB in your firmware, just the mcu uart peripheral which is much much simpler.
Have you considered that option?
 

Offline dpadam450Topic starter

  • Newbie
  • Posts: 5
  • Country: us
Re: PIC32 USB to PC Job
« Reply #8 on: May 03, 2023, 12:52:15 am »
Not wholly familiar, but if PIC32MX250 apparently has the hardware to communicate via USB/COM without anything other than a USB cable (from my understanding), then no reason to spend more money. Extra controller chip times 1000 units (including the fact things go out of stock), is not something I'm very interested in doing. Do arduinos have a UART translator or is it raw USB when you use the Serial.Print() function?
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2231
  • Country: gb
Re: PIC32 USB to PC Job
« Reply #9 on: May 03, 2023, 07:30:40 am »
I've never used arduino but there are different versions of course, probably both methods you mention are used on one board or another.

Have you chosen a specific PIC32MX250 variant?
Any hardware available to test with, dev boards or whatever?
 

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 6696
  • Country: va
Re: PIC32 USB to PC Job
« Reply #10 on: May 06, 2023, 02:14:30 pm »
Quote
Not wholly familiar, but if PIC32MX250 apparently has the hardware to communicate via USB/COM without anything other than a USB cable (from my understanding), then no reason to spend more money.

Yes, that's the case. I used one (2xx) to provide a serial console via a PC. Apart from the normal protection, you just run D+ and D- straight into the PIC.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf