Shop OBEX P1 Docs P2 Docs Learn Events
Microsoft Visual C# and Parallax — Parallax Forums

Microsoft Visual C# and Parallax

Tony StarkTony Stark Posts: 3
edited 2009-03-22 09:29 in General Discussion
I'm a newbie to microchips. I'm playing with a PIC16F690 and PIC12F509(Microchip, Inc...not Parallax). I just learned that if I want to get away from assembly language and get into C programming language, I have to spend $150 for a C compiler. That was a big turn-off for me. I'm thinking of switching over to Parallax microchips just for that very reason. Anyway...

...I want to get into RS-232 communications. I wasn't able to do it with the PIC chip (demo compiler doesn't support my chip unless I spent $150). I'm looking at Parallax chips and I understand there are 3 families: BASIC, SX and Propeller. I don't get the impression that BASIC family chips support serial communication. Is this true? Should I start with an SX chip? I love it that I get a compiler with my purchase of the starter kit for the SX!

And now, the BIG QUESTION: in the end, I want to create a custom Windows interface that talks with a microchip via RS-232. Do any of you know if it's possible to get an SX microchip (programmed for serial comm.) to talk with a program created using Microsoft Visual C# 2008 Express Edition? Anybody done it before?

Don't get me wrong--displaying stuff on a 2x16 LCD is neat, but I'm a sucker for fancy graphics. I would do anything to display stuff on a custom interface on my PC instead! Let's talk about this...

-Tony Stark

Comments

  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-09 06:23
    What you want to do is very very easy with the SX or Propeller (possible with the BASIC Stamp, but not as straightforward). I use the SX all the time and have just created a new SX-based commercial product (prop controller) that has a serial port and a PC slave mode.

    This is an old article but will show you how; of course, you'd want to update the code and create a protocol that suits your GUI
    -- www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol6/col/nv125.pdf

    I think the Express Edition allows serial control -- Jan Axelson wrote an article on VB.NET an serial control of microcontrollers last May (also in Nuts & Volts). I downloaded her program (from www.lvr.com) and connected it to an SX running a program I wrote to duplicate what she was doing with a PIC.
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2009-03-09 16:16
    Tony,

    most of my commercial applications today are the combination of an SX-based hardware, and a PC with a GUI, "talking" to the SX unit via RS-232.

    Usually, I write my SX code in assembly, and to create the PC GUI, I use VB 6.0. I'm not familiar with the Visual C# Express Edition, so I can't tell if it supports serial COM ports but I think it should.

    On the SX side, a serial receiver/transmitter requires just a couple of code lines in assembly. When you use SX/B, it is just the SERIN/SEROUT commands.

    Normally, I use some "home-brew" protocol for communications. For example, the PC sends a specific command character, eventually followed by a sequence of parameter bytes, and the SX unit sends back an acknowledge character, like an "O" for Ok, eventually followed by a sequence of parameter bytes. In critical applications I usually include checksums in the parameter sequences so that both units can detect communication errors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • Tony StarkTony Stark Posts: 3
    edited 2009-03-10 00:53
    JonnyMac: thanks for the help. I actually own Jan Axelson's book "Serial Port Complete: 2nd Edition". That book introduced me to MS Visual C# Express. I feel there is a long long learning curve, but I take things one step at a time. (I just got the book last month). Thanks for the website link to her site.

    Guenther: Wow...did you say you have "commercial applications"? That's serious stuff! I'm doing this as a hobby, but my job can use a lot of help from PC's talking to a micro that is monitoring valves, motors, meters, etc. Ultimately, I want to create a presentable GUI on a PC with the micro sending info. (data acquisition) to it. In the end, my program might replace a few employees...I wish them well in their new jobs--he-he!

    I am very pleased to hear that this is not only possible, but as you both say, very easily accomplished. I am on my way to getting started. Thanks.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-10 01:10
    I've attached a demo to get you going -- connect it to a terminal and give it a try. These are the routines that I use in my projects and products, like this:
    -- www.efx-tek.com/php/smf/index.php?topic=994.0
  • uptonryanuptonryan Posts: 28
    edited 2009-03-22 03:04
    Jonny Mac,

    I tried your code but I got three compile errors.

    Line 234 Invalid number of Parameters
    Line 239 Invalid number of Parameters
    Line 405 Unknown command STR

    Ryan
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-22 09:29
    You need to upgrade SX/B to 2.00.16 -- see the sticky thread at the top of the forum.
Sign In or Register to comment.