News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

CDC USB

Started by JonW, Jul 17, 2024, 02:33 PM

Previous topic - Next topic

JonW

Has anyone worked on implementing a CDC stack on a USB-enabled Micro, such as the 16F145x? If you have any demo code that would be great. 


John Lawton

Have you tried looking in: "C:\Program Files (x86)\ProtonIDE\PDS\Includes\Sources" where there is:

CDC_Descriptor.inc
HID_Descriptor.inc
Mouse_Descriptor.inc
USB_CDC.inc
USB_Dev.inc
USB_HID.inc
USB_MemAlloc.inc

The Descriptor file calls up the rest of the HID stack.

There are newer versions of the stack in: "C:\ProgramData\PDS\Samples\New Samples\Proton_USB_HID_Stack"

A few examples (USB18 Mouse etc) in: "C:\ProgramData\PDS\Samples"

I hope that helps a bit. I designed a multi-axis HID joystick controller, so didn't actually use the CDC.

John



JonW

Cheers John, Ill take a look.  I have a copy of Jan Alexson USB monster book I am working through.
Did you use a USB protocol analyser like Beagle 12 or any monitoring software?

John Lawton

Lol, I have Jan's book too but I've used Les's code to do the hard work, I don't pretend to understand a lot of what goes on 'under the bonnet'. I've used one of her utility programs.

Here's the long forum thread I created for the Joystick which I think is worth reading: https://protoncompiler.com/index.php/topic,443.0.html

In this post: https://protoncompiler.com/index.php?msg=3844 I describe using http://www.usblyzer.com/ to try to debug the operating code. Trastikata found the actual problem for which I will be eternally grateful.

John



JonW

#4
Thanks for the information John.  I have developed a simple 16F1459 development board so I can have a play around with CDC and HID and debug easily via VCP port or OLED

Board Hardware is as follows

USB1 CP2102 for Serial to PIC
USB2 PIC16F1459 USB
TEMP SENSOR
3V3/VUSB VDD
3 LED
3 SWITCHES
1306 OLED
ALL PINS PORTED
ICSP

USB_1459_DEV.jpg

John Lawton

Nice, good luck with it!

trastikata

Looks very good, what software did you use for the design and the 3d model?

JonW

#7
Hi Trastikata

For rapid turnaround and sub 6GHz, I use Easy Eda standard edition. It's unbeatable in my opinion, as it has LCSC libraries available for SMT, and the software is free. Manufacturing is also seamless if you use their package.  It's also extremely fast; Schematic and Layout took about 3 - 4 hours, and that is everything you need: 10 minutes on JLC, and it's being manufactured.  Its great for development but has decimated local PCB manufacturers in the UK.


trastikata

Thank you John. Is it hard to learn, somehow similar to Proteus?

JonW

#9
No, it's really easy and much more straightforward than Ares (Proteus). There are some really useful add-ons for board flipping HERE , HTML Assembly drawings, etc., and you can even write your own. I think it would take a day to become proficient in both Schematic and Layout. 
BTW, I wouldn't bother with the Pro version unless you have some really dense designs; I have used it a couple of times and it's much slower to do a simple PCB.




trastikata

Quote from: JonW on Jul 22, 2024, 05:33 PMBTW, I wouldn't bother with the Pro version unless you have some really dense designs; I have used it a couple of times and it's much slower to do a simple PCB.

Heh, already installed it and I was wondering why are you using the standard version if both have free licenses :).

Thank you for the suggestions.

JonW

If you PM me your Email, I will send you the above full project file for standard and explain how to get it into the project tree. 

trastikata

Quote from: JonW on Jul 22, 2024, 05:44 PMIf you PM me your Email, I will send you the above full project file for standard and explain how to get it into the project tree. 

Thank you John. But first I need to get a bit familiar with the interface, right now it is completely new to me.

RGV250

Hi,
Just a couple of questions, can you use the files produced for yourself or do you have to get them to produce the PCB. I have a CNC engraver and fancy having a go at milling them. The old free Eagle does not like my Win 10 machine.
Also does it have an arduino style template for shields as I expect that would be difficult to get exact.

Bob

JonW

#14
It produces Gerber and you are free to send this anywhere you please.  Its also pretty good at importing DXF too

There are alot of example projects on the web and.the libraries also contain user generated parts and outlines so Arduino is likely out there.

Note be wary of using the user designs, I have fallen foul to them in the past where you trust them and the pinouts or package dimensions are wrong.  I do occasionally use them but check them against the data sheet

Tip if you want SMT and to use LCSC parts, then find the part on LCSC and copy the LCSC Cxxx part number and paste it in the library search in easy eda, if it comes up then JLC can access it.  If it's not in the library then it will not be SMT'd.  They now have a service that can utilise Digikey or your own parts but I have not used it. 

To increase the SMT amount of board use panelisation, it saves loads of cost if you can deal with V cut boards. 

JonW

Another really powerful use case for Easy EDA and JLC is the Aluminium PCB process. I use this for enclosure end panel or lid designs. I draw the end panel or lid in Fusion 360 and export it as a 2D DXF into Easy EDA. I then form the cutouts ( draw apertures and select generate cutout). I flood the design with copper so JLC doesn't need to remove it, and then I add silk screen text.
A 1mm fully routed, painted, and text-printed front panel, made from Aluminium for less than 10 cents!  This example is for Lab test kit in a Hammond enclosure with the JLC front panel, the buttons are purposely sub flush to stop accidental activation.

 Ali_process.jpg

John Lawton

Hi Jon,

clever of you to use the Aluminium pcb process to make front panels, a nice bit of lateral thinking. I use PCB Way rather than JLC but they also offer Al pcbs, indeed I ordered some recently. They offer some interesting challenges as I wanted to mount an LED on the top side but to connect wires through from the rear/bottom side. I got some boards made but the through holes in the aluminium weren't insulated, so I'm looking for a SMT mounted through connector for my revised layout....

Anyway I don't want to hijack your thread, I wanted to ask about the 4 pin OLED display, I've never used them before. Is this 128 x 32 /0.9" ? I see OLEDs are available on AliExpress (so cheap!) but do you know a UK stockist please?

John

JonW

#17
Hi John
Hyjack away, guys; I have all the info on the USB; I just need time to give it a go! If you PM me your address, I'll send you a couple of populated boards when I get them in; I will send them out by the end of the week, and it will take 2 weeks ish to get back.  The 1306 OLEDs work with Atomix's libraries and are a doddle to get going with. Hmm, I think I will add a 64kbit external EEPROM to the board as this only has 8K flash, and USB + Oled Libraries are likely to leave little room for fonts, etc. Look for anything with 1306, and they will work in the library.

OLED


If I need a panel or lid with parts on the surface or rear, I just use a 4-layer FR4 and do the same process.  I have done this with capacitive touch pads, LEDs and the OLED's.  You can also get a reverse lens or side mount SMT LED fitted on the back of the panel PCB and visible with an unplated drill hole.  You can then use a Flex cable or even mount a display MCU on the rear; I use a 4-layer PCB and keep the inner solid copper for EMC shielding; otherwise, a 2-layer is ok. The result is the same-looking panel  with FR4 or ALI and looks professional; I tend to keep the resist black to hide the traces.  If you want a smooth board, then you can epoxy fill the vias; however, to keep the cost down, use the smallest via for the cheap process and black resist as this has lots of pigment that fills the vias.  We use the process for all sorts, Go no go guages, drill templates, SMT trays, Drill bit holders, SMT jigs, connector alignment and LED alignment jigs.


JonW

#18
Added a 64k E2 with opt-out pads and xtal option on the bottom

USBDEV_E2.jpg