Microprocessor Techniques Project [SUBMISSION]
DIGITAL STORAGE OSCILLOSCOPE USING A TIVA C SERIES LAUNCHPAD
Tiva C Series LaunchPad (TM4C123G) is an in-expensive single-board microcontroller evaluation platform for the ARM Cortex-M4F created by the company Texas Instruments. This project will be using Texas Instruments Tiva C Series microcontroller in creating a Digital Storage Oscilloscope (DSO); DSO is an electronic test instrument that allows to observe signal voltages, it is analysing the input signals digitally instead of analogue displaying the results in graphic form utilising an x-y co-ordinate system approach to data distribution.
The aim of this project is to create a digital oscilloscope using the Tiva C Series LaunchPad programmed specifically with embedded C-Language within a time-frame of 25th August 2017 to 21st September 2017. The digital oscilloscope will be displayed in graphical form in the terminal using special ANSI escape characters, as well as the parameters will be controlled via the terminal using certain keyboard buttons corresponding with actions such as:
A graphical representation will be displayed on the computer using the terminal which will be where these actions can be implemented. The short-term goal is a minimum graphical design of the graph that will be displayed, where-as a long-term goal would be a deeper design of the graph and friendlier visual in terms of analysing the data presented as well as incorporation of a physical design such as a user-friendly enclosure.
The project's greatest challenge is the setup of the ADC to receive data from the pin and relating the readings over a period into graphical representation using ANSI within the terminal, the more user friendly and better design requires more in-depth knowledge to code a better interface to interact with the user, the physical designing of the connection that will attach voltage signal to wires that will connect the to the observing pin will be minimal first and later if time allows will create a better design to incorporate user friendly interaction.
Tiva C Series LaunchPad (TM4C123G) Evaluation Board
Image reference “Tiva C Series TM4C123G LaunchPad Evaluation Board – User’s Guide by Texas Instrument, 2013”.
Tiva TM4C123GH6PMI microcontroller – 32-bit ARM Cortex M4-based microcontroller
256 kB Flash memory, 32 kB SRAM, and 80MHz operation
16 MHz crystal – microcontroller main internal clock
External 32.768 kHz crystal – for hibernation module
Internal PLL – for frequencies up to 80 MHz
USB 2.0 device interface with micro-USB connector
2 programmable user switches/buttons
I/O available via headers
On-board Tiva In-Circuit Debug Interface (ICDI)
Switch-selectable power sources (USB, ICDI)
Use of ARM Thumb-compatible Thumb-2 instruction set
Features of the board represented by the different subsystems that exist.
Image reference: “Embedded systems: Introduction to the ARM Cortex™-M microcontrollers, Volume 1 by Jonathan Valvano, 2012”.
The subsystems that will be used in the project of creating a DSO will be:
UART0 activated on pins A [0, 1]
ADC0 activated on pin E [3]
UART stands for Universal Asynchronous Receiver-Transmitter, the subsystem will be used for serial communication between the board and the computer through a terminal, transmitting and receiving data – this project will be using UART0 which uses General Purpose Input-Output (GPIO) Port A, Pin 0 & Pin 1.
ADC stands for Analogue-Digital Converter, the subsystem that uses an electronic process to receive varying signal in voltage (analogue) and converts the signal to a digital level. The digital levels are determined by how many bits the analogue signal will be digested into, such as if the signal is being digested by 12-bit than the digital level will be between the limits of 0 to 4095, where 4095 would reflect 3.3 Volts (V) because the limits of the Tiva is between its lowest voltage of Ground (GND)\0 V and Supply voltage (Vcc) \ 3.3 V analogue signals that move below or above the limited voltages will be truncated to fit within the boards limitation. The project will be using ADC0 which uses GPIO Port E, Pin 3.
General Purpose Timers (TIMER) is a subsystem of programmable timers that are connected to GPIO pins, it will count down and trigger the ADC once zero is reached, this will relate to a frequency as which the ADC is being triggered. The project will be using TIMER0 which will be activated on the ADC Pin and will connect to the ADC triggering.
Two set ups were used as the items used in the laboratory could not be replicated exactly outside the lab when the project was worked on during non-laboratory allocated time. The list of hardware during these times are:
The general equipment will be used in laboratory and non-laboratory testing.
Tiva C Series TM4C123G LaunchPad
Female to Male or Male to Male pins
The laboratory equipment will be used only in the laboratory – an older model Oscilloscope (DSO/CRO) which does not have a wave generator will need a function generator where-as later models will have this feature.
Digital Storage Oscilloscope
The non-laboratory equipment will be used to test the project outside of laboratory allocated time.
Potentiometer (Varying resistor)
The most complex parts of this experiment are the setting up of the UART and ADC with TIMER along with each subsystem’s subtasks and manipulating the data received from the ADC’s Analogue Input Pin to feed into specific functions such as creating the DSO graph as well as signal information that can be accessed before the calling of the graph output. Main algorithms:
Signal information via user interface
Main blocks & sub-tasks & off-tasks
Subsystems that are not being manipulated by the prepared functions by TivaWare will needed to be accessed via direct register set-up using embedded C, even though Assembly (ASM) direct register set-up takes more lines of code, both can yield errors when via destructive masks or not turning the right bits within the register, within the main block of setting up the registers, off-tasks that utilise the set-up will be included though they are not subtasks but are needed tasks that rely on a perfect set-up.
The manipulating of ADC data received will be given to the DSO output graph after it has been manipulated to fit within the graph size, the data received from the ADC will also be manipulated and fed to the user interface that will allow the user to see information before moving onto the output graph.
GPIO initialisation for UART
Printing strings via UART transmitting of characters
GPIO initialisation for ADC
TIMER initialisation for ADC
Frequency changes to TIMER via preload change
Transmitting of data via ADC
Pre-defined set-up for graph using key and actions
Manipulating data to export values
Manipulating data to represent values
Simplified & complex project design
The simplified design in the project is to create a user interface that allows the person to implement predefined actions before the screen refreshes to two different graphing outputs, one being a single measurement and the other being a repeating measurement for 5 seconds. The physical aspect of the project will be within the style of just pins (female to male or male to male) connected to the Tiva board either directly to the CRO/DSO/Wave generator or via a variable resistor using a breadboard.
The complex design in the project is to create a user interface that sits off-side to the graph, the main feature of the project is an already set graph and at the bottom people can control the features along with continuous fresh readings of the instantaneous voltage and minimum and maximum voltages, with more ability for higher sampling rates, the graph will run at a single measurement or a repeating measurement however adjustments can be made within the same window meaning that at no point will the window refresh but only the values themselves in real time. The physical aspect of the project will be for a more complex design is an enclosure that the Tiva will sit in an enclosure with either a breadboard or pins sticking out of the enclosure to be attached onto it, with enough time also a short instructional pictogram to show how to effectively use it.
Block diagram of system structure
Block diagram representing the system and its connections between the ‘moving’ parts.
Circuit diagram showing Tiva Board’s connection via ADC Ain0 with testing connections to a variable resistor and signal generator.
The system clock is enabled for ADC0, Port E and TIMER0 – legacy registers were used for ADC and TIMER, delays were used afterwards to force the board to wait and stabilised.
GPIO set-up for Port E clearing all digital settings and input settings to enable alternative select and analogue mode.
ADC0 – Sequencer 3 (SS3) is disabled and priority of SS3 is made highest while priority of SS0 is made low.
The TIMER0A is disabled to be configured for a periodic triggering to the ADC that has a prescaler of 255 with an arbtriary value of 255 within the preload which will be changed when the program starts, match value is zero for no use of duty cycle.
SS3 is set to timer trigger as well as sampling control bits through source Ain0 then both TIMER0A and SS3 are enabled to be used.
UART0 is disabled so transmitting and receiving data can be set and specified parameters for baud rate, word length, parity, stop bit are set as well.
GPIO for UART0 is set with alternative select enabled, digital enabled and the port control numbers to specific the alternative function (U0Rx, U0Tx – UART0) with enabling UART.
Algorithm of the main code processes the actions via user input, the key and actions are explained in the introduction of the report.
Action algorithm that results in the user choosing specified actions before outputting the actions to the construction of the graph.
Smaller algorithms from the action algorithm revealing how some of the processing works.
The testing of correct operation of subsystems were a step-by-step activation via the debugger built within Keil and ultimately via the UART testing that the terminal linking to the UART’s specified baud rate, word length, parity, stop bit and flow control (921600, 8-bit, odd parity, 2-bit stop, no flow control) and receiving and transmitting characters via an echo loop.
The ADC set-up was activated slowly by first through activating just the ADC0 and then testing the debug, then GPIO and then finally TIMER, once the debug showed that the set-up was not being caught in a loop, data retrieval was testing using a potentiometer via Port E Pin 3, ADC data was printed straight to screen unprocessed showing indeed that the step values was from 0 to 4095.
Each function within the program was tested via known variables and hardcoding static values that would be used in the program, the results needed were displayed straight to screen.
Upon successfully connecting your Tiva C Series “DSO” LaunchPad to the computer and ensured that component that will be tested is attached to the appropriate pins via the circuit diagram, open Tera Term and begin to set-up the serial port to the specifications below:
Tera Term specifications.
When the specifications is correct you will be given an input list of keyboard buttons and the actions that will occur; below is the list of buttons to press as well as the outputs you will be expected to see, leading up to the predefine values for the graph output and the two different types of graph output that the user can choose from – single measurement or measurement over 5 seconds.
Single measurement graph output.
5 second measurement graph output.
The project in which a Tiva C series TM4C123G LaunchPad Evaluation Board is used to create a Digital Storage Oscilloscope (DSO) is successful with resulting in a plotting of the signal that is being set once the user has set parameters within the user interface that is separated from both graph outputs while using a simple physical project design of using pins directly connecting to the Tiva board to the CRO/DSO via allotted laboratory time while outside the laboratory the simple connection was via a breadboard and a variable resistors.
Due to the project being within a time-frame, not enough time could have been utilised to create an enclosure for the Tiva board, the code for the complex project was not managed to be implemented however the user interface of the graph was recreated to provide better visual representation than the simplified white.
Problems have occurred during the creation of the project which will be explained in the discussion section of this report however although most problems have been solved or altered; a major on-going problem which due to the time-sensitive nature of this project, the ADC happens to halve all input values through the Ain0 pin which will also be discussed.
The problems that have occurred during the project is within the initialisation of the ADC, during the debug testing it would move through the ADC without a problem however the input pin’s ADC data value was pulling zero values to the screen, upon inspection of the registers and content it was revealed that the preload register was set to a value that was outside the parameter causing the register to wrap around in value to zero thus ADC not triggering at all.
Embedded C has functions that don’t work or are left as a skeleton that needs to be filled in, one such example is the ‘printf()’ function that exists within the ‘stdio.h’ header that is left as a skeleton ready to be filled in with self-created functions that are known as ‘fgets()’, ‘fgetc()’ and ‘ferror()’. These functions that need to be created in order for ‘printf()’ to work however even with the self-created functions the function still did not work thus using a ‘out_char’ function that outputs a character via UART data register is used in a for loop until length of the string is reached, the starting memory address of the string is given to the print string function using a pointer to the start of the string wanted to be printed.
Due to the time-frame and the set back with the direct register set-up taking longer than expected the complex project milestones could not be implemented such as the single page graph with user commands and dynamic values that would be constantly updated upon user selection or while the graph was in use with either single measurement or set time.
A major on-going issue is that the ADC is halving the input numbers being read by the pin, the registers are been looked through and the generator signal was tested by the Tiva board and by the CRO in which was generated by the CRO so evaluated possible problems, the registers although have been looked through intensely via the datasheet available for the TM4C123G – the only solutions thus far is debugging and ultimately re-writing the functions that create the graph as well as re-evaluating the direct register set-up or re-building the project from the ground up using the previous code as a frame-network possibly re-creating more efficient ways of handling the task.
Although the project is completed and complex project model has not been implemented, with the exception of the ADC halving values being sent to the pin and not allowing the solution of hard-coding the project does indeed project a input signal at different frequencies via the user input as predefined values before analysing the signal through a display of the graph output, room for improvement of the project overall as how it could work and how it could look could have been implemented given more time of excess of a week however the dates were already set with no flexibility.
Texas Instruments, 2013, Tiva C Series TM4C123G Evaluation Board – User’s Guide, Texas Instruments Incorporated, Dallas, Texas 75265. Literature Number: SPMU296
David Rowlands, 2017, 1B) Introduction to uCs - 2303ENG Lecture Notes, Griffith School of Engineering, Griffith University.
David Rowlands, 2017, 6B) General Purpose Timers - 2303ENG Lecture Notes, Griffith School of Engineering, Griffith University.
David Rowlands, 2017, Analog Signals - 2303ENG Lecture Notes, Griffith School of Engineering, Griffith University.
Github link to the C source file
These links are not the C source file however they are needed for the project.
Github link to the Startup.s file
Github link to the uVision project file
Github link to the register Header file
Github link to the UART C & Header file
Github link to the ADC C & Header file
Github link to the Functions C & Header file
Github link to the Graphc C & Header file