PDA

View Full Version : Writing interface software for PC to microcontroller



Cobalt
03-26-2007, 05:12 PM
I've been wanting to learn this for a while, I just never took the time to try and heavily research it, but I'm hoping to tap into the oceans of information from the users here.
Simply(hopefully) put, I want to be able to write a simple, windows-based program that will use a port on the computer to interface to an external circuit.
For example, write a program that is just a small window with a button in it that each time you press it, a line of code is sent to the RS232 port, which will be read in by a propeller (or other uC), and the microcontroller will respond to the code by making a stepper motor make a step (or whatever you want).

I'm not sure what language or IDE to use for making something like this. I'm also not to sure how detailed this can get. Any help will be appreciated!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
while alive = 1
wakeup
program(propeller)
eat(3)
sleep(7)

Loopy Byteloose
03-26-2007, 05:40 PM
Currently I am using a free program called Terminal.exe that is quite good. Unlike Hyperterminal, it splits into two sections -- received and sent.

But I want to be able to have a seamless application that uses the RS-232 port. So far, it seems like only Microsoft provides an logical alternative - Visual Basic.

I really dislike Visual Basic as it is quite unlike Parallax Basic and has a fairly steep learning curve. One could turn to Java or C if one has prior knowledge. But I don't.

So I am currently fooling with Win32Forth to see if I can get an RS-232 port involved. They have a Yahoo group and the software is free. It really is easy to use in a Windows environment and compiles a complete executible program.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.и Not enough?и Eat the manual."ииииииии


ииииииииииииииииииии Tropical regards,иииии G. Herzog [и黃鶴 ]иin Taiwan

Loopy Byteloose
03-26-2007, 06:26 PM
BTW
I just located a Win32Forth 'word' [the equivalent of a subroutine or function] that appears to support the serial port.

Try WINSER.F in the Win32Forth lastest free version. There is also a parallel port word - WINPAR.F

I have high hopes that this will provide a lot of utility and the software is FREE!!!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.и Not enough?и Eat the manual."ииииииии


ииииииииииииииииииии Tropical regards,иииии G. Herzog [и黃鶴 ]иin Taiwan

steve_b
03-26-2007, 08:06 PM
Hmmm...I'll have to look at WIN32FORTH.

Python is also free....any thoughts on using it? I've downloaded the manual but haven't had the time to really get in to it!

cheers

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
и

Steve

"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."

crgwbr
03-26-2007, 08:33 PM
I'm used Python for a very similar task right now. You can download Python 2.5, the win32all module, and the USPP (Universal Serial Port Python Library) all for free. It took me about a day to get a full blown GUI written for a task significantly more complex that what your suggesting. You can use the tKinter module for the GUI development, I attached a few sample programs so you can see how it all works. Anyway, accessing the serial port with USPP is as easy as:



from uspp import *

print "Stopping..."
tty = SerialPort("COM6", 1000, 9600) #Open Serial Port Com6, 1000 mS timeout, 9600 baud

tty.write("o") #Write "o" to Open Port

Acknowledge = tty.read() #Read serial port, assign to variable 'Acknowledge'

if Acknowledge == "k": #Make Decision
print "Stop Successful"

else:
print "Stop Unsuccessful"



Hope you get everything working,
Craig

P.S. To open the Python Files, you must have Python installed. To see the code behind them, right click on the file and select 'Edit with Idle'

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
NerdMaster
For
Life

Loopy Byteloose
03-26-2007, 09:14 PM
I really had not considered PYTHON as I have never even looked at it. Mostly, this is about making a choice that you feel comfortable with. Of course it really helps to have a completely free compiler so that you can make an application that is user friendly for 'non- computer geeks'. You just mouse on an icon, bring up the window, and make your choices accordingly.

Also the GUI can have the menus and dialogue. If you using a single or two byte communication code to the BasicStamp, you have a lot more EEPROM for actual control applications. DEBUG requires you write the menus into the BasicStamp.

Originally, [circa 1984] I was quite interested in FORTH, but it lacked a Serial Port interface - so I gave up on it. This is a much more evolved form. But still, I think it easily does complex math functions with ease - charts too.

WIN32FORTH is a larger dictionary [thousands of words] so it may take longer to comprehend and get something initially useful. The WINSER.F is there in the package, but not automatically installed. It needs to be added in and complied to become operational. That is a useful exercise as sometimes you don't need all the bells and whistles.

And of course, there is a user group. Maybe in a few days I will have a GUI linked to a serial port. It really would be nice to have my devices able to have their own window that is formated to the applications I/O.

I believe the site is win32forth.sourceforge.net/ and I have the latest stable version - ver. 6.10.05

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.и Not enough?и Eat the manual."ииииииии


ииииииииииииииииииии Tropical regards,иииии G. Herzog [и黃鶴 ]иin Taiwan


Post Edited (Kramer) : 3/27/2007 5:29:20 PM GMT

Kevin Wood
03-26-2007, 09:48 PM
Here's a thread that has some gui examples in VB.Net, C#.Net, and C++.Net:

http://forums.parallax.com/showthread.php?p=607328

Here is a thread with a TCL example:

http://forums.parallax.com/showthread.php?p=630273

The TCL sample is command line, but can be made into a gui with TK.

T Chap
03-26-2007, 11:20 PM
Included is a REALbasic file that does just what you want. It is shown as OSX, but if you go to realbasic.com you can find a PC demo, it will load the file posted and you can test it out. I haven't used Python, so I can't compare it. I really like REALbasic though, there is a pretty good forum for it where you can get answers really quickly, the tuturials are great too. I use if for GUIs for Propelller projects all the time.

This app looks terrible, it is just a serial port tester, you can get as fancy as you want with the program and graphics.

The command to write a string to the serial port using the User Defined button shown is as simple as this:




Dim OutputString As String
OutputString = "1" 'change this to your string
Serial1.Write outputString


Post Edited (TChapman) : 3/27/2007 6:15:36 PM GMT

Unsoundcode
03-27-2007, 05:09 AM
Hi Cobalt, when I was wanting to create a GUI to go with a Stamp I didn't realise there was so much choice. I had an old copy of Visual Basic so thats where I started. Then I downloaded and started using VB Express when I discovered it was for free.

Like Kramer says it is unlike Parallax basic but what helps are the thousands of examples and what they term "walkthroughs"иwhich makes learning easier, so VB express is what I use.

I don't know a lot about the other programs but if I wasn't into VB I might opt for Real Basic from what I have seen the graphics of the interface look good.

I am not an expert with Visual Basic but if I can give you a few pointers that might help let me know.

Jeff T.


this is myиSS of a two servo controllers with 6 switches used as inputs or outputs.