push button on 7-inch touch screen to send some strings through the serial port.

Dear all,

I’m a complete newbie in this community. As a postdoc, I’m responsible of building a off-computer control system. I decided to use BeagleBone as the central controller. But since I have other academic jobs, I wish I could finish the project quick and dirty. So maybe I need some specific guidance on it.

Now for the first version of the system, my idea is just have two buttons appearing the touch screen and when I press either of the buttons, the BBB will send out a string through the serial port. I have another device waiting for the string command to trigger some control, so the rest is already ready.

I think this is rather easy, isn’t it? But I spent about a whole day today trying to figure out how to send the string out, and still cannot be successful. Not to mention the touchscreen part. I have experience in Matlab and LabVIEW programming, a little C experience, no Javascript or Python, and now I have a BBB, a 7-inch touch screen, a USB cable, and a 5V 3A power supply. I can make the serial port with connectors to the board with no difficulty. I have tried to boot the board with the 5 power supply and the LCD screen hooked up, and I could see the operating system. So could anyone tell me how to step into this field with a relatively quicker method? Thanks!

Sincerely,
Henry

did you want to use soft buttons (buttons generated on the touchscreen as needed in software) or hard buttons (buttons on the display that consist of an actual hardware switch that causes a detectable contact closure) for this? For the soft buttons I’d look at Qt. For the hard buttons, look at how the beagle can edge detect an input and generate an interrupt based upon that. I’d be happy to look a bit further once you have an idea which direction you want to go.

Eric

Dear Eric, thanks for the reply! I’m planning to use soft button, not the hard button. Because in the end, I will end up adding many soft buttons with different names that can send different strings to the next device through serial port.

Now I have very rookie questions:

  1. I have connect the BBB to the computer, and I have opened the webpage of http://192.168.7.2, and can perform the scripts on the webpage text box; I have also opened Cloud9 IDE (http://192.168.7.2:3000/) and performed some programs. But I noticed that the Cloud9 access some path that the USB disk cannot find. My question is, how to get to the beagle# status before entering any command to modify the configuration of the serial port? From the terminal of the computer? Or Cloud9? Or webpage test box?
  2. It seems that when I connect the BBB to the back of the touch screen and turn it on, the board enters a system with touch control. So I suppose that I should run some GUI (some soft buttons) program from that system, instead of from computer via a USB cable. How to do that?

Now I’m reading the book “Bad to the Bone: Crafting Electronic Systems with BeagleBone and BeagleBone Black”. It’s a very good book, but the progress seems to be too slow. I hope I could finish this by this weekend. But based on my background, there seems to be some barrier I should conquer first. So I really need some expert like you to instruct a little bit. Look forward to your reply. Thanks again.

Henry

在 2015年6月12日星期五 UTC-4下午3:43:14,Eric写道:

As a quick hack, the hard button(s) may be easier with less code, but you are right, using the soft button approach with software based menus is much more flexible. With the touchscreen attached, the beagle starts running it’s display on the touchscreen and enables the touch interface as if it were a mouse. what you will likely want to do is when the system starts have it start your button menu interface. that program will be the main thing the user sees and by pushing certain buttons in the menu you create each button causes a software action or conversely a software routine can bring up a window or button.

take a look at the following to get you started:

https://en.wikipedia.org/wiki/PyQt
https://wiki.python.org/moin/PyQt
https://en.wikipedia.org/wiki/PySide
https://en.wikipedia.org/wiki/PyGTK
https://en.wikipedia.org/wiki/WxPython
https://en.wikipedia.org/wiki/Tkinter

https://www.youtube.com/watch?v=53oeJPKRttY
https://www.youtube.com/watch?v=fqK8N48kPXs
https://www.youtube.com/watch?v=0vvb7Kv59qA
https://www.youtube.com/watch?v=8D_aEYiBU2c

within python you ought to be able to use the python serial library and one of the above libraries/toolkits to get your buttons working. i.e. push software button, execute routine that spews string over serial, return to menu.

Eric

Dear Eric,

Thanks for all the information! I will read all the articles and videos. Now I have a small problem. I followed the video to map an image of Angstrom on my SD card, and boot the BBB with this system. However, when I try to connect the BBB to my mac through USB, the ip of the BBB won’t be assigned automatically (it shows “self assigned IP”, 169.254.51.158). Also I cannot ssh to it from Terminal. So I cannot get the control of the BBB from my computer. Do you know how to solve it?

Thanks!
Henry

在 2015年6月12日星期五 UTC-4下午10:46:34,Eric写道:

If you Google “Beaglebone latest images” you will see that the OS of choice (and best supported) is Debian.

I suggest that you flash that image to your uSD card.

Dear Eric,

It turned out that If I restart the BBB, the DHCP will work normally. Don’t know the reason, but at least I know how to solve this problem. Now I can SSH to the BBB as root from terminal.

What you described is exactly what I expected: whenever I turn on the BBB, after the system logs in, the program I write will pop up automatically, and occupy the whole screen as a full screen software. On the window there are several buttons, aligned in a clear manner for end users. When one of the buttons is pressed, a series of strings will be sent out as commands to the next device connected to the BBB via serial port cable.

The software doesn’t have to have any further functionalization, just if the end user finishes using, instead of turning off the system by unplug the power cable, it’s better to have a button act as shut down the operating system.

I have searched over the internet, and the only teaching video I can find is this link by Derek Molley : http://derekmolloy.ie/beaglebone/qt-with-embedded-linux-on-the-beaglebone/. However, in the videos he used C++ and he used an old version of Angstrom image, and I’m facing some difficulty in installing the Qt4-embedded in the newer version of the kernel. And I cannot boot from the same kernel he was using in the video. So basically I cannot follow his instructions.

I’ve already installed the Qt environment on my desktop computer, both Mac and Linux. I agree that PyQt seems to be good for GUI programming, and I believe after some effort I could build a GUI on my desktop computer. But I don’t know the relationship between the software on desktop and BBB. How to run the same program on BBB and control the serial port? Is there any teaching video about how to do PyQt on Beaglebone?

I’d appreciate any comments. My weekend is turning over.

在 2015年6月13日星期六 UTC-4上午9:00:41,Henry Yongfan Men写道:

Dear Will,

Thanks for the suggestion. Now I know how to flash the image to the µSD card. It’s just I don’t know what to do with Debian. Do I need to install any package to let Debian to support Qt? Thanks.

在 2015年6月13日星期六 UTC-4上午10:51:33,William Pretty Security写道:

Hi Henry,

Did you ever get something going?

I just received my BBB with Debian and 4D Systems 7" LCD cape.

All I want my app to do is display a few soft buttons that control some gpios. I also want the BBB to boot into my app automatically at startup.

I just downloaded QT Creator on my Win7 PC, and was hoping there’s an example program that I can cross compile for the BBB and be off and running within a few hours. Does not seem like the case. Is cross compilation even possible from Win7 PC for BBB target?

Ideally I do not want to use a uSD card with some other Linux version to make this work. I’d like to just send a binary to the BBB running the pre-installed Debian and have it work without much reconfiguring.

If you or anyone else can shed some more light on this that would be much appreciated. Thanks.

I just downloaded QT Creator on my Win7 PC, and was hoping there’s an example program that I can cross compile for the BBB and be off and running within a few hours. Does not seem like the case. Is cross compilation even possible from Win7 PC for BBB target?

Cross compiling QT can, and will be quite a daunting task for the inexperienced. I can tell you that I have experience in several programming languages, and compilers since around '93, and I’m not sure I could do this. Or if I could, I know it would be a difficult task.

Honestly though, short of the possibility of someone already having gone through the process, who frequents this google group. This question is best asked of the QT project maintainers. That is, for the QT specific questions. As for the rest . . . Toggling GPIOs should not be too hard to do. I have not done this myself to date, but there are many blog post on the web covering the subject. Using SYSFS, mmap, and bonescript, just to name 3 ways.

Ideally I do not want to use a uSD card with some other Linux version to make this work. I’d like to just send a binary to the BBB running the pre-installed Debian and have it work without much reconfiguring.

So you propose writing a binary for an ARM + Linux target on Windows ? This may be possible, but really is asking for trouble. Let me clarify. I use Windows on a daily basis. All my desktops run some form of Windows from Win 7 on up. Having said that, I would not dream of doing the above. Perhaps “dream” is also the wrong word. “Nightmare” would be more like it.

Hate to burst your bubble, but if you want to develop for the BBB, running Linux. You’re going to have to learn, and use Linux as a development tool. It may take some time sure, but that is nothing compared to the troubles you’re very likely to run into when developing software on Windows for the BBB running Linux. Just for starters: If you run into a problem that is specific to a Linux API / library. How would you know what to look for ? OR How would you even use the linux-header files for your specific kernel?

Anyway, it is not impossible, but trust me it is more headache than it’s worth. That, and you’d probably be spinning your wheels indefinitely, when instead you could simply setup a Linux machine in hardware, or virtual machine, and be long done with all that.

Another option I did not mention is developing natively on the beaglebone. There are also ways to keep from ruining flash media in the process as well. Such as using a rootfs mounted over a network, or a rootfs mounted from a USB hard drive. Self powered of course.

William, thanks for taking the time to answer. I’m using TightVNC to remote to the BBB, so native development is a go.

How would flash get ruined? So do you mean having a secondary rootfs? Is it possible to have the rootfs on an sd card and everything else running from eemc as-is?

So back to the original question: what is the best/easiest/quickest way to create a simple gui with a few soft buttons controlling a couple gpios and talking to the adc? Is there any sample code for the BBB running Debian?

Dear Frank,

Sorry I didn’t reply soon because my wife has just given birth to a baby girl last week, so I was busy with life and stuff.

Yes I think I’ve gotten what I wanted. Now the LCD touch screen is working, and serial command could be sent to outside.

I got stuck about several weeks ago, then I bought this book by Derek Molloy. I was in a rush so I drove to Barns & Noble and picked up the book right away, although it was a lot cheaper to buy the book online…

Then my progress got leaped. The book taught me how to connect to the BBB via SSH or serial connection, how to do internet-over-usb, how to install the Qt Development Tools on the BBB, how to run VNC viewer, and run the example program. The sample program on page 448 really helps me. From the attached image you can see my program is based on this sample (press any of these large soft buttons, and some hardware will start moving!). So if you really want to make progress, maybe buying this book is the easiest way, because all the information is well organized in this book. Plus you can get access to many resources from the website accompanied with the book. I’ve wrote to Derek Molloy, and got some reply also, which makes me feel rather good.

With VNC viewer, you can literally connect to the ‘remote desktop’ onto the BBB from any operating system. I’ve done this from windows, mac os, and linux. Now I’m even using BBB with my new chromebook! With VNC, you can run GUI programs as if it’s run on the touch screen, but with much more convenient way, because you can type in the letters with actual keyboard. And the resolution from VNC is actually higher than that from the touch screen (See the second attached picture).

Another important thing is you should connnect your BBB to the internet. This could be done by internet-over-usb, which is a piece of cake on Windows and Mac OS X, a little pain on linux. Also you could simply plug the net cable on, or use a supported wifi adapter to go wireless. With internet, you can set your current time right, and install all the necessary packages on line, including the Qt environment, which is the essential for the GUI development.

So my suggestion is, 1) get the book, 2) get VNC and internet working on the BBB, and 3) try running the sample program on BBB following the guidance from the book, and boom! you are a brand new expert.

Best, Henry
IMG_1561.JPG
IMG_1563.JPG

William,

I don’t know anything about compiling Qt, but I think what Frank and I wanted is not that complicated. And I’ve succeeded (at least I believe so). See the image I attached in the previous post? The BBB is running a customized GUI, and if I press any of the large buttons at the lower part of the screen, there is going to be a change (GPIO, or serial connection) happening.

And I’m no expert in programming, not even electrical engineering. I’m majored in mechanical engineering and I’m doing research in bio-medical-engineering. The reason I want to use BBB is this could make my biology experiments easier. And this doesn’t require a very professional programming expertise. All one needs to do is finding the right book to read, and try by oneself. There is still very little information about Qt on BBB online, but I believe there will be more gradually. So William, please stop being a devil’s advocate, and let’s solve the technical problem instead.

Best,
Henry

Frank,

Again the easiest way to do so is like my way: use VNC to remote to the BBB, run the Qt sample program for the first time, and if that works, you can start messing with the mainwindows.ui and mainwindow.cpp, and see if you can add the function you want to the program. The Qt Designer could be run natively on the BBB.

I don’t know if it’s legally permitted to expose any content of the book I mentioned here, but Frank if you want, we can communicate privately, and I am willing to share everything I could to you, trying to get your purpose realized.

Cheers,
Henry

I think William is right about developing natively on the beaglebone. The GUI design could be done from other desktop and copied to BBB, or done natively. So are the cpp files (if you are using C++, I don’t know how to do other languages like Python or bonescript). But all the program files (to me there are only four: mainwindow.h, mainwindow.cpp, mainwindow.ui, and mian.cpp) should be kept together into a single folder (the folder’s name should be the project’s name), and compiled and built by very simple command as follows: 1) qmake - project; 2) qmake; 3) make.

Henry, many thanks for the info and congrats on the new addition to the family!

Some of the pages of the book are available online and the example section at the end is exactly the example I was looking for. I went ahead and ordered it off Amazon Prime.

Looks like installing QT4 and QT developer is all you really need on the BBB to be able to run some quick GUI examples. This is great news!!!

I hope to have something running this weekend. Once again, thanks for your time and I hope you get some sleep in the coming weeks :wink:

Frank, thanks. The ‘good sleep’ really sounds ancient to me. But I love my wife and daughter, so everything that is in trade is worthy.

Anyway, I’m glad that you feel more on track now. Let me know if you have any further questions (especially questions in detail) so that we can discuss and grow together.

I’m also rookie in dealing with this little guy, but I’m confident that eventually both of us could be an expert on that because it’s really a useful little thing. And FYI many start-ups are using BBB as the embedded systems in their products. For example, openqPCR <http://beagleboard.org/project/openqpcr/>. See the touch screen on the machine panel? We can do that soon, too!

Have you read about a book that you can build a high-end home security system out of this BBB? I’m gonna do that when I build my own house in the future. I will.

Henry

I think William is right about developing natively on the beaglebone. The GUI design could be done from other desktop and copied to BBB, or done natively. So are the cpp files (if you are using C++, I don’t know how to do other languages like Python or bonescript). But all the program files (to me there are only four: mainwindow.h, mainwindow.cpp, mainwindow.ui, and mian.cpp) should be kept together into a single folder (the folder’s name should be the project’s name), and compiled and built by very simple command as follows: 1) qmake - project; 2) qmake; 3) make.

Well more exactly compile natively. But I think you got the idea. As for the devils advocate “thing” I know what I would have done, and it probably had nothing to do with what either of you were trying to accomplish.

So what I would have done - Is that I would have forgotten about the LCD, and tossed together a Nodejs app, and had the GUI on a remote web browser page. Honestly I really do not care for javascript much, but if I needed a super quick proof of concept - that probably would have been the easiest route for me. For you two . . . no idea.

Anyway, like I said, that does not sound like the direction that either of you wanted to go.

Dear William,

I think we still need some experts like you to guide us on to be on the right track. Because the deeper we go in, the more difficulties we are likely to encounter. And sometimes we have to step back, and start from the fundamentals. Because the coding is not that easily picked up from sideways.

For example, now I’m facing two difficulties:

  1. I need my BBB to communicate with a device that has a Serial-USB chip, which means that the only physical connector is USB. Is it possible to use a USB cable to connect the BBB to that device and use serial command to communicate? Does BBB need to install any drivers to recognize this serial-USB chip?

  2. When coding the GUI program, I need multi thread functions. For example, some of the buttons doesn’t work when I press one of the buttons ---- becasue the sub function when the button is pressed is being called, and the whole program is waiting for it to finish. But I need to have at least an emergency stop button. I don’t know what is the easiest way of doing so.

Please, if you would, share some of your ideas. Anything would be appreciated. Thanks!

Best,
Henry

在 2015年7月27日星期一 UTC-4下午6:13:43,William Hermans写道: