Quick and Easy PIC config over USB - Page 1
Forum section: electronics / general

author: katzohki
author_rank: Frequent Contributor
timestamp: December 31, 2014, 07:23:45 pm
content: OK, so maybe I'm dreaming. I want the user to be able to change a simple configuration of my PIC application over USB and I'm looking for a simple solution. It seems like the easiest thing would be to put a USB storage module on-board, which the PIC can access and read the configuration file when the USB is off. The other idea would be to put a USB-Serial part on board and write an application that communicates with the PIC directly (I'm a bit out of practice for this I think). The final option I thought of was to use a PIC that can communicate over USB directly, but that strikes me as a lot of effort, especially since the application runs on a PIC10 now and I'd have to use at least a PIC16.The config information is a string and a couple settings or so (may as well be strings too). Any ideas? All input is appreciated.

author: Christopher
author_rank: Frequent Contributor
timestamp: December 31, 2014, 08:16:07 pm
content: A usb->serial chip might as well cost as much as a cheap USB pic.At with the PIC you can make it a flash drive with a simple text file in it .

author: katzohki
author_rank: Frequent Contributor
timestamp: December 31, 2014, 08:32:06 pm
content: Quote from: Christopher on December 31, 2014, 08:16:07 pmI'm ok with the cost of adding the USB to serial chip. It's the development time I'm worried about.Are you saying that you can make the PIC look like a simple flash drive with text file?

author: Christopher
author_rank: Frequent Contributor
timestamp: December 31, 2014, 08:33:46 pm
content: The usb to serial would be easy as it's literally a uart and u arts on the pic are very simpleMicrochip has a usb stack with usb thumb drive example. Check it out.

author: lewis
author_rank: Frequent Contributor
timestamp: December 31, 2014, 09:14:27 pm
content: Communicate with the PIC via a USB to UART chip (eg FT232 - make sure you use a genuine one!) and store whatever configuration you need in PIC's internal EEPROM (or Flash if the PIC doesn't feature EEPROM).You'll need to write an application for the PC end in order to get the data into the PIC. Lots of free tools (code::blocks) available to do that and google has some examples of source code like this one:https://batchloaf.wordpress.com/serialsend/. It can be modified to send files.There are more elegant ways to do it, but this is probably the simplest.

author: katzohki
author_rank: Frequent Contributor
timestamp: December 31, 2014, 10:13:43 pm
content: Thanks guys! This is great. I don't think I'll try to make it work like a USB thumb drive. It would be cool, but the USB to UART will be easier to handle. I didn't want to have to write too much of a user program, but based on your example I think I can keep it very simple. Probably just have a .txt config file and a program that will translate and send it.

author: Christopher
author_rank: Frequent Contributor
timestamp: January 01, 2015, 03:17:17 pm
content: Visual c# express 2010 is a free download and great for making little serial guis.

author: miguelvp
author_rank: Super Contributor
timestamp: January 02, 2015, 12:06:09 am
content: Quote from: Christopher on January 01, 2015, 03:17:17 pmJust an FYI:Visual Studio Community 2013 is free and has all the compilers including c# and it's the full Visual Studio Professional without the limitations that the Express editions have.But I don't even know if the OP is running windows.

author: katzohki
author_rank: Frequent Contributor
timestamp: January 02, 2015, 09:10:54 pm
content: Thanks all, good info. I haven't programmed in C lately, but I've had classes in C++ and the .NET framework so I should be able to handle. I'll have to check out the free C# programs.

author: Jeroen3
author_rank: Super Contributor
timestamp: January 02, 2015, 11:33:48 pm
content: Use a serial port, thats the most compatible and fastest. Especially when you're using ftdi, almost every computer nowadays knows how to use those.Then get Qt and make a portable application that can run either windows/mac/linux. Avoid the microsoft vendor lock, because they are toying with their future in the recent Windows versions.Have some though of way to communicate. Keeping it extensible en small. (See modbus)