The document discusses the PIC16F877A microcontroller. It provides details about its architecture, memory organization, peripherals like timers and serial communication modules, interrupts, and how to interface it with an LCD display. The PIC16F877A is a Harvard architecture microcontroller with an in-built ADC. It has program memory, data memory, timers, serial communication capabilities using SPI and I2C protocols, and 15 interrupt sources. Code examples are given to initialize and send data to a 16x2 LCD display using the PIC16F877A.
Arduino is an open- source computer hardware and software company, project and user community that designs and manufactures microcontroller-based kits for building systems consisting of digital devices, interactive objects that can sense and control in the physical world.
The document discusses open loop transfer functions and stability analysis using Nyquist plots. It begins with an outline of topics including partial fraction expansion, open loop systems, Nyquist plots, and stability criteria. It then provides examples of using partial fraction expansion to decompose transfer functions with real distinct roots, complex conjugate roots, and repeated roots. The document explains open loop and closed loop system nomenclature. It introduces the Nyquist stability criterion, which involves plotting the open loop transfer function on the Nyquist plot and checking if it encircles the critical point at -1.
This document provides an introduction to microcontrollers and electronics basics using Arduino and RedBoard microcontrollers. It covers topics such as Arduino and RedBoard overview, downloading the Arduino IDE, connecting boards to computers, installing drivers, selecting boards and serial devices in the IDE interface, and an overview of the key areas of the Arduino GUI. It also introduces basic electronics concepts like circuits, Ohm's Law, analog and digital signals. Several example circuits are presented to blink an LED, read input from a potentiometer to control blink rate, use a light sensor to control an LED, and read temperature from a sensor.
This document summarizes various computer interfaces including wired interfaces like USB, serial ports, and parallel ports as well as wireless interfaces like WiFi and Bluetooth. It also discusses 'embedded' interfaces like SPI, I2C, and 1-Wire. The document then focuses on the RS232 serial port protocol and issues like voltage levels. It provides an example project of an Arduino thermometer and includes the Arduino and PC code used. It concludes with mentioning an example OrangeMessenger project.
Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...Amr E. Mohamed
The document discusses frequency response analysis and Bode plots. It begins with an introduction to frequency response and how the steady state response of a linear time-invariant system to a sinusoidal input is another sinusoid at the same frequency with a different magnitude and phase. The complex ratio of the output to input is called the frequency response. It then discusses Bode plots which show the magnitude and phase of the frequency response on logarithmic scales. Key features of components in open-loop transfer functions and how they affect the Bode plot shapes are explained. An example demonstrates drawing the Bode plots for a sample transfer function.
The document describes a project on designing a 4-bit linear feedback shift register (LFSR). It discusses how an LFSR works by shifting bits left and applying an XOR operation to the last two bits. It then provides details on the circuit components including D flip-flops and XOR gates. Applications mentioned include generating pseudo-random numbers for cryptography, digital communications systems, and testing systems.
This presentation provides a very brief overview of a Seven Segment Display.
For details on how to use Seven Segment Display with Arduino please visit www.harekrishnahub.com
The document discusses the PIC16F877A microcontroller. It provides details about its architecture, memory organization, peripherals like timers and serial communication modules, interrupts, and how to interface it with an LCD display. The PIC16F877A is a Harvard architecture microcontroller with an in-built ADC. It has program memory, data memory, timers, serial communication capabilities using SPI and I2C protocols, and 15 interrupt sources. Code examples are given to initialize and send data to a 16x2 LCD display using the PIC16F877A.
Arduino is an open- source computer hardware and software company, project and user community that designs and manufactures microcontroller-based kits for building systems consisting of digital devices, interactive objects that can sense and control in the physical world.
The document discusses open loop transfer functions and stability analysis using Nyquist plots. It begins with an outline of topics including partial fraction expansion, open loop systems, Nyquist plots, and stability criteria. It then provides examples of using partial fraction expansion to decompose transfer functions with real distinct roots, complex conjugate roots, and repeated roots. The document explains open loop and closed loop system nomenclature. It introduces the Nyquist stability criterion, which involves plotting the open loop transfer function on the Nyquist plot and checking if it encircles the critical point at -1.
This document provides an introduction to microcontrollers and electronics basics using Arduino and RedBoard microcontrollers. It covers topics such as Arduino and RedBoard overview, downloading the Arduino IDE, connecting boards to computers, installing drivers, selecting boards and serial devices in the IDE interface, and an overview of the key areas of the Arduino GUI. It also introduces basic electronics concepts like circuits, Ohm's Law, analog and digital signals. Several example circuits are presented to blink an LED, read input from a potentiometer to control blink rate, use a light sensor to control an LED, and read temperature from a sensor.
This document summarizes various computer interfaces including wired interfaces like USB, serial ports, and parallel ports as well as wireless interfaces like WiFi and Bluetooth. It also discusses 'embedded' interfaces like SPI, I2C, and 1-Wire. The document then focuses on the RS232 serial port protocol and issues like voltage levels. It provides an example project of an Arduino thermometer and includes the Arduino and PC code used. It concludes with mentioning an example OrangeMessenger project.
Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...Amr E. Mohamed
The document discusses frequency response analysis and Bode plots. It begins with an introduction to frequency response and how the steady state response of a linear time-invariant system to a sinusoidal input is another sinusoid at the same frequency with a different magnitude and phase. The complex ratio of the output to input is called the frequency response. It then discusses Bode plots which show the magnitude and phase of the frequency response on logarithmic scales. Key features of components in open-loop transfer functions and how they affect the Bode plot shapes are explained. An example demonstrates drawing the Bode plots for a sample transfer function.
The document describes a project on designing a 4-bit linear feedback shift register (LFSR). It discusses how an LFSR works by shifting bits left and applying an XOR operation to the last two bits. It then provides details on the circuit components including D flip-flops and XOR gates. Applications mentioned include generating pseudo-random numbers for cryptography, digital communications systems, and testing systems.
This presentation provides a very brief overview of a Seven Segment Display.
For details on how to use Seven Segment Display with Arduino please visit www.harekrishnahub.com
ARM is a 32-bit reduced instruction set computing (RISC) architecture developed in 1985. It features a load/store architecture, uniform instruction length, and conditional execution of instructions based on status flags. ARM processors operate in different modes like user, system, and interrupt modes. Newer ARM features include more control over arithmetic logic unit and shifter operations, auto-increment/decrement addressing, and conditional execution of instructions. ARM uses load/store instructions to transfer data between registers and memory.
This document provides an introduction to microprocessors and microcontrollers, with a focus on the Texas Instruments MSP430. It discusses the historical background of microprocessors from the invention of transistors in 1947 to the development of the first microcontroller in 1978. It also describes Moore's Law predicting the doubling of transistor density every 1-2 years. The document outlines the key features of microcontrollers like small size, low cost, and low power consumption. Finally, it provides an overview of the MSP430 microcontroller family and its applications in low-power embedded systems.
Types of encoders and decoders with truth tablesAbdullah khawar
Encoders and decoders are used to convert data between different forms. Encoders convert analog to digital signals, while decoders convert digital to analog. There are different types of encoders and decoders like 4-bit, 8-bit, etc. They are designed using logic gates. Encoders have multiple inputs but only one is active at a time, producing an output code. Decoders have a single input but multiple outputs, with only one active at a time. Encoders and decoders are used in applications like motor speed synchronization, remote-controlled robots, home automation, and wireless health monitoring. RF technology is often used to transmit data between the encoder and decoder.
The document discusses read and write operations in computer memory. A write operation transfers the address and data to the memory lines and activates the write control line. A read operation transfers the address and activates the read control line. The memory enable line determines if a read or write occurs based on whether the read/write line is set to 0 or 1. Memory stores data in n-bit words that can be accessed using k address lines, with data input and output lines transferring data during write and read operations respectively.
This document discusses several methods for designing sequential circuits, including state tables, state assignment, and deriving flip-flop input equations. It then provides examples of implementing sequential circuits using ROMs, PLAs, CPLDs, and FPGAs. Specifically, it designs a comparator circuit and code converter as examples of iterative and sequential circuits. It also discusses implementing a parallel adder and shift register using an FPGA.
O documento descreve o desdobramento e escalonamento de um loop MIPS de 4 instruções para melhorar o seu desempenho no pipeline. Inicialmente, o loop é desdobrado em 4 cópias, renomeando os registradores em cada cópia. Em seguida, as instruções são reordenadas para remover dependências e evitar bolhas no pipeline. O código desdobrado e escalonado consegue executar em menos ciclos de clock do que o código original não otimizado.
This document contains lecture notes on general purpose input/output (GPIO) for AVR microcontrollers. It discusses GPIO pins on the ATmega32 microcontroller, how to configure pins as inputs or outputs, and interfacing examples with LEDs and buttons. It provides code examples for blinking an LED, reading a button press, and two programming projects - a password system using buttons and LEDs, and a two-player game to increment port values and identify the first to reach 255. The document is intended to teach basic GPIO concepts and their application in microcontroller programming.
The document discusses the architecture of the TMS320C50 digital signal processor. It describes the TMS320C50's key components including its central processing unit with arithmetic logic unit, parallel logic unit, auxiliary register arithmetic unit, and memory mapped registers. It also outlines the processor's bus structure, on-chip memory including RAM and ROM, and on-chip peripherals such as timers, I/O ports, and serial interfaces. The TMS320C50 uses a Harvard architecture with separate program and data buses for high parallelism and is optimized for digital signal processing applications with features like a single-cycle multiply-accumulate instruction.
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauriGaurav Pandey
The document provides an overview of the Arduino platform for beginners. It defines Arduino as an open-source platform used for building electronics projects. All Arduino boards contain a microcontroller, which is a small computer. It then describes some popular Arduino boards like the Uno, Nano, Due, and Mega and their key specs and applications. The document proceeds to explain the main components of an Arduino Uno board such as the power supply, USB port, microcontroller, analog and digital pins. It provides details on the functions of these components and how they enable the Arduino board to operate.
Digital fundamentals 8th edition by Thomas Floyd Dawood Aqlan
This document provides information about the textbook "Digital Fundamentals (8th Edition)" by Thomas L. Floyd. The textbook provides thorough coverage of digital fundamentals from basic concepts to more advanced topics like microprocessors, programmable logic, and digital signal processing. It is known for its clear explanations of theory supported by exercises and examples. The book uses a full-color format with visual aids to help students understand complex concepts.
DC-DC converters are essential components that transform direct current from one voltage level to another, enabling compatibility between electronic components. There are several types of DC-DC converters, including buck converters (which step down voltage), boost converters (which step up voltage), and buck-boost converters (which can do either). Converters operate in either continuous or discontinuous conduction mode depending on load conditions and design goals. Proper control strategies are needed to efficiently regulate output voltage.
Digital Systems Design Using Verilog 1st edition by Roth John Lee solution ma...endokayle
link full download: https://testbankstudy.com/product/digital-systems-design-using-verilog-1st-edition-by-roth-john-lee-solution-manual/
Language: English
ISBN-10: 1285051076
ISBN-13: 978-1285051079
ISBN-13: 9781285051079
Approximation techniques used for general purpose algorithmsSabidur Rahman
Survey on approximation techniques used for general purpose algorithms, data parallel applications ans solid-state memories. It is interesting to see how approximation algorithms can contribute to solve real-life problems with better efficiency and lower cost!
Questions? krahman@ucdavis.edu.
Design of -- Two phase non overlapping low frequency clock generator using Ca...Prashantkumar R
This document describes designing a two-phase non-overlapping clock generator circuit with buffered outputs. The circuit is required to generate clean square wave clock signals from a single-phase input clock between 10-100MHz. The output signals must drive a 0.33pF capacitive load without distortion. The design will be implemented using Cadence tools and modified through simulation to meet the objectives of generating true non-overlapping signals with at least 1ns of underlap that can operate over the specified frequency range and drive the required load.
FPGA Based Implementation of Electronic Safe LockIOSR Journals
Abstract :Thispaper is based on design of an “Automatic Security System Using VHDL” providing understandable and adequate operating procedure to the user. The operation is conducted by six different modules. If any of the modules fails, the failed module can be replaced without affecting the activity of others. The safety is ensured to the user by setting a secret code number which is the combination of three numbers, by doing so, only the authorized users can unlock the safe. The paper finds its appositeness in big organizations, military and banking sectors. Simulation through VHDL is quite generous and fiscal due to the reduction in number of components. Important operation consideration is to not give any indication to the user that the combination entered is incorrect until after the user has entered the all three numbers and pressed the OPEN key. Otherwise, it is possible for a user to determine the combination in no more than 96 attempts, as opposed to no more than 32,768 attempts. Keywords –FPGA, FSM, LOCK, VHDL, XILINX
https://www.udemy.com/vlsi-academy
http://vlsisystemdesign.com/noise_margin.php
Noise margin is the amount of noise that a CMOS circuit could withstand without compromising the operation of circuit. Noise margin does makes sure that any signal which is logic '1' with finite noise added to it, is still recognised as logic '1' and not logic '0'. It is basically the difference between signal value and the nosie value.
The document discusses the 8051 microcontroller. It defines a microcontroller as a self-contained system with peripherals, memory and a processor that can be used as an embedded system. Examples of early microcontrollers are provided. The document outlines the content, provides the pin diagram and architecture of the 8051 microcontroller, lists its features and applications. It compares microcontrollers to microprocessors and notes the advantages and disadvantages of microcontrollers.
This document discusses two methods for PID tuning using the Ziegler-Nichols method: the step input or open loop method and the critical gain-critical period or closed loop method. The step input method analyzes the response of a plant to a step input to determine delay time and time constant. These values are then used to calculate PID parameters according to Ziegler-Nichols formulas. The critical gain-critical period method increases the proportional gain with the integral and derivative terms set to zero until sustained oscillations occur, allowing determination of critical gain and period to again calculate PID parameters.
Application of code composer studio in digital signal processingIAEME Publication
This document discusses the Code Composer Studio (CCS) integrated development environment for digital signal processing applications on Texas Instruments processors. CCS provides tools for editing, building, debugging, and testing programs. It allows writing code in C/C++ and includes compilers, assemblers, linkers and debuggers. The document outlines the software development flow in CCS, including compiling, assembling, linking and debugging programs. It also provides steps for creating a new project in CCS and adding source files.
coma Study Room vol.2 Arduino WorkshopEto Haruhiko
This slide explains how to control motors by Arduino and Processing.
You can see one of the applications of motor control in this vid:
youtu.be/0nw3DtXrLLI
(Raspberry Pi is used here instead of Arduino)
coma Study Room vol.2
3.22(Sat) 18:00-22:30@Bullet’s
http://coma.io/coma-study-room-vol-2/
ARM is a 32-bit reduced instruction set computing (RISC) architecture developed in 1985. It features a load/store architecture, uniform instruction length, and conditional execution of instructions based on status flags. ARM processors operate in different modes like user, system, and interrupt modes. Newer ARM features include more control over arithmetic logic unit and shifter operations, auto-increment/decrement addressing, and conditional execution of instructions. ARM uses load/store instructions to transfer data between registers and memory.
This document provides an introduction to microprocessors and microcontrollers, with a focus on the Texas Instruments MSP430. It discusses the historical background of microprocessors from the invention of transistors in 1947 to the development of the first microcontroller in 1978. It also describes Moore's Law predicting the doubling of transistor density every 1-2 years. The document outlines the key features of microcontrollers like small size, low cost, and low power consumption. Finally, it provides an overview of the MSP430 microcontroller family and its applications in low-power embedded systems.
Types of encoders and decoders with truth tablesAbdullah khawar
Encoders and decoders are used to convert data between different forms. Encoders convert analog to digital signals, while decoders convert digital to analog. There are different types of encoders and decoders like 4-bit, 8-bit, etc. They are designed using logic gates. Encoders have multiple inputs but only one is active at a time, producing an output code. Decoders have a single input but multiple outputs, with only one active at a time. Encoders and decoders are used in applications like motor speed synchronization, remote-controlled robots, home automation, and wireless health monitoring. RF technology is often used to transmit data between the encoder and decoder.
The document discusses read and write operations in computer memory. A write operation transfers the address and data to the memory lines and activates the write control line. A read operation transfers the address and activates the read control line. The memory enable line determines if a read or write occurs based on whether the read/write line is set to 0 or 1. Memory stores data in n-bit words that can be accessed using k address lines, with data input and output lines transferring data during write and read operations respectively.
This document discusses several methods for designing sequential circuits, including state tables, state assignment, and deriving flip-flop input equations. It then provides examples of implementing sequential circuits using ROMs, PLAs, CPLDs, and FPGAs. Specifically, it designs a comparator circuit and code converter as examples of iterative and sequential circuits. It also discusses implementing a parallel adder and shift register using an FPGA.
O documento descreve o desdobramento e escalonamento de um loop MIPS de 4 instruções para melhorar o seu desempenho no pipeline. Inicialmente, o loop é desdobrado em 4 cópias, renomeando os registradores em cada cópia. Em seguida, as instruções são reordenadas para remover dependências e evitar bolhas no pipeline. O código desdobrado e escalonado consegue executar em menos ciclos de clock do que o código original não otimizado.
This document contains lecture notes on general purpose input/output (GPIO) for AVR microcontrollers. It discusses GPIO pins on the ATmega32 microcontroller, how to configure pins as inputs or outputs, and interfacing examples with LEDs and buttons. It provides code examples for blinking an LED, reading a button press, and two programming projects - a password system using buttons and LEDs, and a two-player game to increment port values and identify the first to reach 255. The document is intended to teach basic GPIO concepts and their application in microcontroller programming.
The document discusses the architecture of the TMS320C50 digital signal processor. It describes the TMS320C50's key components including its central processing unit with arithmetic logic unit, parallel logic unit, auxiliary register arithmetic unit, and memory mapped registers. It also outlines the processor's bus structure, on-chip memory including RAM and ROM, and on-chip peripherals such as timers, I/O ports, and serial interfaces. The TMS320C50 uses a Harvard architecture with separate program and data buses for high parallelism and is optimized for digital signal processing applications with features like a single-cycle multiply-accumulate instruction.
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauriGaurav Pandey
The document provides an overview of the Arduino platform for beginners. It defines Arduino as an open-source platform used for building electronics projects. All Arduino boards contain a microcontroller, which is a small computer. It then describes some popular Arduino boards like the Uno, Nano, Due, and Mega and their key specs and applications. The document proceeds to explain the main components of an Arduino Uno board such as the power supply, USB port, microcontroller, analog and digital pins. It provides details on the functions of these components and how they enable the Arduino board to operate.
Digital fundamentals 8th edition by Thomas Floyd Dawood Aqlan
This document provides information about the textbook "Digital Fundamentals (8th Edition)" by Thomas L. Floyd. The textbook provides thorough coverage of digital fundamentals from basic concepts to more advanced topics like microprocessors, programmable logic, and digital signal processing. It is known for its clear explanations of theory supported by exercises and examples. The book uses a full-color format with visual aids to help students understand complex concepts.
DC-DC converters are essential components that transform direct current from one voltage level to another, enabling compatibility between electronic components. There are several types of DC-DC converters, including buck converters (which step down voltage), boost converters (which step up voltage), and buck-boost converters (which can do either). Converters operate in either continuous or discontinuous conduction mode depending on load conditions and design goals. Proper control strategies are needed to efficiently regulate output voltage.
Digital Systems Design Using Verilog 1st edition by Roth John Lee solution ma...endokayle
link full download: https://testbankstudy.com/product/digital-systems-design-using-verilog-1st-edition-by-roth-john-lee-solution-manual/
Language: English
ISBN-10: 1285051076
ISBN-13: 978-1285051079
ISBN-13: 9781285051079
Approximation techniques used for general purpose algorithmsSabidur Rahman
Survey on approximation techniques used for general purpose algorithms, data parallel applications ans solid-state memories. It is interesting to see how approximation algorithms can contribute to solve real-life problems with better efficiency and lower cost!
Questions? krahman@ucdavis.edu.
Design of -- Two phase non overlapping low frequency clock generator using Ca...Prashantkumar R
This document describes designing a two-phase non-overlapping clock generator circuit with buffered outputs. The circuit is required to generate clean square wave clock signals from a single-phase input clock between 10-100MHz. The output signals must drive a 0.33pF capacitive load without distortion. The design will be implemented using Cadence tools and modified through simulation to meet the objectives of generating true non-overlapping signals with at least 1ns of underlap that can operate over the specified frequency range and drive the required load.
FPGA Based Implementation of Electronic Safe LockIOSR Journals
Abstract :Thispaper is based on design of an “Automatic Security System Using VHDL” providing understandable and adequate operating procedure to the user. The operation is conducted by six different modules. If any of the modules fails, the failed module can be replaced without affecting the activity of others. The safety is ensured to the user by setting a secret code number which is the combination of three numbers, by doing so, only the authorized users can unlock the safe. The paper finds its appositeness in big organizations, military and banking sectors. Simulation through VHDL is quite generous and fiscal due to the reduction in number of components. Important operation consideration is to not give any indication to the user that the combination entered is incorrect until after the user has entered the all three numbers and pressed the OPEN key. Otherwise, it is possible for a user to determine the combination in no more than 96 attempts, as opposed to no more than 32,768 attempts. Keywords –FPGA, FSM, LOCK, VHDL, XILINX
https://www.udemy.com/vlsi-academy
http://vlsisystemdesign.com/noise_margin.php
Noise margin is the amount of noise that a CMOS circuit could withstand without compromising the operation of circuit. Noise margin does makes sure that any signal which is logic '1' with finite noise added to it, is still recognised as logic '1' and not logic '0'. It is basically the difference between signal value and the nosie value.
The document discusses the 8051 microcontroller. It defines a microcontroller as a self-contained system with peripherals, memory and a processor that can be used as an embedded system. Examples of early microcontrollers are provided. The document outlines the content, provides the pin diagram and architecture of the 8051 microcontroller, lists its features and applications. It compares microcontrollers to microprocessors and notes the advantages and disadvantages of microcontrollers.
This document discusses two methods for PID tuning using the Ziegler-Nichols method: the step input or open loop method and the critical gain-critical period or closed loop method. The step input method analyzes the response of a plant to a step input to determine delay time and time constant. These values are then used to calculate PID parameters according to Ziegler-Nichols formulas. The critical gain-critical period method increases the proportional gain with the integral and derivative terms set to zero until sustained oscillations occur, allowing determination of critical gain and period to again calculate PID parameters.
Application of code composer studio in digital signal processingIAEME Publication
This document discusses the Code Composer Studio (CCS) integrated development environment for digital signal processing applications on Texas Instruments processors. CCS provides tools for editing, building, debugging, and testing programs. It allows writing code in C/C++ and includes compilers, assemblers, linkers and debuggers. The document outlines the software development flow in CCS, including compiling, assembling, linking and debugging programs. It also provides steps for creating a new project in CCS and adding source files.
coma Study Room vol.2 Arduino WorkshopEto Haruhiko
This slide explains how to control motors by Arduino and Processing.
You can see one of the applications of motor control in this vid:
youtu.be/0nw3DtXrLLI
(Raspberry Pi is used here instead of Arduino)
coma Study Room vol.2
3.22(Sat) 18:00-22:30@Bullet’s
http://coma.io/coma-study-room-vol-2/
1. 3台以上のArduinoでのSPI通信 ver.1 = 2017-07-20
以下の記事を参考にした
How do you use SPI on an Arduino? - Arduino Stack Exchange
https://arduino.stackexchange.com/questions/16348/how-do-you-use-spi-on-an-arduino
1totでの接続はSS=10が基本
いくつかの例題を見ると、SS=10, MOSI=11, MISO=12, SCK=13がよく用いられる。
1つのMasterに複数のSlaveをつなげる一つの方法はSSを増やすこと。
3台のArduinoでMaster-Slavesをやる場合:
2台のSalveをつなげる場合は、例えば、SS1=10,SS2=9とする。
それぞれのSlaveがMasterとSSを共有する。
SCK,MISO,MOSIは3台で共有できる。
GNDは繋いだ方が良いかもしれない。
サンプルプログラム ( Arduino Codes)
ここではSlave1=SS=10, Slave2=SS=9とした
Master:
#include <SPI.h>
void setup (void)
{
Serial.begin (115200); // Serialの通信スピード
Serial.println ();
digitalWrite(10, HIGH); // ensure SS=10 stays high for now
2. digitalWrite(9, HIGH); // ensure SS=9 stays high for now
SPI.begin ();
// Slow down the master a bit
SPI.setClockDivider(SPI_CLOCK_DIV8);
} // end of setup
byte transferAndWait (const byte what)
{
byte a = SPI.transfer (what);
delayMicroseconds (20);
return a;
} // end of transferAndWait
void loop (void)
{
byte a, b, c, d;
// enable Slave Select
digitalWrite(10, LOW); // Slave1=SS=10
digitalWrite(9, LOW); // Slave2=SS=9
transferAndWait ('a'); // add command
transferAndWait (10);
a = transferAndWait (17);
b = transferAndWait (33);
c = transferAndWait (42);
d = transferAndWait (0);
// disable Slave Select
digitalWrite(10, HIGH); // Slave1=SS=10, slave2=SS=9
Serial.println ("Adding results:");
Serial.println (a, DEC);
Serial.println (b, DEC);
Serial.println (c, DEC);
Serial.println (d, DEC);
// enable Slave Select
digitalWrite(10, LOW); // Slave1=SS=10
transferAndWait ('s'); // subtract command
transferAndWait (10);
a = transferAndWait (17);
b = transferAndWait (33);
c = transferAndWait (42);
d = transferAndWait (0);
// disable Slave Select
digitalWrite(9, HIGH); // Slave1=SS=9
Serial.println ("Subtracting results:");
Serial.println (a, DEC);
Serial.println (b, DEC);
Serial.println (c, DEC);
Serial.println (d, DEC);
delay (1000); // 1 second delay
3. } // end of loop
Slave1:
// what to do with incoming data
volatile byte command = 0;
void setup (void)
{
Serial.begin (115200); // Serialの通信スピード
// have to send on master in, *slave out*
pinMode(MISO, OUTPUT);
// turn on SPI in slave mode
SPCR |= _BV(SPE);
// turn on interrupts
SPCR |= _BV(SPIE);
} // end of setup
// SPI interrupt routine
ISR (SPI_STC_vect)
{
byte c = SPDR;
switch (command)
{
// no command? then this is the command
case 0:
command = c;
SPDR = 0;
break;
// add to incoming byte, return result
case 'a':
SPDR = c + 15; // add 15
break;
// subtract from incoming byte, return result
case 's':
SPDR = c - 8; // subtract 8
break;
} // end of switch
} // end of interrupt service routine (ISR) SPI_STC_vect
void loop (void)
{
// if SPI not active, clear current command
if (digitalRead (10) == HIGH){ // slave1=SS=10
Serial.println ("called by MASTER, slave01");
4. command = 0;
}
} // end of loop
Slave2:
// what to do with incoming data
volatile byte command = 0;
void setup (void)
{
Serial.begin (115200); // Serialの通信スピード
// have to send on master in, *slave out*
pinMode(MISO, OUTPUT);
// turn on SPI in slave mode
SPCR |= _BV(SPE);
// turn on interrupts
SPCR |= _BV(SPIE);
} // end of setup
// SPI interrupt routine
ISR (SPI_STC_vect)
{
byte c = SPDR;
switch (command)
{
// no command? then this is the command
case 0:
command = c;
SPDR = 0;
break;
// add to incoming byte, return result
case 'a':
SPDR = c + 15; // add 15
break;
// subtract from incoming byte, return result
case 's':
SPDR = c - 8; // subtract 8
break;
} // end of switch
} // end of interrupt service routine (ISR) SPI_STC_vect
void loop (void)
{
5. // if SPI not active, clear current command
if (digitalRead (9) == HIGH){ // slave2=SS=9
Serial.println ("called by MASTER, slave02");
delay(500);
command = 0;
}
} // end of loop
MacでのArduinoとのシリアル通信
以下のコマンドをターミナルで実行すると、Arduinoがつながったポートがわかる:
$ ls /dev/tty.*
/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbmodem14121
/dev/tty.iPad-WirelessiAP /dev/tty.usbmodem14131
/dev/tty.lpss-serial1 /dev/tty.usbmodem14141
/dev/tty.lpss-serial2
ここで
/dev/tty.usbmodem14121, /dev/tty.usbmodem14131, /dev/tty.usbmodem14141
がArduinoが接続されたポート
Arduino IDEを使っても、確認できる