background image

BUILD IT

Summary of Contents for Arduino starter kit with Logic Analyzer

Page 1: ...Arduino starter kit with Logic Analyzer The best kit to get started with Arduino coding and electronics...

Page 2: ...n and the provisions of relevant collective licensing agreements no reproduction of any part may take place without the written premission of Zeroplus Graphics Artwork Alberto Piganti Layout David Ant...

Page 3: ...Software Tutorial Serial Interface Experiment 1 LED Experiment 2 Photoresistor Experiment 3 Sensors Experiment 4 Find the Key Experiment 5 Temperature Controlled DC Motor Experiment 6 LCD Experiment...

Page 4: ...ook consists of experiments that cover several aspects of electronics Arduino programming and logic acquisition After finishing this book we hope the reader to have a better understanding of logic acq...

Page 5: ...NSIDE THE BOX 4 The box contains a Zeroplus LAP Educator 8 channel logic analyzer bundled with an Arduino UNO and a number of modules components and accessories that will allow you to do all the exper...

Page 6: ...le 1 x Sound Sensor Detects sound 1 x USB Bridge Converts type A to type B USB 1 x I2C RGB LED I2C controlled LEDs VCC D D GND J2 Q4 R4 R7 R6 R5 R11R 10 SW1 R9 R8 U1 J1 VCC A1 A0 DS4 DS3 DS2 DS1 R3 R2...

Page 7: ...Cable For the Arduino UNO 1x8 and 1x2 and 1x1 Female to female jumpers Provided with the LAP Educator 20 x Male to male jumpers Breadboard to Arduino connections 1 x Type A mini B connector For the LA...

Page 8: ...Motor 5 x LED 1 x Photoresistor 2 x 104 F Capacitor 4 x Push button 1 x 10k Potentiometer 1 x BC337 NPN Transistor 1 x LM335 Temperature Sensor 1 x 1N4148 Diode 4 x 10k Resistor 2 x 2 2k Resistor 4 x...

Page 9: ...ototypes and experiments Bus strips bue and red provide power to the electronic components There is one for ground and one for a supply voltage Terminal links in green connect smaller areas together L...

Page 10: ...W h a t I s a L o g i c A n a l y z e r...

Page 11: ...he characteristics of analog signals such as waveforms amplitude frequency or phase but they can t handle the complexity of digital circuits or a large number of signals Logic analyzers capture and di...

Page 12: ...mple 8 channel logic analyzer with an all new UI Users can easily learn Arduino programming and work with the sensors and modules included with the LAP Educator CONNECTIONS WITH THE ARDUINO UNO LAP ED...

Page 13: ...12 PORT OVERVIEW L A P E D U C A T O R...

Page 14: ...S o f t w a r e I n s t a l l a t i o n a n d I n t r o d u c t i o n...

Page 15: ...E In the drop down menu Product choose Arduino starter kit with logic analyzer Click on Search and click on the Software download link Follow the steps on the next page to install ZP Studio on your co...

Page 16: ...xt Step7 Click on Finish Step8 Restart your computer Step1 Click on Next Step2 Accept the license agreement Step3 Enter your name and the name of your organization Step4 Click on Next Step5 Click on I...

Page 17: ...book except for the chapter Keyboard which doesn t require the Arduino You don t need to understand the source code to get through the book but we encourage you to look at it and even modify it Exper...

Page 18: ...GETTING TO KNOW THE INTERFACE Option menu Start capturing Waveform area Sampling settings Tabs Quick access panels Channels S O F T W A R E...

Page 19: ...located to pre trigger data and 90 to post trigger data External clock Used for state analyses an external clock signal from your device defines when the logic analyzer latches the input signals 4 4 T...

Page 20: ...t and Sampling Settings buttons Start is used for starting an acquisition capture and Sampling Settings contains basic settings for the logic analyzer The Option Menu is located at the top right corne...

Page 21: ...ANALYZING 1 Set the sample rate memory depth and trigger level 2 Set the trigger condition Decode protocols 4 Check the decoded result on the tab Packet List 5 3 Start capturing 1 4 5 2 3 20 S O F T W...

Page 22: ...ues occur you will need to track and analyze a lot of signals which sometimes proves to be a difficult task due to insufficient memory depth By enabling compression the Logic Educator extends the reac...

Page 23: ...ed channel by channel in the dialog box and new curly traces in the waveform area evidence where the two signals differ Open two files then select a reference and a contrast file 1 Under Display Optio...

Page 24: ...rea Switch to Repeated Capture Mode by right clicking on the Start Capture button The cursors are used for measuring the distance between two events unit shown in seconds or number of sample points Sh...

Page 25: ...this is very good for beginners The Arduino UNO is a microcontroller board based on the ATmega328 It has 14 digital input output pins of which 6 can be used as PWM outputs 6 analog inputs a 16 MHz ce...

Page 26: ...the Arduino IDE from www arduino cc en Main Software Open the file you have downloaded Step1 Click on I Agree Step2 Click on Next Step3 Click on Install Step4 Click on Close You can find more informat...

Page 27: ...e sketch currently open 1 New Creates a new sketch 3 Verify Checks your code and compiles it Upload Compiles your code and uploads it to the Arduino UNO 2 4 Open Opens an existing sketch 5 Save Saves...

Page 28: ...duino Genuino Uno in the menu Tools Board Second choose the port to which your board is connected to Sometimes the IDE fails to upload the code to the Arduino When it happens simply try again until it...

Page 29: ...follow the procedure below to upload the source code to the Arduino UNO Open the sketch file corresponding to the relevant chapter Verify and compile Upload to the Arduino UNO UPLOADING SKETCHES TO T...

Page 30: ...L o g i c A c q u i s i t i o n a n d S o f t w a r e T u t o r i a l...

Page 31: ...30 G O A L S Learn basic concepts of logic acquisition Introduce import ant software functions x 8...

Page 32: ...load it to the Arduino Uno In the Arduino IDE open the serial monitor In the serial monitor enter 1 then click on Send In ZP Studio set the trigger to rising edge on the channel A0 the sample rate at...

Page 33: ...riod Try with a lower sample rate for example 400KHz and click on Run Repeat until you can see two or more periods of the signal Notice the two icons in the menu Settings The leftmost icon enables the...

Page 34: ...Now we need to group the channels into what is called a bus Right click on the channel A1 and select Add channel bus Click on Bus and on Next then use right arrow to select the channels that you want...

Page 35: ...er is displayed on the bus channel Step 3 Connect the logic analyzer to the Arduino UNO as shown on the diagram In the serial monitor enter 3 and click on Send Other settings remain unchanged Click on...

Page 36: ...s are caused by the delay between the channels and they interfere with the decoding You can use the Noise filter in the option menu to remove them Place the bar A shift A at the beginning of the value...

Page 37: ...r dialog box select the bus click on the right arrow and enter the duration you measured Verify that the transitional values have disappeared Step 4 Connect the logic analyzer to the Arduino UNO as sh...

Page 38: ...sing edge Set the trigger to rising edge on the channel connected to the pin 9 channel A2 Set the sample depth to 2kb Click on Run Result Notice how few samples are necessary to reproduce the signals...

Page 39: ...the logic gates It is appropriate for capturing synchronous signals In this type of acquisition signals are sampled on the edges of the device s clock either when rising falling or both A timing acqu...

Page 40: ...f the port B pins 8 to 13 as outputs CODE EXPLANATION Logic analyzers are used by engineers working with digital circuits to observe signals to ensure data are correctly transmitted and to track down...

Page 41: ...cessary samples Too low and you ll miss a lot of information resulting in a waveform which is not a correct representation of the real signal 2 How to determine whether a certain voltage should be rea...

Page 42: ...S e r i a l I n t e r f a c e...

Page 43: ...42 Introduce the concept of protocol Visualize packets with a protocol decoder Communicate with the Arduino board via the serial monitor G O A L S x 2...

Page 44: ...are ubiquitous such as I2C SPI or 1 wire Serial protocols use a single line to send data one bit at a time whereas parallel protocols send data over several wires in one clock cycle Serial protocols...

Page 45: ...oose ASCII You should see the frame below There are three blocks A Start bit in blue 7 data bits in green and a Stop bit in red The Start and Stop bits separate each piece of data When the pin 8 of th...

Page 46: ...pinMode pin8 INPUT_PULLUP The pin is pulled up so that by default it is at a logic 1 Connect it to the ground to force it to 0 CODE EXPLANATION C O D E...

Page 47: ...trial applications Also most microcontrollers such as the one embedded on your Arduino board is equipped with a UART Pictured below the RS 232 connector was widely used before USB became a standard RE...

Page 48: ...E x p e r i m e n t 1 L E D...

Page 49: ...48 Familiarize yourself with the Arduino language Connect the Arduino the breadboard and a few basic components together to create your first circuit G O A L S x 1 x 1 x 1 x 1 x 6...

Page 50: ...ght up an LED when a pushbutton is pressed down and switch it off when the button is released 2 The pins on the Arduino can be configured either as inputs to receive information from the outside world...

Page 51: ...50 5V Digital PIN 8 10k 330 Digital PIN 9 A K S C H E M A T I C...

Page 52: ...A K B U I L D I T...

Page 53: ...output void loop Write your code between the brackets It loops until the board is reset or powered off digitalRead buttonPin Reads pins value The function returns 0 or 1 A digital read is perfect for...

Page 54: ...ushbuttons and LEDs are everywhere Think of keys on your keyboard buttons on your Smartphone lights indicating a received notification LED flashlights etc REAL LIFE APPLICATIONS A P P L I C A T I O N...

Page 55: ...usted Look for the flat edge it indicates the cathode As you can see in this circuit the cathode is connected to the ground while the anode is connected to the signal Reverse it and the current will n...

Page 56: ...E x p e r i m e n t 2 P h o t o r e s i s t o r...

Page 57: ...Use a photoresistor Get and manipulate values Obtained from a sensor 56 G O A L S x 1 x 1 x 11...

Page 58: ...sor outputs an analog signal we have to convert this analog signal into a digital signal that can be acquired by the logic analyzer The analog digital conversion is handled by an ADC Analog to Digital...

Page 59: ...58 5V Analog PIN A0 10k S C H E M A T I C...

Page 60: ...B U I L D I T...

Page 61: ...h the channels A0 to A6 right click on the BUS you just created BUS0 and select analog waveform In ZP Studio select the Noise Filter to remove any transitional values as explained in the chapter Logic...

Page 62: ...ambient light light map light sensorLow sensorHigh 0 100 map redefines the working range and assign to the variable a new value from the new scale light constrain light 0 100 constrain forces the valu...

Page 63: ...62 The Arduino can read analog waveforms on the pins A0 to A5 but it cannot generate analog signals REMARKS R E M A R K S...

Page 64: ...E x p e r i m e n t 3 S e n s o r s...

Page 65: ...64 Capturelightandsoundwithaphotoresistor and a sound sensor USE the function millis as an alternative to delay G O A L S x 2 x 1 x 1 x 1 x 12 x 2 R3 R2 R1 SG VR1 L2 R6 A0 G D0 R5 L1...

Page 66: ...ssociated sensor measure a value that goes above a certain threshold the reference value One LED turns on when the sensor detects a sound The other LED turns on when the other sensor detects a certain...

Page 67: ...66 5V Digital PIN 4 330 10k Digital PIN 9 Digital PIN 5 330 Analog PIN A0 GND Out VCC Sound Sensor A K A K S C H E M A T I C...

Page 68: ...A K Sound Sensor GND VCC OUT B U I L D I T...

Page 69: ...he sensor detects a sound we set the flag SoundLed We also save the time it occurred if soundLed HIGH soundCurrentTime currentMillis if soundCurrentTime soundStartTime timeInterval soundLed LOW This p...

Page 70: ...Microphones are sound sensors REAL LIFE APPLICATIONS B U I L D I T...

Page 71: ...could have called delay but delay prevents the microcontroller to perform other tasks in the meantime Using millis the way we do leaves the processor free to monitor the photoresistor REMARKS R E M A...

Page 72: ...E x p e r i m e n t 4 F i n d t h e k e y...

Page 73: ...72 Use the logic analyzer to solve a problem G O A L S x 1 x 1 x 1 x 4 x 1...

Page 74: ...n number is read on the inputs of the Arduino board Our goal is to discover that number with the help of the logic analyzer We opted for a photoresistor to sweep through the whole range of values 1 DE...

Page 75: ...74 5V Digital PIN 13 330 10k Analog PIN A0 A K S C H E M A T I C...

Page 76: ...A K B U I L D I T...

Page 77: ...Studio set the trigger to rising edge on A0 because the signal is rising when the LED turns on and that s what we want to detect In ZP Studio create a bus with the channels A1 to A5 Click on Run The v...

Page 78: ...31 Generates a pseudo random number calibrate This function calibrates the sensor to the light in your environment It does so by calling adjustSentivity several times and runs once in the setup loop C...

Page 79: ...t tests all possible values Most smartphones embed a proximity sensor that turns off the screen during a call when it approaches your ear It avoids accidental touches A light sensor is preferred over...

Page 80: ...E x p e r i m e n t 5 T e m p e r a t u r e c o n t r o l l e d D C m o t o r...

Page 81: ...80 Control a DC motor with a PWM Retrieve the temperature FROM a temperature sensor G O A L S x 1 x 1 BC548 x 1 x 1 LM35 x 1 x 1 1O4 x 1 x 1 x 11...

Page 82: ...principle The sensor monitors the room temperature and turns the motor on or off if the room gets above or below a certain temperature The motor s rotation speed is controlled by a PWM 1 and the power...

Page 83: ...82 Digital PIN 9 Battery Pack 5V E C B BC337 2N222 C E B NPN 330 Adj GND Out LM335 LM335 LM335 GND Out Adj Analog PIN A0 1N4148 2 2k 104uF S C H E M A T I C...

Page 84: ...Adj GND Out LM335 LM335 1N4148 E C B BC337 2N222 B U I L D I T...

Page 85: ...e controlled with a PWM float millivolts read_voltage 1024 0 5000 AnalogWrite AnalogWrite has a resolution of 5 volts divided into 1024 values which equals to a 4 88mV step By multiplying the value re...

Page 86: ...adiator That fan adjusts its rotation speed according to the temperature of the CPU That is why your computer emits a hissing sound when you are watching a movie playing a video game or performing any...

Page 87: ...ltage Digital signals can only be High or Low but using a PWM changing the proportion of time the signal is High compared to when it is Low over a consistent time interval the output voltage can be se...

Page 88: ...E x p e r i m e n t 6 L C D...

Page 89: ...88 DisplaycharactersonanLCD Usethelogiceducatorto captureanddecodeabus withaprotocoldecoder G O A L S x 16 x 1 x 1...

Page 90: ...displayed on the LCD screen via the serial monitor At the same time we capture the signals and use a special function called Image Decode to decode and display the characters in ZP Studio DESCRIPTION...

Page 91: ...N D0 D1 D2 D3 R W RS D4 D5 D6 D7 VE VDD GND EN D0 D1 D2 D3 R W RS D4 D5 D6 D7 BL BL D0 D7 EN R W RS VE VDD GND Data bits 0 to 7 Enable signal Read or Write Register select com or data Adjust LCD contr...

Page 92: ...RS R W EN of the LCD In ZP Studio set the trigger to rising edge on the pin EN In ZP Studio add the protocol decoder LCD1602 In ZP Studio click on Run PROCEDURE Logic Analyzer A0 A1 A2 A3 A4 A5 A6 A7...

Page 93: ...92 In the serial monitor type a few words and click on Send Here is what you should see P R O C E D U R E...

Page 94: ...You can use the table below to match the values shown in ZP studio with the characters P R O C E D U R E...

Page 95: ...function that decodes and displays the words you typed and sent to the LCD screen Rightclick on the bus and select Image Decode Then click on the button Image display and then on the play button Resul...

Page 96: ...2 Maps the physical pins with the pins defined in the library Serial begin 9600 Initializes the serial port 9600 is the rate in Bauds at which data are transmitted over the bus lcd begin 16 2 Initiali...

Page 97: ...96 Most displays surrounding us rely on LCD screens For example TV screens the screen of a printer or of a camera REAL LIFE APPLICATIONS R E M A R K S...

Page 98: ...E x p e r i m e n t 7 K e y b o a r d...

Page 99: ...98 Capture USB packets Use the mode Compression to extend the capture length TAP TAP TAP G O A L S x 1 VCC D D GND x 2 x 1...

Page 100: ...ltless The USB bridge brings the signals out saving you the cumbersome task of soldering wires to the I Os In this experiment we would like to capture the keys pressed on the keyboard but the computer...

Page 101: ...100 D E S C R I P T I O N...

Page 102: ...VCC D D GND S C H E M A T I C...

Page 103: ...e at 10MHz the memory at 32kb and click on the compression icon Click on Run and quickly write something as you will have a short window of time before the buffer becomes full Add the protocol decoder...

Page 104: ...r out irrelevant packets Your packets should be identical to those below except for the values in Data According to the documentation available on the USB Implementers Forum s website 1 the number 11...

Page 105: ...odern consumer electronics Keyboards mouse devices USB sticks countless gadgets all rely on the USB port to either transmit data or to draw their power from it See the conversion table page 53 http ww...

Page 106: ...E x p e r i m e n t 8 I 2 C p r o t o c o l C o n t r o l t h e L E D s...

Page 107: ...engineer a protocol with a logic analyzer G O A L S x 13 J2 Q4 R4 R7 R6 R5 R11R 10 SW1 R9 R8 U1 J1 VCC A1 A0 DS4 DS3 DS2 DS1 R3 R2 R1 Q3 Q2 Q1 VCC SDA SCL G SDA SCL G A1 A0 00 0x20 01 0x21 10 0x22 11...

Page 108: ...led I2C The logic educator has a protocol decoder for I2C but for the sake of the experiment we are going to pretend that it doesn t When we reverse engineer a protocol or a system we see it as a blac...

Page 109: ...2 Q1 VCC SDA SCL G SDA SCL G A1 A0 00 0x20 01 0x21 10 0x22 11 0x23 on 0 off 1 ON I2C RGB_V3 A1 A0 We are going to use the logic analyzer to visualize how the signals change when the buttons are presse...

Page 110: ...the sample depth to 2kb the trigger level to 2 5V and the trigger position to 10 3 Click on Run 4 Press the button connected to the pin 9 The logic analzyer will trigger 5 Save the file menu Option S...

Page 111: ...file choose the first file you saved as a contrast file choose the last file you saved Check the boxes Show files horizontally Synchronize navigation and Highlight differences then click on Apply In...

Page 112: ...to configure the state of the device With the function File comparison we can observe that the line on A1 remains unchanged whereas the end of the signal captured on A0 is different Because of the dut...

Page 113: ...or of the LEDs hasn t changed even though we pressed the button Data 16 Save the file under a new name and use the function File Comparison to compare it with the previously saved file The result is a...

Page 114: ...the end We re going to see why 17 On the I2C module there is a 2 position blue DIP switch Pull the two levers into this position 18 Click on Run and press the buttons Data and Send 19 Notice that the...

Page 115: ...he device matching with the address in the request will acknowledge that request In the fol lowing paragraphs we will call this button the button Address Now we are going to see what happens on the se...

Page 116: ...ill be printed if you push again the button Send And if you press the button connected to the pin 2 then the buttons Data and Send then the button connected to pin 2 again and the button Send it will...

Page 117: ...each digit corresponds to the state of an LED 28 Back to ZP Studio Put the button R W in position Read i e a number is printed on the serial monitor everytime you press Send 29 Keep the same settings...

Page 118: ...re 4 pulses equally spaced Therefore we can assume these four data correspond to the four digits printed on the serial monitor After this brief analysis we already know that the protocol I2C is compos...

Page 119: ...d Stop delimit the beginning and the end of the message The bits Acknowledge tell us whether the address read write bits and the data have been correctly received In the end in this experiment we ofte...

Page 120: ...actions to perform when an interrupt is called It is best to keep it short so that the processor can quickly return to its normal state eliminateBounce The mechanical contacts are not perfect They are...

Page 121: ...on t use interrupts here we would have to check the state of each button with a conditional statement and it would be very likely that we would miss the moment a button is pressed 2 Read the datasheet...

Page 122: ......

Page 123: ......

Reviews: