element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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
  • 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
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Smartedge External GPIO and WiringPi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 13 replies
  • Answers 5 answers
  • Subscribers 664 subscribers
  • Views 3086 views
  • Users 0 members are here
Related

Smartedge External GPIO and WiringPi

ergouser
ergouser over 4 years ago

There's a good discussion of the external IO on the SmartEdge by Jan Cumps here : AVNET SmartEdge IIOT Gateway: Use the Industrial I/O

 

Has anyone used these GPIO with wiringpi or have any ideas how that might be done?

 

Thanks.

  • Sign in to reply
  • Cancel
Parents
  • Jan Cumps
    0 Jan Cumps over 4 years ago

    You talk to the industrial I/O  pins via the Linux file system. They are mapped to character device drivers.

    It would be easy in plain python. No idea how to deal with that with the wiring bridge...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 4 years ago in reply to Jan Cumps

    ergouser  wrote:

     

    ....

    Has anyone used these GPIO with wiringpi or have any ideas how that might be done?

     

    ...

    As far as I can see, the I/Os are managed by an ON Semi i2c port expander: fxl6408fxl6408.

    I derive it from their github: https://github.com/Avnet/smartedge-iiot-gateway/blob/master/drivers/gpio/gpio-fxl6408.c .

    I am not sure, because the On Semi datasheet says the package should mention TX, but the IC on my device says UK RX.

     

    You could try and talk to it from wiringpi. The protocol is documented in the datasheet.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • ergouser
    0 ergouser over 4 years ago in reply to Jan Cumps

    Jan,

     

    Thanks for the input so far.

     

    As far as I can tell, there is already an FXL6408 on the Pi3 which controls some of the existing peripherals (eg hdmi hot-plug) and it has firmware support.  That expander is rumoured to be full, and so do we think that the additional GPIO adds another FXL6408  (which would make some sense)?  The manual also references some reserved I2C addresses:

     

    *NOTE: I2C1 Bus (GPIO2/GPIO3) is shared with onboard devices. I2C addresses: 0x33, 0x43, 0x44, 0x51 are reserved.

     

    Any thoughts on how to confirm these thoughts or how to determine the I2C address?   There's a huge performance advantage to using the firmware driver over using the character file interface from which I'd like to benefit.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 4 years ago in reply to ergouser

    I get this report. It matches with the note above.

    image

    I'm setting up probing with a protocol analyser

    image

    source: https://www.raspberrypi.org/documentation/usage/gpio/

     

    image

     

    Let's see if I can capture a conversation....

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 4 years ago in reply to Jan Cumps

    Here are the results of the i2c capture.

    I made my analyser trigger on a change of the output O1. and captured the traffic before that event.

    Two scenarios: First I sent a 0, then a 1.

    The IC's i2c address is 0b1000011 -> 0x43

     

    image

     

    sudo echo 0 > /sys/class/gpio/gpio201/value

     

    I2C Analysis results


    2 januari 2021
    Bus configuration
    SDAChannel 1
    SCLChannel 0
    Statistics
    Decoded bytes7
    Detected bus errors0
    IndexTimeHexBinDec
    0-2,30 msSTART
    1-2,29 ms0x860b10000110134
    2-2,00 msACK
    3-1,98 ms0x050b000001015
    4-1,71 msACK
    5-1,66 msSTART
    6-1,65 ms0x870b10000111135
    7-1,36 msACK
    8-1,34 ms0x020b000000102
    9-1,07 msNACK
    10-1,02 msSTOP
    11-971,50 μsSTART
    12-955,50 μs0x860b10000110134
    13-667,50 μsACK
    14-651,50 μs0x050b000001015
    15-379,50 μsACK
    16-363,50 μs0x000b000000000
    17-91,50 μsACK
    18-43,50 μsSTOP

     

    sudo echo 1 > /sys/class/gpio/gpio201/value

     

    I2C Analysis results


    2 januari 2021
    Bus configuration
    SDAChannel 1
    SCLChannel 0
    Statistics
    Decoded bytes7
    Detected bus errors0
    IndexTimeHexBinDec
    0-2,23 msSTART
    1-2,21 ms0x860b10000110134
    2-1,92 msACK
    3-1,91 ms0x050b000001015
    4-1,63 msACK
    5-1,59 msSTART
    6-1,57 ms0x870b10000111135
    7-1,28 msACK
    8-1,27 ms0x000b000000000
    9-993,20 μsNACK
    10-945,20 μsSTOP
    11-883,60 μsSTART
    12-867,60 μs0x860b10000110134
    13-579,60 μsACK
    14-563,70 μs0x050b000001015
    15-291,60 μsACK
    16-275,70 μs0x020b000000102
    17-3,60 μsACK
    1844,40 μsSTOP

     

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 4 years ago in reply to ergouser

    ergouser  wrote:

     

    ....

    Any thoughts on how to confirm these thoughts or how to determine the I2C address?   There's a huge performance advantage to using the firmware driver over using the character file interface from which I'd like to benefit.

    In the scheme of things, the majority of time is spent in i2c. Writing to the block device is going to be a snap, compared to the 2.x ms i2c conversation.

    If you want to have direct fast control over the pins, you'll need to bring out the hot air gun.

    You can move the control from the IO expander to a direct GPIO pin, by moving resistors:

     

    In this case I'm showing O1. By moving resistor R156 to position 157, it is now controlled by generic GPIO6.

    image

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • ergouser
    0 ergouser over 4 years ago in reply to Jan Cumps

    Jan Cumps  wrote:

     

    I get this report. It matches with the note above.

    image

    If I understand i2cdetect, the UU means that the device is busy which is validated if you try to read from the device

     

    sudo i2cget -y 1 0x43 5
    Error: Could not set address to 0x43: Device or resource busy

     

    lsmod shows these:

     

    $ lsmod
    Module                  Size  Used by
    bnep                   20480  2
    hci_uart               36864  1
    btbcm                  16384  1 hci_uart
    serdev                 20480  1 hci_uart
    bluetooth             368640  24 hci_uart,bnep,btbcm
    ecdh_generic           28672  1 bluetooth
    rtc_pcf8563            16384  0
    gpio_fxl6408           16384  0
    brcmfmac              307200  0
    brcmutil               16384  1 brcmfmac
    mcp251x                20480  0
    cfg80211              565248  1 brcmfmac
    can_dev                24576  1 mcp251x
    sc16is7xx              20480  0
    rfkill                 28672  4 bluetooth,cfg80211
    i2c_bcm2835            16384  0
    uio_pdrv_genirq        16384  0
    uio                    20480  1 uio_pdrv_genirq
    fixed                  16384  0
    i2c_dev                16384  0
    attiny_btn             16384  0
    attiny_led             16384  0
    attiny_wdt             16384  0
    attiny_mfd             16384  0
    ip_tables              24576  0
    x_tables               32768  1 ip_tables
    ipv6                  446464  22
    crc_ccitt              16384  1 ipv6

     

    if you remove gpio_fxl6408

    $ sudo rmmod gpio_fxl6408

     

    and rerun i2cdetect you get this:

     

         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    30: -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- -- 
    40: -- -- -- 43 44 -- -- -- -- -- -- -- -- -- -- -- 
    50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    70: -- -- -- -- -- -- -- --                        

    After that you can set/get the registers:

    $ sudo i2cset -y 1 0x43 5 255
    $ sudo i2cget -y 1 0x43 5
    0xff

    You can then use the I2C functions of WiringPi to programmatically access the I/O.

     

    What you loose is the ability to control the I/O with the /sys/class/gpio/ files.

     

    0x44 also appears to be an FXL6408.  Any idea what that is or how to configure the gpio_fxl6408 driver to ignore 0x43 and still enable the file access for 0x44?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 4 years ago in reply to ergouser

    I didn't have to unload the libs. I think your device is busy because the Iot example for the smartedge is running. I switched those off.

    Yes the 0x44 is a second bus expander. I don't know what it's used for.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ergouser
    0 ergouser over 4 years ago in reply to Jan Cumps

    Jan Cumps  wrote:

     

    I didn't have to unload the libs. I think your device is busy because the Iot example for the smartedge is running. I switched those off.

     

    The stock apps were disabled long ago. We have some significantly more capable software with OPC, PLC drivers, Cloud AWS, Azure, Docker, etc. that we deploy from our application builder.  The smartedge is a really nice hardware platform.  We delivered it to a customer just to monitor some Modbus (RS485) temperature controllers (onboard serial, configurable as RS232 or RS485 - very nice).  Once the customer saw the I/O they immediately took an interest in motor control and replacing the temperature controllers with direct control from the box.  We have drag-and-drop GPIO support (based on Wiring Pi) for the stock Pi header but the isolated 60V external I/O is an attractive feature that we now want to support.

     

    For the tests that you did, I wouldn't expect you to need to unload the driver.  The UU in i2cdetect indicates that the bus is busy on your system.  I would expect that i2cset and i2cget will fail and report that the resource is busy - please give it a try and let us know.

     

    0x44 is configured for two outputs - bits 5 & 2, register 3 return 0x24 both were high at the time I read them.  I didn't read the input status - maybe some other time.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ergouser
    0 ergouser over 4 years ago in reply to Jan Cumps

    This is an interesting option.  One issue with the industrial I/O being on the I2C bus is that you loose the ability to use either hardware or software PWM.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 4 years ago in reply to ergouser

    ergouser  wrote:

    ... I would expect that i2cset and i2cget will fail and report that the resource is busy - please give it a try and let us know.

     

    You are correct.

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Jan Cumps
    0 Jan Cumps over 4 years ago in reply to ergouser

    ergouser  wrote:

    ... I would expect that i2cset and i2cget will fail and report that the resource is busy - please give it a try and let us know.

     

    You are correct.

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify 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