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

156 views
Skip to first unread message

Henry Yongfan Men

unread,
Jun 12, 2015, 3:32:36 PM6/12/15
to beagl...@googlegroups.com

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

Eric Fort

unread,
Jun 12, 2015, 3:43:14 PM6/12/15
to beagleboard
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

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Henry Yongfan Men

unread,
Jun 12, 2015, 5:33:59 PM6/12/15
to beagl...@googlegroups.com, eric...@gmail.com
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写道:

Eric Fort

unread,
Jun 12, 2015, 10:46:34 PM6/12/15
to Henry Yongfan Men, beagleboard
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

Henry Yongfan Men

unread,
Jun 13, 2015, 9:00:41 AM6/13/15
to beagl...@googlegroups.com, eric...@gmail.com, henr...@gmail.com
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写道:

William Pretty Security

unread,
Jun 13, 2015, 10:51:33 AM6/13/15
to beagl...@googlegroups.com

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.


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.5961 / Virus Database: 4355/9986 - Release Date: 06/10/15

Henry Yongfan Men

unread,
Jun 14, 2015, 3:51:12 PM6/14/15
to beagl...@googlegroups.com, eric...@gmail.com
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写道:

Henry Yongfan Men

unread,
Jun 14, 2015, 3:53:07 PM6/14/15
to beagl...@googlegroups.com
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写道:

Frank Rizzo

unread,
Jul 26, 2015, 2:12:56 PM7/26/15
to BeagleBoard, henr...@gmail.com
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.

William Hermans

unread,
Jul 26, 2015, 6:40:24 PM7/26/15
to beagl...@googlegroups.com
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.

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

--

William Hermans

unread,
Jul 26, 2015, 6:44:56 PM7/26/15
to beagl...@googlegroups.com
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.

Frank Rizzo

unread,
Jul 27, 2015, 9:51:59 AM7/27/15
to BeagleBoard, yyr...@gmail.com
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?

Yongfan Men

unread,
Jul 27, 2015, 2:39:25 PM7/27/15
to Frank Rizzo, BeagleBoard
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 <Exploring BeagleBone: Tools and Techniques for Building with Embedded Linux> 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



--
门 涌帆 (Men Yongfan),  PhD
BIOPIC building   Peking University
+86 18611230987
+86 10 62758323
henr...@gmail.com

Yongfan Men

unread,
Jul 27, 2015, 2:51:06 PM7/27/15
to BeagleBoard
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

You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/z1IBLEx9F5g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Yongfan Men

unread,
Jul 27, 2015, 2:56:45 PM7/27/15
to BeagleBoard, yyr...@gmail.com
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

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/z1IBLEx9F5g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Yongfan Men

unread,
Jul 27, 2015, 3:02:42 PM7/27/15
to BeagleBoard
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.

You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/z1IBLEx9F5g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Frank Rizzo

unread,
Jul 27, 2015, 4:41:36 PM7/27/15
to BeagleBoard, henr...@gmail.com
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 ;-)

 



Yongfan Men

unread,
Jul 27, 2015, 4:55:40 PM7/27/15
to Frank Rizzo, BeagleBoard
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

William Hermans

unread,
Jul 27, 2015, 6:13:43 PM7/27/15
to beagl...@googlegroups.com
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.

--

Henry Yongfan Men

unread,
Jul 29, 2015, 4:40:02 AM7/29/15
to BeagleBoard, yyr...@gmail.com
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写道:

Yongfan Men

unread,
Jul 31, 2015, 5:07:26 PM7/31/15
to William Hermans, BeagleBoard
Dear William,

The chip is Silabs CP2103. 

For standard usage, for example, if I plug the chip via USB cable to a Windows PC, then the OS will ask me to install a driver for the CP201X. After installing the driver, there will be a new COM port in the device manager. Then I can setup the baud rate for the COM port, and start using it.

But for Beaglebone Black, I don't know if there is a driver for this specific chip. So I thought this is not possible. But I found this: <https://fleshandmachines.wordpress.com/2012/05/05/beaglebone-and-usb-serial-converter/#comment-136>
In this post the BBB seems to be able to communicate through the CP2012 chip. So this gives me some hope. But I tried to connect the chip with the BBB with a standard USB cable, and there is nothing showing up when I cat the /dev/ttyUSB0.

Do you think there is a way? Thanks!

Best,
Henry

2015-07-29 12:56 GMT-04:00 William Hermans <yyr...@gmail.com>:
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?

I'd need to know which chip you're speaking of, and then will not necessarily have a better answer. With that said, it sounds like you'd  need a driver for the chip / device, and then you would communicate over / through this device via UART. There is however always libusb, but on the physical layer, it sounds as though you would still be communicating via UART anyway.
 
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.

Sounds like the called button press function is a blocking call. Perhaps refactor these functions to only set flags. Then run a tight control "loop", having the check done for button presses *first*. With priority on your emergency stop button check / code. With all that said. it may behoove you to read up on MISRA C https://en.wikipedia.org/wiki/MISRA_C, especially if this project has to do with human safety. Or MISRA C++ . . .

I think we still need some experts like you to guide us on to be on the right track.

Thanks for the vote of confidence ! However I would not consider myself an expert. Rather I'd consider myself a person who has perhaps had a good bit of experience with Linux. Then who has been programing since the early to mid '90's - As a hobby. Multiple languages, and mostly on Windows. Some bare metal( No OS ), and some Linux programming experience - I'm working on this now. I also do read *a lot* on various aspects related to programming. So perhaps I do know *of* many things, but have no practical hands on experience. Qt for example I've read quite a bit about, But only toyed around with in my own code. For a little while.
Reply all
Reply to author
Forward
0 new messages