element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • 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
Test & Tools
  • Technologies
  • More
Test & Tools
Blog SCPI on a Linux Board - Part 2a: PiFace Digital C programming
  • Blog
  • Forum
  • Documents
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Test & Tools requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 16 Jun 2018 9:40 PM Date Created
  • Views 898 views
  • Likes 7 likes
  • Comments 4 comments
  • raspberry
  • pi
  • piface_digital_2
  • piface
Related
Recommended

SCPI on a Linux Board - Part 2a: PiFace Digital C programming

Jan Cumps
Jan Cumps
16 Jun 2018

I'm building a SCPI device for Linux.

I have the basis working over TCP/IP.

This morning I received a PiFace Digital 2PiFace Digital 2 from element14 (thank you!)

This board, with digital inputs, outputs, relays and LEDs can be a nice LAB automation utility.

 

image

In this post I check if I can control the PiFace Digital 2 via C.

TL;DR yes

 

In this series, I'm focusing on the specifics for TCP/IP communication with a SCPI service.

In the previous posts I made socket server that listens for SCPI commands and parses/handles them.

This is the first post where I talk to hardware. In a later post I'll link the SCPI server and the hardware together.

 

PiFace Digital 2

 

This Pi hat is a port expander that gives you 8 digital inputs and 8 outputs, 4 buttons, 2 relays and 8 LEDs that you can control from your Pi.

Communication goes via SPI.

To get the basics working, check out this great blog from urkraft: PiFace Digital 2 - setup and use

I'm using Ubuntu on my Pi, so I had to install the raspi-config utility first before I could use it to enable SPI.

 

Control the PiFace Digital 2 with C

 

That was easy too. Piface has example code on their github.

You need the c and h files from these two repositories:

libpifacedigital

libmcp23s17

 

Both come with a makefile and you can build them right away on your Pi.

I'm developing on a windows computer and cross-compile for Linux, so I've created a project in the ARM DS-5 IDE.

image

This allows me to interactively debug the program from the windows PC.

As you can see on the photo at the start of the blog post, I was able to control a LED. I've also tested a relay.

 

Here's an action shot of the debug session:

image

 

In the next post I'll try to turn this into some server code that listens to commands and executes any requests.

That's the next step to get a SCPI programmable LAB controller on the Pi.

 

 

 

related blog
SCPI on a Linux Board - Letter of Intent

SCPI on a Linux Board - Part 1: Proof of Concept

SCPI on a Linux Board - Part 2a: PiFace Digital C programming

SCPI on a Linux Board - Part 2b: PiFace Digital C++ programming
SCPI on a Linux Board - Part 3: TCP/IP Socket C++ programming
SCPI on a Linux Board - Part 4: TCP/IP SCPI and Instrument Service
SCPI on a Linux Board - Part 4b: TCP/IP SCPI and Instrument Service 100% Working
SCPI on a Linux Board - Part 4c: TCP/IP SCPI and Instrument Service - Run as a Daemon
SCPI on a Linux Board - Part 5a: LabVIEW Driver for LAB Switch: Open, Close and Switch functions
  • Sign in to reply

Top Comments

  • jomoenginer
    jomoenginer over 5 years ago +2
    Very cool. At my day gig, we have a ton of automated tests that include sending SCPI and GPIB/HPIB over multiple protocols such as Ethernet, USB and Serial on Windows, Linux and Solaris but mainly with…
  • DAB
    DAB over 5 years ago +1
    Good post Jan. DAB
  • DAB
    DAB over 5 years ago

    Good post Jan.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 5 years ago

    Nice addition to your blog series.  You are building up a serious set of test tools there.

    Good luck on your future work on this series.

    Gene

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago

    I’ve checked the hardware on the hat:

    8 digital inputs (can all be turned into outputs)

    8 digital outputs, open collector, each with LED in parallel.

    2 relays with snubber, each sharing one of the outputs. They can be disconnected.

    I/O is buffered, not isolated.

    For isolation, the two relays can be used. up to 20 V.

     

    I need to chech the functionality of the SPI port expander on board.

    Based on its functionality, I’ll write an instrument API. I want to balance between options and ease of use.

    Typically, I base it on my own needs and open source it with the most liberal license I find. If anyone needs something else, it’s there to be extended.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jomoenginer
    jomoenginer over 5 years ago

    Very cool. At my day gig, we have a ton of automated tests that include sending SCPI and GPIB/HPIB over multiple protocols such as Ethernet, USB and Serial on Windows, Linux and Solaris but mainly with Python.  This series has looked like an interesting implementation.     

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
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 © 2023 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