Shop OBEX P1 Docs P2 Docs Learn Events
Communicating with a PC — Parallax Forums

Communicating with a PC

dphensdphens Posts: 10
edited 2011-04-15 20:23 in Propeller 1
Hi all,

I don't have a propeller yet, but I am hoping someone can give me some simple examples of how a Propeller could communicate with a PC over TCP or UDP. One example of what I want to do is having a command sent to a PC whenever I press a button or toggle a switch.

I am very new to this, so I hope what I am asking makes sense. :)

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-04-13 09:23
    @dphens

    Welcome to the Propeller, (and the forums)..

    Question: What type of connection do you intend between the Propeller and your PC? A serial (programming) connection is already present which you could use readily. An Ethernet connection might lead you toward the Spinneret product which is a combination of Propeller and Ethernet.

    OBC
  • dphensdphens Posts: 10
    edited 2011-04-13 10:18
    Question: What type of connection do you intend between the Propeller and your PC?

    That's one thing I am trying to determine. I know that I can send commands to the software using a TCP address/port or by UDP. I don't know from where (USB, Serial, ethernet) I would be sending them at this point. Can a USB or Serial port send to TCP or UDP?
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-04-13 10:46
    Can you share a bit more of what you are trying to accomplish?

    OBC
  • dphensdphens Posts: 10
    edited 2011-04-13 18:56
    Sure. I'm into aviation and one of my hobbies are flight simulations. I want to "build" an interface that would allow me to use real controls to send and receive commands from a simulation. A few examples would be 1) toggling a switch to turn on/off lighting, 2) having LED's illuminate to indicate warnings, etc., 3) using a rotary encoder to tune a radio frequency. Does that give you enough info to tell me if it's possible?

    Being completely new to microcontrollers and programming, I am having a hard time determining on my own if this possible with the Propeller. If it is, I am willing to purchase one and invest the time needed to learn how it all works and how to accomplish this project.

    Thanks!
  • bennettdanbennettdan Posts: 614
    edited 2011-04-13 19:20
    dphens,
    What simulation software do you have?
    I have some RC (Radio Control) flight software that I have done simular things with in the past.
    Their are a few options that you can do to make this work on option is have real world switches and indicators wired to your Propeller and have it send the signals to the PC via most any communication but USB would be rather easy to do if its setup as a virtual serial port on the PC side.
    The PC could have a background program running that when the Prop sends it data it could issue your simulation software keystroke commands just like you was pressign the buttons on the keyboard.
    Also some simulation software allows remoting via a custom software program and the keystroke method is not needed. let us know what the sim software is and we might be able to help more.
  • dphensdphens Posts: 10
    edited 2011-04-14 07:34
    bennettdan wrote: »
    dphens,
    What simulation software do you have?

    I currently use Microsoft's Flight Simulator and Eagle Dynamics A-10C Warthog sim. Both allow input and output but in different ways.
    Their are a few options that you can do to make this work on option is have real world switches and indicators wired to your Propeller and have it send the signals to the PC via most any communication but USB would be rather easy to do if its setup as a virtual serial port on the PC side.

    That's exactly what I'd like to do. :) My main focus is the A-10c sim at the moment and it uses LUA for sending and receiving these signals (something else I am learning about).
    The PC could have a background program running that when the Prop sends it data it could issue your simulation software keystroke commands just like you was pressign the buttons on the keyboard.
    Also some simulation software allows remoting via a custom software program and the keystroke method is not needed. let us know what the sim software is and we might be able to help more.

    I think either of these would work, but the second option using some custom software would seem most flexible. I have learned that the sim is using a LUA interpreter to send/receive data over a TCP port. I am still trying to learn and understand the specifics about this as well.

    I am a bit over my head in all of this, but hope to determine if it's possible and then learn about all the pieces needed to make it work.
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2011-04-14 17:06
    To communicate with the PC, you probably know that you need the FullDuplexSerial object that is by default installed with Propeller Tool v.1.6 or higher. I assume that you have worked with PC software, like Visual Basic, but if you need some help getting the serial communication working between the propeller and the USB port, you can check out this tutorial I wrote last year on it: http://microcontrolled.com/VBSerialTerminalTutorial.pdf (I'm assuming you run Windows).

    I'm not really sure how much of a "beginner" you are, so sorry if this is all simple stuff to you. :-)
  • martinhmartinh Posts: 58
    edited 2011-04-14 17:34
    It seems that Eagle Dynamics uses Lua as an extension language. In principle it should be possible to communicate from the Lua scripting language with a serial port.
    http://luaforge.net/projects/luasys/
  • dphensdphens Posts: 10
    edited 2011-04-14 18:54
    I'm not really sure how much of a "beginner" you are, so sorry if this is all simple stuff to you. :-)

    I am a complete beginner really, so thanks for the link to the tutorial! I'll be going through that. I did code a couple very simple programs in VB years ago, but I've forgotten everything I had learned, so I am starting all over.

    martinh - yes, that is my understanding. Thanks for the link!
  • bennettdanbennettdan Posts: 614
    edited 2011-04-14 20:33
    dphens,
    I found that the Eagle Dynamics Sim software on startup actually start a file called Export.lua which allows the sim software to export/import its data from a socket connection.
    Nowing that you could use the propeller to send data over a USB-Serial connection to say a custom VB.net program that would then allow you to pass that info to a TCP/UDP socket connection to the Eagle Dynamics Sim software.
    One cool option with the custom Vb.net program you can add mutiple monitors like the real bird you are simulating and the extra screens could be setup as a moving map display or even use a touchscreen monitor skys the limit.
    Or you should be able to use the Spinneret Web Server and make a connection directly with the ED Sim software
    You might not be aware what the Spinneret Web Server is it is a Propeller board that allows ethernet comunication.
    Example to set your rudder to the right .5 is like this
    LoSetCommand (3, 0.5)
    You should be able to use a terminal program like hyperterminal to setup a socket connection and send the above command to the Sim software to test the commands out that you want.
    If you need a list of commands let me know I will help as much as I can.
  • dphensdphens Posts: 10
    edited 2011-04-15 06:21
    Thank you very much bennettdan!! Although I have quite a bit to learn, it sound likes it is possible to do it. I think I'll go ahead and purchase one of the Spinneret boards so that I can start experimenting. I like the idea of connecting directly to the sim software. That might be an easier option for me at this point.

    Thanks again! If you don't mind, I may PM you about the command list once I reach a point where I need that. :)

    Dave
  • bennettdanbennettdan Posts: 614
    edited 2011-04-15 11:18
    Dphens I don't mind a pm if you need the list I have an interest in your project I have always wanted to build a home simulator that had a moving platform and force feedback control sticks
  • Computer Geek 101Computer Geek 101 Posts: 179
    edited 2011-04-15 12:41
    I have just completed a material control system. It uses a propeller with an xport. It uses TCP to connect to a windows service written in VB.net 2008. Im going to post the project in a few days.
  • dphensdphens Posts: 10
    edited 2011-04-15 17:00
    I have just completed a material control system. It uses a propeller with an xport. It uses TCP to connect to a windows service written in VB.net 2008. Im going to post the project in a few days.

    Great! Looking forward to seeing that!
  • dphensdphens Posts: 10
    edited 2011-04-15 17:01
    bennettdan wrote: »
    Dphens I don't mind a pm if you need the list I have an interest in your project I have always wanted to build a home simulator that had a moving platform and force feedback control sticks

    Thanks! My project won't have a motion platform, but I do hope to eventually have working guages. :)
Sign In or Register to comment.