I am trying to create a GUI app using Qt 4 to control the pwms on the RC. I have no clue how to integrate serial port communications into it. Could someone lead to an article or software that can help with this? I have no clue where to even look.
I have a question about the serial ports programming.
I am trying to connect an LCD module to the mini RC for creating a GUI that will help control the robot systems while testing and operating the robot (which will later be implemented on our FRC robot).
Problem is i am not a very knowledgeable programmer yet, and I have no idea how to send simple text to the LCD. For example
“To run motor test press 1
To run shooter test press 2”
(That is just an example. obviously we are aiming to have an entire interface to test all the subsystems, get information from batteries, sensors etc.)
If someone could help me with this I would really appreciate it.
What kind of LCD do you have and what kind of serial communication does it use (TTL, RS232, TTL-inverted)?
What serial options does it have?
I took a quick look at that code sample of Kevin’s and as it is currently configured it expects your LCD to be TTL-inverted, running at 2400 BAUD, and hooked up to digital input 1 (although there seems to be some discrepancy in how that digital input is configured - you might want to fix that).
If you are doing this on Windows why aren’t you using .NET 2? It has serial I/O built in.
Maybe a better question would be if you are going to run this on Windows why are you using Qt? If the goal is to make this cross platform you might want to look at mono and glade, but each platform will still have different serial code.
Can you refer me a resource/article on .NET 2 that I could get started with?
No, I don’t need a cross platform program but Qt is the only program that I have found to date that has a simple, straight-forward interface. Do you have any better suggestions for creating windows GUI?
Edit: I am currently downloading Visual C++ Express with .NET 2 Framework. Is this what you had in mind?
I was writing a replacement for IFI Loader awhile back.
It’s written in Qt (Qt3, however) and should compile for both windows and linux. I used some compiler directives to detect the platform and use the appropriate pieces of code. Look for the files called serialio.cpp and serialio.h in the “loader” folder. It’s a class with functions to send and recieve data via the serial port. You should be able to use it as a starting point.
I have to warn you though that I have yet to figure out why it doesn’t work on Windows XP. As far as I can tell, my code is correct. When I compile it, I don’t get any errors. Interestingly the same binary will run correctly on Windows 2000 and WINE, but it will freeze on Windows XP.
For one thing I am using Qt 4, which seems to be quite different for Qt 3 form everything I have read. I still have to figure out how to pull the data form the sliders so I can send it in a struct over the serial port. As you can see I am new to this stuff so I am going to try Visual C++ and .NET 2(hopefully they will make life easier) but thanks anyway.
You can use VC++, but I use C#. You need to look at the System.IO.Ports namespace on MSDN. You are going to want to use the SerialPort class. A couple of examples (in C#) can be found here.
As for the UI, the windows System.Windows.Forms library is very easy to work with and has lots of controls. You can use the Trackbar control (which is the slider) to get input values and then send them to the RC with the serial port.
First I would like to say thanks to everyone that helped. I just downloaded C# and it seems quite promising for me (a beginner). I am currently playing with it and we will see how far I can before I have questions again.