Pages: [1]   Go Down
Author Topic: SPI slaves HID  (Read 1598 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I want to use an Arduino UNO as SPI Master and two Host USB Shield from Circuit@Home as SPI Slaves.

I will connect to the first shield a Keyboard.
To the second one I will connect a Mouse.

All the data received by the SPI Master will be send to the computer using the UART RS232.

My question is: what type of SPI communication do I have to use? Half Duplex or Full Duplex?

I think the half Duplex is better because I don’t loose 8 clock cycle with the USB Status Registers.

My second question is: I don’t want any delay between the moment an action occures on my HID and the moment when I receive the data on my computer. So is the SPI fast enough (in term of frequency and debit) to handle two slaves using the SS pin to switch from one slave to the other one and read their FIFOs? The SPI can handle up to 26 MHz on the Host USB Shield. And I think the USB works at 8 Mhz(not sure).
So normally I could read both slaves one after the other before a new USB clock cycle no?
I know that every slave SPI has FIFOs to handle that problem but if I read the FIFO lately maybe I will have some delay.

So do I have to use the SS signal and select each slave or do I have to use a Daisy-chain?

My last point is: where the enumeration occures? In the host USB shield or the arduino UNO which control the shield using the SPI bus. I can’t find an answer on internet or the documentation. Maybe this question is stupid but this point is not clear for me.

Thanks
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
what type of SPI communication do I have to use? Half Duplex or Full Duplex?

Usually half duplex is the correct mode as many chips don't support full duplex SPI.

Quote
I think the half Duplex is better because I don’t loose 8 clock cycle with the USB Status Registers.

I don't know where this information is from or what it should mean. Full duplex would be the faster option but the slave has to support it.

Quote
I don’t want any delay between the moment an action occures on my HID and the moment when I receive the data on my computer.

This is not possible. There will always be a delay because the information has to arrive on the USB host shield, has to be processed there, must be transmitted to the Arduino, processed there as well and finally transmitted to the PC. Every stage needs some time, so a delay unavoidable.

Quote
So do I have to use the SS signal and select each slave or do I have to use a Daisy-chain?

Correct, the SS signal selects the SPI slave to be active on the bus.

Quote
where the enumeration occures?

Which enumeration?
Logged

Louisville, CO
Offline Offline
Full Member
***
Karma: 2
Posts: 174
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I want to use an Arduino UNO as SPI Master and two Host USB Shield from Circuit@Home as SPI Slaves.


You can't connect two USB Host shields to an Arduino. The shield supports USB hub, you can talk to several USB devices simultaneously via a single shield. 

Logged

/felis

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You can't connect two USB Host shields to an Arduino.

Although I completely agree with your second sentence, why shouldn't it be possible to connect two USB host shields to an Arduino? Sure you cannot just stack them on it but with a rewiring of the SS pin you can connect an additional USB host shield to the SPI bus. Maybe the OP has a reason to use two shields to separate the bus, switch the devices on and off as he likes or anything else.
Logged

Louisville, CO
Offline Offline
Full Member
***
Karma: 2
Posts: 174
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I designed the shield and wrote the code. The low-level support is static, you can't have more than one copy of it.
Logged

/felis

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The OP told nothing about software support. Does the shield (hardware) use any feature of the Arduino that doesn't allow to connect two of it?
As I already wrote, I agree with you that it doesn't make sense, I just wanna learn if there is a hardware detail I missed that doesn't allow multiple shields.
Logged

Louisville, CO
Offline Offline
Full Member
***
Karma: 2
Posts: 174
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The OP told nothing about software support.

The OP told about reading USB devices. In this case, software support is implied; you can't use this (or any other) shield without some supporting code. As far as simply stacking shields on top of Arduino board, you can use any number of them, especially if you are not planning on applying any electrical power to this stack (otherwise I suggest not exceeding 50).
Logged

/felis

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

To begin thanks a lot for your answer. I will try to answer to your questions.


You can't connect two USB Host shields to an Arduino. The shield supports USB hub, you can talk to several USB devices simultaneously via a single shield.  


Well at first I wanted to use a USB hub but it means I will have one more component on my prototype between the HID devices and my USB Host. One more component I have to understand and know how it works. With 2 Shield Host USB I could control each port. For example if a mass storage device is plug instead of a Mouse/keyboard I can switch off the USB port.

One more problem is I don't find a USB Hub controller. I only find all the time a complete fabric USB Hub with 4 ports or more. I just want two and what I saw is that design his own USB Hub is not an easy task. I'm a bit lost with all the USB Hub Controller available. I don't know what to choose because I have to be able to test it with an eval board and then use the chip in my final PCB.

But correct me if I'm wrong. I'm here to learn smiley.


This is not possible. There will always be a delay because the information has to arrive on the USB host shield, has to be processed there, must be transmitted to the Arduino, processed there as well and finally transmitted to the PC. Every stage needs some time, so a delay unavoidable.

Quote
where the enumeration occures?

Which enumeration?

To answer to that question: I know I will have some delay. What I wanted to say is I don't want visible delay for the user. An example if the user move the mouse I don't want to see my data from the mouse on the computer 2 minutes ago smiley. So I know I will have some delay but I would like to reduce this delay as much as I can to avoid visible delay for the user.

For the enumeration part: every USB device has to enumerate itself to communicate with a Host USB. But this question was stupid because obviously the enumeration take place in the arduino UNO. The Host USB shield is just a shield smiley not the main uP.

I designed the shield and wrote the code. The low-level support is static, you can't have more than one copy of it.

Are you the creator of the circuit@home USB Host shield? I didn't get it sorry.

The OP told nothing about software support.

The OP told about reading USB devices. In this case, software support is implied; you can't use this (or any other) shield without some supporting code. As far as simply stacking shields on top of Arduino board, you can use any number of them, especially if you are not planning on applying any electrical power to this stack (otherwise I suggest not exceeding 50).

So to be clear if I try to stay on my solution can I use 2 Host USB shield using a rewiring of the SS pin to communicate with the Arduino Uno? I will apply an external power supply 5V to power supply my design. And if I do that will I have a huge delay between the acquisition of the data form the Host USB and the display on the computer screen? I want to avoid visible delay for the user and because I would have to switch from one slave to the other using the SS pin I'm not sure if it is possible.

And of course I will have a software support on my arduino UNO in order to make some treatment on my data and handle the enumeration process (I want to avoid mass storage).
« Last Edit: October 10, 2012, 03:17:29 am by Xelf » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I only find all the time a complete fabric USB Hub with 4 ports or more.

What's the problem with them? You can close the case of the two additional ports or fill them with hot glue if you really don't want them to be available.

Quote
can I use 2 Host USB shield using a rewiring of the SS pin to communicate with the Arduino Uno?

Yes, you can but you have to almost completely rewrite the software for it. Don't think of this to be an easy task, you have to have some in-depth knowledge of the USB bus protocol as well as of the used chip set. Sure you have the library for the one shield version but you may get some serious problems extending that for a second shield (as felis already told you).

Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the OP is trying to overcome a lack of physical security with a form of hardware solution to prevent people from accessing mass storage devices. We use endpoint security software. It lets users plug in anything they like, but if it hasn't been authorised, the OS can't access it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I only find all the time a complete fabric USB Hub with 4 ports or more.

What's the problem with them? You can close the case of the two additional ports or fill them with hot glue if you really don't want them to be available.

Quote
can I use 2 Host USB shield using a rewiring of the SS pin to communicate with the Arduino Uno?

Yes, you can but you have to almost completely rewrite the software for it. Don't think of this to be an easy task, you have to have some in-depth knowledge of the USB bus protocol as well as of the used chip set. Sure you have the library for the one shield version but you may get some serious problems extending that for a second shield (as felis already told you).

Well I don't get why I could have 2 host shield connect to the same arduino.
They are 2 separated SPI slaves. What is the difference is the library between using one or two Host USB shield? What is the difference between a common multiple slaves SPI usage?

I think the OP is trying to overcome a lack of physical security with a form of hardware solution to prevent people from accessing mass storage devices. We use endpoint security software. It lets users plug in anything they like, but if it hasn't been authorised, the OS can't access it.

Well the mass storage part is a bonus I will say but what I want to is to have 2 HID connected to my board and send to the computer using RS232 the data acquisition.

How can I do that without using the Host USB shield control by SPI.
To me I have to options: 1 Host USB shield + 1 HUB USB and one arduino UNO to send the data to the computer or 2 Host USB shield + the arduino UNO.

The problem with the HUB Usb is that at the end I want to have everything on my board (hub + max3421E + ATmega328 + other components to make it works and communicate with the computer).

So for the prototype I can use a complete fabric Hub (2 or more ports) but for my final board I will need to include it in my board. That's why I need a component who can be the same on my proto and my final board. And I don't find any USB Hub controller for that.

I you can suggest me one it would be helpfull.
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
send to the computer using RS232

So are you going to emulate a serial mouse and keyboard?
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
They are 2 separated SPI slaves. What is the difference is the library between using one or two Host USB shield? What is the difference between a common multiple slaves SPI usage?

The library is designed to handle just one board. If the design is made that way you cannot just connect a second board and expect the library to handle that as well. Because your hardware design is quite exotic (with the two shields) nobody did the work yet to change the software to include this use case. If you wanna use two USB host shields you gonna have to rewrite large parts of the library.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
They are 2 separated SPI slaves. What is the difference is the library between using one or two Host USB shield? What is the difference between a common multiple slaves SPI usage?

The library is designed to handle just one board. If the design is made that way you cannot just connect a second board and expect the library to handle that as well. Because your hardware design is quite exotic (with the two shields) nobody did the work yet to change the software to include this use case. If you wanna use two USB host shields you gonna have to rewrite large parts of the library.

Well that's a bit too much for me. So I will stay on the solution HUB USB + one shield. It will be way easier.

Do you have any idea of a Hub USB Controller I could use?
Otherwise I will use a HUB USB from the market.

Quote
send to the computer using RS232

So are you going to emulate a serial mouse and keyboard?

For the moment I just want to see data send by the mouse and keyboard on my screen.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have found an other way: the V2DIP2 from FTDI
 (http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_V2DIP2-32.pdf). It's 2 Host USB Port and an SPI master. Just what I wanted.

I will just have to check how to adapt their exemple HID Device with SPI Master for 2 HID.
Logged

Pages: [1]   Go Up
Jump to: