Home

EARTH PEOPLE TECHNOLOGY (EPT), Inc

image

Contents

1. TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual Lookim Ji Aedume Analog Monitor Code U 2 amp m Name Date modified Type Asda Monitor Code U2 ine 4 28 2013 11 17 PM INO File Recent Places z Desktop a y Librarves Select the file and click Open The sketch will now populate the Arduino IDE window Compile and Download the sketch into the Arduino microcontroller using the Upload button Page 83 EARTHPEOPLE TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual 5 Arduino Analog Monitor Code U2 Arduino 1 0 1 Fille Edit Sketch Tools Help Arduino Analog Monitor Code LI rag Copyright Earth People Technology Inc 2013 Analog Monitor Platform EPT 570 4P Uz vy int AdcValue int Upperd dcValue void setup 1 DDRD B11111111 Ser Port D as outputs PDUEID BlIllllll Turn on Fort D pins PORE BO Dllllll Set Port B as outputs PORTE BOOOOODOOO Turn on Port B pins Arduinoa Uno on COMME The Arduino IDE will compile the project then transmit the machine level code into the ATMega328 SRAM to start the program The CPLD should already be programmed with its Fast Oscilloscope Open the EPT Fast Oscilloscope on the PC by browsing to the Fast Oscilloscope folder Locate the executable in the bin x64 Release folder Organize v s Open E mail Bum New folder 9 EPT Analog Monitor J EPT_Analog_Monitor APNE dJ bin z
2. 3 EARTHPEOPLE E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual EARTH PEOPLE TECHNOLOGY Inc FAST ARDUINO OSCILLOSCOPE PROJECT User Manual Bl EPT Oscilloscope re C fm Close Device Connected Stop Fea Horizontal Time Base p 5 2 milliseconds Per Division Time Scale p X Position p Data Collection Control Store Show Samples FIFO Hold Enable Auto Fifo Hold Off on Voltage Scale Vertical k Voltage Reference Trigger Menu 1 Volt AREF AVCC Intemal 1 1V m o I Per Division So de Trigger Voltage T me mm E33 Toggle Faling Rising The Fast Oscilloscope is designed for EPT USB CPLD Development System It converts an analog signal to digital and displays the result on the PC in real time Circuit designs software and documentation are copyright O 2012 2014 Earth People Technology Inc Page 1 fb ARTHPEOPLE TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual Microsoft and Windows are both registered trademarks of Microsoft Corporation Altera is a trademark of the Altera Corporation All other trademarks referenced herein are the property of their respective owners and no trademark rights to the same are claimed Table of Contents Fast Oscilloscope Introduction ccccccccccccsssseseeccececeeeaeeseeeceeeeeeseeeeeeeeeeeeeeeaaeeeees 4 IPRC VIT B 4 1 2 ORE Ee Instelldt
3. E5 active_transfer cs EE Formi cs Form1 Designer cs Form1 resx ct Program cs Button CheckBox CheckedListBox ComboBox 1210 dx3 aseqejeq DateTimePicker Label LinkLabel ListBox ListView MaskedT extBox MonthCalendar NotifyIcon NumericUpDown He mE ERIS e timerUSB PictureBox D E Bel Ex EL EX I 9 ProgressBar Error List Qo Errors iN 2 Warnings i 0 Messages Description Column Project ir Error List RES Eb Cc Double click on the Open button The C Explorer will automatically switch to the Forml cs code view The callback function will be inserted with the name of the button along with click appended to it The parameter list includes object sender System EventArgs e These two additions are required for the callback function to initiate when the click event occurs Private void btnOpenDevice click object sender System EventArgs e There is one more addition to the project files Double click on the Form1 Designer cs file in the Solution Explorer Locate the following section of code btnOpenDevice this btnOpenDevice Location new System Drawing Point 24 13 this btnOpenDevice Mame btnOpenDevice this btnOpenDevice Size new System Drawing 5ize 5 23 this btnOpenDevice TabIndex 2 this btnOpenDevice Text Open this btnOpenDevice UseVisualStyleBackColor true this btnOpenDevice Click new
4. Project The name of the file containing build configuration and other inf Page 60 ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Locate the Projects_ActiveHost_64Bit EPT_Fast Oscilloscope folder in the UNO_FAST OSCILLOSCOPE_PROJECT_CD Copy the following files active_transfer_x64 cs Forml cs Form1 Designer cs Form 1 resx Program cs ScaleFactorMenu cs Open a Windows Explorer window and browse to C Users NelsonsTrfgr Documents Visual Studio 2010 Projects EPT_Fast Oscilloscope EPT_Fast Oscilloscope Paste the files to this folder X gt Libraries Documents My Documents Visual Studio 2010 Projects EPT Analog Monitor t 6 items selected Date modified 3 30 2013 1 12 AM 5 2 Date created 5 22 2013 11 13 PM Organize v eo Open E mail Burn New folder ol ences Documents library n BridgePort R2D Comms EPT_Analog_Monitor gt J EEx MCA E x E di EPT_Analog_Monitor di Name 4 EPT Analog Monitor J obj b i bin di Properties b Ji obj c active transfer x64 cs Ji Properties EPT_Analog_Monitor csproj 4 Ki EPT Transfer Test EPT Analog Monitor csproj user gt J EPT Transfer Test d Eome Ram State B Shared Size 73 4 KB Shared with In the Solution Explorer Window right click on the project name EPT_Fast Oscilloscope and select Add gt Existing Item lt EPT Analog Moni File Edit
5. This will select the device and allocate all memory needed for the Active Host EndTerms Next the user must click on the Start button Clicking this button will set the start stop bit of the control register and send it to the UnoProLogic The CPLD will decode this message and assert the Start Stop Control signal Once this signal is asserted the user must click on the On Off button to send a serial command to the Arduino This 1s the Start ADC command This causes the Girino code to fill up the ADC Buffer When the Girino code has detected a trigger and filled the ADC Count has reached its max waitDuration it transmits all bytes in the ADC Buffer up to 500 bytes Each byte is transmitted through the Active Block Endterm of the CPLD code When the blocks are received by the C Window the read callback function is called The read callback will call the EPTParseReceive function which calls the TransferOutReceive function In this function each byte is stored in the byte array ScopeBuffer This process of filling the ScopeBuffer array continues until the Girino code signals completion of the ADC Buffer transmission When the Girino code has Page 13 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual completed the transmission of the entire ADC Buffer it asserts the End Of Buffer signal This signal is connected to pin 3 of J9 of the UnoProLogic The CPLD uses this signal to send a Trigger 2
6. define cbi sfr bit SFR BYTECsfr2 amp _B bit 3 7 6 5 4 3 2 1 b endif itnder sbi An example of define sbi sfr bit SFR BYTECsfr l _BYCbit gt a register endif Page 18 B9 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 3 6 Whatare the Interrupts As we will see in the next steps the use of interrupts 1s required in this project Interrupts are signals that tell the microcontroller to stop the execution of the main loop and pass it to some special functions The images give an idea of the program flow The functions that are executed are called Interrupt Service Routines ISR and are more or less simple functions but that do not take arguments Let us see an example something like counting some pulses The ATMega328P has an Analog Comparator that has an interrupt associated that 1s activated when a signal surpasses a reference voltage First of all you must define the function that will be exectuted ISR ANALOG COMP vect counter j This is really simple the instruction ISRQ is a macro that tells the compiler that the following function is an Interrupt Service Routine While ANALOG COMP vect is called Interrupt Vector and it tells the compiler which interrupt 1s associated to that routine In this case it is the Analog Comparator Interrupt So everytime that the comparator sees a signal bigger than a reference it tells the microcontroller to execute that code id est
7. the state machine will stay in this state until the next byte from the active transfer 1s received 7 If the byte from transfer to device is a Ox7e the transfer control state will be changed to TRANSFER DECODE BYTE 8 If the byte from transfer to device is not a Ox7e the transfer control state will go back to idle 9 In the TRANSFER DECODE BYTE state the state machine will stay in this state until the next byte from the active transfer 10 The next byte transferred from active transfer will be decoded as the Control Register Page 45 B9 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual The bits of the Control Register are defined below Bits Control Transfer In Loop Back 7 7 49 USB Transfer State Machine The USB Transfer State Machine is quite a bit different than the Transfer Control state machine It is two always statement one hot finite state machine It is used here because it provides high speed glitch free operation One hot means that it has one register for each state The two always block setup allows a synchronous operation to be relegated to moving the state machine to the next state Next State Logic always posedge CLE 66 or negedge RST begin if RST begin State lt 6 h000 state IDLE lt 1 bl end else State lt next end An asynchronous always block is used to select which state will be the next state All of the outputs are handled in th
8. 4 a EPT_Analog_Monitor Sa Properties L3 References ES active transfer x64 cs 4 L amp Forml cs 3 Form1 Designer cs 93 Formi resx Program cs ES ScaleFactorMenu cs jusing System using System Collections Generic using System ComponentModel using System Data using System Drawing using System Ling using System Text using System Windows Forms using System Threading using System Runtime InteropServices using System Diagnostics ms 4 xoqjo0 x 110Jdx3 aseqejeq jnamespace EPT Analog Monitor public partial class EPT_Analog_Monitor Form l public EPT_Analog Monitor InitializeComponent for int i 0 i lt EPTTransmitDevice Length i EPTTransmitDevice i new Transfer Gi Solution Exp L Class View Error List vx Errors _1 0 Warnings i 0 Messages Description i i Column Project The C Express compiler will start the building process If there are no errors with code syntax function usage or linking then the environment responds with Build succeeded We Error List E Find Results Build succeeded If the build fails you will have to examine each error in the Error List and fix it accordingly If you cannot fix the error using troubleshooting methods post a topic in the Earth People Technology Forum All topics will be answered by a member of the technical staff as s
9. 570 AP 4 CPLD Active Transfer EndTerms Coding The EPT 570 AP will accept the digitized data sampled by the Arduino and transfer it to the PC It is designed to plug directly into the Arduino Uno and there is no need for external wires to be added The Active Transfer Library 1s used to send the data to the PC The Active Transfer EndTerms are used to connect the Active Transfer Library to the user code This makes it easy to transfer data to and from the PC via the USB The user needs to create a state machine to control the transfer between the incoming data and the Active Transfer EndTerms 4 1 Define the User Design In this step we will define the user s code and include EndTerms and the EPT Active Transfer Library The Active Transfer Library contains a set of files with a vqm name extension which select particular operations to perform e g byte transfer block transfer trigger The active transfer library vqm file must be included in the top level file of the project The EndTerms will connect to the active transfer library and provide a path to connect user code to the library All of these files are available on the Earth People Technology Project CD Page 40 EARTITRPEORPRPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual SINGLE TRANSFE ENDTERM CTIVE TRANSFER LIBRARY BLOCK ENDTERIV We will build our CPLD project using Quartus II
10. 570 AP board The user will write the Verilog code for the CPLD which stores each sample from the Arduino board then I1 HH Page 7 TECHNOLOGY Fast Arduino Oscilloscope Project User Manual initiates the write cycle to PC Finally the user will write the C code to accept each byte from the EPT 570 AP board and assemble the bytes into the original analog signal and display it in the graphics box in a Windows Form 2 1 Designing a Simple Fast Oscilloscope The Fast Oscilloscope is an advanced project and not for beginners to the Arduino family However it does serve as an introduction to advanced programming techniques using Verilog for programming the CPLD and C for programming the user interface on the PC The user should be familiar with the beginners projects for the Arduino Uno For an introduction to Verilog go to www asic world com verilog introl html Introduction For an introduction to C go to http www homeandlearn co uk csharp csharp html 2 2 Fast Oscilloscope Equipment Needed The equipment you will need for the Fast Oscilloscope is EARTH PEOPLE TECHNOLOGY UNOPROLOGIC ARDUINO UNO USB TYPE B CABLE ANALOG INPUT CUSTOM CABLE Page 8 ZAIATIHI2EOIPLIE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 5 VOLT DC POWER SUPPLY ONE PAIR OF BANANA CLIP LEADS DIGITAL FUNCTION GENERATOR BNC TO ALLIGATOR CLIPS e Arduino Uno e EPT UnoProLogi
11. 6 Connecting the Project Together Now we will connect the Arduino EPT 570 AP U2 and the PC to make an Fast Oscilloscope First connect a USB cable from a USB port on the PC to the Arduino Second connect a USB cable from a open USB port on the PC to the EPT 570 AP U2 T i Next let s connect the Six 5VDC Power Supplies to the analog inputs of the Arduino We will do the by using the following parts 6 Pin 2 54 mm Male Header 10 Pin 2 54 mm Male Header Six 5VDC Power Supplies Five Black Banana Lead jumpers to connect the Power Supplies together One Black Banana Clip Lead to connect the Power Supplies to the Arduino e Six Red Banana Clip Leads to connect the Power Supplies to the Arduino Connect the 10 Pin 2 54 mm Male Header into the J12 connector of the EPT 570 AP board Next connect the 6 Pin 2 54 mm Male Header into the J9 connector of the EPT 570 AP board Connect the black banana jumpers between the grounds of all the supplies Connect the black banana clip lead to one of the power supply grounds and Pin 7 of J12 Connect one red banana clip lead to each of the power supply positive outputs and connect to one of the pins on the J9 connector Page 81 ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual ALTERA EPMS70 F Next open the Arduino IDE and select File gt Open and select your sketch created earlier Arduino_Fast Oscilloscope_Code_U2 ino Page 82 EARTITRPEORPLE
12. BIT ADC VALUE Host dll it populates the EPTReceiveData object It then calls EPTParseReceive function This function uses a case statement to call the TransferOutReceive function private void EPTParseReceive i switch EPTReceiveData Command i case TRANSFER OUT COMMAND TransferOutReceive break default break TransferOutReceive is the function that decodes the message selects the EndTerm address reads and stores the upper byte reads and stores the lower byte and updates the textboxes with the digitized values from the Arduino analog conversion When a transfer message has been received from the EPT 570 AP the TransferOutReceive function uses the EPTReceiveData object address to conditionally branch to a set of statements This is done using a switch case statement Page 78 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual public void TransferOutReceive i Store the address history from the EPT Receive Object SecondPreviousActualAddr FirstPreviousActualAddr FirstPreviousActualAddr EPTReceiveData Address Main Conditional Branch for populating the Textboxes switch EPTReceiveData Address i case TRANSFER OUT ADDRESS 1 Send the one character buffer if DisplayAddress 1 amp FirstDisplayByte 5 1 10 C Project Completion This is all that is needed for the Fast Oscilloscope The Arduino will generate a 10 bit digitized word for each channel It the
13. DISPLAY OSCILLOSCOPE DATA ON SCREEN oT LI ORIZ a PRESS EVENT Lh ad SENT HORIJ E TO ARDUINO 5 1 Coding the C Project The user code is based on the NET Framework and written in C The language is great for beginners as it is a subset of the C language It has the look and feel of the familiar C language but adds the ease of use of classes inheritance and method overloading C is an event based language which changes the method of writing code for this project You will need to get some background knowledge in coding with C and the NET Framework on the PC For a better description of event based language programming and C see the following for a turtorial http www homeandlearn co uk csharp csharp html Page 59 ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 5 1 1 C Project Creation To start the project use the wizard to create project called EPT_Fast Oscilloscope When the wizard completes the C Express main window will look like the following Start Page Micros fisual C z J A btnOpenDevice WW Solution Explore N a Recent Templates Sort by Hi Search Installed Templates Type Visual C e Windows Forms Application Visual C Visual C A project for creating an application with a s Windows Forms user interface Online Templates WPF Application Visual C 3 Console Application Visual C Eoi Class Library
14. Project Build Debug Data Tools Window Help iDa G dg aala tgh Reese e ESO nu Aa Forml cs x Paue D Aela a Solution EPT ae SE EPT Analog Monitor EPT 7 Eusing System EPT Analog Monitor TES Aons Generic m Build to del Rebuild Publish Add Add Reference Add Service Reference Forms xog oo x Ja10 dx3 aseqeyeq G Enn P F Set ac StartUp Project p Debug onitor Ctrl X Ctrl V pa fass EPT Analog Monitor Paste Remove lalog Monitor Rename eComponent 5 Solution Exp Pc uis pen 1s Verify that the Hn label has Active x64 selected from the drop down box 3 EPT Analog Monitor Mi EIS SEEKCESEE E PSU G M SSS e Eten se Jiai enorenters ESERSS WW Solution Explorer ax Formi cs Forml cs Design ia 2 e 59 Solution EPT Analog Monitor Application CA EPT Aon Ment Configuration Pao v 1 F fo Ei Ea Properties Build m L References General a Z ES active transfer x64 cs E 7 3 N E Formi cs Debug Conditional compilation symbols Program cs E Define DEBUG constant F Q E ScaleFactorMenu cs Resources Define TRACE constant Setti E Allow unsafe code Reference Paths Optimize code Signing Errors and warnings ad Warning level a Suppress warnings S Solu
15. View Project Build Debug Data Tools Window Help Pal gulisacaeo e g e qum Debug 1x86 btnc Ale a m e a ci ELE Se meds e 3 Bt er ERE ca a t uum Solution Explorer 4 XG Formi cs Design x 3 5 SEM Solution EPT Analog Monitor LM a 3EPT Analog Monitor Sa Properties 3 Build 0 uj References Rebuild EE Formi cs k Bama M Publish 3 J New em Ctrl Shift A E Add Reference Existi i Add Service Reference C New Folder Set as StartUp Project Windows Form Debug gt amp j User Control Cut Ctrl X g Class Shift Alt C i Paste Ctrl V X Remove Del T J Rename du Solution Exp OX iS Properties Alt Enter Select the following files e active transfer x64 cs e ScaleFactorMenu cs Page 61 Organize v New folder sg Microsoft Visual C 2010 Express i Projects Fr Favorites RE Desktop Downloads 1 Dropbox Recent Places Libraries 3 Documents 2 Music i Pictures B Videos File name Click Add ScaleFactorMenu cs ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Search EPT_Analog_Monitor NE e Documents library EPT Analog Monitor Arrange by Folder v Name Date modified Type d bin J obj d Properties active transfer x64 cs Formi cs Formi Designer cs ca Form1 resx c Program cs ScaleFactorMenu cs
16. assignments that created at an earlier time Under Assignments Select Import Assignments Gy Quartus I 64 8it C altera 12 1sp1 quartus qdesigns EPT_Transfer_Test EPT_570_AP_U2_Top EPT_570_AP_U2 Top Me exse x File Edit View Project Processing Tools Window Help 5 Do gA tag Dee Project Navigator _ Settings Entity TimeQuest Timing Analyzer Wizard MAXI EPM570T100C5 gt EPT 570 AP U2 Top i ae ait Remove Assignments f Back Annotate Assignments Import Assignments Export Assignments Assignment Groups amp LogicLock Regions Window 3x Design Partitions Window A Hierarchy amp Files Tasks ag x z Task d 4 gt Compile Design gt B Analysis amp Synthesis gt M Fitter Place amp Route gt B Assembler Generate programmin gt gt TimeQuest Timing Analysis gt W EDA Netlist Writer 3 Program Device Open Programmer J r Ctrl Shift E Ctrl Shift A Ctrl Shift N Alt L Alt D ZITATE 9 V AX moad Subscripti ME ASU LE ADVANTAGE EE WHAT S NEW QUARTUS II Version 12 1 7 Buy Software View Quartus Il Information Documentation OAM v lt x n Type ID Message Em ports assignments from other sources At the Import Assignment dialog box Browse to the Wrojects HDIAEPT Transfer Test VAltera EPM570 U2 folder of the EPT FAST OSCILLOSCOPE P
17. co s5005u59 4 amp e979 Project Navigator 28x Compilation Report EPT 570 AP U2 Top Entity Table of Contents qe MAX I EPM570T100C5 E5 Flow Summary Successful Thu Mar 14 00 11 06 2013 4 Bid EPT 570 AP U2 Top f Flow Settings it Versi 12 1 Build 243 01 31 2013 SP 1 SJ Web Edition abd active transfer ACTIVE TRANSFER INST ff Flow Non Default Global Settings EPT 570 AP U2 Top gt bd active transfer library ACTIVE TRANSFER L Ff Flow Elapsed Time EPT 570 AP U2 Top abd active_trigger ACTIVE_TRIGGER_INST Ef Flow OS Summary esum abd eptWireOR wireOR a 283 570 50 51 76 67 0 0 1 0 J Compile Design M Analysis amp Synthesis M Fitter Place amp Route Assembler Generate programmin TimeQuest Timing Analysis i EDA Netlist Writer w Program Device Open Programmer v 7 v v v v Ar e A a P lt lt Search gt gt Type ID Message mx D 332102 Design is not fully constrained for hold requirements gt wD Quartus II 64 Bit TimeQuest Timing Analyzer was successful 0 errors 13 warnings Ww RRR RRR RRR RRR RRR gt QD Running Quartus II 64 Bit EDA Netlist Writer wD Command quartus eda read settings files off write settings files off EPT 570 AP U2 Top c EPT 570 AP U2 Top Ww 204018 Generated files EPT 570 AP U2 Top vho and EPT 570 AP U2 Top vhd sdo in directory C altera 12 1spi quartus q
18. does not modify them Just like Arduino registers that can change value for some external interventions Why does the compiler want to know about such variables That 1s because the compiler always tries to optimize the code that we write to make it faster and it modifies it a little bit trying not to change its meaning If a variable changes by its own it could seem to the compiler that it is never modified during execution of say a loop and it could ignore it while it could be crucial that the variable changes its value So declaring volatile variables it prevents the compiler to modify the code concerning those For some more information I suggest to read the Wikipedia page http en wikipedia org wiki Volatile variable Page 33 E gt EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual extern volatile wait extern uinti6_t waitDuratton extern volatile uintl6_t stopIndex extern volatile uintl6 t ADCCounte t ADCCounter extern volatile uint8 t ADCBuffer ADCBUFFERSIZE freeze uint8 t prescaler uint8 t triggerEvent trigge ve uint8 t threshold commandBuf fer COMBLIFFERSIZE 1 3 18 Writing the kernel of the sketch Finally we have gotten to the kernel of the program As we saw before I wanted a continuous acquisition and I wrote the ADC Interrupt Service Routine to store in the circular buffer the data continuously It stops whenever it reaches the index that 1s equal to stopInde
19. et M 3P VO Lines DIGITAL om E Li 28 pin POU 32 teed TOFP 28 pad OF WMLF and 32 ped QFN MLF Operating Vonage 48 53V for ATmegeiSPAREPA WBPA2UP 40 Cho esc Grede ARDUINO 0 20 MMz 1 8 5 5V Low Power ConsumgGon at t MHz 15V 25 C for ATmegad8PASSPA 168PA 328P Active Mode 0 2 mA Power down Mode 0 1 pA Power seve Mode 0 75 pA inctuding 32 kHz ATC 3 4 Debug output I usually put a lot of debug output in my programs because I want to keep track of anything that happens the problem with Arduino 1s that we do not have a stdout to write to I decided to use the Serial port as a stdout Be aware though that this approach does not work all the times Because writing to the Serial port requires some time for the execution and it can dramatically change things during some time sensible routines I usually define debugging outputs inside a preprocessor macro so when the debug is disabled they simply disappear from the program and do not slow down the execution dprint x Writes to the serial port something like x 123 dshow Some string Writes the string This is the definition tif DEBUG define dprint expression Serial print Serial print expression Serial print serial printIn expression define dshow expression Serial printIn expression else define dprint expression Page 17 Bit B9 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscillos
20. files EPT 570 AP U2 Top vho and EPT 570 AP U2 Top vhd sdo in directory C altera 12 1spl quartus qdesigns gt Ww Quartus II 64 Bit EDA Netlist Writer was successful 0 errors 0 warnings IN Q 293000 Quartus II Full Compilation was successful 0 errors 47 warnings Lg wu E vr 2 r 100 00 00 24 The Programmer Window will open up with the programming file selected Click on the Hardware Setup button in the upper left corner Search altera com w E o O E ISP to allow background programming for MAX II and MAX V devices File ili Stop gH Auto Detect 3X Delete y Add File Device Checksum Usercode Program Configure Verify Blank Examine Security Check Bit Acme My Hee DS E Save File The Hardware Setup Window will open In the Available hardware items double click on EPT Blaster v1 3b Page 55 ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Rn Hardware Setup Hardware Settings Select a programming hardware setup to use when programming devices This programming hardware setup applies only to the current programmer window Available hardware items ecPT Blaster v1 3b Remove Hardware If you successfully double clicked the Currently selected hardware dropdown box will show the EPT Blaster v1 3b NJ Hardware Setup saan Hardware Settings J
21. in this case to increment that variable The next step is to enable the interrupt associated To enable it we must set the ACIE Analog Comparator Interrupt Enable bit of the ACSR Analog Comparator Setting Register register Sbi ACSR ACIEB In the following site we can see the list of all Interrupt Vectors http www nongnu org avr libc user manual group avr interrupts html Loop is suspended control goes to ISR x N S Start t Q Start J A ISR CINT vect C 7 T Sa a p Control goes back Y i void loopO to main loop Normal flow Interrupt 3 7 Continuously acquire with a circular buffer The concept of using a Circular Buffer is pretty straight forward Page 19 ZAIATIHI2EOIPLIE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Acquire continuously till a signal is found then send the digitized signal to the computer This approach allows to have the incoming signal shape also before the trigger event I prepared some diagrams to make myself clear The following points are referring to the images On the first image we can see what I mean with continuous acquisition We define a buffer that will store the data in my case an array with 1280 slots then we start to continuously read the ADC output register ADCH ad filling the buffer with the data When we get to the end of the buffer we restart from t
22. lll o eoo adsinisn aed pepaubs E E 5 O CI IOs mat uii E Tm o TET 5 Lae Active Transfert Library End Terms ip cvaccaseccs cease etu ensenre ssa buc etu nas 6 2 ne Development Processerna i a ie aai 7 2 1 Designing a Simple Fast Oscilloscope ccccccccccccccceeeeseeeeeccceeeeeeaeeseeeceeeeeeaaas 8 2 2 Fast Oscilloscope Equipment Needed ccccecccccccccccesseeeseeeeeeeeeaeeneeeeeeeeeeeaas 8 2 9 XJSEIIOSCODO HardWare ec weasansetnentadnwsesasasanestesnasanaseianedaadmwveciesteteatetmevacasesenedentawss 9 24 Fast Oscilloscope Data FOW secssrcrsonecesnersoraner iera 10 P EE SCELTE 11 242 UnoProLosie Foncionahiyessecsnnsasen i R 12 2 4 3 CH Window Functionality eeeeeeeesssssesseeeeeeenene eene 13 3 Arduino Girino Fast Oscilloscope Code eeeeesssseeeeeeeeeeeeeeeenns 14 3 Grrino Fast Arduino Oscilloscope esee 14 3 2 Disclaimer THE AUTHOR OF THIS INSTRUCTABLE MAKES NO GUARANTEE OF VALIDITY AND NO WARRANTY WHATSOEVER 15 es NEM 1 1 0 lc SNO 16 S MN aa cetera 17 S MEE DAI IMEEM 18 o0 MHBStdre GINS Inte ECUDUS eco rs ce ecanccene E E 19 3 7 Continuously acquire with a circular buffer cc eesseeeeecceceeeeeeeeeseeeeeees 19 20 OSCIMO SCO DC Te RIDE 21 I HOw 402 5092 704 e ee eS ee ee eee 22 3 10 AT OG TN CES cuore secs sez cresoten cts ae oat Deor dnc dut cron eD eo HIER UTMDE oe dnsesaeces 23 3 11 vio UMM UP a
23. on the same position of the screen or at least most of the times creating the illusion of a stable plot The trigger is associated with a threshold that activates a sweep when the signal passes it A sweep is the phase in which the oscilloscope records and displays the signal After a sweep another phase occurs the holdoff in which the oscilloscope rejects any incoming signal The holdoff period can be composed of a part of dead time in which the oscilloscope is unable to accept any signal and a part that can be user selectable The dead time can be caused by various reasons like having to draw on the screen or having to store the data somewhere Looking at the image we get a sense of what happens 1 Signal 1 surpasses the threshold and activates the sweep 2 signal 2 1s inside the sweep time and gets caught with the first 3 after the holdoff signal 3 activates the sweep again 4 instead signal 4 1s rejected because it falls inside the holdoff region 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 1s 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
24. scaling The slider lets you zoom into the signal to see details Most of these features are implemented with sliders The sliders make it easy to select from multiple values Once the value is selected by the slider an underlying event in the C code causes the UnoProLogic to transmit a command and the value to the Aruino Girino code The Fast Arduino Scope does have its limitations It is most notably limited by the ATMega 328 microcontroller The chip uses an ADC which we select the 8 bit mode to increase the throughput speed In the block diagram of the internal ADC circuit of the 328 microcontroller we can see the circuit functionality The Source 1 input is from our analog signal to be displayed The signal is selected by a multiplexor and is directly applied to the Conversion Logic This logic 1s directly controlled by the ADC clock Changing this clock value changes the amount of time between conversions And it ultimately controls how fast a signal can be applied at the analog input The ADC has eight selectable clock inputs to drive the conversion of analog to digital The Horizontal Slider controls which of the prescaler values is selected These values determine what the ADC clock frequency is These frequencies are e 125 KHz 250 KHz 500 KHz 1 000 KHz 2 000 KHz 4 000 KHz 8 000 KHz 16 000 KHz Page 86 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual The ADC is not designed to handle frequen
25. software from Altera The primary file defining the user s CPLD project is named EPT 570 AP U2 Top v It defines the user code and connects the active transfer library and Endterms www asic world com verilog introl html Introduction 42 Select the Input Outputs We need to set the inputs and outputs for EPT_570_AP_U2_Top v The I O nets will stay the same for all EPT projects All of the usable pins are connected to traces on the EPT 570 AP board and serve specific functions However the pins that connect to the Arduino can be set to either inputs or outputs It is in the port section of the Verilog module that the Arduino pins can be set For the Fast Oscilloscope we will read from the J8 and J10 connectors So we set these as inputs Since the analog inputs to the Arduino are on the J9 connector we will set it up as inputs The following nets are used to connect to the EPT 570 AP connectors Page 41 fb ARTIIPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Arduino Uno E CHEN I Pi Connector Port E 5 to 4 cm to4 LB IOL Fast Oscilloscope lower byte NENNEN LB IOH Fast Oscilloscope upper byte 1 LB SER Fast Oscilloscope upper byte 0 LB IOH Fast Oscilloscope address 2 d m Bits 1 to O Write Enable eco n Connects EN LB IOH Fast Oscilloscope address 1 Oscilloscope address 0 LB IOH Fast Oscilloscope en Each net is followed by the n
26. the ADC and to provide a voltage level for the trigger If you want you could send the signal directly to the Arduino and use some voltage reference defined by a voltage divider or even the 3 3 V given by the Arduino itself Page 16 ZAI ATIHIP2EOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Features High Performance Low Power AVA 8 84 Microcontrolier 13 Powerful instructions Most Single Clock Cycle Executor Bp ene ap ther mos aea Staves Upto 20 MIS Trough at 29 M AT megad RPA RAPAA 68 9A 228P 256 512 512 K Bytes CEPROM ATmegata PAARE PA 65PA 224 P 127 K TKUZK Bytes Internal SRAM ATmegatsPA ERPA I Write Ernse Cycies 10 000 Flash 109 000 EEPROM Data retention 20 years at RF C 100 years at 25 C Two Sbit Timer Counters with Seperate Prescater and Compare Mode One 16 04 Tinet Counter with Seperate Prescaler Compare Mode and Capture Mode Ree aaa Qwcilwtor Six PM C channel IOAR ADE in TOPP ead OFWANILF pachage Temperatuer Measurement channel 10 54 ADC in PDIP Pacha Temperature Moasurement Programmabic USART Manator Stave SPI Serial Interface 2wire Serial intertace Philips FC compatible Programmable Watchdog Timer with Separate On chip Oscillator On chip 8 bit AVR Microcontroller with 4 8 16 32K Bytes In System Programmable Flash ATmega48PA ATmega88PA ATmega168PA ATmega328P on 0 MON TMANG VO and
27. the Open Music Labs that I suggest to read http www openmusiclabs com learning digital atmega adc http www openmusiclabs com learning digital atmega adc in depth Since my purpose is to get a fast oscilloscope I decided to limit the precision to 8 bits This has several bonuses 1 the data buffer can store more data 2 you do not waste 6 bits of RAM per datum 3 the ADC can acquire faster The prescaler lets us divide the frequency by some factors by setting the ADPSO 1 2 bits of the ADCSRA register Seeing the plot of the precision from the Open Music Labs Article we can see that for 8 bits precision the frequency could go up to 1 5 MHz good But since the ability of changing the prescaler factor lets us change the acquisition rate we can use it also to change the timescale of the oscilloscope There is a good feature about the output registers we can decide the adjusting of conversion bits by setting the ADLAR bit in the ADMUX register If it is 0 they are right Page 22 ES EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual adjusted and viceversa see the image Since I wanted 8 bits precision I set it to 1 so I could read just the ADCH register and ignore the ADCL I decided to have just one input channel to avoid having to switch channel back and forth at every conversion One last thing about the ADC it has different running modes each one with a different trigger source Free Running m
28. the PC the callback function will do something with the data and command Page 70 B9 EAITIHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Actual callback function which will read messages coming from the EPT device unsafe void EPTReadFunction Int32 device id Int32 device channel byte command byte payload i byte message data Select current device EPT AH SelectActiveDeviceByIndex device id Add command and device channel to the receive object EPTReceiveData Command command amp COMMAND DECODE gt gt 3 EPTReceiveData Address device channel Check if the command is Block Receive If so use Marshalling to copy the buffer into the receive fobject if EPTReceiveData Command BLOCK OUT COMMAND i EPTReceiveData Length data size EPTReceiveData cBlockBuf new Byte data size Marshal Copy new IntPtr message EPTReceiveData cBlockBuf 6 data size else i EPTReceiveData Payload payload EPTParseReceive I Because the callback function communicates directly with the dll and must pass pointers from the dll to the C marshaling must be used Marshaling is an advanced C topic and will not be covered in this manual We will let the callback function work in the background and we only need to use the EPTParseReceive function to handle incoming data 5 1 7 CH Project Controls Controls such as buttons are added to the Forml cs Design window whic
29. 2 UnoProLogic Functionality The CPLD does not need any initialization as the device 1s ready to operate soon after the power is applied The data flow in the UnoProLogic starts with a wait loop for the Start Stop Control signal to be asserted from the Control Register Once this happens the data flow will fall 1nto the wait loop for the Write Enable When the Write Enable from the Girino asserts it causes the block of code that writes bytes into the FIFO to read the data byte on Ports B and C Then clock the byte into the FIFO This process continues until the internal FIFO count reaches eight bytes When this happens fifo full flag sets When the fifo full signal is asserted the State Machine leaves the IDLE state and enters the STORE FIFO COUNT state In this state the fifo out count is updated with the full count of the FIFO The state machine will immediately enter the Page 12 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual START_SEND_BLOCK state and asserts the block_out_send signal which informs the Active Block Endterm that a block transfer has started This state will wait for the block_busy signal to assert which is an acknowledgement that the block transfer has been accepted by the Active Transfer Library Next the FIFO_HI state is entered In this state Active Block Endterm toggles the block_byte_ready signal to inform the user code to put a new byte on the block_out_byte The user code wil
30. B Debug Name Date modified Type Documents library Arrange by Folder v di Release amp ActiveHost64 dll 5 4 2013 9 51 PM Application extens do EPT Analog Monitor exe 5 26 20139 310 PM Application M Release EPT_Analog_Monitor pdb 5 26 2013 9 10PM Program Debug D Ji obj 7 EPT_Analog_Monitor vshost exe 6 10 2013 2 12PM Application di Properties amp EPT Analog Monitor vshost exe manifest 8 31 2009 12 40 AM MANIFEST File jo EPT Transfer Test ftd2 9654 dll 1 18 2013 3 54 PM Application extens J EPT_Transfer_Test DM a B EPT Analog Monitor exe State B Shared Size 28 0 KB Shared with Homegroup Application Date modified 5 26 2013 9 10 PM Date created 5 23 2013 12 11 AM 4 Initiate the application by double clicking the application icon in the Release folder of the project The application will open and automatically load the Active Host dll The Page 84 EARTIIPEORPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual application will locate the EPT 570 AP U2 device Next the combo box at the top will be populated with the name of the device EPT USB lt gt Senal amp JTAG Cable B Monitor 1 Monitor 2 Monitor 3 Monitor 4 Monitor 5 Monitor 6 T su Scie Select the EPT 570 AP device and click the Open button If the Active Host application connects to the device a label will indicate Device Connected glog M Or slaa co EPT USB l
31. B is written when operating in PWM mode When writing a logical one to the FOC2A bit an immediate Compare Match is forced on the Waveform Generation unit The OC2A output is changed according to its COM2A1 0 bits setting Note that the FOC2A bit is implemented as a strobe Therefore it is the value present in the COM2A1 0 bits that determines the effect of the forced compare A FOC2A strobe will not generate any interrupt nor will it clear the timer in CTC mode using OCR2A as TOP The FOC2A bit is always read as zero cbi TCCR2B FOC2A cbi TCCR2B FOC2B The three Clock Select bits select the clock source to be used by Page 32 fb ARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual the Timer Counter CS22 CS21 CS20 Prescaler 0 0 0 No clock source Timer Counter stopped 0 0 1 No prescaling 0108 0 1 132 1 00 64 10 1 128 1 10256 1 1 1 1024 cbi TCCR2B C5S22 cbi TCCR2B CS21 http www instructables com id Girino Fast Arduino Oscilloscope sbi TCCR2B CS20 pinMode errorPin OUTPUT pinMode thresholdPin OUTPUT analogWrite thresholdPin 127 j void initPins void i 3 17 Volatile variables I can not remember where but I read that variables that are modified inside an ISR should be declared as volatile Volatile variables are variables that can change during time even if the program that is running
32. CAL ANO KORDAITAI DAPLAY OLCRLOSCOPE DATA ON SCREEN functions The first function turns on the ADC initialized in the setup routine and causes the ADC to convert whatever 1s on its analog input into a digital word When this conversion is complete an interrupt function is called ISR ADC vect When this happens the loop function is stopped and the interrupt function executes It examines if the trigger bit has been set If it is not then the update is set to true and the interrupt exits When the interrupt is complete the loop function continues with the next instruction It will eventually check if the update bit has been set If so the value of the ADC conversion is stored in the ADCBuffer and the buffer array index is Page 11 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual incremented The ADC has been configured to continuously start a new conversion on the completion of the previous conversion This process repeats until the Analog comparator has sensed the input to the analog channel has breached the threshold level This is the trigger threshold level and is set by applying an analog voltage at pin 8 of the J8 connector The pin 8 of the J8 connector is attached to the internal analog comparator inside of the ATMega328 chip It is connected to the negative input of the comparator The positive input to the comparator is connected to pin 7 of the J8 conne
33. File folder File folder File folder Visual C Source 5 22 2013 11 00 PM 5 22 2013 11 00 PM 5 22 2013 11 00 PM 5 22 2013 4 24 PM 5 22 2013 4 28 PM 4 28 2013 12 48 AM 4 28 2013 12 48 AM 3 30 2013 1 12 AM 4 28 2013 2 14 PM Visual C Source Visual C Source NET Managed Re Visual C Source Visual C Source 4 r v Visual C Files cs resx setti v active transfer x64 cs 5 1 2 C Project Environment Setup The project environment must be set up correctly in order to produce an application that runs correctly on the target platform Visual C Express defaults new projects to 32 bits If your OS 1s a 64 bit platform use the following directions to set up a 64 bit project First we need tell C Express to produce 64 bit code if we are running on a x64 platform Go to Tools gt Settings and select Expert Settings File Edit View Refactor Project Build Debug Data Tools Window Help al i Saals Fe A le e Er X 3 tu Connect to Database binOpenDevice ol iy B POI RE rlllo A gt Code Snippets Manager Ctrl K Ctrl B WW Solution Explorer dE Idi Formi cs x Pee Choose Toolbox Items 3 gu R 5 ES iz 4g EPT Analog Moni amp j Extension Manager Analog Monitor A 5d Solution EPT Analog Monitor Elusing Syster External Tools Blinc nay ied ic Setti E gt BE Propeties using Syster Settings b Basic Settings B8 ia us
34. Giro means rotation and adding the suffix ino you get a small rotation but Girino also means tadpole This way I got a name and a mascot KUNO meam ARDUINO 3 2 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 1s 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 Page 15 B9 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 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 3 3 What you need What we really need for this project 1s an Arduino board and the datasheet of the ATMega328P The datasheet is what tells us how the microcontroller works and it is very important to keep it if we want a lower lever of control The datasheet can be found here http www atmel com Images doc8271 pdf The hardware that I added to the Arduino is partly necessary its purpose is just to form the signal for
35. HPEOPLE TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual I decided to use the Timer number 2 because Timer 0 is used internally by the Arduino IDE for functions such as millis Timer has an output frequency too slow because it is a 16 bit timer In the ATMega328P there are different kinds of operation mode of the timers but what I wanted was the Fast PWM one with no prescaling to get the maximum possible output frequency Signal 1007 Mean EE oy x Main Clock Timer Control Registers 5V4 l i 1 l l Y TCCR2A TCCR2B ov pus Prescaler 5V 4 NE NUN i 60 Timer Clk y X TCNT2 kii re ister I 40 E h Waveform L PL enerator et 5V 4 f OCR2B E 20 register SV 0 i d Pulse Width PWM Timer Modulation Signal scheme Period 8 bit bus 3 16 Setting up the PWM In the sketch I wrote another initialization function that sets up all the parameters of the Timer functioning and initializes a couple of pins void initPins void These bits control the Output Compare pin OC2A behavior If one or both of the COM2A 1 0 bits are set the OC2A output overrides the normal port functionality of the I O pin it 1s connected to However note that the Data Direction Register DDR bit corresponding to the OC2A pin must be set in order to enable the output driver When OC2A is co
36. IDRO ADC4D sbi DIDRO ADC3D sbi DIDRO ADC2D sbi DIDRO ADC1D sbi DIDRO ADCOD void TALtADCC void t 3 12 How the Analog Comparator works The Analog Comparator is an internal module of the microcontroller and it compares the input values on the positive pin Digital Pin 6 and negative pin Digital Pin 7 When the voltage on the positive pin is higher than the voltage on the negative pin AINI the Analog Comparator outputs a 1 in the ACO bit of the ACSR register Optionally the comparator can trigger an interrupt exclusive to the Analog Comparator The associated vector is ANALOG_COMP_vect We can also set the the interrupt to be launched on a rising edge falling edge or on a toggle of the state The Analog Comparator is just what we need for the triggering connecting out input signal to pin 6 now what is left is a threshold level on pin 7 Analog Comparator Control Register ACSR Digital Pin 6 jp AC iseer Digital Pin 7 A l Analog lt Signal am S bic tis Comparator Page 27 GB ARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 3 13 Setting up the Analog Comparator In the sketch I wrote another initialization function that sets up all the parameters of the Analog Comparator functioning The same issue about ADC digital buffers applies to the Analog Comparator as we can see on the bottom of the routine void initAnalogComparator void When
37. IHI2EOIPLIE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 1 Fast Oscilloscope Introduction The Fast Oscilloscope uses the Earth People Technology USB CPLD development system hardware and the Arduino Uno connected to a Windows PC The project software uses the Microsoft C Express in conjunction with the Active Host dll THE EARTH PEOPLE TECHNOLOGY USB PLD DEVELOPMENT SYSTEM ACTIVE HOST COMMUNICATES ACTIVE HOST SDK WITH CPLD USING EPT 570 AP ENDTERMS ARDUINO w t ay 4 ACTIVE TRANSFER LIBRARY ARDUINO CODE USERS CPLD CODE USERS CODE COMMUNICATES COMMUNICAES WITH HOST USING WITH CPLD ENDTERMS This User Manual will guide the user to create the Arduino code that will sample the Analog input and transfer the digitally converted samples to the CPLD The user will be given instructions on creating the CPLD code that accepts each sample from the Arduino and transmits it via USB to the PC The manual completes with instruction of how to create the C application that will decode each sample and display on the screen This is an advanced project and not for beginners to the Arduino family However it does serve as an introduction to advanced programming techniques using Verilog for programming the CPLD and C for programming the user interface on the PC The first two sections provide a background for the PC and CPLD libraries 1 1 Driver Installation Follow the instructions in the EPT USB CPLD Dev
38. M Copy the file and browse to c altera xxx quartus qdesigns EPT_Fast Oscilloscope directory Paste the file Page 52 EARTITRPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual s cA n gt Computer Gateway C altera 121spl quartus qdesigns EPT Data Collector N 3 ee Organize v _ Open Burn New folder Ji qdesigns Name Date modified Type Size J EPT Data Collector J EPT Transfer Test J fir filter incr comp makefile d vhdl verilog tutorial d sopc builder B altera inspector log zip 1 book di Brother Jo CIMTEMP a Documents and Settings Ji Jolly di Business Opportunities J Capitol College Code FPGA Dactuments EPT 570 AP U2 Top sdc Date modified 1 24 2013 10 01 PM Date created 3 14 2013 12 09 AM SDC File Size 3 39 KB J db 3 14 2013 12 07 AM File folder EPT_570_AP_U2_Top qpf 3 14 2013 12 06 AM QPF File 2 KB EPT 570 AP U2 Top qsf 3 14 2013 12 07 AM QSF File 4 KB EPT 570 AP U2 Top qsf bak 3 14 2013 12 08 AM BAK File 4 KB _ EPT 570 AP U2 Top sdc 1 24 2013 10 01PM SDC File 4 KB m 1 T and select the Start Compilation button E This will cause the compile and synthesization process After successful completion the screen should look like the following File Edit View Project Assignments Processing Tools Window Help 5 Search altera com Qu amp 34 5c msmewm vo499o
39. Next the device is made the active device and the call back function is registered using the RegisterCallBack function Finally the Open button 1s grayed out and the Close button is made active Page 69 ZAIATIHI2EOIPLIE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Open the device public unsafe Int32 OpenDevice 1 device index int cmbDevList SelectedIndex if EPT AH OpenDeviceByIndex device index 8 1 String message Could not open device Marshal PtrToStringAnsi IntPtr EPT AH GetDeviceName device index Marshal PtrToStringAnsi IntPtr EPT AH GetDeviceSerial device index MessageBox Show message return 6 else labelDeviceCnt Text Connected to device Marshal PtrToStringAnsi IntPtr EPT AH GetDeviceName device index Marshal PtrToStringAnsi IntPtr EPT AH GetDeviceSerial device index I Make the opened device the active device if EPT AH SelectActiveDeviceByIndex device index 8 1 String message Error selecting device 4s Marshal PtrToStringAnsi IntPtr EPT AH GetLastError MessageBox Show message return 6 Register the read callback function RegisterCallBack btnOpenDevice Enabled false btnCloseDevice Enabled true return 6 5 1 6 C Project Callback Initialization Next the callback function is populated This function will be called from the Active Host dll When the EPT Device has transferred data to
40. ROJECT CD Select the EPT 570 AP U2 Top qsf file Page 51 ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Gees a ANM enn Specify the source and categories of assignments to import File name echnology EPT USB CPLD Development System CD Projects HDL EPT Transfer Test Altera EPM570 UZ EPT 570 AP U2 Top gsf Copy existing assignments into EPT 570 AP Transfer Test qsf bak before importing Next we need to add the Synopsys Design Constraint file This file contains timing constraints which forces the built in tool called TimeQuest Timing Analyzer to analyze the path of the synthesized HDL code with setup and hold times of the internal registers It takes note of any path that may be too long to appropriately meet the timing qualifications For more information on TimeQuest Timing Analyzer see http www altera com literature hb qts qts_qii53018 pdf GSA_pos 1 amp WT oss_r 1 amp WT oss TimeQuest Timing Analyzer Browse to the Projects_HDL EPT_ Fast Oscilloscope Altera_EPM570_U2 folder of the EPT USB CPLD Development System CD Select the EPT 570 AP U2 Top sdc file GO Products Earth People Technology EPT USB CPLD Development System CD gt Projects HDL gt EPT Data Collector gt EPT 570 AP U2 Top X A Se EE ET m aa a s Organize v _ Open Share with v Burn New folder Ji Earth People Technology Name Date modified Type Siz
41. System EventHandler this btnOpenDevice Click This code sets up the button size placement and text It also declares the System EventHandler This statement sets the click method which is a member of Page 75 E gt EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual the button class of the btnOpenDevice button to call the EventHandler btnOpenDevice Click This is where the magic of the button click event happens private void btnOpenDevice Click object sender EventArgs e Open the Device OpenDevice lblDeviceConnected Text Device Connected private void btnCloseDevice Click object sender EventArgs e EPT AH CloseDeviceByIndex device index btnOpenDevice Enabled true btnCloseDevice Enabled false lblDeviceConnected Text 1 When btnOpenDevice Click is called it calls the function OpenDevice This function is defined in the dll and will connect to the device selected in the combo box This is a quick view of how to create add files and add controls to a C project The user is encouraged to spend some time reviewing the online tutorial at http www homeandlearn co uk csharp csharp html to become intimately familiar with Visual C NET programming In the meantime follow the examples from the Earth People Technology to perform some simple reads and writes to the EPT USB CPLD Development System The btnOk and btnClose buttons are used to end the applic
42. TAG Settings Select a programming hardware setup to use when programming devices This programming hardware setup applies only to the current programmer window Currently selected hardware EPT Blaster v1 3b MBUSE Y gt 7y a Available hardware items Hardware Server Port Add Hardware EPT Blaster v1 3b Local MBUSB 0 Remove Hardware Click the Close button Next selet the checkbox under the Program Configure of the Programmer Tool The checkboxes for the CFM and UFM will be selected automatically Page 56 EARTITRPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual File Edit View Processing Tools Window Help 5 a pm M Programmer C altera 12 1sp1 quartus qdesigns EPT_Transfer_Test EPT_570_AP_U2_Top EPT 570 AP U2 Top Chain2 cdf FEE Search altera com Hardware Setup EPT Blaster v1 3b MBUSB 0 E Enable real time ISP to allow background programming for MAX II and MAX V devices Mode TAG 1 7 id File Device Checksum output files EPT 570 A EPM570T100 CFM UFM 002CD72E Usercode FFFFFFFF Program Configure T A Verify Blank Check Examine Se Click on the Start button to to start programming the CPLD The Progress bar will indicate the progress of programming File Edit View Processing Tools Windo
43. TECHNOLOGY Fast Arduino Oscilloscope Project User Manual capacitor at AREF pin cbi ADMUX REFS1 Sbi ADMUX REFSO The ADLAR bit affects the presentation of the ADC conversion result 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 l ADCPIN amp 0x07 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 p
44. Visual C di WPF Browser Application Visual C amp xoqjoo 4x 1810Jdx3 aseqejzeq ei Empty Project Visual C EPT Analog Monitor Error List 21x Description L i a Line Column Project MA The setup statements create the namespace and the class for the project There are several other files that are created by the wizard such as Form1 Designer cs Program cs Form1 resx We don t need to go into these support files we will just focus on the Forml cs as this is where all the user code goes Click on File gt Save Project as Browse to C Users lt user name gt Documents Visual studio 201 Projects and click Select Folder Click the Save button EPT Analog Moni Expres Hie Edit View Project Build Debug Data Tools Window Hep Iaa gag aala e a h Debug he6 pe amp A T of l 2 i EB EE one ee S St g eE Ld o 1 e t c a v m Microso Niicrosort 8 btnOpenDevice x REER DA EPT_Analog_Monitor Project Prop Ae fod Solution EPT Analog Monito f G EPT Analog Monitor E gt Ea Properties Project File EPT Analog Monit 8 wj References A ES Form1 cs 5 Program cs E Name EPT Analog Monitor Location C Users NelsonsTrfgr Documents Visual Studio 2010 Projects i Solution Name EPT_Analog_Monitor V Create directory for solution 2 Description Line Column
45. alled it in turn calls the ListDevices Main object loader private void EPT Analog Monitor Load object sender System EventArgs e i Call the List Devices function ListDevices 5 1 4 C Project ListDevices The ListDevices function calls the EPT AH Open function to load up the Page 67 EARTITRPEORPRPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual C WINDOW FUNCTIONALITY Initialize Variables Controls Events Read Callback Function Open EPT 570 AP Device Send Start Control to EPT 570 AP Device Y Await for Read Callback Event ADDRESS SELECTION BYTE SELECTION READ UPPER BYTE FROM TRANSFER ENDTERM READ LOWER BYTE FROM TRANSFER ENDTERM UPDATE TEXTBOX WITH 10 BIT ADC VALUE ActiveHost DII Next it calls EPT_AH_QueryDevices which searches through the registry files to determine the number of EPT devices attached to the PC Next EPT_AH_GetDeviceName is called inside a for loop to return the ASCII name of each device attached to the PC It will automatically populate the combo box cmbDevList with all the EPT devices it finds List Devices function private unsafe Int32 ListDevices i Int32 result Int32 num devices Int32 iCurrentIndex Open the DLL result EPT AH Open null null null if result 6 i MessageBox Show Could not attach to the ActiveHost library return 6 Query connected devices num devices EPT AH QueryDevices Prep
46. alog Monitor Code U2 ino v Arduino Analog Monitor Code U2 ik Copyright Earth People Technology Inc 2013 Analog Monitor Six Channel Analog Sampler Platform EPT 570 AP UZ int AdcValue int Upper dcValue void setup DDRD Bllllllll Set Port D as outputs PORTD amp Bllllllll Turn on Port D pins DDRB B00111111 Set Port B as outputs PORTB B00000000 Turn on Port B pins A e Click the Verify button Arduino Uno on COME Page 37 EARTIHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 9 Arduino Analog Monitor Code U2 Arduino 1 0 1 File Edit Sketch Tools Help Arduino Analog Monitor Code l2 Copyright Earth People Technology Inc 2012 alog Monitor Six Channel Analog Platform EPT 570 AP U2 int AdcValue int Upper AdcValue void setup DDRD B11111111 Set PORTD B11111111 DDRB B00111111 Set PORTE B00000000 5 Arduino Uno on COME e The sketch will compile e If there are no errors the compiling will complete successfully Arduino Uno on COME Now we are done with compiling and ready to program the Arduino 3 20 Programming the Arduino Programming the Arduino 1s the process of downloading the user s compiled code into the Flash memory of the Atmel ATMega328 chip Once the code is downloaded the Arduino IDE resets the chip and the processor starts executing out of Flash memory To
47. alog signal to a digital pin induces it to toggle between HIGH and LOW states especially if the signal is near the boundary between the two states this toggling induces some noise to the near circuits like the ADC itself and induces a higher energy consumption To disable the digital buffer we should set the ADCnD bits of the DIDRO register sbi DIDRO ADCSD sbi DIDRO ADC4D sbi DIDRO ADC3D sbi DIDRO ADC2D sbi DIDRO ADCID sbi DIDRO ADCOD sbiCDIDR ADCSD sbiCDIDRO ADCAD sbiCDIDRO ADC3D SbiCDIDRO ADC2D SbiCDIDRO ADCID sbiCDIDRO ADCOD 3 11Setting up the ADC In the sketch I wrote a initialization function that sets up all the parameters of the ADC functioning As I tend to write clean and commented code I will just past the function here We can refer to the preceding step and to the comments for the meaning of the registers void initADC void These bits select the voltage reference for 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 The internal voltage reference options may not be used if an external reference voltage is being applied to the AREF pin REFSI REFSO Voltage reference 0 0 AREF Internal Vref turned off 0 1 AVCC with external capacitor at AREF pin 1 0 Reserved 1 1 Internal 1 1 V Voltage Reference with external Page 24 fib ARTHPEOPLE
48. are the Combo box for population iCurrentIndex cmbDevlist SelectedIndex cmbDevList Items Clear Go through all available devices for device index 8 device index lt num devices device index i String str str Marshal PtrToStringAnsi IntPtr EPT AH GetDeviceName device index cmbDevList Items Add str I return Page 68 EARTITRPEORPRPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 5 1 5 C Project Open Device The user will select the device from the drop down combo box This value can be sent C WINDOW FUNCTIONALITY Initialize Variables Controls Events Read Callback Function Select EPT 570 4P Device Send Start Control to EPT 570 AP Device Y Await for Read Callback Event m ADDRESS SELECTION BYTE SELECTION READ UPPER BYTE FROM TRANSFER ENDTERM READ LOWER BYTE FROM TRANSFER ENDTERM UPDATE TEXTBOX WITH 10 BIT ADC VALUE to the OpenDevice function using the button Click of the Open button Open the device if EPT AH OpenDeviceByIndex device index false i printf Could not open device s n EPT AH GetDeviceName device index exit The device_index variable is used to store the index of the device selected from the combo box This variable is passed into the EPT_AH_OpenDeviceByIndex This process is started by the user clicking on the Open button If the function is successful the device name is displayed in the label labelDeviceCnt
49. ation It calls the function EPT AH CloseDeviceByIndex to remove the device from the Active Host dll The buttons btnOpen and btnClose have their Enabled parameter set to true and false respectively The Enabled parameter controls whether the button is allowed to launch an event or not If it is not enabled the button is grayed out At the end of each click event the Application Exit method 1s called This exits the form Page 76 B9 EAITIHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual private void btnOk Click object sender EventArgs e i EPT AH CloseDeviceByIndex device index btnOpenDevice Enabled true btnCloseDevice Enabled false lblDeviceConnected Text Application Exit I private void btnCancel Click object sender EventArgs e 1 EPT AH CloseDeviceByIndex device index btnOpenDevice Enabled true btnCloseDevice Enabled false lblDeviceConnected Text Application Exit 1 The btnStart and btnStop buttons are used to start and stop the EPT 570 AP USB Trasnfer They call the function EPT AH SendTransferControlB yte to set the bit 0 in the control register The function passes the control byte to the Active Host dll They both operate on the click event which are setup in the Forml1 Designer cs file this btnStart Click new System EventHandler this btnStart Click this btnStop Click new System EventHandler this btnStop Click The EPT_AH_SendTransferControlBy
50. c e USB Type A cable e USB Type Mini B cable e Solid core wire e 5VDC Variable Power Supply with cables e Function Generator with cables 2 3 Oscilloscope Hardware The Arduino uses the analog comparator to trigger the scope The ADC then samples the analog channel 0 The samples are stored in a buffer in the ATMega328 SRAM Because of the method of using the Arduino hardware to behave as an oscilloscope we have to build some hardware The analog signal must be applied to both the analog channel 0 and the input to the analog comparator To do this connect the UnoProLogic to the Uno Next connect the 5V variable power supply up Connect the ground to pin 6 of J12 on the UnoProLogic Page 9 EARTIIPEORPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Connect the positive lead of the supply to Digital input 7 pin 8 of J8 on the UnoProLogic Next connect the ground lead of the of the Function Generator to pin 7 of J12 Next we need to build a cable that connects the signal to be displayed to Analog O pin 1 of J9 on the UnoProLogic and to Digital input 6 pin 7 of J8 on the UnoProLogic Finally connect the positive lead of the Function Generator to the Y cable that connects analog input 0 and comparator input 2 uon m uuuwsS 3 AR RAL ALL EE SE GG eeseceeeeeeeees 2 4 Fast Oscilloscope Data Flow The Fast Arduino Oscilloscope is controlled by the C application After app
51. cies above 1 MHz and this can be seen in the graph of the Effective Number of Bits You can see from the graph that the resolution deteriorates to less than 8 bits at frequencies above 1 MHz So we will keep the ADC input frequency to 1 MHz or less 6 1 2 Oscilloscope Functions As you can see on the screen the EPT Fast Arduino Oscilloscope has 9 divisions in the horizontal direction and 9 divisions in the vertical Grab the Horizontal Time Base Slider and pull it to the right to decrease the time per division This allows us to scale into the wavelength of the signal by changing the ADC clock This reduces the time between conversions and lets us see faster signals at the analog input There are 450 samples that are displayed in the window This results in 50 samples per division Divide the selected ADC clock frequency by one and multiply by 13 clocks per conversion Then multiply by 50 samples per division to arrive at the time per division If we choose IMHz for the ADC Clock and perform the same calculation we arrive at 650 microseconds per division This can adequately examine a 3KHz analog signal at the input Examining the Scope performance I can move the position of the waveform in the window using the X position slider Use the Voltage Scale slider to give a boost to small voltage signals so that we can see them better Use the Vertical Position Slider to reposition the waveform for better viewing There are other user controls
52. cope Project User Manual define dshow expression endif Rafine dprintiemrenrst Beupra 3 5 Setting register bits With the purpose of being fast it is necessary to manipulate the microcontroller features with lower lever functions than the standard ones provided by the Arduino IDE The internal functions are managed through some registers that are collections of eight bits where each one governs something particular Each register contains eight bits because the ATMega328P has an 8 bit architecture The registers have some names that are specified in the datasheet depending on their meanings like ADCSRA for the ADC Setting Register A Also each meaningful bit of the registers has a name like ADEN for the ADC Enable Bit in the ADCSRA register To set their bits we could use the usual C syntax for binary algebra but I found on the internet a couple of macros that are very nice and clean Defines for setting and clearing register bits ifndef cbi define cbi sfr bit SFR BYTE sfr amp _BV bit endif ifndef sbi define sbi sfr bit _SFR_BYTE sfr l BV bit endif Using them is very simple if we want to set to the Enable Bit of the ADC we can just write sbi ADCSRA ADEN While if we want to set it to O 1d est clear it we can just write cbi ADCSRA ADEN ADCSRA ADC Control and Status Register A ff Defines for setting and ADEN ansc ADKTE ADIF ADTE hops3anPs aoeso ifndef cbi i
53. coso cesses 24 3 12 How the Analog Comparator works ccccccccccceseeeeeeeeeeeeeeaaeeeseeeeeeeeeenaas 24 3 13 Setting up the Analog Comparator ccccccccccccccssseseeeeeeeeeeeaneeseeeeeeeeeeaaas 28 3 14 TEATS SIG RENTRER pues uses oa T T TM 29 3 15 How the Pulse Width Modulation works eeeeeeereeeeeeeess 30 3 16 CU Up The T MU atest E PME CUm UMS 3l 3 17 NOT AUC VAR ONES ern A E E EAS SM nts co v ie U Rede 33 3 18 Writing the kernel of the sketch nneossseoeennsssssssseeersssssssseeersssssssssseerssssss 34 3 19 B ildins Arduino PIOIeEusnseousit pese obke vot ae Eia 59 3 20 Programming the Arduino eeesssssssssseeeeseeeeeeeeeee enne eene nnns 38 4 CPLD Active Transfer EndTerms Coding eeeeeeeeeeeeeeeeeeeene nnne 40 Page 2 6 E EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 4l Define the User Design ccssedcsisccdicccssacaessndaccdenedaedasiaenslaaeesananesacacesasedaelansacadiaasns 40 22 CECE ie TU CIOS scissomutiseno miei untur OSEE EEEE 4 4 gt Resistors and Parameter S sessionerne tires Ere eri os Qio PP EUR LC pU tU NEP MULT ON iD EUN 43 AA AS NET TU m 43 Bo Hc p MT 43 dO PUROS E ETE 44 4 7 Start Stop and Write Enable detection nnsesssoooeeesssssssseeersssssssssserrsssssssees 44 4 8 Transfer Control Register State Machine sesss
54. ctor The Fast Arduino Oscilloscope cable harness connects pin 7 of J8 to pin 1 of J9 this is the attachment for the analog signal to be displayed on the oscilloscope When the analog input signal on the positive input to the comparator is greater than the input on the negative input to the comparator an interrupt is called This interrupt 1s ISR ANALOG COMP vect The loop function will exit and start execution of the first instruction in the comparator interrupt vector The first thing 1s to turn off the analog comparator interrupt so that no following comparator interrupts can disrupt the process Next the wait variable is set to true The stopindex is then set to the current count of the ADCCounter plus an additional number of counts set by waitDuration These extra counts will allow a full cycle of the analog input signal to be captured and displayed Finally the value TriggerCount is set to the ADC Counter This will be used when transmitting the ADCBuffer to the UnoProLogic When the ADCBuffer has completed transmission the Girino code asserts the End Of Buffer signal This signal is used to create Trigger 2 in the Active Trigger Endterm After that reset the trigger variables and re start the ADC During each cycle of the loop function The serial port is checked to see if a new command has arrived from the C application If a new command has arrived the Girino code will perform the selected command 2 4
55. designs gt QD Quartus II 64 Bit EDA Netlist Writer was successful 0 errors 0 warnings E D 293000 Quartus II Full Compilation was successful 0 errors 49 warnings i Page 53 ES EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual If the synthesis fails you will see the failure message in the message window Note that in addition to fatal errors the compile process can produce warnings which do not necessarily prevent execution of the code but which should be corrected eventually At this point the project has been successfully compiled synthesized and a programming file has been produced See the next section on how to program the CPLD 4 13 Program the CPLD The final step is programming the pof file into the CPLD e Connect the EPT 570 AP to the PC e Open up Quartus II e Open the programmer tool If the project created in the previous sections is not open open it Click on the Programmer button Page 54 ZAI ATIHIP2EOT2L E TECHNOLO GG Y Fast Arduino Oscilloscope Project User Manual E e um x a MM a 4 File Edit View Project Assignments Processing Tools Window Help E Search altera com gud 428 9 eo r OAT O o Project Navigator 28x d Compilation Report EPT 570 AP U2 Top a Entity Table of Content
56. e i EPT DC Project CD EPI 5 U AP UZ lop tit summary 3 3 2013 1 12 AM SUMMARY File 1 KB db EPT Projects Folders _ EPT_570_AP_U2_Top flow rpt 3 3 2013 1 12 AM RPT File 7 KB M EPT USB CPLD Development System CD _ EPT_570_AP_U2_Top jdi 3 3 2013 1 12 AM JDI File 1 KB IB Arduino IDE L EPT_570_AP_U2_Top map rpt 3 3 20131 12AM RPT File 42 KB Documentation _ EPT 570 AP U2 Top map smsg 3 3 2013 1 12 AM SMSG File 1KB Ji Drivers _ EPT 570 AP U2 Top map summary 3 3 2013 1 12 AM SUMMARY File 1 KB Projects ActiveHost 32Bit 3 _ EPT 570 AP U2 Top pin 3 3 2013 1 12 AM PIN File 15 KB Ul Projects ActiveHost 64Bit EPT 570 AP U2 Top pof 3 3 203112 AM POF File 15 KB Projects Arduino e EPT_570_AP_U2_Top qpf 10 22 2012 12 04 QPF File 2 KB n Projects HDL _ EPT 570 AP U2 Top qsf 1 28 2013 12 07 AM QSF File 6 KB I EPT_Data_Collector EPT_570_AP_U2_Top qsf bak 10 22 2012 12 05 BAK File 3 KB EPT 570 AP M4 Top _ EPT 570 AP U2 Top qws 3 3 2013 1 31 AM QWS File 2 KB EPT 570 AP U2 Top _ EPT 570 AP U2 Top sdc 1 24 2013 10 01 PM SDC File 4 KB B src EPT 570 AP U2 Top sta rpt 3 3 203112 AM RPT File 139 KB Bl EPT Transfer Test EPT 570 AP U2 Top sta summary 3 3 203112 AM SUMMARY File 1KB Quartus Programmer _ EPT 570 AP U2 Top assignment default 1 24 2013 9 18 PM QDF File 56 KB EPT 570 AP U2 Top sdc State 2B Shared Size 3 39 KB Shared with Homegroup SDC File Date modified 1 24 2013 10 01 PM Date created 1 28 2013 11 30 P
57. e PC and provides transparent connection HOST APPICATION EPM570 CPLD USER APPLICATION TRIGGER 8 naam ACTIVE TRIGGER ENDTERM A adi TRANSFER E Cit pows HE E VE LIBRARY 8 BIT DATA BUS TRANSFER HOST USB USB BUS TRANSFER ENDTERM ENDTERM Dir DRIVER E i H ARDUINO BLOCKENDTERM rh Y C CONSOLE d BLOCK ENDTERM a 6 BIT CONTROL BUS ad from PC application code through the USB driver to the user CPLD code The user code connects to Endterms in the Active Host dll These Host Endterms have Page 5 fb ARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual complementary HDL Endterms in the Active Transfer Library Users have seamless bi directional communications at their disposal in the form of e Trigger Endterm e Transfer Endterm e Block Endterm User code writes to the Endterms as function calls Just include the address of the individual module there are eight individually addressable modules of each Endterm Immediately after writing to the selected Endterm the value is received at the HDL Endterm in the CPLD Receiving data from the CPLD is made simple by Active Host Active Host transfers data from the CPLD as soon as it is available It stores the transferred data into circular buffer When the transfer is complete Active Host invokes a callback function which is registered in the users application This callback function provides a mechanism t
58. een 5 V and GND is sufficient While for software selection we need a low pass filter that filters a PWM signal coming from the Arduino PWM signals more on this to follow are square signals with a constant frequency but a variable pulse width This variability brings a variable mean value of the signal that can be extracted with a low pass filter A good cutoff frequency for the filter is about one hundredth of the PWM frequency and I chose about 560 Hz After the two threshold sources I inserted a couple of pins that allows to select with a jumper which source I wanted After the selection I also added an emitter follower to decouple the sources from the Arduino pin Page 29 fb ARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual PWM 1 Threshold setting 3 15 How the Pulse Width Modulation works As stated before a Pulse Width Modulation PWM signal is a square signal with fixed frequency but variable width On the image we see an example On each row there is one of such signals with a different duty cycle 1d est the period portion in which the signal 1s High Taking the mean signal over a period we get the red line that correspond to the duty cycle with respect to the signal maximum Electronically taking the mean of a signal can be translated to passing it to a low pass filter as seen on the preceding step How does the Arduino generate a PWM signal There i
59. eir own always blocks and separate from the state machine State Definitions always 8 State or transfer write or first byte complete or second byte complete or transfer write or start transfer array or transfer busy array begin next 6 h000 This asynchronous always block is the one which causes the state machines conditional branches to update If the conditional branches are not updated with the correct inputs Page 46 E B EARTHPEOPLE TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual then the next statement will not get updated with the correct state and the state machine could get stuck in the wrong state So each input into the state machine MUST be entered into the sensitivity list of the State Definitions always block pic scu ee SECOND BYTE RDY If byte stored byte transferred The state machine stays in state IDLE In state STORE FIFO COUNT In state START SEND BLOCK In state FIFO_HI In state FIFO LO In state INCR_ COUNT In state BLOCK SEND COMPLETE 4 10 EndTerm Instantiation 4 11 Compile Synthesize the Project The Quartus II application will compile synthesize the user code active_transfer_library and the Active EndTerms The result of this step is a file containing the CPLD code with pof First we need to create a project in the Quartus II environment Follow the directions in the section Compiling Synthesizing and Programming CPLD
60. elopment System User Manual to install all of the software and drivers for use with the hardware Page 4 EARTITRPEORPRPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual File Action View Help 9s t 3 H E ees 4 S23 HP DeskTop 3005 JE Computer gt xg Disk drives amp Display adapters xis DVD CD ROM drives gt cg IDE ATA ATAPI controllers A amp Monitors amp Network adapters J Ports COM amp LPT Di Processors gt i Sound video and game controllers gt gii System devices 4 F Universal Serial Bus controllers be vy Standard Enhanced PCI to USB Host Controller g Standard Enhanced PCI to USB Host Controller bes y Standard OpenHCD USB Host Controller F Standard OpenHCD USB Host Controller 8 USB Composite Device USB Root Hub USB Root Hub USB Root Hub USB Root Hub USB Serial Converter A USB Serial Converter B If the driver has been installed correctly you can go to the Device Manager and click on the Universal Serial Bus controllers and see USB Serial Converter A and USB Serial Converter B 1 2 Software Installation Follow the the instructions in the EPT USB CPLD Development System User Manual to install the following software e Altera Quartus II e Microsoft C Express e Arduino Wiring IDE 1 3 Active Host EndTerms The Active Host SDK is provided as a dll which easily interfaces to application software written in C C or C It runs on th
61. enables of the 74LVC4245 transceivers are set low and the outputs become active When start stop cntrl goes low the output enables of the 74LVC4245 transceivers are set high and sets the outputs to inactive 48 Transfer Control Register State Machine The start stop cntrl signal is set by using the TRANSFER CONTROL state machine in the following section So if the start stop cntrl signal is set the CPLD code will enter the conditional branch code and wait for the Write Enable signal to assert Next we add the TRANSFER CONTROL state machine to read the Control Register from the Host PC using the active transfer EndTerm This state machine will decode the 8 bit control register only after a sequence of three 8 bit bytes 1n the order of 0x5a 0xc3 Ox 7e The operation of the state machine is as follows 1 The TRANSFER CONTROL state machine will stay in the idle state of the parallel encoder until a byte from the active transfer transfer to device register receives a OxSa 2 This will cause the transfer control state to be changed to TRANSFER CONTROL HDRI 3 The state machine will stay in the TRANSFER CONTROL HDRI state until the next byte 1s read from the active transfer 4 If the byte from transfer to device is a Oxc3 the transfer control state will be changed to TRANSFER CONTROL HDR2 5 If the byte from transfer to device is not a Oxc3 the transfer control state will go back to idle 6 In the TRANSFER CONTROL HDRG2 state
62. ernet looking for Arduino Oscilloscopes already implemented but I did not like what I found The projects that I found were mostly composed of a Graphical User Interface for the computer written in Processing and a very simple arduino sketch The sketches were something like void setup Serial begin 9600 j void loopQ int val analogRead ANALOG_IN Serial printin val j This approach is not wrong and I do not want to insult anyone but this 1s too slow for me The serial port is slow and sending every result of an analogRead through it is a bottleneck Page 14 ES EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual I have been studying Waveform Digitizers for some time and I know reasonably well how do they work so I got inspiration from them These were the starting points of the oscilloscope that I wanted to create the incoming signal should be decoupled from the arduino to preserve it with an offset of the signal it is possible to see negative signals the data should be buffered a hardware trigger 1s required to catch the signals a circular buffer can give the signal shape prior to the trigger more to follow on this point using lower lever functions that the standard ones makes the program run faster The sketch for the Arduino is attached to this step along with the schematic of the circuit that I made The name that I came up with Girino is a frivolous pun in Italian
63. esoeenssssssssoeeresssssssseerrsssssssees 45 4 9 USB Transfer State Machin essasnestrosnini aeo a 46 4 10 Eng Terni lnstan alioi eteoecucranecere nacho a E UE sn 47 4 11 Compile S ynthesize the Project sees 47 4 12 YUM SUZ occ E cosh poeta eceee count E E E R 51 4 13 lio ura CPLD Parente fee ane TT aC Re nee ere 54 lu Sor duse MBA a MEUM 58 SL COGN The Iure ve TT Temm 50 dure ved Susie NR T UU T 60 V 60 2 12 CoP Projet Environment Sell ssec oin tege eu mitte Pepe eodem pex ERU ne dad 62 5 1 3 Cs Object Initialization 0 0 ec ccccccccccseesssseeeecccecsaeeessseecccesssseeesseseeeees 67 314A CH Project SC V1 NR 67 Dl CA Project Open DEC 69 5 1 06 C Project Callback Initialization eese 70 ET CEPE T COO mU E 71 SEP CH Project EET LT 72 5 1 9 CX Project EPTReadFunction Callback eeeeeeeeese 78 JN MEG Pie scu E TS 79 5 2 PC Compiling the Active Host Application essere 79 5 2 1 Adding the DLL s to the Project sseeessssssssseseeeeeeenennnnnnnnnnnns 80 Connecting the Project TOS CINE escenes 8l OL Xesumb E E E E repu sidere esos dn M aeq M A E ET 85 OLL Oscrloscope WeSC MON uiatetusdoc ads ortatobiuv credi T 86 OZ Oscilloscope PII LIOBS scssi savant EEEE 87 6 1 3 Oscilloscope Performance seeeeesssseeeeeeeee nnne nennen nennen 87 Page 3 ZAIAT
64. et type wire or reg If it is a vector the array description must be added Page 42 gt EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual module EPT 570 AP U2 Top e input wire 1 9 aa input wire 1 0 bc in output wire 2 0 bc out inout wire 7 bd inout input wire 1 0 LB SEE XIOH J10 input wire 5 0 LB AD AD 73 input wire 7 0 LB IOH XIOH J10 input wire 7 0 LB IOL XIOL J8 Transceiver Control Signals output wire IR DIR 1 output reg IR OE 1 output wire IR DIR 2 output reg IR OE 2 output wire IR DIR 3 output reg IR OE 3 input wire SOW USER 1 input wire SW USER 2 output wire 2 0 LED Ls 4 3 Registers and Parameters 44 Assignments Next add the assignments These assignments will set the direction of the bus transceivers that interface to the Arduino I O s The transceivers also include an output enable bit 4 5 Reset Circuit The reset signal 1s generated by a counter that starts counting upon power up When the counter reaches GLOBAL RESET COUNT Page 43 E EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual f PEER E REE RE REE EERE REE EE EEE EEK EKER ERE ER ERE 4 A4 A DI 2ZI Reset Signal always posedge CLE IN or negedge aa begin if aa o begin reset signal reg lt 1 b0 reset counter lt 0 end else begin if reset counter GLOBAL RESET COUNT begin reset
65. gn The final piece of the Fast Oscilloscope is the PC application This application will fetch the data from the CPLD of the EPT 570 AP and display it on the screen It includes user code windows form and the Active Host DLL gv tm i x sone mmm ele ACTIVE TRANSFER ACTIVE HOST LIBRARY DLL The Active Host DLL is designed to transfer data from the CPLD when it becomes available The data will be stored into local memory of the PC and an event will be triggered to inform the user code that data is available from the addressed module of the CPLD This method from the user code on the PC makes the data transfer transparent The data just appears in memory and the user code will direct the data to a textbox on the Windows Form The Fast Oscilloscope will perform the following functions Find UnoProLogic Device Open UnoProLogic Device Start the Arduino data conversion process Wait for data from UnoProLogic Add byte to ScopeBuffer Wait for Trigger 2 to signal End of Buffer Display digital data on a graphics window Page 58 ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual C WINDOW FUNCTIONALITY Initialize Variables Controls Events Read Callback Function Select EPT 570 AP Device USB TRANSFER Y Wait for Read Callback READ ADC DATA BYTES INTO BUFFER END OF BUFFER TRIGGER REFRESH OSCILLOSCOPE DATA SCALE DATA IN VERTICAL AND HORIZONTAL
66. h allow turning on and off signals These include e btnOk btnCancel btnOpenDevice btnCloseDevice btnStart btnStop btnSetScaleFactor btnResetBlock1 6 Textboxes are used to display information on the Windows form These textboxes are Page 71 B9 EAITHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual cmbDevList tbMonitorl tbMonitor2 tbMonitor3 tbMonitor4 tbMonitor5 tbMonitor6 5 1 8 C Project Buttons Although the C language is very similar to C Code there are a few major differences The first is C NET environment is event based A second is C utilizes classes This guide will keep the details of these items hidden to keep things simple However a brief introduction to events and classes will allow the beginner to create effective programs Event based programming means the software responds to events created by the user a timer event external events such as serial communication into PC internal events such as the OS or other events The events we are concerned with for our example program are button clicks or dropdown box clicks The user events occur when the user clicks on a button on the Windows Form or selects a radio button We will add a button to our example program to show how the button adds an event to the Windows Form and a function that gets executed when the event occurs The easiest way to add a button to a form is to double click the Forml cs in the Solution 3 Expl
67. he beggining without clearing it If we immagine the array arranged in a circular way it is easy to see what I mean When the signal surpasses the threshold the Analog Comparator Interrupt is activated Then we start a waiting phase in which we continue to acquire the signal but keep a count of the ADC cycles that passed from the Analog Comparator Interrupt When we waited for N cycles with N lt 1280 we freeze the situation and stop the ADC cycles So we end up with a buffer filled with the digitization of the signal temporal shape The great part of this 1s that we have also the shape prior to the trigger event because we were already acquiring before that Now we can send the whole buffer to the serial port in a block of binary data instead of sending the single ADC reads This reduced the overhead required to send the data and the bottleneck of the sketches that I found on the internet Continuous Wait for N acquisition ADC cycles Signal start a y a j Signal P uint8 t ADCBuffer 1280 start ih Y ic x Freeze Write buffer SUrpsss1d situation to Serial Page 20 fib ARTHPEOPLE TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual 3 8 Oscilloscope Triggering An oscilloscope shows on its display a signal on that we all agree but how can it show it steadily and do not show it jumping around the screen It has an internal trigger that 1s able to show the signal always
68. hesis Optimizations src EPT 570 AP U2 Top v Verilog HDL File None EDA Tool Settings src active trigger vqm Verilog Quartus Mapping File None Design Entry Synthesis Jsrcfactive transfer library vqm Verilog Quartus Mapping File None Simulation srcfactive_transfer vqm Verilog Quartus Mapping File lt None gt Formal Verification Board Level Analysis amp Synthesis Settings VHDL Input Verilog HDL Input Default Parameters Fitter Settings TimeQuest Timing Analyzer Assembler Design Assistant SignalTap II Logic Analyzer Logic Analyzer Interface PowerPlay Power Analyzer Settings SSN Analyzer m O Buy Software ox cancel aoni Select Next at the Device Family group select MAX II for Family In the Available Devices group browse down to EPM570T100C5 for Name Page 50 ZAI ATIHIPEEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Select Next leave defaults for the EDA Tool Settings Select Next then select Finish You are done with the project level selections 4 12 Synthesizing With the project created we need to assign pins to the project The signals defined in the top level file in this case EPT_570_AP_U2_Top v will connect directly to pins on the CPLD The Pin Planner Tool from Quartus II will add the pins and check to verify that our pin selections do not violate any restrictions of the device In the case of this example we will import pin
69. how fast is follows the change in input Next I will change the Function Generator output to random noise So you can see that the EPT Fast Arduino Oscilloscope has high performance Next lets look at the equipment that is need for this project Page 88
70. ing Syste Customize 7 ter Sainas E using Syster Online p 3 at transfer x64 cs ib uud pti M E gt Ss Formi cs B 2 di using System Text Import and Export Settings e amp Program cs using System Windows Forms Q e ScaleFactorMenu cs using System Threading using System Runtime InteropServices using System Diagnostics Elnamespace EPT Analog Monitor Form public partial class EPT Analog Monitor public EPT Analog Monitor InitializeComponent Go to Tools gt Options locate the Show all settings check box Check the box Page 62 EARTITRPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 4 Environment Recent files General items shown in Window menu Fonts and Colors Keyboard 10 items shown in recently used lists b Text Editor Debugging Visual experience Automatically adjust visual experience based on client performance Enable rich client visual experience Use hardware graphics acceleration if available Visual Studio is currently using hardware accelerated rendering The visual experience settings automatically change based on system capabilities Show status bar Close button affects active tool window only Auto Hide button affects active tool window only Restore File Associations _ Show all settings In the window on the left go to Projects and Solutions Locate the Show advanced build config
71. ing the Arduino project is the process of converting compiling the code you just wrote into machine level code that the processor can understand The Arduino IDE is the software tool that does the compiling The machine level code is a set of basic instructions that the processor uses to perform the functions the user code Browse to the Projects_Arduino Arduino_Fast Oscilloscope Arduino Fast Oscilloscope Code U2 folder of the UNO FAST OSCILLOSCOPE PROJECT CD Locate the Arduino_ Fast Oscilloscope Code U2 ino file To compile your code e Open up the Arduino IDE Page 35 ZAI ATIHIP2EEOT2L EE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual d gt Computer gt Jolly Laptop PC C Jolly Products Arduino arduino 101 Organize v Open Burn New folder p Download x M n Drivers A rivers d FunctionalSpec examples j License p p Products E d hardware Altera E a i p Aptina mae B Arduino di libraries ef d arduino 1 0 1 di reference J MEGA 2560 Ji tools e arduino exe S cygiconv 2 dll di Uno B Atmel amp y cvawinl dll sketch oct27a Arduino Shared witl File Edit Sketch Tools Help sketch oct27a Page 36 ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual in Arduino Analog Monitor Code U2 Q amp m Date modified Type Desktop Lor E Libraries Arduino An
72. l toggle the FIFO read enable signal to push the first byte in the FIFO onto the block_out_byte The state machine will then cycle on to the FIFO_LO state In this state the state machine will wait for the Active Transfer Library to complete the transfer across the USB When the transfer 1s complete the block byte ready signal goes low and causes the state machine to go to the INCR COUNT state In this state the block out flag is checked for assertion If it is asserted the state machine goes to the FIFO HI state to wait for block byte ready to signal that the Active Block Endterm is ready for the next byte from the FIFO If the block out flag is not asserted in the INCR COUNT state then the block out counter is checked to determine if the count has surpassed the fifo out count If this statement is true state machine goes to the BLOCK SEND COMPLETE state When the block busy signal de asserts the state machine goes back into the IDLE state The data flow waits in a loop for the fifo full signal to assert again and start the process again 2 4 3 Ctt Window Functionality The C data flow on the PC starts with the initialization of variables controls events and read callback functions The Windows Form is displayed on the PC and the system registry is scanned for any Earth People Technology devices Any devices that are found are added to the drop down box The user must then select the available EPT device and click the Open control
73. lying power and opening the UnoProLogic use the button events to send commands to the Arduino to perform selected functions such as starting the display changing the Trigger polarity voltage reference etc Use the sliders to select new values for the Horizontal Time Base Time Scale Vertical scale etc The data flow for the Fast Oscilloscope consists of the Arduino Girino code the UnoProLogic code and the C Window code Page 10 ARDUINO GIRINO FUNCTIONALITY Mitiate Ports and Variaties POSTS GAC 10871 vALUL fact to toe of Loop END DS Srn Assert End Of Buffer Signal ZAI ATIHIP2EEOT2L E TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual UNOPROLOGIC FUNCTIONALITY C MEE BIAI nasa at tate ad Pam Oscilloscope Window On d Write Enable to Assert WRITE TO FIFO INCREMENT FIFO COUNTER M FIF FULL IS SET THEN 2 4 1 Arduino Functionality When the Arduino powers up it initializes the ports variables and registers Once the UnoProLogic has been started the On button will send the Start ADC command to the Arduion Girino code When the Start ADC command is received and decoded the Girino code calls the start ADCO and the start AnalogComparator OE WINDOW FUNCTIONALITY inthatine Variablet Control vecti fead Cabak Function TD Wait for Read Calfback Event EEAO ADC DATA BYTTS WTO Un PTS ind OF GUNES TOGOA VEL OSOLEOLCOPE GATA SCALE DATA N VERTI
74. n transmits that word to the CPLD using the Write_Enable Address and data pins The CPLD transmits each 10 bit word to the PC using the Active_Transfer EndTerm Active_Transfer Library and One Hot State Machine The dll reads the 10 bit word into local memory It then calls the Callback function EPTReadFunction Each 10 bit value is finally displayed to screen using the TransferOutReceive function 5 2 PC Compiling the Active Host Application Building the Fast Oscilloscope project will compile the code in the project and produce an executable file It will link all of the functions declared in the opening of the Fast Oscilloscope Class with the Active Host dll The project will also automatically link the FTD2XX dll to the object code To build the project go to Debug gt Build Solution Page 79 ZAI ATIHIP2EEOT2L EE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual EPT_Analog_Monitor Microsol al C 20 nose File Edit View Refactor Project Build Debug Data Tools Window Help GD Gd a A e Build Solution 6 Ga ET BR a fe zm Rebuild Solution fi btnTransferReset JA F 83 2e B1 3 a DS Publish EPT_Analog_Monitor WW Solution Explorer active transfer x64 cs sx Formi cs Des sign Properties SEFTA Tl A e ae Configuration Manager Ln lll Lane Tran mus RP a Ae 5d Solution EPT Analog Monito
75. nnected to the pin the function of the COM2A1 0 bits depends on the WGM22 0 bit setting Fast PWM Mode COM2A1 COM2A0 0 0 Normal port operation OC2A disconnected 0 1 WGM22 0 Normal Port Operation OCOA Disconnected WGM22 1 Toggle OC2A on Compare Match 1 0 Clear OC2A on Compare Match set OC2A at BOTTOM 1 1 Clear OC2A on Compare Match clear OC2A at BOTTOM Page 31 fb ARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual cbi TCCR2A COM2A I cbi TCCR2A COM2A0 sbi TCCR2A COM2B1 cbi TCCR2A COM2B0 Combined with the WGM22 bit found in the TCCR2B Register these bits control the counting sequence of the counter the source for maximum TOP counter value and what type of waveform generation to be used Modes of operation supported by the Timer Counter unit are Normal mode counter Clear Timer on Compare Match CTC mode two types of Pulse Width Modulation PWM modes Mode WGM22 WGM21 WGM20 Operation TOP 0 0 0 0 Normal OxFF 1 00 1 PWM OxFF 20 10 CTC OCRA 30 1 1 Fast PWM OxFF 4 1 0 0 Reserved 5 1 0 1 PWM OCRA 6 1 1 O Reserved 7 111 Fast PWM OCRA cbi TCCR2B WGM22 sbi TCCR2A WGM21 sbi TCCR2A WGM20 The FOC2A bit is only active when the WGM bits specify a non PWM mode However for ensuring compatibility with future devices this bit must be set to zero when TCCR2
76. o transparently receive data from the CPLD The user application does not need to schedule a read from the USB or call any blocking threads 1 4 Active Transfer Library EndTerms The Active Transfer Library is a portfolio of HDL modules that provides an easy to use yet powerful USB transfer mechanism The user HDL code communicates with EndTerms in the form of modules These EndTerm modules are commensurate with the Active Host EndTerms There are three types of EndTerms in the Active Transfer Library e Trigger Endterm e Transfer Endterm e Block Endterm They each have a simple interface that the user HDL code can use to send or receive data across the USB Writing to an EndTerm will cause the data to immediately arrive Page 6 EARTITRPEORPRPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual RIGGER ENDTERI NGLE TRANSFE ENDTERM VE TRANSFER LIBRARY LOCK ENDTERIV at the commensurate EndTerm in the Active Host user application The transfer through the USB is transparent User HDL code doesn t need to set up Endpoints or respond to Host initiated data requests The whole process is easy yet powerful 2 The Development Process The development of the Fast Oscilloscope starts with the Arduino The user will write the code to sample an Analog input using the ADC in 8 bit mode then assert the write enable which initiates the read cycle on the EPT
77. ode Analog Comparator External Interrupt Request 0 Timer CounterO Compare Match A Timer CounterO Overflow Timer Counter Compare Match B Timer Counter Overflow Timer Counterl Capture Event I was interested in the free running mode that is a mode in which the ADC continuously converts the input and throws an Interrupt at the end of each conversion associated vector ADC_vect ADC Control Registers ADMUX ADCSRA ADCSRB Temp Sensor hr a GND gt ADC Output 2 Bandgap Ref gt Registers s 84 tn AS p S A4 Aa E Ka E A3 P 8 i 1 z A2 H IL ELPTIT ADC Clock Fs Al gt ole gl ME Prescaler aie P a Sienai A 125kHz 250kHz 500kHz MH 2MHz 4MHz 8 bit bus Main Clock ATmega ADC Clock Frequency s 1 ADC9 ADC8 ADCH a a anor ncs anes anca avoa nc anc anco ADCL Bit 7 6 5 B 3 2 1 0 p u ADC9 ADC8 ano7 ance anes nca anca anca ADCH e Re E ano1 anco z m ADCL Bit 7 6 5 4 3 2 1 0 ADLAR effect on Output 3 10 Digital input buffers The analog input pins of the Arduino can also be used as digital I O pins therefore they have an input buffer for digital functions If we want to use them as analog pins Page 23 E EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual you should disable this feature Sending an an
78. of the User Manual Bring up Quartus II then use Windows Explorer to browse to c altera xxx quartus qdesigns create a new directory called EPT Fast Oscilloscope Page 47 EARTITRPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual File Edit View Project Assignments Processing Tools Window Help 6G Search altera com E DeHge exsm5mgoc I O a G a gt Pay se abo CH we tro HE Take an Compilation Hierarchy ied Online Training SS Class for Free Learn What s New Take Free Online Training Tasks eam ance OUA LUE MI Task Version 12 0 4 Compile Design gt Analysis amp Synthesis ww Buy Software b M Fitter Place amp Route I gt P Assembler Generate programming files t gt P TimeQuest Timing Analysis 4D Documentation X x Y lt lt Search gt gt Type Message el 3 k Location Under Quartus Select File gt New Project Wizard The Wizard will walk you through setting up files and directories for your project Page 48 ZAI ATIHIPEEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 44 Quartus II 32 bit File Edit View Project Assignments Processing Tools Window Help G2 Ci Save Project Close Project Download Ctrl s Ctrl Shift 5 Directory Name Top Level Entity page 1 of 5 What is the working directory for this projec
79. 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 ADTSO Trigger source 0 0 0 Free Running mode 0 0 1 Analog Comparator 0 1 0 External Interrupt Request O 0 1 1 Timer CounterO Compare Match A 1 0 0 Timer CounterO Overflow 1 O 1 Timer Counter Compare Match B 1 1 0 Timer Counterl Overflow 1 1 1 Timer Counterl Capture Event Cbi ADCSRB ADTS2 Cbi ADCSRB ADTSI Cbi ADCSRB ADTSO Page 26 TECHNOLOGY E EARTHPEOPLE Fast Arduino Oscilloscope Project User Manual 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 ADCS 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 DIDRO ADCSD sbi D
80. oon as possible 5 2 1 Adding the DLL s to the Project Locate the UNO_FAST OSCILLOSCOPE_PROJECT_CD installed on your PC Browse to the Projects_ActiveHost folder choose either the 32 bit or 64 bit version depending on whether your OS is 32 or 64 bit Open the Bin folder copy the following files e ActiveHostX X dll e ftd2xxXX dll Page 80 gt EARTHPEOPLE TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual and paste them in the EPT Fast Oscilloscope EPT_Fast Oscilloscope bin x64 Release folder of your EPT Fast Oscilloscope project IC Bl L Visual Studio 2010 Organize v 17 Open with Wi EPT Analog Monitor Documents library EPT Analog Monitor Riesen velease bin n Debug Name Date modified J Release ActiveHost 4 dll 5 4 2013 9 51 PM Jo 64 1 EPT Analog Monitor exe 5 26 20139 10 PM Application Ji Release EPT Analog Monitor 5 26 2013 9 10 PM bb obj 1 EPT Analog Monitor 6 1 2013 8 18 PM bb Properties jJ EPT Analog Monitor 8 31 20091240 AM MA bo EPT Transfer Test ftd2064 dll 1 18 20133 54PM A Ji EPT Transfer Test Ba 2 items selected State BR Shared Size 286 KB Shared with Homegroup wee Date modified 1 18 2013 3 54 PM 5 4 Date created 5 26 2013 4 58 PM At this point the environment has produced an executable file and 1s ready for testing Next we will connect everything together and see it collect data and display it
81. orer Click on the button to launch the Toolbox Page 72 ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual E File Edit View Project Debug Data Tools Window Help aau Fadl aala e a tooltip JA 5 2e eA PG iS amp alm ob ak 2 Sl i e S St aep al WW Solution Explorer dE Forml cs Forml Designer cs ES ie z gt All Windows Forms I J Solution EPT Transfer Test 1 project ud Active Host 4 c EPT Transfer Test j l Pointer b Em Properties gt ba References EE active transfer cs 4 amp Formi cs Formi Designer cs 3 Form1 resx Program cs Button CheckBox CheckedListBox ComboBox Jajojdxq aseqejeg DateTimePicker Label LinkLabel ListBox ListView MaskedT extBox MonthCalendar NotifyIcon NumericUpDown PictureBox S gt gt a ogame a Solution Explorer E ProgressBar D E Re fal BE ER E s Error List O okor 2 Warnings D 0 Messages Description Line Column Project rr Error List REM bnc Locate the button on the Toolbox grab and drag the button onto the Forml cs Design and drop it near the top Page 73 EARTIFTPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual roject Debug Data Format Tools Window Help 4 4a 0 D 9 tooltip Fe pe D i op at a l BEE ooe Se S St a et a isi mg Solution Explorer 4X Formi cs Form1 Designer cs Forml cs De
82. pServices using System Diagnostics b ba References Ea 51 cr 21 21 La m m om m mi E D ao m Enamespace EPT Analog Monitor ih public partial class EPT_Analog Monitor i public EPT Analog Monitor i InitializeComponent Eyl Solution Exp mM s In the Configuration Manager window locate the Active solution platform label select New from the drop down box Active solution platform Project Configuration EPT_Analog_Monitor Release In the New Solution Platform window click on the drop down box under Type or select the new platform and select x64 Page 64 ZAI ATIHIP2EEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Active solution configuration Active solution platform Reese Project contexts check the project configurations to build or deploy Project Data Collector Type or select the new platform Any CPU Itanium Create new project platforms Ganc Click the Ok button Verify that the Active Solution Platform and the Platform tab are both showing x64 Data_Collector Click Close Then using the Solution Explorer you can right click on the project select Properties and click on the Build tab on the right of the properties window Page 65 EARTITRPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual File Edit View Refactor
83. program the Arduino e Connect the USB cable from PC to Arduino Page 38 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual e Plug in your board and wait for Windows complete the driver installation process e Next click on Tools and select Serial Port then click the available port File Edit Sketch Tools Help Auto Format Archive Sketch Fix Encoding amp Reload Serial Monitor Ctrl Shift M Arduino Analo int AdcValu int UpperAdi Board said estes Serial Port DDRD Blll PORTD BL Burn Bootloader Programmer DDRB B00111111 Set Port B as outputs PORTB B00000000 Turn on Port B pins void loop delay 10 Delay 10 ms Read Analog Signal 0 Arduino Uno on COMB e To load the code click on the Upload button Page 39 TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual 5 Arduino Analog Monitor Code U2 Arduino 1 0 1 leh x File Edit Sketch Tools Help Arduino Analog Monitor Code l2 int AdcValue int UpperAdcValue void setup DDRD Bllllllll Set Port D PORTD amp Bllllllll Turn on Port DDRB B00111111 Set Port B as outputs PORTB B00000000 Turn on Port B pir void loop delay 10 Delay 10 ms When the code has completed loading the Arduino IDE will automatically command the processor to start executing the code The Arduino is now ready for the EPT
84. rogress 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 ADATB When this bit is written to one and the I bit in SREG 1s 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 ADPSO Division Factor Page 25 fb ARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 1 0002 1 0012 1 0104 0118 10016 10132 11064 1 11128 sbi ADCSRA ADPS2 sbi ADCSRA ADPS1 sbi ADCSRA ADPSO 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 AINI 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
85. s Ae Flow Summary gt MAX IE EPM570T100C5 EB Flow Summary Flow Status Successful Wed Mar 13 22 00 21 2013 b abd EPT_570_AP_U2_Top Flow Settings Quartus I 64 Bit Version 12 1 Build 243 01 31 2013 SP 1 SJ Web Edition Flow Non Default Global Settings Revision Name EPT_570_AP_U2_Top 55 Flow Elapsed Time Top level Entity Name EPT_570_AP_U2_Top E Flow OS Summary t Device EPM570T100C5 S Flow Log E gt 53 Analysis amp Synthesis Taning Models doen Fi y Total logic elements 557 570 98 95 NNNM Total pins 51 76 67 a V Total virtual pins 0 q 7 gt B _ Analyzer UFM blocks 0 1 0 Ab Herr ME Design Units aga gt Lg EDA Netlist Writer Tasks lgx Flow Compilation Customize Task v 4 i Compile Design v gt M Analysis amp Synthesis v gt M Fitter Place amp Route v gt B Assembler Generate programmin I d gt gt TimeQuest Timing Analysis v gt M EDA Netlist Writer wW Program Device Open Programmer lt r r IH OB Gey sam Y B q Type ID Message 2 N 332102 Design is not fully constrained for hold requirements b dp Quartus II 64 Bit TimeQuest Timing Analyzer was successful 0 errors 5 warnings Gp RRR RRR RRR RRR RRR RHR RRR RRR RRR RR RRR RRRRRRERRRRERERRRERRERRRRRRRREREE gt WD Running Quartus II 64 Bit EDA Netlist Writer Ww Command quartus eda read settings files off write settings files off EPT 570 AP U2 Top c EPT 570 AP U2 Top QD 204018 Generated
86. s a really good tutorial about PWM here http arduino cc en Tutorial SecretsOfArduinoPWM We will see just the points that are needed for this project In the ATMega328P there are three timers that can be used to generate PWM signals each one of those has different characteristics that you can use For each timer correspond two registers called Output Compare Registers A B OCRnx that are used to set the signal duty cycle As for the ADC there is a prescaler see image that slows down the main clock to have a precise control of the PWM frequency The slowed down clock is fed to a counter that increments a Timer Counter Register TCNTn This register 1s continuously compared to the OCRnx when they are equal a signal is sent to a Waveform Generator that generate a pulse on the output pin So the trick 1s setting the OCRnx register to some value to change the mean value of the signal If we want a 5 V signal maximum we must set a 100 duty cycle or a 255 in the OCRnx maximum for a 8 bit number while if we want a 0 5 V signal we must set a 10 duty cycle or a 25 in the OCRnx Since the clock has to fill the TCNTn register before starting from the beginning for a new pulse the output frequency of the PWM is f Main clock prescaler TCNTn maximum exempli gratia for the Timer 0 and 2 8 bit with no prescaler it will be 16 MHz 256 62 5 KHz while for Timer 1 16 bit it will be 16 MHz 65536 244 Hz Page 30 E B EART
87. sign X PRETIGO E 2 gt All Windows Forms 2d Solution EPT Transfer Test 1 project ve Hos f 1 4 E EPT Transfer Test Pointer E Properties Button ba References CheckBox c active transfer cs CheckedListBox 4 E Forml cs ComboBox Form1 Designer cs Formi resx ct Program cs FEY e aseqejyeqg DateTimePicker Label LinkLabel ListBox ListView MaskedTextBox MonthCalendar NotifyIcon NumericUpDown PictureBox EJ E E EI E D E Re kx BL ER E s ProgressBar c Solution Explorer KASSERET Error List O otom AN 2Wamings o 0 Messages Description Fi Line Column Project z F Error List REM bcnc Go to the Properties box and locate the Name cell Change the name to btnOpenDevice Locate the Text cell and change the name to Open Page 74 ZAI ATIHIP2EOT2L EE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual File Edit View Project Debug Data Format Tools Window Help Pdl d amp a tooltip J A 9 2e B eS Pali a alm 582 dE ope He n 2 t Et at EH 5 coda Se P i amp S OF ob l R al 3 GE one We we St Be es Er 2 cu 2 F Solution Explorer X Forml cs Form1 Designer cs Formi cs Design active transfer cs ES s rs Mm 7 gt All Windows Forms ZJ Solution EPT Transfer Test 1 project x 4 c EPT Transfer Test Pointer Sa Properties b3 References
88. signal reg lt 1 bO reset counter lt reset counter i bi end else begin reset signal reg lt 1 bl end end 4 6 Input Registers The section labled Register the Inputs applies the inputs from the Arduino to clocked registers This will eliminate any noise on these inputs from propagating through to the state machines of the CPLD 4 7 Start Stop and Write Enable detection Next we will add the transfer detection signal from the Arduino This block will sample the Write Enable signal and wait for it to go high xc ent far Start 5top Control ta be Asserted trom Analog Monitor Window PORTSR ED p i0 BITWALLUE j wa Wait for Write Enable to Assert ENDTERM ADDRESS WRITE ENABLE It is also used to provide start stop control for the CPLD code This block will use four registers to control the data and starting the state machine Page 44 EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual e transfer write reg This is a latch register to hold the state of the Write Enable e transfer write This register is used to start the state machine and initiate the multi byte write to the PC e transfer write data This is a 10 bit register to hold the value of the analog sample from the Arduino e transfer address 8 bit register to hold the EndTerm address from the Arduino The start stop cntrl signal is monitored every clock cycle If it is sampled high the output
89. t C altera 12 isp 1 quartus qdesigns EPT_Data_Collector je What is the name of this project BTSMAPU2T a What is the name of the top level design entity for this project This name is case sensitive and must exactly match the entity name in the design file EPT_570_AP_U2 Top 7 a Page 49 ZAIATIHI2EOIPLIE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual At the Top Level Entity page browse to the c altera xxx quartus qdesigns EPT_Fast Oscilloscope directory to store your project Type in a name for your project EPT 570 AP U2 Top Follow the steps up to Add Files At the Add Files box click on the Browse button and navigate to the project Fast Oscilloscope install folder in the dialog box Browse to the Projects_HDL EPT_ Fast Oscilloscope EPT_570_AP_U2_Top folder of the EPT USB CPLD Development System CD Copy the files from the src directory Active_transfer vqm e Active_trigger vqm e Active_transfer_library vqm e eptWireOr v e ETP_570_AP_U2_Top v Add the files settings EPT 570 AP U2 Te General Files Libraries Select the design files you want to include in the project Click Add All to add all design files in the project directory to the Operating Settings and Conditions Project Voltage Temperature File name Add on Pr PSY Ting Estate Fie Name Type Library Design Entry Incremental Compilation srcfeptWireOR v Verilog HDL File lt None gt Physical Synt
90. t gt Serial amp JTAG Cable B v Device Connected Monitor 1 Monitor 2 Monitor 3 Monitor 4 Monitor 5 Monitor 6 Gone sa Semi Facto 6 1 Testing the Project For this video we connect our UnoProLogic to a laboratory Function Generator to provide an analog signal to capture with the Fast Arduino Oscilloscope We use a 45 Volt DC supply to provide a trigger threshold level Starting the Oscilloscope is just a click on the application file in the Project CD folder Then select the EPT device in the drop down box Click on the Open button Click on Page 85 EAITHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual the Start button Then select the On Off button and the scope is displaying the analog signal Here the Function Generator is providing a sweep of sine waves from 10 Hz to 250 Hz Set the Function Generator to produce a 1KHz Sine wave with 4 5 Volt amplitude For the trigger voltage level input we use a lab supply Set this supply up to 3 Volt DC This will give us a dc threshold which the analog signal must cross in order for the scope to display the waveform 6 1 4 Oscilloscope Description The EPT Fast Arduino Oscilloscope has the same functions as a full featured scope These features include Trigger Settings Rising Falling and Toggle e Horizontal Time base selection Vertical Scaling Voltage Amplitude scaling Grab the slider and you can scale the voltage up or down e Time
91. te requires two parameters address and control register The address must correspond to the correct EndTerm in the EPT 570 AP code private void btnStart_Click object sender EventArgs e EPT AH SendTransferControlByte char 2 char 1 private void btnStop Click object sender EventArgs e EPT AH SendTransferControlByte char 2 char 8 I The button SetScaleFactor will call the ScaleFactorMenuOpenWindow This code is explained later It will set up textboxes buttons and labels at runtime for use in retreiving the scale factors for each analog channel private void btnSetScaleFactor Click object sender EventArgs e 1 H The buttons RstMonitorX X 1 to 6 are used to call the textbox clear method When this is envoked the text in the textbox will be cleared ScaleFactorMenuOpenWindow private void btnRstMonitor amp 6 Click object sender EventArgs e i tbMonitor amp Clear Page 77 ES EARTIHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 5 1 9 C Project EPTReadFunction Callback When EPTReadFunction callback is called and passed parameters from the Active C WINDOW FUNCTIONALITY Initialize Variables Controls Events Read Callback Function Select EPT 570 AP Device Open EPT 570 AP Device Send Start Control to EPT 570 AP Device ADDRESS SELECTION BYTE SELECTION READ UPPER BYTE FROM TRANSFER ENDTERM READ LOWER BYTE FROM TRANSFER ENDTERM UPDATE TEXTBOX WITH 10
92. this bit is written logic one the power to the Analog Comparator is switched off This bit can be set at any time to turn off the Analog Comparator This will reduce power consumption in Active and Idle mode When changing the ACD bit the Analog Comparator Interrupt must be disabled by clearing the ACIE bit in ACSR Otherwise an interrupt can occur when the bit is changed cbi ACSR ACD When this bit 1s set a fixed bandgap reference voltage replaces the positive input to the Analog Comparator When this bit is cleared AINO is applied to the positive input of the Analog Comparator When 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 1s set the Analog Comparator interrupt is activated When written logic zero the interrupt 1s disabled cbi ACSR ACIE When written logic one this bit enables the input capture function in Timer Counterl 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 Counterl Input Capture interr
93. tion Exp EZ Next unsafe code needs to be allowed so that C can be passed pointer values from the Active Host Locate the Allow unsafe code check box Check the box Page 66 B9 EARTHPEOPLE TECHNOL O G Y Fast Arduino Oscilloscope Project User Manual EPT Analog Monitor X EKD Ee Forml cs Design Application Configuration Active Release Y Platform Active x64 Y Build Build Events z Debes Conditional compilation symbols W Define DEBUG constant Resources V Define TRACE constant Settings 4 Allow unsafe code Reference Paths V Optimize code Signing Errors and warnings Security Warning level REED Suppress warnings 5 1 3 C Object Initialization Now we are ready to start coding Next we add two classes for our device One class stores the information useful for our device for Transmit to the EndTerms such as address of module length of transfer etc Create an array of the Transfer Class for device Transfer EPTTransmitDevice new Transfer 8 The next class is used to store parameters for receiving data from the device Create a Receive object of the Transfer Class Transfer EPTReceiveData new Transfer The first function called when the Windows Form loads up is the EPT Fast Oscilloscope Load This function is called automatically upon the completion of the Windows Form so there is no need to do anything to call it Once this function is c
94. to select the Voltage Reference AREF AVCC or Internal reference voltage So lets dial up the frequency and you can see the window display the resulting waveform I will slide the Horizontal Time Base over by one to scale into the signal the Time Scale slider and scale into the wave form to get more details on the signal This is just a scaling of the samples that are transmitted to the PC It just adds a delay time between each sample 6 1 3 Oscilloscope Performance Now I will dial the Function Generator up to a 3 KHz sine wave The Horizontal Time base slider has selected 650 microseconds per division Here we can see about five complete periods of the wave Grab the time scale slider and we can zoom into the 3 KHz wave Next I will set the Function Generator up for a sweep This will slowly increase the frequency from 100 Hz to 3 KHz You can see that changing the signal from the Function Generator immediately shows up on the EPT Fast Oscilloscope this shows the high performance of the Oscilloscope Next I will decrease the time scale so that we can see more cycles of the 3KHz wave Page 87 ES EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual Now I will set the Function Generator up to produce a pulse which repeats every second The pulse duration is 10 milliseconds Next I will change the pulse duration to 20 milliseconds Then 25 milliseconds This is just showing the performance of the scope and
95. upt When written logic zero no connection between the Analog Comparator and the input capture function exists To make the comparator trigger the Timer Counterl Input Capture interrupt the ICIEI 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 ACISO Mode Page 28 fb ARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual 0 0 Toggle 0 1 Reserved 1 O Falling edge 1 1 Rising edge sbi ACSR ACIS1 sbi ACSR ACISO 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 1s 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 AINOD j void init amp nalogComparator void i 3 14 Threshold Recalling what we said about the trigger we can implement these two solutions for the threshold using a trimmer we can manually set a voltage level using the PWM of the Arduino we can set the level by software On the image we can see the hardware implementation of the threshold in both paths For the manual selection a multi turn potentiometer put betw
96. urations check box Check the box on B TN eT b Environment Projects location f a Projects and Solutions c users nelsonstrfgr documents visual studio 2010 Projects m General f Build and Run e Cu m EP Tot bir c users nelsonstrfgr documents visual studio 2010 Templates ProjectTemp m gt Debugging User item templates location gt Database Tools c users nelsonstrfgr documents visual studio 2010 Templates ItemTemplat m gt Text Templating gt Windows Forms Designer Always show Error List if build finishes with errors ack Actis an Explorer Always show so Save new projects when created Warn user when the project location is not trusted E Show Output window when build starts Prompt for symbolic renaming when renaming files Go to Build gt Configuration Manager Page 63 ZAI ATIHIPEEOT2L E TECHNOLOGY Fast Arduino Oscilloscope Project User Manual lt EPT Analog Monitor Micros File Edit View Refactor Project Build Debug Data Tools Window Help Build Solution Rebuild Solution Solution Explorer Pesca Solution EPT Analog Monitor Eusing System a isl EPT_Analog_Monitor using System Collections Generic Ea Properties using System ComponentModel using System Data at active_transfer_xO4 cs ji ing BEIM Bras E using System Ling frames using System Text 3 Program cs using System Windows Forms E ScaleFactorMenu cs using System Threading using System Runtime Intero
97. using the Active Trigger EndTerm At this point the ScopeBuffer has a complete cycle of the analog signal to display in its window The Trigger 2 Active Trigger Endterm causes the invalidate function to be called This function will automatically cause the functions with a Graphics variable to be refreshed During the Refresh of the display data the vertical and horizontal scaling is performed Nexti Redrawing the graphics will cause the new values in the ScopeBuffer to be displayed in the Oscilloscope window Finally all data 1s displayed on screen The cycle repeats until the Stop button is pressed The button events will cause code to be executed when a button 1s pressed The Visual NET framework takes care of the background code which monitors the button events and any interrupts associated with executing this code 3 Arduino Girino Fast Oscilloscope Code The following is a reprint from the Girino Fast Arduino Oscilloscope by Caffeinomane 3 1 Girino Fast Arduino Oscilloscope I am a Physicist and the nicest part of working in this field 1s that I get to build my own instruments With this way of thinking I decided to build a homebrew Arduino Oscilloscope This instructable was written with the purpose of teaching a bit about microcontrollers and data acquisition Some time ago I was working on an Arduino project and I needed to see if the output signal was into compliance with the specifics Thus I spent some time on the int
98. 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 Page 21 fb ARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual n 2 Threshold E IA Signal J 1 E 4 4 Sweep Holdoff Sweep Holdoff Triggering a signal 3 9 Howthe ADC works The Arduino microcontroller features a single 10 bit successive approximation ADC Before the ADC there is an analog multiplexer that lets us send to the ADC the signals from different pins and sources but only one at a time Successive Approximation ADC means that the ADC takes 13 clock cycles to complete the conversion and 25 clock cycles for the first conversion There is a clock signal dedicated to the ADC that is computed from the main clock of the Arduino this is because the ADC is a little slow and can not keep up with the pace of the other parts of the microcontroller It requires an input clock frequency between 50 kHz and 200 kHz to get maximum resolution If a lower resolution than 10 bits 1s needed the input clock frequency to the ADC can be higher than 200 kHz to get a higher sample rate But how much higher rates can we use There are a couple of good guides about the ADC at
99. w Help 5 Ui Programmer C altera 12 1spl quartus adesigns EPT Transfer Test EPT 570 AP U2 Top EPT 570 AP U2 Top Chain2cdr bhale Search altera com 3 Hardware Setup _ Enable real time ISP to allow background programming for MAX II and MAX V devices File Device Checksum output files EPT 570 A EPM570T100 002CD72E CFM 3 Auto Detect UFM X Delete By Add File ar Change File Usercode FFFFFFFF Program Configure Verify Blank Check Examine Sd Ab Save File 29 Add Device fius pu Down When the programming is complete the Progress bar will indicate success Page 57 ES EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual y Programmer C altera 12 1sp1 quartus qdesigns EPT_Data_Collector EPT_570_AP_U2_Top EPT 570 AP U2 Top Chain3 cdf balba File Edit View Processing Tools Window Help 57 Search altera con kr proe T moe Enable real time ISP to allow background programming for MAX II and MAX V devices xh File Device Checksum Usercode Program Verify Blank Examine Sec i trt Configure Check E dila Stop output files EPT 570 A EPM570T100 00313A26 FFFFFFFF v E E CFM V A E T h Auto Detect yeu At this point the EPT 570 AP is programmed and ready for use 5 PC C Project Desi
100. x The buffer is implemented as circular employing the modulo operator ISR ADC vect When ADCL is read the ADC Data Register is not updated until ADCH 1s read Consequently if the result is left adjusted and no more than 8 bit precision 1s required it 1s sufficient to read ADCH Otherwise ADCL must be read first then ADCH ADCBuffer A DCCounter ADCH ADCCounter ADCCounter 1 ADCBUFFERSIZE if wait if stopIndex ADCCounter Freeze situation Disable ADC and stop Free Running Conversion Mode cbi ADCSRA ADEN freeze true The Analog Comparator Interrupt Service Routine that is called when a signal passes the threshold disables itself and tells the ADC ISR to start the waiting phase and sets the stopIndex http www instructables com id Girino Fast Arduino Oscilloscope Analog Comparator interrupt Page 34 SA EARTHPEOPLE TECHNOLOGY Fast Arduino Oscilloscope Project User Manual ISR ANALOG_COMP_vect Disable Analog Comparator interrupt cbi ACSR ACIE Turn on errorPin digitalWrite errorPin HIGH sbi PORTB PORTBS wait true stopIndex ADCCounter waitDuration ADCBUFFERSIZE j This was really easy after all that grounding ADCCounter ADCCounter 1 ADCBUFFERSIZE cbiC ADCSRA ADEN 5 stopIndex ADCCounter waitDuration ADCBUFFERSIZE 3 19 Building Arduino Project Build

Download Pdf Manuals

image

Related Search

Related Contents

Philips Inca 311 Security Camera User Manual  Philips CD1811B  ! AVERTISSEMENT - Napoleon Products  Westinghouse One-Light Outdoor Pendant 6750900 Instruction Manual  1. 北里大学メディカルセンターにおける タブレット端末の活用と導入  installation instructions  EcoPro G2 Cabinets - Foster web spares  User Manual  User manual - Appliances Online  

Copyright © All rights reserved.
Failed to retrieve file