Confronto tra il protocollo DPM del sistema Theremino
e il protocollo CAN
Il CAN è sicuramente superiore al DPM, per quel che riguarda la immunità ai disturbi, il DPM ha una immunità minore, ma una frequenza di ripetizione più alta.
In presenza di forti disturbi elettrici, il DPM può permettersi di perdere qualche pacchetto senza conseguenze, grazie alla sua alta frequenza di ripetizione.
Quando non ci sono disturbi (cosa che normalmente accade per la maggioranza del tempo), il DPM sfrutta la sua alta frequenza di ripetizione (fino a oltre 900 fps), per permettere la massima fluidità, nel controllo di sistemi multimediali.
Nelle pagine seguenti, abbiamo raccolto le principali informazioni sul CAN, che potranno essere utili a chi volesse studiare, un metodo di comunicazione alternativo, per il sistema Theremino.
Confronto distanze e tempi tra DPM e CAN
DPM
Speed
|
DPM
tempo
di cella
|
DPM
bit/s
|
|
Massima distanza
|
|
CAN
bit/s
|
CAN
tempo
di cella
|
1
|
1 mS
|
1K
|
|
10 Km
|
|
|
|
2
|
500 uS
|
2K
|
|
5 Km
|
|
|
|
3
|
200 uS
|
5K
|
|
2 Km
|
|
|
|
4
|
100 uS
|
10K
|
|
1 Km
|
|
62.5K
|
16 uS
|
5
|
50 uS
|
20K
|
|
500 m
|
|
125K
|
8 uS
|
6
|
20 uS
|
50K
|
|
200 m
|
|
250K
|
4 uS
|
7
|
10 uS
|
100K
|
|
100 m
|
|
500K
|
2 uS
|
8
|
5 uS
|
200K
|
|
50 m
|
|
600K
|
1.66_uS
|
9
|
2 uS
|
500K
|
|
20 m
|
|
660K
|
1.5 uS
|
10
|
1 uS
|
1M
|
|
10 m
|
|
1M
|
1 uS
|
11
|
500 nS
|
2M
|
|
5 m
|
|
|
|
12
|
250_nS
|
4M
|
|
2.5 m
|
|
|
|
Esempio con 8 Cap Sensors
– DPM: (24 bit comando + 24 bit dati) * 8 slaves = 216 bit totali
– CAN: (133 bit trasmissione + 133 bit ricezione) * 8 slaves = 2128 bit totali
In questo esempio, il CAN usa molti più bit, per trasmettere le stesse informazioni (il rapporto tra i di bit è circa 10 volte)
Si noti anche, che il DPM risponde sempre una conferma, al termine di ogni comando, mentre il CAN, per dare la stessa sicurezza, deve inviare come conferma, un intero pacchetto di risposta da 133 byte. In alcuni casi, il rapporto tra i bit trasmessi, supera le 20 volte.
I pacchetti CAN “Standard” ed “Extended”
Figure 2. Standard CAN: 11-Bit Identifier
( 1 + 11 + 1 + 1 + 1 + 4 + 64 + 16 + 2 + 7 + 7 = 64 + 51 = 115 bits )
Figure 3. Extended CAN: 29-Bit Identifier
(1 + 11 + 1 + 1 + 16 + 1 + 1 + 1 + 4 + 64 + 16 + 2 + 7 + 7 = 64 + 69 = 133 bits)
The CAN communication protocol is a carrier-sense multiple-access protocol with collision detection and arbitration on message priority (CSMA/CD+AMP). CSMA means that each node on a bus must wait for a prescribed period of inactivity before attempting to send a message.
CD+AMP means that collisions are resolved through a bit-wise arbitration, based upon a preprogrammed priority of each message in the identifier field of a message. The higher priority identifier always wins bus access.
The first version of the CAN standards listed in Table 1, ISO 11519 (Low-Speed CAN) is for applications up to 125 kbps with a standard 11-bit identifier. The second version, ISO 11898 (1993), also with 11-bit identifiers provides for signaling rates from 125 kbps to 1 Mbps while the more recent ISO 11898 amendment (1995) introduces the extended 29-bit identifier. The ISO 11898 11-bit version is often referred to as Standard CAN Version 2.0A, while the ISO 11898 amendment is referred to as Extended CAN Version 2.0B.
The Standard CAN 11-bit identifier field in Figure 2 provides for 211, or 2048 different message identifiers, while the Extended CAN 29-bit identifier in Figure 3 provides for 229, or 537 million identifiers.
Il cavo di trasmissione
The cable is specified to be a shielded or unshielded twisted-pair with a 120-O characteristic impedance (Zo). The standard defines the interconnection to be a single twisted-pair cable.
The interconnection is terminated at both ends with a resistor equal to the characteristic impedance of the line to prevent signal reflections. Nodes are then connected to the bus with unterminated drop cables, or stubs, which should be kept as short as possible to minimize signal reflections.
If multiple devices are placed along the cable, only the devices on the ends of the cable need termination resistors. Figure 2 shows an example of how to terminate a high-speed network.
Figure 2 – Terminating a High-Speed Network
Note per l’utilizzo con il sistema Theremino
– Il cavo CAN deve essere twistato.
– Con i cavetti standard non è possibile portare CAN e alimentazione a 5 volt
Una buona soluzione, potrebbero essere 2 doppini twistati, con connettori RJ da 4 poli. (più o meno come un cavo di rete a 4 fili)
Anche se il cavo non deve essere passante, sarebbero ugualmente necessari due connettori per ogni slave.
Note sulla lunghezza dei collegamenti CAN
CAN Rates are achieved with the SN65HVD230 in high-speed mode (Texas Instruments 2003) The ISO 11898 standard specifications are given for a maximum bus length of 40 m and maximum stub length of 0.3 m with a maximum of 30 nodes. However, with careful design, longer cables, longer stub lengths, and many more nodes can be added to a bus—always with a trade-off in signaling rate. A transceiver with high input impedance such as the HVD230 is needed to increase the number of nodes on a bus.
Il CAN richiede un transceiver esterno
PIC – CAN/LIN Products
(da Microchip Connectivity Solutions – Summer 2010)
I microcontrollori non hanno il transceiver CAN. Si deve aggiungerlo esternamente, come nel controller CAN mostrato qui sopra.
CAN – Immunità ai disturbi
Il bus CAN ha ottime caratteristiche di High Short-Circuit Protection, High ESD Protection, Wide Common-Mode Range, Common-Mode Rejection e presenta una alta immunità ai disturbi, in ambienti difficili.
Queste caratteristiche indicano che il CAN fa pochi errori e non si rompe, ma NON vuol dire che non fa errori, in presenza di disturbi.
Error Checking and Fault Confinement
The CAN protocol incorporates five methods of error checking: three at the message level and two at the bit level. If a message fails with any one of these error detection methods, it is not accepted and an error frame is generated from the receiving nodes, causing the transmitting node to resend the message until it is received correctly. However, if a faulty node hangs up a bus by continuously repeating an error, its transmit capability is removed by its controller after an error limit is reached.
At the message level are the CRC and the ACK slots displayed in Figures 2 and 3. The 16-bit CRC contains the checksum of the preceding application data for error detection with a 15-bit checksum and 1-bit delimiter. The ACK field is two bits long and consists of the acknowledge bit and an acknowledge delimiter bit. Finally, at the message level there is a form check. This check looks for fields in the message which must always be recessive bits. If a dominant bit is detected, an error is generated. The bits checked are the SOF, EOF, ACK delimiter, and the CRC delimiter bits.
At the bit level each bit transmitted is monitored by the transmitter of the message. If a data bit (not arbitration bit) is written onto the bus and its opposite is read, an error is generated. The only exceptions to this are with the message identifier field which is used for arbitration, and the acknowledge slot which requires a recessive bit to be overwritten by a dominant bit. The final method of error detection is with the bit stuffing rule where after five consecutive bits of the same logic level, if the next bit is not a compliment, an error is generated. Stuffing ensures rising edges available for on-going synchronization of the network, and that a stream of recessive bits are not mistaken for an error frame, or the seven-bit interframe space that signifies the end of a message. Stuffed bits are removed by a receiving node’s controller before the data is forwarded to the application.
With this logic, an active error frame consists of six dominant bits—violating the bit stuffing rule. This is interpreted as an error by all of the CAN nodes which then generate their own error frame. This means that an error frame can be from the original six bits to twelve bits long with all the replies. This error frame is then followed by a delimiter field of eight recessive bits and a bus idle period before the corrupted message is retransmitted. It is important to note that the retransmitted message still has to contend for arbitration on the bus.
CAN – The layered ISO 11898
The CAN bus was developed by BOSCH as a multi-master, message broadcast system that specifies a maximum signaling rate of 1M bit per second (bps).
The CAN communications protocol, ISO 11898, describes how information is passed between devices on a network, and conforms to the Open Systems Interconnection (OSI) model that is defined in terms of layers. Actual communication between devices connected by the physical medium is defined by the physical layer of the model. The ISO 11898 architecture defines the lowest two layers of the seven layer OSI/ISO model as the data-link layer and physical layer in Figure 1.