+ Reply to Thread
Page 1 of 3
1 2 3 Last
Results 1 to 15 of 32

Thread: Can we Program PIC Microcontroller in Microsoft Visual C??

  1. #1
    Ayne Newbie
    Join Date
    Apr 2006
    Location
    Multan, Pakistan.
    Posts
    416

    Default Can we Program PIC Microcontroller in Microsoft Visual C??

    Q No:1- Which is the better Visual C# OR Visual C++ and why????

    Q No:2- Can we program PIC Microcontrollers in Visual C# OR Visual C++, if yes then how, if not than why not???

    Q No:3- What we need to program PIC in Visual C# OR Visual C++???


  2. #2
    evandude Good evandude Good evandude Good
    Join Date
    Oct 2003
    Location
    Maine, USA
    Posts
    1,395

    Default

    your first question doesn't make any sense, it's like asking "which is better, english or french?" (or any other language) It's a matter of personal preference and everyone is entitled to their opinion.

    No, you cannot program a PIC in VC++ or VC#. That also doesn't even make any sense, both are written for 32-bit and 64-bit computer systems, it's crazy to think they would work on a PIC.

    It is possible to program PICs in plain old C, there are a lot of compilers for that. There are one or two compilers around somewhere for C++, however they never got very popular, probably because many of the features of C++ are way too complicated to be used (or needed) on an 8-bit microcontroller.

    Once again, you really need to consider what kind of extremely simple hardware you're programming for. The kind of stuff that is fine on a PC is incredibly inefficient on a PIC - 32-bit values, floating-point math, etc. There's nothing stopping you from doing some amazing stuff with these 8-bit microcontrollers, you just have to be creative in your programming.
    Last edited by evandude; 25th December 2006 at 03:37 PM.

  3. #3
    Ayne Newbie
    Join Date
    Apr 2006
    Location
    Multan, Pakistan.
    Posts
    416

    Default

    Infact I am planing to learn one of those languages but i don't know which is best for me. Infact my object is make graphs in computer and other programs that control my Embedded system from PC.

  4. #4
    evandude Good evandude Good evandude Good
    Join Date
    Oct 2003
    Location
    Maine, USA
    Posts
    1,395

    Default

    Wait, are you talking about programming the PIC, or writing a PC program to interface with the PIC?

    If you're talking about writing a PC program to interface with the PIC, then it's another story entirely. Either VC++ or VC# can do it quite well, as can Visual BASIC if you like that language. If you're using the .NET 2.0 framework with any of those languages, interfacing with the serial port (which is the simplest way to interface with a microcontroller from a PC) is quite easy. The first time I played with the System.IO.Ports.SerialPort object in C#, I was able to put together a simple 2-way communication serial terminal program as a demo within an hour or so.
    Last edited by evandude; 25th December 2006 at 04:47 PM.

  5. #5
    Ayne Newbie
    Join Date
    Apr 2006
    Location
    Multan, Pakistan.
    Posts
    416

    Default

    I want to write PC programs, like u said interfacing with the serial port and making graphs and other programs.
    I have read many stories that C++ is more powerfull than C#. What is ur view?
    I think i will go with C++ what u say??

  6. #6
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,792

    Default

    Quote Originally Posted by Ayne
    I want to write PC programs, like u said interfacing with the serial port and making graphs and other programs.
    I have read many stories that C++ is more powerfull than C#. What is ur view?
    I think i will go with C++ what u say??
    Either are equally powerful really, it's down to what you do with them - I would expect C# to be more resource hungry and run slower?.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  7. #7
    evandude Good evandude Good evandude Good
    Join Date
    Oct 2003
    Location
    Maine, USA
    Posts
    1,395

    Default

    Pretty much, Nigel. C++ pretty much invariably makes much faster programs, but it's also a lot more complicated to write programs in general, ESPECIALLY if you want to create applications with a GUI, as opposed to a command-line-only application.

    C# is a completely object-oriented language, which is generally a very intuitive programming model, and it's generally a lot easier to write programs with it. It's also a very managed language; it makes you be clearer about what you are trying to do so you don't leave as many ambiguities and make as many stupid mistakes. With visual studio, or some of the other IDE's out there, creating a GUI application is as easy as dragging and dropping some objects (serial port, buttons, text boxes, etc) onto a form, and then writing some code to tie them together. As I said, a basic app using serial communication can be thrown together very easily, in very little time. Visual BASIC is very similar to C#, everything is structured about the same way, it just comes down to your preference of C vs BASIC.

    It really comes down to what you're looking for. If you want raw speed, try C++ (or even C). Just be prepared to learn a lot - even something like opening a single, empty window in VC++ can take several dozen lines of code. If you don't want to spend a ton of time programming, something like C# or VB might be a better choice. Personally, I prefer to spend less time programming my PC software and more time working on the hardware and firmware of the PIC system, even if it means my application runs a little slower.

    But just for the sake of comparison, I wrote a USB bootloader app in C#, and it takes on the order of 4 or 5 seconds to do a complete read of an 18F4550. The Microchip demo application, which is written in C++, takes about the same amount of time, maybe a second faster, but not much more. To me, the additional time that it would have taken for me to write such an application in C++ would not be worth the savings of a second or so every time it's used. If you were in an industrial setting and needed to perform this action tens of thousands of times a day, as fast as possible, then this speed difference would probably matter to you a whole lot more.

    I think probably the best thing you can do is to just go search around the web and look for some example code. I'd recommend http://www.codeproject.com/ . Look at some demo applications in C++ and in C# and compare the code, and see which one you think you'd prefer.
    Last edited by evandude; 25th December 2006 at 05:45 PM.

  8. #8
    3v0
    3v0 is offline
    3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent
    Join Date
    Jul 2006
    Location
    USA
    Posts
    6,464
    Blog Entries
    11

    Default

    Because you do not know C, C++, or C# I suggest you use C#. They all will work, but I think you will get apps working faster with C#. It can be easier to make things happen in C#, it does more for you, hides more details. It will use more CPU time, but a modern PC has more then enough power to handle it.

    I think you will find that visual studio is a good environment to learn and program in. A bonus is that you can find C# examples that explain most of the problems you will run into on the net.

    Regardless of which VS language you use you will be working with the .Net framework. The .NET 2.0 has easy to use serial port support. You drag the serialport from the toolbox to you forms design, set the baud rate etc in the properties window, and write a data recieved callback (function called on data recieved) and you are ready to go.

    3v0

  9. #9
    akg
    akg is offline
    akg Newbie
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,406

    Default

    C# and C++ are both powerful in there own class. if you want to know under the hood working of system, and tweak it (forget asm ) then VC++ is the choice , and it is the native language of windows . if you just need to put a program as fast as possible with little headache , then VC# is the language to choose.
    Gods own Country
    Incredible !ndia

    www.flickr.com/photos/_akg/

    "Give a man a fish, and he will eat for a day. Teach that man to fish, and he will eat for a lifetime."

  10. #10
    i_build_stuff Good i_build_stuff Good
    Join Date
    Jul 2005
    Location
    Pittsburgh, PA (USA)
    Posts
    134

    Default

    Between those two, I say go with C++. There are C / C++ compilers for just about every chip / OS ever made, and many of them are free. C# only has one compiler, which only writes binaries for Windows.

    If you want something in a simple / high-level scripting language, I'd look into Python and Java. They're both extremely popular, and are well-supported on a lot of architectures.

  11. #11
    3v0
    3v0 is offline
    3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent
    Join Date
    Jul 2006
    Location
    USA
    Posts
    6,464
    Blog Entries
    11

    Default

    Quote Originally Posted by i_build_stuff
    Between those two, I say go with C++. There are C / C++ compilers for just about every chip / OS ever made, and many of them are free. C# only has one compiler, which only writes binaries for Windows.

    If you want something in a simple / high-level scripting language, I'd look into Python and Java. They're both extremely popular, and are well-supported on a lot of architectures.
    From http://www.mono-project.com/Main_Page
    What is Mono?

    Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix. Sponsored by Novell (http://www.novell.com), the Mono open
    3v0

  12. #12
    Banned donniedj Bad donniedj Bad
    Join Date
    Jan 2004
    Location
    So Cal
    Posts
    337

    Thumbs up

    Ayne:
    I understand you are new to microcontrollers but please do not plaint seeds that directly or indirectly envolve M$ with this discipline. One, such a union does not fix anything since nothing is broken. Two, such a union could only lead to the hindering of the other. Three, such a union creates complication, increased resource, and monitary, volumetric, and temporal dependencies. In other words it puts more to get out the same which inarguably means to get less. Those who have intiment knowledge of the two know why one has continually advance and the other remains relatively static.

    Lets not forge microcontrolling coding from a state of being potentially to that of a guaranteed slow, ambiguous, redundant, excessive, inefficient, bloated, and monopolized. If I can save you one of them its all be worth it.

  13. #13
    raedbenz Newbie
    Join Date
    Nov 2006
    Posts
    50

    Default

    of course u can't...
    choose the MIKROC compiler..u could also found a lot of helping files there
    rabusanad.tripod.com

  14. #14
    hashlock Newbie
    Join Date
    Oct 2009
    Posts
    1

    Default

    Actually, Visual Studio allows you to create a Makefile project, which allows you to then compile your application using a third-party compiler. In your case you could use PIC-C, or any other Pic command line compiler. Need to know all the command line options and setup the makefile, but it can be done. That gives you the benefits of the VS IDE and the ability to cross compile for a non Intel x86 architecture (like PIC).

  15. #15
    Russ Hensel Okay
    Join Date
    Sep 2007
    Location
    South Dartmouth
    Posts
    125

    Default

    On the PC side use "processing" They have software that makes this really easy. Processing is a odd variant of Java but easier to get into. You can extend it with full fledged Java if you want. Java is in a way the next step after C++ and is very close to C#. C# is Java after MS stole as much of Java as it could. C# runs with anything MS. Java runs anywhere ( begin flame war )

    Processing is also the laguage of the PC side of the Arduino ( not the only one however ) On the uC side the Arduino uses sort of C and C++.

+ Reply to Thread
Page 1 of 3
1 2 3 Last

Similar Threads

  1. visual basic program for parallel port interface
    By group_x3m in forum Micro Controllers
    Replies: 5
    Latest: 26th May 2006, 01:49 AM
  2. How to connect LED detector 2 Pins?..program microcontroller
    By Terrano in forum General Electronics Chat
    Replies: 3
    Latest: 31st March 2005, 04:38 PM
  3. Tough assembly program for the PIC16F84
    By asmpic in forum Micro Controllers
    Replies: 34
    Latest: 3rd December 2004, 06:50 PM
  4. Visual BAsic communications with a microcontroller
    By Erwin_Macaraig in forum Micro Controllers
    Replies: 2
    Latest: 22nd November 2004, 12:12 AM
  5. PicBasic Keypad program
    By Sora in forum Micro Controllers
    Replies: 0
    Latest: 20th April 2004, 07:02 PM

Tags for this Thread