Hardware Reference
In-Depth Information
Again, it takes a byte, val , and sends it on the SPI bus. It returns result as a
byte. However, you must also indicate the slaveSelectPin . This function has
an optional parameter, transferMode . Because the extended SPI library requires
you to specify the slave select pin, the library will change the outputs of the
slave select pin. By specifying the SS pin, this output is pulled low to access the
selected slave. By default, when a byte has been sent, the extended SPI library
will then output a logical one to the SS pin, deselecting the slave. To avoid this,
use the transferMode parameter. This parameter is one of two possible values,
as shown in Table 7-2.
Table 7-2: The Transfer Modes Available on the Arduino Due
TRANSFER
MODE
RESULT
SPI_CONTINUE
The SS pin is not driven high; it remains low. The slave is still selected.
SPI_LAST
Specifi es that this is the last byte to send/receive. The SS pin is driven
high; the slave is deselected.
By default, SPI_LAST is used. Please be aware that some SPI devices automati-
cally send data when they are selected; deselecting and reselecting the slave
after every byte can result in unexpected data.
To stop the SPI interface for a particular pin, use end() :
SPI.end(slaveSelectPin);
This terminates the SPI interface for this particular slave select pin, freeing
the pin for other uses, but keeps the SPI interface active if other slave select pins
were coni gured.
Example Program
For this application, you create a digital thermometer using a thermocouple. A
thermocouple is a temperature measuring device created by the contact of two
different conductors: differences in temperature from different points creates
voltage. The voltage generated is extremely small (often a few microvolts per
degree Celsius) so they are often coupled with amplii ers.
The major advantage to thermocouples is their price—just a few dollars per
cable. Their downside is their accuracy; they can sometimes be off by a few
degrees (type K typically has a +/-2° C to +/-6° C accuracy), but their tempera-
ture range more than makes up for this. A typical thermocouple can work with
temperatures between -200° C and +1000° C (-238° F to +1800° F). Although it
is not likely that such a device would be used in medical applications, they are
frequently used in the industry to monitor temperatures in ovens. To illustrate
 
Search WWH ::




Custom Search