[fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”1″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Introduction[/fusion_title][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=””]

This is the chapter web page to support the content in Chapter 6 of the book: Exploring BeagleBone – Tools and Techniques for Building with Embedded Linux. The summary introduction to the chapter is as follows:

This chapter integrates the Linux, programming, and electronics groundwork from earlier chapters to show you how to build circuits and write programs that interface to Beagle board single-wire inputs and outputs.

Learning about binary signals and programming can be difficult if you do it by yourself,  you can check Get Educated Online’s Review of Datacamp to see the positive outcomes of it, and start learning about coding and programming, it will be much easier to have an expert with you every step of the way so you can give this chapter a more profound outlook and have a better understanding with no issues.

In this chapter, you will see practical examples that explain how to use a general-purpose input/output (GPIO) to output a binary signal to switch on an LED, or to read in a binary input from a push button. Optocoupler circuits are discussed so that you can safely interface to externally powered circuits. Also included are the steps required to read in an analog input and to send out a pulse-width modulated (PWM) output. GPIO interfacing is first performed using sysfs to ensure that you have skills that are transferrable to other embedded Linux devices. Next, BoneScript and memory-mapped approaches are investigated, which are largely specific to the AM335x SoC. Finally, there is a brief discussion on the impact of udev rules and Linux permissions on GPIO interfacing.

[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”3_5″ layout=”3_5″ last=”no” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=””]

Learning Outcomes

After completing this chapter, you should be able to do the following:

  • Use a Beagle board GPIO to output a binary signal to a digital circuit, or read in a binary input from a digital circuit.
  • Write shell scripts and C++ code in order to control a Beagle board GPIO.
  • Describe the use of internal pull-up and pull-down resistors.
  • Describe the device tree model that is used to configure certain hardware on the Beagle boards and make minor modifications to the model.
  • Use a PWM pin to output an analog voltage or as a control signal for motors and certain types of servos.
  • Use an analog input to safely read in a value from an analog circuit, using an op-amp to protect the board from damage and/or invalid measurement.
  • Write C++ code, which utilizes advanced functionality, to efficiently read in a digital input using a custom GPIO
  • Use an advanced Linux configuration that allows for user-level control of the sysfs entries.

[/fusion_text][/fusion_builder_column][fusion_builder_column type=”2_5″ layout=”2_5″ last=”yes” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_text][toc][/fusion_text][fusion_sharing tagline=”Share this page:” tagline_color=”” title=”Exploring BeagleBone: Chapter 1″ link=”http://exploringbeaglebone.com/chapter1/” description=”” pinterest_image=”” icons_boxed=”” icons_boxed_radius=”4px” box_colors=”” icon_colors=”” tooltip_placement=”” backgroundcolor=”” class=”” id=”” /][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”1″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Digital Media Resources[/fusion_title][fusion_text]Here the digital resources referred to in the chapter web page. There are high-resolution versions of some of the key figures and links to important videos that are described in the chapter.[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent=”yes” overflow=”visible” margin_top=”” margin_bottom=”20px” background_color=”rgba(255,255,255,0)”][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_separator style_type=”shadow” sep_color=”#9b9b9b” icon=”” width=”” class=”” id=”” /][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_2″ layout=”1_4″ last=”no” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_separator style_type=”none” top_margin=”20″ bottom_margin=”” sep_color=”” icon=”” width=”” class=”” id=”” /][fusion_lightbox type=”” full_image=”http://exploringbeaglebone.com/wp-content/uploads/2019/01/533160-c06f009.png” video_url=”” thumbnail_image=”http://exploringbeaglebone.com/wp-content/uploads/2019/01/533160-c06f009-300×207.png” alt_text=”” description=”The BBB P9 and PB headers” class=”” id=””][/fusion_lightbox][fusion_separator style_type=”shadow” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” sep_color=”” top_margin=”” bottom_margin=”” border_size=”” icon=”” icon_circle=”” icon_circle_color=”” width=”” alignment=”center” /][fusion_lightbox type=”” full_image=”http://exploringbeaglebone.com/wp-content/uploads/2019/01/533160-c06f008.png” video_url=”” thumbnail_image=”http://exploringbeaglebone.com/wp-content/uploads/2019/01/533160-c06f008-300×234.png” alt_text=”” description=”The BBB P8 and PB Headers” class=”” id=””][/fusion_lightbox][/fusion_builder_column][fusion_builder_column type=”1_2″ layout=”1_2″ last=”yes” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=””]

BeagleBone and PocketBeagle Header Charts

Figure 6-8 and Figure 6-9 from Chapter 6 are available for download as a high-resolution PNG raster format using the following links:

These are high-resolution images that can be displayed and/or printed in color.

[/fusion_text][fusion_separator style_type=”shadow” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” sep_color=”” top_margin=”” bottom_margin=”” border_size=”” icon=”” icon_circle=”” icon_circle_color=”” width=”” alignment=”center” /][fusion_title hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” content_align=”center” size=”3″ font_size=”” line_height=”” letter_spacing=”” margin_top=”” margin_bottom=”” text_color=”” style_type=”default” sep_color=””]

Optocoupler Circuits

[/fusion_title][fusion_lightbox type=”” full_image=”http://exploringbeaglebone.com/wp-content/uploads/2019/01/533160-c06f012.png” video_url=”” thumbnail_image=”http://exploringbeaglebone.com/wp-content/uploads/2019/01/533160-c06f012-300×99.png” alt_text=”” description=”Optocoupler Input Circuit” class=”” id=””][/fusion_lightbox][fusion_separator style_type=”shadow” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” sep_color=”” top_margin=”” bottom_margin=”” border_size=”” icon=”” icon_circle=”” icon_circle_color=”” width=”” alignment=”center” /][fusion_lightbox type=”” full_image=”http://exploringbeaglebone.com/wp-content/uploads/2019/01/533160-c06f011.png” video_url=”” thumbnail_image=”http://exploringbeaglebone.com/wp-content/uploads/2019/01/533160-c06f011-300×100.png” alt_text=”” description=”Optocoupler Output Circuit” class=”” id=””][/fusion_lightbox][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=””]

Figure color key:

  • RED — pins are already allocated (e.g., to HDMI or eMMC). See Chapter 6 for information on how to re-allocate these pins. Do not use these pins without re-allocating them.
  • GREEN — pin mode is for enhanced GPIOs for the PRU-ICSS (see later chapters)
  • BLUE — pin mode is for UART functionality on the PRU-ICSS

[/fusion_text][fusion_separator style_type=”shadow” top_margin=”” bottom_margin=”20″ sep_color=”#9b9b9b” icon=”” width=”” class=”” id=”” /][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”1″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Source Code[/fusion_title][fusion_text]The full source code listing for this chapter is available in the GitHub repository directory exploringBB/chp06. There are the important source code listings for this chapter, which describe how you can interact with a GPIO using a custom class and how you can interact with the GPIOs using a Bone-Keys device:[/fusion_text][fusion_separator style_type=”none” top_margin=”20″ bottom_margin=”” sep_color=”” icon=”” width=”” class=”” id=”” /][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_tabs design=”” layout=”horizontal” justified=”yes” backgroundcolor=”” inactivecolor=”” bordercolor=”” class=”” id=””][fusion_tab title=”GPIO.h” icon=””]


[/fusion_tab][fusion_tab title=”GPIO.cpp” icon=””]


[/fusion_tab][fusion_tab title=”Read ADC” icon=””]


[/fusion_tab][fusion_tab title=”Bone Keys (dts)” icon=””]


[/fusion_tab][fusion_tab title=”Bone Keys (cpp)” icon=””]


[/fusion_tab][/fusion_tabs][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”1″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Errata[/fusion_title][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=””]

Second edition:

  • None so far

First edition:

  • Page 246. At the top of the page “P9_15(GPIO49)” should be “P9_15(GPIO48)”. It is correct in all other locations.
  • Page 247(Loc 7296). There are three ‘-‘ characters when there should be two ‘-‘ characters in three locations, in front of ‘path’, ‘attribute’, and ‘action’ on the command calls to udevadm.

[/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_sharing tagline=”Share This Story, Choose Your Platform!” tagline_color=”” title=”” link=”” description=”” pinterest_image=”” icons_boxed=”” icons_boxed_radius=”4px” box_colors=”” icon_colors=”” tooltip_placement=”” backgroundcolor=”” class=”” id=”” /][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]