Sensor Calibration with Lookup Tables

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Listen to an AI-generated conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

In the context of microcontrollers, what is the primary advantage of using lookup tables for sensor calibration?

  • They allow for correcting non-ideal sensor behavior through software without requiring hardware adjustments. (correct)
  • They reduce the overall program memory footprint compared to other calibration methods.
  • They eliminate the need for any hardware tuning of sensor gain and offset.
  • They increase the speed of sensor data acquisition by directly interfacing with the sensor hardware.

Computed GOTO lookup tables store lookup values in data memory.

False (B)

What is the main disadvantage of using computed GOTO tables for lookup operations in microcontrollers?

Increased memory usage

When implementing table reads and writes in PIC18F45K22, accessing each byte individually is possible because the program memory is implemented as ______ registers.

<p>8-bit</p>
Signup and view all the answers

Match the components with their function in the context of table reads:

<p>Table Pointer (TBLPTR) = Specifies the address of the memory location to be accessed within the program memory. TABLAT Register = Temporarily stores the byte read from the program memory. TBLRD* Instruction = Used to transfer the content of the specific program memory register into the TABLAT register.</p>
Signup and view all the answers

What is the consequence of omitting the ADDWF PCL instruction in a computed GOTO subroutine?

<p>The subroutine will always return from the first <code>RETLW</code> instruction. (B)</p>
Signup and view all the answers

It is possible to write one byte at a time into the program memory within PIC18F45K22.

<p>False (B)</p>
Signup and view all the answers

What is the purpose of the db directive in MPASM when creating data tables?

<p>Declare Data of one Byte</p>
Signup and view all the answers

In the context of lookup tables and calibration, if a sensor circuit's value can saturate, a direct offset of 0.5V should not be applied because it will cause an ______value for white.

<p>incorrect</p>
Signup and view all the answers

Associate the following components of seven-segment display code with their functions

<p><code>movlw 0x06</code> = Specifies the number of bytes that the program counter should advance and should be multiples of 2 (LBS = 0)., loads the offset value W register <code>call DataTable</code> = Is the special subroutine which calls data tables. <code>DataTable:</code> = Is the subroutine label which is a <code>add W value to PCL</code></p>
Signup and view all the answers

Consider the code snippet:

ADDWF PCL
RETLW 0x00
RETLW 0x0A
RETLW 0x0F

If the W register contains the value 0x02 before this code is executed, from which line will the subroutine return?

<p><code>RETLW 0x0A</code> (C)</p>
Signup and view all the answers

Lookup tables always require limit testing to ensure the accuracy of values.

<p>True (A)</p>
Signup and view all the answers

In the context of PIC microcontrollers, what does PCL stand for, and how is it manipulated in computed GOTO tables?

<p>Program Counter Low Byte</p>
Signup and view all the answers

Before calling a data table subroutine, if you want the program to go to the third RETLW instruction, the W register has to be loaded with a value equal to ______.

<p>four</p>
Signup and view all the answers

Match the following concepts related to tables with their description:

<p>Program Memory = Memory section often containing computed GOTO tables, and memory used by TABLE READ operations Data Memory = A place where the lookup table gets destroyed when micro controller is reset, Indirect Addressing = Method of dynamically changing addresses to data memory locations.</p>
Signup and view all the answers

Regarding the retrieval of data using TABLAT register, what must occur before the register can supply the correct memory location?

<p>It must be loaded with the memory location address into the TBLPTR register. (C)</p>
Signup and view all the answers

Macros can't receive variables during implementation.

<p>False (B)</p>
Signup and view all the answers

In assembly language terminology, what is the role of the include file regarding macros?

<p>Storing macros</p>
Signup and view all the answers

A macro is a sequence of instructions grouped as a unit, which enables it to be embedded into firmware through a one-liner referred to as program ______.

<p>statement</p>
Signup and view all the answers

Match the element in assembly with the advantage it offers during implementation:

<p>Table usage = Allows for the storage/reference of necessary data( parameters) during code. Macro Usage = Permits faster coding, less time spent. Modular Programming = Facilitates the easier writing of macros and other code.</p>
Signup and view all the answers

Flashcards

Lookup Table

List of data bytes stored sequentially in program or data memory, used for sensor calibration or other data retrieval.

Computed GOTO lookup

Computed GOTO tables store lookup values as part of CPU instructions, useful for directing program flow based on inputs.

Table Reads/Writes

Allows individual byte access in program memory, storing two bytes per program word.

Data Memory Lookup Tables

Lookup table stored in data memory, which is erased upon reset, suitable for calibration but requires re-initialization each time.

Signup and view all the flashcards

Macro

A named block of code to reduce redundancy.

Signup and view all the flashcards

Study Notes

  • Lookup tables are lists of data bytes stored sequentially in program ROM or RAM, often used to store calibration data for sensors in order to compensate for non-ideal sensor behavior
  • Calibration can be done in hardware or software, tuning the gain and offset for each sensor or calibrating via a lookup table to correct the output value

Hypothetical Sensor Calibration

  • Sensor 2's output is offset by 0.5 V from Sensor 1, and Sensor 3's output is 1.2 times Sensor 1's output
  • Lookup tables can calibrate the outputs of Sensors 2 and 3 relative to Sensor 1
  • Option 1 for calibrating Sensor 2 involves a subtraction after the offset is looked up, while Option 2 saves the "correct" values directly in the lookup table, saving a subtraction

Considerations for Lookup Tables

  • Complex relationships between input and output values can be handled with lookup tables
  • Limit testing may be required to apply a lookup value for ranges of input values
  • In Computed GOTO lookup tables, the lookup values are stored in program memory
  • Implemented as a normal subroutine that is called when a value needs to be looked up
  • First instruction manipulates the program counter
  • Subroutine has multiple lines from which it can return using the RETurn with Literal in W (RETLW) instruction

Computed GOTO Characteristics:

  • Values of the table are successively included in the instructions
  • With the ADDWF instruction omitted, the subroutine will always return from the first RETLW instruction
  • With the WREG pre-loaded with a value, this pre-loaded value is added to the PCL, and the subroutine will return from the instruction at the altered address
  • The PCL needs to be offset in even numbers to avoid a word alignment

Computed GOTO Lookup Disadvantage

  • Computation is easy to use but each data byte takes up two bytes of program memory because the data has to be coded as part of an instruction

Table Reads and Writes:

  • The program memory is implemented as 8-bit registers, so table reads and writes allow access to each byte individually
  • Two bytes can be stored per program word

Implementing Dense Data Tables:

  • Refer to Section 5.2.2.2 Table Reads and Table Writes, and Section 6.1 Table Reads and Table Writes in the PIC18F45K22 datasheet
  • The table pointer is loaded with the address of the memory location to be accessed.
  • Special instruction places the content of a specific program memory register into the TABLAT register
  • Lookup tables can be stored in data memory, but will be destroyed upon reset
  • Calibration lookup tables can be stored in data memory

Indirect Addressing:

  • Achieves dynamic changing of addresses to data memory locations
  • Allows implementation of pointers in Assembly Language

NIBBLE Table Basics

  • Understanding of the different ways in which data tables can be implemented in a µC including the assembly language coding of data tables

Code Example 16: Computed GOTO

  • The values are coded into a number of RET(urn) with Literal in) W (register), i.e. RETLW, instructions
  • Offset value (in WREG) specifies the number of bytes that the program counter should advance
  • It should be multiples of 2 (LSB = 0)

Code Example 17:

  • Demonstrates implementation of a table where the bytes are stored successively in program memory
  • Only data are stored without needing to store it as part of an instruction
  • The "db" directive in MPASM stands for "declare data of one byte".
  • Used to reserve space in memory to be intialised with bytes
  • label db value1, value2, .... valueN

Code Example 17b: Table Writes

  • It's not possible to write one byte at a time on the PIC18F45K22
  • The hardware allows writing a block of 64 bytes at a time to the program memory
  • One would need two write operations if more than 64 bytes needs writing to memory -- first writes 64 bytes -- second writes the remaining bytes

Macros: code Example 19

  • Reduces the repetitiveness of coding
  • Macro will be coded only once that will be copied as needed
  • Can customize certain requirements
  • Sequence of instructions/statements will be coded ONE time within the macro definition
  • It supports modular programming in assembly language
  • Has an include file
  • The invoked macros code can be physically inserted into the program code to verify it.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Master Table Lookup Acceleration
3 questions
Excel Lookup Formulas and Functions Quiz
3 questions
Mastering Lookup Tables
3 questions

Mastering Lookup Tables

ExuberantMossAgate avatar
ExuberantMossAgate
Use Quizgecko on...
Browser
Browser