11 Replies Latest reply on Apr 29, 2015 7:27 AM by KurtE

    Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)

    kirilligum

      Hi,

       

      I'm working on a sensor suit and currently using arduino but I want to see if I can switch to edison.

       

      What stops me is that arduino pro mini is small and has enough pins to connect sensors through SPI (i2c allows only 2 sensors).

       

      the sensors that i'm using is mpu9250. I went with SPI because mpu9250 allows only for 2 different i2c addresses.

       

      intel edison doesn't have that many ports and I couldn't find information on multiplexers for edison. I'm also still new to this.

      I would rather not use an expansion board because it has to be wearable. But i do understand that one way to go about it is to use arduino-edison board and figure out details later.

       

      So, any advices or guidance on getting a large number of SPI ports from intel is highly appreciated.

       

      Best regards,

      --Kirill

        • 1. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
          DiegoV_Intel

          Hi kirilligum,

           

          If I'm not wrong the Arduino Pro Mini has one SPI port, so how did you connect your sensors to it? And why did you say Edison has fewer ports than the Arduino Pro Mini?

           

          You could use the Edison with the Arduino Expansion Board and use it as an Arduino UNO. You will have access to the SPI port like in the Arduino.

           

          Now, to attach many SPI devices you only need one SPI interface and a CS (chip select) for each one. All the devices will be attached to the same SPI bus and they will be selected through the CS pin of each one.

           

          Regards,

          Diego.

          • 2. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
            kirilligum

            I'm still getting the code to work for spi on arduino but the way I connected it is i used one spi port (miso,mosi,clk) for all sensors and a separate CS foe each sensor.

             

            So my question how do i get 10 or more SPI CS (chip select) ports from edison without the expansion board. I would prefer to avoid using expansion board since i'll be wearing it and the small factor is critical.

            • 3. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
              kirilligum

              this schematics Intel® Edison Boards and Compute Modules — Arduino* Board Schematic shows that I need to use MUX, level shifter and jumper section to get more digital pins to expand SPI, does anyone know what are the components? any advice on connecting them?

              • 4. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
                DiegoV_Intel

                Hi kirilligum,

                 

                If you are using the Arduino Expansion Board, there is no need to use a level shifter or jumper section, the GPIOs are 3.3V/5V tolerant. The Arduino Expansion Board has an SPI interface: MOSI, MISO, and CLK. You can attach the SPI Slave devices to this bus and use one GPIO for each CS. The Arduino Expansion Board has 14 digital IO pins so you can attach up to 11 Slave devices (the other 3 IO pins are for MISO, MOSI, and CLK). I haven't attached so many SPI devices to the same bus so I'm not sure if it will work.

                1280px-SPI_three_slaves.svg.png

                If you want to use more SPI Slave devices you will need an IO expander or a MUX to be able to select more SPI devices through the CS pin. You can use a MUX like this one: http://www.nxp.com/documents/data_sheet/74HC_HCT4051.pdf just as an example. With a MUX like this one you will be able to select up to 8 SPI devices with only 3 pins from the Arduino Expansion Board.

                 

                Regards,

                Diego.

                • 5. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
                  kirilligum

                  So to use edison directly with mux, I should use 3 edison's gpio pins?

                   

                  Thank you for the link to a compatible mux.

                   

                  And just to make clear again, I want to avoid expansion boards to keep things small and wearable.

                  • 6. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
                    DiegoV_Intel

                    Hi kirilligum,

                     

                    I know that you don't want to use expansion boards, but the more SPI devices you want to attach; the more hardware you will need because you would need a CS for each device. All depends on how many SPI devices you want to attach to the SPI bus. I explained to you that the Arduino Expansion Board (this is the board you are using, right?) has 14 digital IO, where 3 of them would be used for MISO, MOSI and CLK signals, and the rest can be used as CS for the SPI devices. This means that you would be able to attach up to 11 SPI devices without using any other external MUX, but if you want to attach more than 11 SPI devices, it would be necessary to use a MUX to expand the possible IO lines.

                     

                    I suggested you a MUX 3x8 just as an example. You can find another MUX of your preference. I know there are also some IO expanders that use I2C so you would need only 2 GPIOs in this case to control it.

                     

                    How many SPI devices you will attach? If you are planning to use 10 devices, I believe it would be possible to do it only using the Arduino Expansion Board without any other IC.

                     

                    Regards,

                    Diego.

                    • 7. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
                      gerrik84k

                      hi ,

                       

                      one additional question, how does the mraa library manage the cs part. i mean there are two cs pins in the docu but i cant find something about choosing one of them in the c++ library. do i have to write high or low by myself to the corresponding pin ?

                       

                      thanks in advance 

                      • 8. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
                        DiegoV_Intel

                        Hi gerrik84k,

                         

                        The MRAA library set the SPI interface using the CS1 by default. If you want to use CS0 you have to set it up manually as a GPIO. However, the CS pin is just a GPIO pin used to select a slave device so the pin used as CS could be any pin you want, it is not necessary to set a particular pin as CS.

                         

                        Regards,

                        Diego.

                        • 9. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
                          nniles

                          gerrik84k,

                           

                          I think you're asking whether the MRAA SPI library will handle your chip selects for you.

                           

                          It doesn't appear that the (SPI) library has any provision to toggle any chip selects, and so, as you suspected, you would be required to handle this yourself by connecting some GPIO pin to the chip select of each sensor and toggling them appropriately in your code before performing SPI communications.

                           

                          Hope this helps,

                          • 10. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
                            gerrik84k

                            thanks, that was exactly what i wanted to know . maybe as a suggestion for future versions of mraa i would welcome the opportunity to set the chipselect on init or as a method of the spi class.

                            • 11. Re: Intel edison with multiple sensors in small size (sensor suit, 10x SPI?)
                              KurtE

                              Hi, sorry if this is slightly off the actual question asked.

                               

                              It could be done and is probably already slightly done in some the code or in pull request to MRAA.  For me it would still not be sufficient unless they enabled better support for when CS is asserted and when it is de-asserted. That is with some devices like TFT display, the CS must stay asserted during some of the logical complete steps.  Like when I am reading contents of pixels from the screen.   SPIDEV does have the ability to control some of this, but so far it does not look like it is fully supported and MRAA has no support to control this.   

                               

                              But for me step 1 would be to first fix some of the major issues of SPI, including delay times, power management, and documentation, and enable FIFO and maybe DMA, CS IOCTL support)... (My impression is they are working on some of this, hopefully soon they will release it)

                               

                              Once that is done, my guess is that you can maybe define more logical SPI hardware devices, where you specify some general purpose pins to be used as CS pins.  In fact one of the two SPI CS pins is that now.  Once that is done either an actual hardware device or a SPIDEV device could be created and then a way should be added in MRAA to make use of this.

                               

                              But until then, I do all of my CS support external from the MRAA SPI code.  I know that I am running a risk, on the Arduino board that the Analog converter also uses the SPI buss, and if you do something that causes the system to have to read/write to the ADC, during one of the logical TFT commands, it could screw up the SPI data...

                               

                              Again sorry if I am slightly off topic here.

                               

                              Kurt