element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
BeagleBoard
  • Products
  • Dev Tools
  • Single-Board Computers
  • BeagleBoard
  • More
  • Cancel
BeagleBoard
Forum Accessing GPIO and PWM on BeagleBone AI
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join BeagleBoard to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 36 replies
  • Answers 21 answers
  • Subscribers 104 subscribers
  • Views 8091 views
  • Users 0 members are here
  • beaglebone ai
Related

Accessing GPIO and PWM on BeagleBone AI

Sean_Miller
Sean_Miller over 5 years ago

I'm running through the BeagleBone examples for the AI, but the ones that attempt to read or write to pins throw errors in both Python and bonescript.

 

Here is the output from analoginout.js:

 

Hit ^C to stop

info: No pinmux for P9_14

fs.js:733

  var r = binding.read(fd, buffer, offset, length, position);

                 ^

Error: ETIMEDOUT: connection timed out, read

    at Error (native)

    at Object.fs.readSync (fs.js:733:19)

    at tryReadSync (fs.js:488:20)

    at Object.fs.readFileSync (fs.js:528:19)

    at Object.readAIN (/usr/local/lib/node_modules/bonescript/src/hw_mainline.js:287:30)

    at Object.f.analogRead (/usr/local/lib/node_modules/bonescript/src/index.js:330:19)

    at Timeout.loop [as _onTimeout] (/var/lib/cloud9/BeagleBone/AI/analogInOut.js:23:19)

    at ontimeout (timers.js:386:11)

    at tryOnTimeout (timers.js:250:5)

    at Timer.listOnTimeout (timers.js:214:5)

 

Is there a config I need to do first?  I see other's in the world with this issue on older BeagleBone's and the responses vary considerably.

 

This is the code:

const b = require('bonescript');


const inputPin  = "A3";
const outputPin = "P9_14";


console.log('Hit ^C to stop');
b.pinMode(outputPin, b.ANALOG_OUTPUT);
setTimeout(loop, 200);  // work-around to wait for PWM permissions


function loop() {
    var value = b.analogRead(inputPin);
    process.stdout.write(inputPin + '-->' + outputPin + ': ' + (value*100).toFixed(1) + '%   \r');
    b.analogWrite(outputPin, value);
    setTimeout(loop, 10);
}

 

Thanks,

Sean

  • Sign in to reply
  • Cancel

Top Replies

  • Sean_Miller
    Sean_Miller over 5 years ago in reply to Sean_Miller +4
    YYYYYEEEEEAAA!!!!!!!! blinkLED.js works now!!! I always tell the boy...if you can blink an LED, you can change the world. The door is open! See ya', Sean
  • Sean_Miller
    Sean_Miller over 5 years ago in reply to clem57 +2 suggested
    I saw these two references tonight in my hunt. My thoughts were "this surely is handled in by the bonescript and Python libraries on the fly, right?" "Otherwise, it would be in the comments in the header…
  • mayermakes
    mayermakes over 5 years ago in reply to clem57 +2 suggested
    The only thing I could find out about this issue is that the device tree files for the BB-AI are missing, there is currently no suitable file provided for the BB-AI all the BBB black files just brick the…
Parents
  • clem57
    0 clem57 over 5 years ago

    #include <unistd.h>

    #include <stdio.h>

    using namespace std;

     

     

    int main()

    {

       FILE *export_file = NULL; //declare pointers

       FILE *IO_direction = NULL;

       FILE *IO_value = NULL;

       char str1[] = "0";

       char str2[] = "1";

       char str3[] = "out";

       char str[] = "23";

       //this part here exports gpio23

       export_file = fopen ("/sys/class/gpio/export", "w");

       fwrite (str, 1, sizeof(str), export_file);

       fclose (export_file);

       //this part here sets the direction of the pin

       IO_direction = fopen("/sys/class/gpio/gpio23/direction", "w");

       fwrite(str3, 1, sizeof(str3), IO_direction); //set the pin to HIGH

       fclose(IO_direction);

       usleep (1000000);

     

       for (int i=0; i<10; i++){ //blink LED 10 times

            IO_value = fopen ("/sys/class/gpio/gpio23/value", "w");

            fwrite (str2, 1, sizeof(str2), IO_value); //set the pin to HIGH

            fclose (IO_value);

            usleep (1000000); //delay for a second

     

     

            IO_value = fopen ("/sys/class/gpio/gpio23/value", "w");

            fwrite (str1, 1, sizeof(str1), IO_value); //set the pin to LOW

            fclose (IO_value);

            usleep (1000000); //delay for a second

            }

    }

     

    The 3 bold lines are the setup for pin 23.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • mayermakes
    0 mayermakes over 5 years ago in reply to clem57

    The only thing I could find out about this issue is that the device tree files for the BB-AI are missing, there is currently no suitable file provided for the BB-AI
    all the BBB black files just brick the BB-Ai if loaded with uENv.txt. the Universal cape also does not support the processor.
    I raised an Issue on the github for the examples and messaged them,. hope Beaglebone will shortly provide a suitable overlay file /inlcuded it loaded in the next OS image release.

    thanks for posting your solution!

    For generall usage these setup procedures should be handeled in a Library or the u-boot (like intended).
    To get an urgent project working i had to do some workaround which thought me about interfacing it with USB devices, but I really would like to redo it without any additional hardware.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Sean_Miller
    0 Sean_Miller over 5 years ago in reply to mayermakes

    I got excited when I read this article on Adafruit:  https://learn.adafruit.com/introduction-to-the-beaglebone-black-device-tree/overview

     

    But then I read your post that the BeagleBone Black overlays will brick the AI.

     

    Oh well, at least I understand it now, just not enough to make my own overlay.

     

    See ya',

    Sean

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • Sean_Miller
    0 Sean_Miller over 5 years ago in reply to mayermakes

    I got excited when I read this article on Adafruit:  https://learn.adafruit.com/introduction-to-the-beaglebone-black-device-tree/overview

     

    But then I read your post that the BeagleBone Black overlays will brick the AI.

     

    Oh well, at least I understand it now, just not enough to make my own overlay.

     

    See ya',

    Sean

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube