MSP430 programming for serial interfacing with sensors

13
Network and Systems Laboratory nslab.ee.ntu.edu.tw se

description

MSP430 programming for serial interfacing with sensors. se. SPI. Master–Slave mode Synchronous protocol All transmissions are referenced to a common clock Clock generated by the master (MCU) Four main signals Master Out Slave In (MOSI): data from master to slave - PowerPoint PPT Presentation

Transcript of MSP430 programming for serial interfacing with sensors

Page 1: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

se

Page 2: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

SPIMaster–Slave modeSynchronous protocolAll transmissions are referenced to a common clockClock generated by the master (MCU)Four main signalsMaster Out Slave In (MOSI): data from master to slaveMaster In Slave Out (MISO): data from slave to masterSerial Clock (SCLK or SCK): clockChip Select (CS): select particular peripheral when

multiple peripherals are connected to master

Page 3: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

SHT11Relative humidity and temperature sensors Digital output Manufacturer defined interface

two wires bi-direction

1. Use a GPIO pin as clock (SCK), it is always output direction

2. Use another GPIO as DATA, dynamic setting it to input(read) or output(write) direction

Page 4: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

Taroko Connections

Page 5: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

Start Transmission and Send CommandHow to start

What are the commands available

Page 6: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

An Example: SHT11Timing diagram

Pull-up

Data pin in output

direction

Set data pin to input direction,

then SHT11 controls the DATA line

Page 7: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

Software Implementation

Page 8: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

Software Implementation

Page 9: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

Software Implementation

Page 10: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

Convert to Physical Values 12-bit humidity, 14-bit temperatureTemperature

Humidity

Page 11: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

Device DriverDownload here

http://nslab.ee.ntu.edu.tw/courses/wsn-labs-spring-09/labs/sht11Driver.rar

Important functions in SHT1x_sensirion.cvoid sht1xInit();void sht1xReset();char sht1xMeasure(unsigned char *p_value,

unsigned char *p_checksum, unsigned char mode);

void sht1xCalculate(float *p_humidity ,float *p_temperature);

Page 12: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

Functionschar sht1xMeasure(unsigned char *p_value, unsigned

char *p_checksum, unsigned char mode);mode: { TEMP, HUMI }Store measured value to *p_valueStore 8-CRC checksum to *p_checksumvoid sht1xCalculate(float *p_humidity ,float

*p_temperature);Convert measured value to physical valuePut the measured value in *p_humidity, *p_temperatureResult will also place in *p_humidity, *p_temperature

(overwrite)

Page 13: MSP430 programming for serial interfacing with sensors

Network and Systems Laboratorynslab.ee.ntu.edu.tw

Example