Programming Computers to work with Micros - Page 1
Forum section: electronics / projects

author: Strube09
author_rank: Regular Contributor
timestamp: September 09, 2010, 08:41:13 pm
content: Hey everyone,Just wondering is anyone can suggest a good language to learn to create PC programs. Specifically I want to be able to create interfaces that work with my micro projects.Basically I want to use USB or 232 to communicate with the micros. Example might be that I can control what the micro is doing from the PC or the Micro can report some external events to the computer. I know I can use some hyperterminal type software, but I want to be able to have my own enviroment with custom buttons and a nice GUI.Visual basic, c++ something else?Thanks,Strube

author: migsantiago
author_rank: Frequent Contributor
timestamp: September 09, 2010, 09:10:02 pm
content: I use Visual C# 2010 Express Edition for USB connections and a lot of stuff. It's free for personal and commercial use.http://www.microsoft.com/express/windows/

author: DavidDLC
author_rank: Frequent Contributor
timestamp: September 09, 2010, 09:18:58 pm
content: I also use Visual Studio C# to communicate with microcontrollers via USB.

author: Unknown
author_rank: Unknown
timestamp: September 09, 2010, 11:23:40 pm
content: Depending on your experience, starting with a more friendly language likePythonmight also be a good idea. VB is dead, and VB.net is basically C# with a different syntax. I wouldn't consider C# easy for someone without CS or programming background. What you want is probably possible in almost any modern language, it's just a question how hard it is to accomplish.

author: Zad
author_rank: Super Contributor
timestamp: September 09, 2010, 11:47:33 pm
content: Visual Basic is dead in the same way that Fortran is dead. In other words, it just isn't. There is such a huge code and skills base out there that it isn't going to die for quite some time. If you want marketable skills to put on your CV/resume, don't go with Python. I'm sure it has it's benefits, but then so do hundreds of other minor languages that <0.01% of the population know.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: September 10, 2010, 12:03:53 am
content: I statred with VB6 years ago, and is still OK-ish, but the biggest pains are that when flipping between C on the micro and VB on the PC, you start writing C in VB and vice versa...Another problem is when I need to give PC code to a customer to support/test/program/calibrate the hardware widget, you need the VB DLLs so need to make a setup package, plus you can't officially but VB6 any more so can be a problem if I want a customer to be able to do mods themselves. Another minor irritant is that VB doesn't support unsigned types - I had a hell of a job doing some code to generate a 32 bit checksum a while ago..!What I'd really like to find is a C/C++ based dev environment which is as quick and easy as VB to do UI stuff, easy to learn, produces a single exe that requires no support DLLs or installing anything else (e.g. .net framework), and is available (free or not too expensive) and easy to install for when I need to set up a customer with it.I had a play with The free Visual Studio a while ago to write a Virtualdub plugin, but AFAICS the free version doesn't have a GUI editor.A few people I know useCode Blocks, which may be worth a look.Any other suggestions welcome

author: Unknown
author_rank: Unknown
timestamp: September 10, 2010, 12:11:41 am
content: Quote from: Zad on September 09, 2010, 11:47:33 pmFortran compilers are still sold and developed (eg. Intel's compiler). VB was never a standard language to begin with, it was Microsoft exclusive, and Microsoft discontinued it, so it's just a question of time before VB6 becomes unusable on the next Windows version / platform.I missed the part where Strube wanted to learn this for his resume. As long as you've got a good background in programming, picking up a new language is easy. I think considering Python one of the obscure languages like Haskell is unfair, a quick search on Monster.com suggests C# developer vs. Python developer is about 6:1. C# is definitely more popular, but nothing like 30% vs. <0.01%. It depends on the industry. For enterprise applications, Java and .NET are the big platforms. For online applications, other languages like Python, Ruby and PHP are pretty popular. But I don't expect an EE to go into hardcore software development. For small projects, whatever the developers are familiar with and gets the job done is fine.

author: Strube09
author_rank: Regular Contributor
timestamp: September 10, 2010, 12:44:25 am
content: Thanks for all the replies.And while it would be nice for the resume basically need to develope small interfaces that can communicate witha calibration and test board that has a micro on it. Then I can store the results on the computer for tracking and other purposes. Eventually I would like to be able to store the info on our network too.... But I will take it one step at a time.C# Sounds like the way to go. Any good development enviroments I should look for?Thanks againStrube

author: migsantiago
author_rank: Frequent Contributor
timestamp: September 10, 2010, 02:08:47 am
content: Quote from: Strube09 on September 10, 2010, 12:44:25 amThe Visual C# Express Edition includes an interface designer which can be Windows Forms or WPF (nicer looks). You just draw the buttons, menus, combo lists, etc. and assign code to them. It's really easy.It also includes a Publish option to include the Net Framework into a setup file, so your users won't bother downloading it.http://msmvps.com/blogs/haarongonzalez/archive/2007/04/09/772757.aspx

author: DavidDLC
author_rank: Frequent Contributor
timestamp: September 10, 2010, 02:24:30 am
content: If you are a student you can get Visual Studio 2010 for free, that will be a good option for people still in school.Even if you are taking some trainings, you can also get it.If not you can go to ebay and get Visual Studio 2008, I saw a lot of offers that claims the software is un-opened and legal.

author: TopherTheME
author_rank: Regular Contributor
timestamp: September 10, 2010, 03:06:04 am
content: I do stuff like this with my projects all the time but I like to use Matlab instead of any of the typical programming languages. Its probably not the most elegant way of going about it but most my projects involve some pretty serious computation which for me makes Matlab the best option hands down even though Matlab GUIs can be a bit of a pain sometimes.I've also done this before with just plain old VBA in excel. Although that was back in the office 2003 days, I'm sure its changed by now. A lot of people crap their pants when I show them full blown custom GUIs that control some stupid little robot or something done entirely with MS excel!

author: migsantiago
author_rank: Frequent Contributor
timestamp: September 10, 2010, 03:23:29 am
content: Quote from: DavidDLC on September 10, 2010, 02:24:30 amVisual Studio Express Editions are free for personal and commercial use. There's no need to buy a pro or enterprise edition because we electronics engineers won't use all the features those versions offer.

author: DavidDLC
author_rank: Frequent Contributor
timestamp: September 10, 2010, 03:31:38 am
content: I agree on that Santiago

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: September 10, 2010, 09:10:47 am
content: Quotewhich (apart from the download size) is fine until you get PCs on which the .net install crashes inexplicably - this happens on 2 of my PCs.

author: scrat
author_rank: Frequent Contributor
timestamp: September 10, 2010, 09:38:38 am
content: I've done some experiments with Visual C++ Express Edition and Microchip examples for USB (Microchip USB Framework). They're easy to use, provided that you know quite well C++. Visual C++ has some strange things out from standard C++, but not so much difficult to understand. I chose C++ instead of C# because of examples from Microchip were in that language and more because I've studied C++ (it's not so common to learn C# at university here). Visual IDE help is really useful and self-contained, so you can easily find the way to add and use new objects.I found it very funny to do something like a very rudimentary software scope and a PC-controlled PWM with a simple PIC18F4550.BTW, can someone please give some practical differences between programming (generally, not only about interfacing with micros) in C++ and C#? How much is it worth to learn to use C# if one has a quite good knowledge of C++?Thanks

author: PeterG
author_rank: Frequent Contributor
timestamp: September 10, 2010, 11:05:49 am
content: I believe your choice of programming platform is a personal choice. All the Visual Studio languages have there strong points. I use VB Express and can use C#/++ is the need arrises. VB is a nice RAD environment to code "Project Level" applications. But all the Microsoft Visual Studio languages use a common runtime now days so the differences are now come down to syntax. The big bonus with VB is the huge amount of code examples on the net. Sites like "The Code Project" are a great resource.Best of luck Strube.

author: Zero999
author_rank: Super Contributor
timestamp: September 10, 2010, 01:12:43 pm
content: Quote from: alm on September 10, 2010, 12:11:41 amAgreed, let that be a warning to anyone who considers using a proprietary product for anything in future.Same with electronics, I tend to avoid proprietary ICs wherever possible: I always think what are the alternatives? Is a compatible IC made by anyone else? If the company stops making that IC how easy is it to adapt the design to a different part?Going back to the original question, I've done it before, but with good old fashioned RS-232 which was easy to do. Unfortunately it was for work and I had to use VB6. I agree the installation program wizard creates horribly bloated code which was much larger than my program. If I did it again, I would try to use something like FreeBASIC, make the program text mode (I didn't think a GUI was needed or helpful), it would've been under 200KB and required no installation - just run straight from a USB stick or CD.

author: Strube09
author_rank: Regular Contributor
timestamp: September 10, 2010, 01:23:53 pm
content: Hero999,Yeah I would try to use a text base interface but this would be used in production for testing and I have very little confidence in them taking the time to completely read a sentance... or understanding it.They seem to like pictures and our picture book of assemblies. Especially when some of this will be done in china and the Chinglish translation is sometime confusing.While I feel as though I do alright with C in the micro world I need to learn (in any language) how to address the 232 or USB in the computer programming world.... is there just a library that can help me with this? Basic C books don't really get into using the computer ports.Does C# or Visual C++ make this easy?Thanks again for all your help... as you can see I am not a trained programmer... just an EE trying to make it work.Strube

author: migsantiago
author_rank: Frequent Contributor
timestamp: September 10, 2010, 01:30:38 pm
content: Quote from: Strube09 on September 10, 2010, 01:23:53 pmI wrote a basic bulk USB tutorial for C# which may be helpful for PICs.http://www.migsantiago.com/index.php?option=com_content&view=article&id=9&Itemid=10Just use the translator above.PS And also download the latest mchpupsb.dll which now works with Windows 7 32 and 64 bit edition.

author: scrat
author_rank: Frequent Contributor
timestamp: September 10, 2010, 09:30:47 pm
content: Quote from: Strube09 on September 10, 2010, 01:23:53 pmWell, as I said above, and as Migsantiago agrees, Microchip made very suitable drivers and examples. Once you have MPLAB IDE and Visual Express installed properly, it is easy to develop Visual C++ applications that exchange command-response with a PIC. There are a number of PIC18F with an integrated USB peripheral, like PIC18F2550/4550, but beware that one which is really cheap (I think it was something like PIC18F14k50) has not the In-Circuit Debugging hardware. Firmware/software examples show a few different ways to access to PIC by USB, the more interesting ones for a simple monitoring/control are in my opinion serial emulation (it should allow you to write the same PC software for a real RS-232 device and for a USB one) and WinUSB driver.On the PC side I used Visual Express 2005, since 2008 release didn't work (perhaps because of Win Vista). Starting to modify the examples from Microchip, creation of graphical windows with buttons, gauges and even an xy graph is quite easy (it was my first application in Visual C++). You can do very nice things as long as you can manage with C++ and you use the huge help resource which is installed.If you would decide to go this way, just ask, I'd like to take off some dust from that thingQuote from: Hero999 on September 10, 2010, 01:12:43 pmRS232... On new PCs serial port is an optional!Why did they implement such a complex protocol in USB? I'm hardly convinced it was really needed, wasn't it possible to design a standard that substituted RS-232? I mean, if a USB device was by default in a RS232-like mode, and then you could select which mode you'd like, wouldn't it be great thing? For example, USB protocol FW on PIC is a quite large piece of code, although it has a dedicated USB peripheral, seems too complex to me!OK, people who wrote USB standard are of course experts, while I'm a simple engineer, but I suspect sometimes big interests (look at how much income FTDI makes with their chips) overcome engineering reasons.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: September 10, 2010, 10:19:11 pm
content: QuoteBecause RS232 is about the least of what USB was designed to do. And even then, RS232 wasn't a heavily used interface compared to the sort of things USB replaced when it first came out, it was stuff like scanners, printers and other stuff that was previously kludged onto printer ports or needed its own dedicated card, not to mention its own power supply.

author: Mechatrommer
author_rank: Super Contributor
timestamp: September 11, 2010, 04:45:14 pm
content: I work in Windows XP. I learnt VB and VC++, i've made Arduino Mega controllable through a C++ program in PC, which the development environment was built on a VB program. Thats the only thing i know until i'm dead or the VB/VC dead (unsupported in my OS).

author: migsantiago
author_rank: Frequent Contributor
timestamp: September 12, 2010, 12:06:50 am
content: Quote from: scrat on September 10, 2010, 09:30:47 pmWhy not?USB is an universal serial bus which may accept any expansion board you require. From audio, video, HID, Communication, security, Wifi, Mass storage, healthcare, printing, and on... you can connect anything and anything should work on your pc when using the appropiate drivers and OS.The word universal is what made the USB protocol so complex.Rs232 is just an interface. USB is a whole protocol.I know its complexity scares anyone away, but there's people who know about scarey guys and make their lives easier...http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en546923... way better than any FTDI...

author: migsantiago
author_rank: Frequent Contributor
timestamp: September 12, 2010, 12:20:08 am
content: And there's people who can actually take apart some USB-RS232 almost-compliant cables and turn them into USB TTL adapters for their projects...http://hackaday.com/2010/09/11/cheap-cable-reused-to-add-usb-to-your-project/

author: scrat
author_rank: Frequent Contributor
timestamp: September 16, 2010, 05:30:37 pm
content: Quote from: mikeselectricstuff on September 10, 2010, 10:19:11 pmSorry for such a late reply. Of course, USB makes things that RS-232 could not, and USB standard defines the protocol.I like the differential signalling (was already there in RS-485, and it was widely used in industry), the automatical sensing of a device (so it allows for automatical plug-and-play), the presence of a (standard rated) power supply and the overall flexibility.What I was trying to say is that, since many of the USB devices we use don't require much more than RS-232 performances, if the standard was something that by default was the simplest replacement for RS-232 (like the numerous USBtoRS-232 adaptors make), perhaps we could make many things to work very easily. Just needed to implement the physical level, and it worked. Then, if one needed something more, could add handshaking and a proper driver to achieve it.Instead, with this standard, even the simplest device has to manage a quite complex procedure prior to become useful. This means a large piece of code on a PIC18F, for example (provided that already has an USB peripheral) and a peculiar driver on the PC.Then there is the problem of making own USB peripherals, since one should buy a licence to use a peripheral ID and a vendor ID.Although FTDI chips are very versatile and useful, their widest use is just for traslating USB RS-232 emulation mode into UART. This perhaps could be avoided if USB was by default simpler.A last little thing: USB is called a bus, but physically isn't. One host peripheral can manage many devices, but they must pass through a "smart" hub (it has not only physical connections). Couldn't it be done as a real bus?However, I appreciate very much when a standard is accepted widely like USB has been, historically this has always led to technical acceleration (USB allowed to do so many tiny devices, first of all USB pens).In the future I'll try to be more humble and to stay in my place... and to write less words