Girino Fast Arduino Oscilloscope PDF
Girino Fast Arduino Oscilloscope PDF
Girino Fast Arduino Oscilloscope PDF
Living
Outside
Play
Technology
Workshop
Step 11: How the Analog Comparator works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Step 12: Setting up the Analog Comparator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Step 13: Threshold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Step 14: How the Pulse Width Modulation works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Step 15: Setting up the PWM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Step 16: Volatile variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Step 17: Writing the kernel of the sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Step 18: Forming incoming signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Step 19: Bypass capacitors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Step 20: Power sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Step 21: Preparing a Shield Connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Step 22: Soldering and testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Step 23: Test signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Step 24: Time calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Step 25: Done! (Almost) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Step 26: To be continued... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
File Downloads
Girino.7z (90 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'Girino.7z']
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
Step 1: Disclaimer
THE AUTHOR OF THIS INSTRUCTABLE MAKES NO GUARANTEE OF VALIDITY AND NO WARRANTY WHATSOEVER. Electronics can be dangerous if you do not know what you are doing and the author cannot guarantee the validity of the information found here. This is not a professional advice and anything written in this instructable can be inaccurate, misleading, dangerous or wrong. Do not rely upon any information found here without independent verification. It is up to you to verify any information and to double check that you are not exposing yourself, or anyone, to any harm or exposing anything to any damage; I take no responsibility. You have to follow by yourself the proper safety precautions, if you want to reproduce this project. Use this guide at your own risk!
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
The raison d'tre of the holdoff phase is to prevent some undesired signals to get in the sweep region. It is a little bit long to explain this point and it eludes the purpose of this instructable. The moral of this story is that we need: 1. a threshold level to wich we can compare the incoming signal; 2. a signal that tells the microcontroller to start the waiting phase (see preceding step). We have several possible solutions for point 1. : using a trimmer we can manually set a voltage level; using the PWM of the Arduino we can set the level by software; using the 3.3 V provided by the Arduino itself; using the internal bangap reference we can use a fixed level. For point 2. we have the right solution: we can use the interrupt of the internal Analog Comparator of the microcontroller.
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
// in the ADC Data Register. Write one to ADLAR to left adjust the // result. Otherwise, the result is right adjusted. Changing the ADLAR // bit will affect the ADC Data Register immediately, regardless of any // ongoing conversions. sbi(ADMUX,ADLAR); // The value of these bits selects which analog inputs are connected to // the ADC. If these bits are changed during a conversion, the change // will not go in effect until this conversion is complete (ADIF in // ADCSRA is set). ADMUX |= ( ADCPIN &0x07 ); //--------------------------------------------------------------------// ADCSRA settings //--------------------------------------------------------------------// Writing this bit to one enables the ADC. By writing it to zero, the // ADC is turned off. Turning the ADC off while a conversion is in // progress, will terminate this conversion. cbi(ADCSRA,ADEN); // In Single Conversion mode, write this bit to one to start each // conversion. In Free Running mode, write this bit to one to start the // first conversion. The first conversion after ADSC has been written // after the ADC has been enabled, or if ADSC is written at the same // time as the ADC is enabled, will take 25 ADC clock cycles instead of // the normal 13. This first conversion performs initialization of the // ADC. ADSC will read as one as long as a conversion is in progress. // When the conversion is complete, it returns to zero. Writing zero to // this bit has no effect. cbi(ADCSRA,ADSC); // When this bit is written to one, Auto Triggering of the ADC is // enabled. The ADC will start a conversion on a positive edge of the // selected trigger signal. The trigger source is selected by setting // the ADC Trigger Select bits, ADTS in ADCSRB. sbi(ADCSRA,ADATE); // When this bit is written to one and the I-bit in SREG is set, the // ADC Conversion Complete Interrupt is activated. sbi(ADCSRA,ADIE); // These bits determine the division factor between the system clock // frequency and the input clock to the ADC. // ADPS2 ADPS1 ADPS0 Division Factor // 0 0 0 2 // 0 0 1 2 // 0 1 0 4 // 0 1 1 8 // 1 0 0 16 // 1 0 1 32 // 1 1 0 64 // 1 1 1 128 sbi(ADCSRA,ADPS2); sbi(ADCSRA,ADPS1); sbi(ADCSRA,ADPS0); //--------------------------------------------------------------------// ADCSRB settings //--------------------------------------------------------------------// When this bit is written logic one and the ADC is switched off // (ADEN in ADCSRA is zero), the ADC multiplexer selects the negative // input to the Analog Comparator. When this bit is written logic zero, // AIN1 is applied to the negative input of the Analog Comparator. cbi(ADCSRB,ACME); // If ADATE in ADCSRA is written to one, the value of these bits // selects which source will trigger an ADC conversion. If ADATE is // cleared, the ADTS2:0 settings will have no effect. A conversion will // be triggered by the rising edge of the selected Interrupt Flag. Note // that switching from a trigger source that is cleared to a trigger // source that is set, will generate a positive edge on the trigger // signal. If ADEN in ADCSRA is set, this will start a conversion. // Switching to Free Running mode (ADTS[2:0]=0) will not cause a // trigger event, even if the ADC Interrupt Flag is set. // ADTS2 ADTS1 ADTS0 Trigger source // 0 0 0 Free Running mode // 0 0 1 Analog Comparator // 0 1 0 External Interrupt Request 0 // 0 1 1 Timer/Counter0 Compare Match A // 1 0 0 Timer/Counter0 Overflow // 1 0 1 Timer/Counter1 Compare Match B // 1 1 0 Timer/Counter1 Overflow // 1 1 1 Timer/Counter1 Capture Event cbi(ADCSRB,ADTS2); cbi(ADCSRB,ADTS1); cbi(ADCSRB,ADTS0); //--------------------------------------------------------------------// DIDR0 settings //---------------------------------------------------------------------
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
// When this bit is written logic one, the digital input buffer on the // corresponding ADC pin is disabled. The corresponding PIN Register // bit will always read as zero when this bit is set. When an analog // signal is applied to the ADC5..0 pin and the digital input from this // pin is not needed, this bit should be written logic one to reduce // power consumption in the digital input buffer. // Note that ADC pins ADC7 and ADC6 do not have digital input buffers, // and therefore do not require Digital Input Disable bits. sbi(DIDR0,ADC5D); sbi(DIDR0,ADC4D); sbi(DIDR0,ADC3D); sbi(DIDR0,ADC2D); sbi(DIDR0,ADC1D); sbi(DIDR0,ADC0D); }
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
// the bandgap referance is used as input to the Analog Comparator, it // will take a certain time for the voltage to stabilize. If not // stabilized, the first conversion may give a wrong value. cbi(ACSR,ACBG); // When the ACIE bit is written logic one and the I-bit in the Status // Register is set, the Analog Comparator interrupt is activated. // When written logic zero, the interrupt is disabled. cbi(ACSR,ACIE); // When written logic one, this bit enables the input capture function // in Timer/Counter1 to be triggered by the Analog Comparator. The // comparator output is in this case directly connected to the input // capture front-end logic, making the comparator utilize the noise // canceler and edge select features of the Timer/Counter1 Input // Capture interrupt. When written logic zero, no connection between // the Analog Comparator and the input capture function exists. To // make the comparator trigger the Timer/Counter1 Input Capture // interrupt, the ICIE1 bit in the Timer Interrupt Mask Register // (TIMSK1) must be set. cbi(ACSR,ACIC); // These bits determine which comparator events that trigger the Analog // Comparator interrupt. // ACIS1 ACIS0 Mode // 0 0 Toggle // 0 1 Reserved // 1 0 Falling edge // 1 1 Rising edge sbi(ACSR,ACIS1); sbi(ACSR,ACIS0); //--------------------------------------------------------------------// DIDR1 settings //--------------------------------------------------------------------// When this bit is written logic one, the digital input buffer on the // AIN1/0 pin is disabled. The corresponding PIN Register bit will // always read as zero when this bit is set. When an analog signal is // applied to the AIN1/0 pin and the digital input from this pin is not // needed, this bit should be written logic one to reduce power // consumption in the digital input buffer. sbi(DIDR1,AIN1D); sbi(DIDR1,AIN0D); }
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
sbi(TCCR2B,CS20); pinMode( errorPin, OUTPUT ); pinMode( thresholdPin, OUTPUT ); analogWrite( thresholdPin, 127 ); }
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
//----------------------------------------------------------------------------// Analog Comparator interrupt //----------------------------------------------------------------------------ISR(ANALOG_COMP_vect) { // Disable Analog Comparator interrupt cbi( ACSR,ACIE ); // Turn on errorPin //digitalWrite( errorPin, HIGH ); sbi( PORTB, PORTB5 ); wait = true; stopIndex = ( ADCCounter + waitDuration ) % ADCBUFFERSIZE; }
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
Image Notes 1. They should be soldered on this side but there is no copper.
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
File Downloads
TaraturaTempi.ino (981 bytes) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'TaraturaTempi.ino']
readgirino.py (1 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'readgirino.py']
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
one because is has just two data and its calibration can not be trusted. Following there is a table with the acquisition rates for each prescaler setting. Prescaler Acquisition rate [kS/s] 128 64 32 16 8 9.74 0.04 19.39 0.06 37.3 0.6 75.5 0.3 153 2
The cited errors are coming from the Gnuplot fit engine and I am unsure about them. I also tried an unweighted fit of the rates because you can see that they roughly double when the prescaling halves, this looks like an inverse proportionality law. So I fitted the rates vs the prescaler settings with a simple law of y=a/x I got a value for a of a=1223 with a ?=3.14 and 4 degrees of freedom, this means that the law is accepted with a 95% confidence level!
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/
Related Instructables
Reading Digital TV Callipers with OSCILLOSCOPE an Arduino / (Photos) by USB by j44 far.peter
Low speed AVR oscilloscope V2.00 (Is updated on 19 Mar 2011) by serasidis
http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/