Q&A from Live Webinar
If I need to monitor GPIO status very precisely (up to 1 msec), which method for C++ would you recommend?
- This is getting to the limit of what can be done with sysfs. You would either want to do this from a dedicated microcontroller, or use a GPIO library like WiringPi that directly accesses the GPIO registers and is more efficient.
How can we use QObject::connect for GPIO status ON/OFF change?
- Yes. See this example which uses QSocketNotifier to emit a signal when a GPIO input in sysfs changes state: https://github.com/tranter/webinars/tree/master/GPIO/ButtonInterrupt
Where should I go to start hooking up an M4 core on a Colibri Imx7 chip to handle GPIO?
- The M4 is a dedicated microcontroller core available on some i.MX7 systems in addition to the two Cortex-A7 cores. I have not personally done this, but there appears to be lots of documentation available from nxp.com, toradex.com, and others.
I'm using Qt, the M4 core would need to be programmed in C?
- You should be able to use C or C++. You could even potentially use the recently released Qt for Microtocontrollers product if you felt there were benefits to using Qt in this part of your application.
Hi, I’m taking the course Qt programming for embedded system, would I be able to control peripheral attached to I2C or spi from the Qt touch screen programming?
- The focus is Qt and QML and it doesn’t cover I2C or SPI programming. The hardware used for that course should support I2C and SPI programming, so you could do it but would need to find some references to help you learn how to do it.
You mentioned that the Colibri is used with a 'carrier board'. What does that board do, or why is that required (rather than connecting directly to the Colibri)?
- The Colibri SOM is in a SIMM format which is a small device with a hundred or so pins on a connector. It needs to be installed on a carrier board which buffers the signals and brings them out to suitable connectors for power, USB, Ethernet, etc.
About offloading GPIO communication to another processor -- did you mean that for a HMP scenario (A-core and M-core)?
- Yes, that is one scenario. Or it could be a physically separate microcontroller if your SOM/SOC does not have a microcontroller core on board.
Some people advise using physical resistor instead of builtin pullup, pulldown, because it is more reliable etc. Does it make sense? By physical I mean discrete, separate.
- The advantage of using separate discrete resistors would be that you could adjust the resistor values used. The disadvantage over using built-in pullups/pulldowns is that it would add slightly to the hardware and testing cost. I don’t expect much difference in reliability either way.
Isn't sysfs deprecated?
- Yes, the sysfs interface is being deprecated in favor of a new GPIO character device API. The new API addresses a number of issues with the sysfs interface. However, it can't be easily used from the file system like sysfs, so the simple examples used sysfs, which is still going to be supported for some time.
How do I tie up the physical pins to GPIO numbers?
- You will typically have a datasheet or other documentation that lists the physical pin or connectors to GPIO names for your particular hardware.
libgpiod pwm lower than 5ms period is not possible in libgpiod, is there an alternative for that?
- You could do it in software, or if it is supported at the hardware level on our platform you could access the GPIO registers directly.
Is it ok to process GPIO and run UI on a multi-core system, eg. iMX 6q?
- See slide 7. If there are real-time requirements you can do this but you will need to ensure that the operating system will not preempt the real-time process.
What would be add on's to Linux for real-time capability?
- There are several addons or extensions for Linux for real-time. Google for RTLinux and real time Linux.
Does gpio number get generated in the device tree?
- Yes, I believe it typically does but I am not familiar with the details.
Could you explain how pull-down/pull-up is done?
- Here is one reference: https://www.electronics-tutorials.ws/logic/pull-up-resistor.html If the platform supports internal pullup/pulldown resistors, how it is done is platform specific.
Can WiringPi be used on a non-Raspberry platform?
- The official WiringPi only supports the Raspberry PI platform. I have heard that there are unofficial ports to some other platforms. The API is also similar to the Wiring library used on the Arduino platform.
So the input and output are always defined from the MCU or Linux point of view?
- Yes, it is defined with reference to the processor it is running on or where the GPIO hardware is located.
How do we know if a particular GPIO pin is already being used by some other programs? Are they always visible in /sys/class/gpio ??
- They only become visible to a given process when you export them. If you have a valid design where you want to share the same GPIO pins across different processes, I would suggest using some interprocess communication and locking scheme outside of sysfs to manage how they are allocated.
What are DHT11, DHT22?
- These are two low cost (US$5-$10) temperature/humidity sensors that are popular sensor devices.
Can I use a docker container with this?
- I imagine so. I’m not very familiar with Docker so there may be an issue with visibility to sysfs from within a container.
Any interface to .net and C# ? C# possible?
- Microsoft C# does appear to have an interface to GPIO (Windows.Devices.Gpio.Provider) but I don’t have any experience using it.