• Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Neuron - Addressing GPIO from C++

    Official EVOK API
    2
    28
    8277
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      Boy Lenssen last edited by tomas_hora

      I have experience with addressing the GPIO pins on the Pi and using https://www.abelectronics.co.uk/p/54/IO-Pi-Plus?CatName=0&c=18 to expand the number of ports. Now we want to use the UniPi (already have it (the L20x)), but how do I address each pin from C++?

      The IO Pi Plus expansion board also uses i2c and I use it's library to address them. How does that work for UniPi?

      1 Reply Last reply Reply Quote 0
      • B
        Boy Lenssen last edited by

        Ok, I found something here, someone trying the same => http://unipi.technology/forum/viewtopic.php?t=75

        seems straight forward, I guess I should try that. But where is the list of GPIO's (addresses)?

        1 Reply Last reply Reply Quote 0
        • T
          tomas_hora administrators last edited by

          Hi,

          the Neuron does not use the GPIOs of RPi for the I/Os. Instead there are 1-3 ARM processors (depending on the S/M/L Neuron version) for each group which communicate with the RPi using SPI, where a kind of Modbus protocol is used.

          We are working on the Evok to be finalized and debloated images. Right now there is a pretty simple possibility of using the TCP modbus server (available at localhost:502) which is included in the Mervis img, map of the register is available at http://downloads.unipi.technology

          So the easiest way for you might be to get a C++ library for TCP Modbus and get the advantage of the Modbus interface.

          Do not forget to stop and disable unneeded seriveces which are included in the Mervis OS:

          systemctl stop sharkrt
          systemctl stop configtool
          systemctl disable sharkrt
          systemctl disable configtool
          
          B 1 Reply Last reply Reply Quote 1
          • B
            Boy Lenssen @tomas_hora last edited by

            @tomas_hora Thanks a lot for your response!

            I will have to change the communiation layer in my application then, no problem but I just need to figure out how this works.

            I also have no idea if Mervis will be able to substitute my on software (it is a kind of 'if this then that' thing)

            1 Reply Last reply Reply Quote 0
            • T
              tomas_hora administrators last edited by

              @Boy-Lenssen I am sorry for that but we had to move on from the RPi GPIOs forward to allow better scalability and variability of our products.

              Mervis is basically if this than that platform that runs in loop... Not a realtime solution but suitable for most automation applications.

              1 Reply Last reply Reply Quote 1
              • B
                Boy Lenssen last edited by

                @tomas_hora I see that EVOK uses PIGPIO, which uses GPIO, is it still then usable with the neuron? I actually have no idea at the moment what Mervis does, need to check the tutorials on Youtube...

                Also, no knowledge on Modbus yet. I will start trying it out as soon as I have the Neuron (at a colleague's place now)

                1 Reply Last reply Reply Quote 0
                • T
                  tomas_hora administrators last edited by

                  @Boy-Lenssen Since the GPIOs are not used in Neuron, than PIGPIO does not have any sence there. You could use it to write your own implementation of the low level protocol on SPI, but why?

                  1 Reply Last reply Reply Quote 0
                  • B
                    Boy Lenssen last edited by

                    @tomas_hora I will first check Mervis and otherwise try http://libmodbus.org/ or something. I think I'll manage, thanks!

                    1 Reply Last reply Reply Quote 0
                    • B
                      Boy Lenssen last edited by Boy Lenssen

                      @tomas_hora I had this project in the fridge for now, but picking it up now. I actually want to try to talk to the I/O ports via modbus, but need a bit of a start.

                      I understand that I need to connect via IP and port number, but how do I talk to the ports next? How do I set them to pullup/down and input / output? How do I get triggered when an input changes?

                      I want to try this out with Android Things IoT OS. Can I setup a modbus server myself to be able to talk to the ports?

                      edit:
                      I'm so sorry, I just can't find a way to get started...Should I install Mervis and use a second Pi with Android Things to connect to the modbus?

                      T 1 Reply Last reply Reply Quote 0
                      • T
                        tomas_hora administrators @Boy Lenssen last edited by tomas_hora

                        @Boy-Lenssen All the I/Os (except 1Wire) are acessible using the TCP Modbus protocol, the map of each register/coil can be found here

                        Since it does not uses GPIOs of RPi, you do not need to set any pullups. Just use the registers/coils to set and read the states of IOs. You will need to poll the registers/coils periodically to catch the state of the I/O.

                        I suggest you to take a look at some C++ ModBus TCP library that supports client mode.

                        You can also use the Websockets, or HTTP REST api that evok provides (it is using the underlaying TCP Modbus): https://github.com/UniPiTechnology/evok#testing-latest-git-versions

                        1 Reply Last reply Reply Quote 1
                        • B
                          Boy Lenssen last edited by

                          @tomas_hora of course! How stupid of me, no pullups etc and input/outputs are dedicated on the device.

                          One last question before I can start investigating: to get it working, I need to flash the Mervis image on SD card and use that on the Pi located in the Neuron, right? And then I need an additional Pi (if i want to run Android Things) to work as a client to address it?

                          T 1 Reply Last reply Reply Quote 0
                          • T
                            tomas_hora administrators @Boy Lenssen last edited by tomas_hora

                            @Boy-Lenssen You can use the Mervis which already includes teh TCP Modbus. Or the standard Raspbian and install it on your own from github https://github.com/UniPiTechnology/neuron_tcp_modbus_overlay

                            And yes, than you would need to run Android Things on a different RPi.

                            B 1 Reply Last reply Reply Quote 1
                            • B
                              Boy Lenssen @tomas_hora last edited by

                              @tomas_hora Thanks for the patience! It is all becoming clear to me!

                              T 1 Reply Last reply Reply Quote 0
                              • T
                                tomas_hora administrators @Boy Lenssen last edited by

                                @Boy-Lenssen You are welcome :) I am glad I helped a bit...

                                1 Reply Last reply Reply Quote 1
                                • B
                                  Boy Lenssen last edited by Boy Lenssen

                                  @tomas_hora Well, it looks like more questions arise, so I think I keep bothering you for just a bit more :) But if this thing works out, we will be buying a lot more of these devices!

                                  I am working on a project where it is quite critical we know when an input has changed. I would like to know which method is the fastest of the ones listed here: https://github.com/UniPiTechnology/evok#testing-latest-git-versions

                                  Another thing: if I need to shut down the system (it is shut down every day), should I create something that will gracefully shut down the Pi in the Neuron (when I'm using the Mervis image) or is that SD Card read-only and is there no chance of corruption?

                                  T 1 Reply Last reply Reply Quote 0
                                  • T
                                    tomas_hora administrators @Boy Lenssen last edited by

                                    @Boy-Lenssen The fastest is definitely only the TCP Modbus since more SW between your calls and the HW causes more delays. The TCP Modbus server can handle easily thousand of requests per seconds. Evok does not scan that fast (by default twice per second but can be re-configured).

                                    If you disable the mervis system (sharkrt + configtool) on the MervisOS, than there is nothing else I am aware of that will try to write to the card. So everything except Mervis shoudl be read-only, but I cannot guarantee there is no chance of corruption.

                                    There is no ready solution for easy shutdown (except standard linux features like cronjob).

                                    1 Reply Last reply Reply Quote 0
                                    • B
                                      Boy Lenssen last edited by

                                      @tomas_hora I fired up the system with the december 6th version of Mervis software image (https://files.unipi.technology/index.php/s/zTmrEbQEvifNd6W?path=%2FSoftware%2FMervis).

                                      2 issues:

                                      1. what is the login for it? I have the Neuron connected to my screen and only get to the login.

                                      2. http://192.168.1.102/rest/all (where I checked it's IP address via my router) does not return anything. It gives a 404 in the browser and wget -qO- http://192.168.1.102/rest/all does nothing. http://192.168.1.102 shows a page with a login button, so the server is running.

                                      T 1 Reply Last reply Reply Quote 0
                                      • T
                                        tomas_hora administrators @Boy Lenssen last edited by

                                        @Boy-Lenssen

                                        1. root:unipi
                                        2. The mervis services are still running, thus also its web interface on port 80 where you see the page with login. See the port of evok in /etc/evok.conf

                                        Btw. I suggest you to disable the sharkrt and configtool services first or even get started with a clean raspbian (lite) so you do not get confused by some of tuneups that are implemented in the MervisOS.

                                        B 1 Reply Last reply Reply Quote 0
                                        • B
                                          Boy Lenssen @tomas_hora last edited by

                                          @tomas_hora so it is normal not to have access to the REST api? I thought this was available on the Mervis image.

                                          I just wanted to get some basics to try out, that is why I took the Mervis img

                                          T 1 Reply Last reply Reply Quote 0
                                          • T
                                            tomas_hora administrators @Boy Lenssen last edited by

                                            @Boy-Lenssen The mervis image does not contain the newest version of evok that supports Neurons (since it is not needed). That is only available on github as above

                                            B 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post