| Electronic Components Datasheet Search |
|
MPXM2102AS Datasheet(PDF) 545 Page - Motorola, Inc |
|
|
|||||||||||||||||||||||||||||
MPXM2102AS Datasheet(HTML) 545 Page - Motorola, Inc |
|
545 / 670 page ![]() AN1950 3–399 Motorola Sensor Device Data www.motorola.com/semiconductors Software Function Descriptions Main Function The main function calls an initialization function “ALLINIT”, calls a warm–up function “WARMUP” to allow extra time for the lcd to initialize, then checks if buttons PB1 and PB2 are being pressed. If they are both pressed, then it calls a calibration function “CALIB”. If they are not both pressed, then it enters the main function loop. The main loop displays the menu, moves the cursor when the PB1 is pressed and enters the function corresponding to the highlighted menu option when PB2 is pressed. Calibration Function The calibration function is used to obtain two calibration points. The first calibration point is taken when the head tube is not placed in water to obtain the pressure for 0mm of water. The second calibration point is obtained when the head tube is placed at the bottom of a container with a height of 160mm. When the calibration function starts, a message appears displaying the A/D values for the corresponding calibration points currently stored in the flash. To program new calibration points, the user must press PB1 to take 256 A/D readings at 0mm of water. The average is calculated and stored in a page of flash. Then the user has the option to press PB1 to exit the calibration function or obtain the second calibration point. To obtain the second calibration point, the head tube should be placed in 160mm of water and then the user should press PB2 to take 256 A/D readings. The average is taken and stored in a page of flash. Once the two readings have been taken, averaged, and stored in the flash, a message displays the two A/D values that were stored. Level Function The Level function will initialize the graphics characters. Once this is complete, it will continue looping to obtain an average A/D reading and display the Water Level, the Water Flow, and a Graphical History until the user presses and holds both PB1 and PB2 to return to the main function. The function first clears the 40 pressure readings that it will be updating for the Graphical History. It then enters the loop which first displays 8 special characters, each containing 5 data points of water level history. The function “adcbyta” is called to obtain the current averaged A/D value. The function “LfNx” is called to convert the A/D value to a water level, which is then compared to the Calibration points, the maximum and minimum points, to determine if the container is full or empty. If true, then it displays the corresponding message. The current water level is compared to the previous read and displays the message “filling” if it has increased, “emptying” if it has decreased, and “steady” if it has not changed. The water level calculation has to be converted to decimal in order to display it in the LCD. To convert the water level calculation to decimal, the value is continually divided with the remainder displayed to the screen for each decimal place. To display the Rate of Water Flow, the sign of the value is first determined. If the value is negative, the one’s complement is taken, a negative sign is displayed, and then the value is continually divided to display each decimal place. If the number is positive, a plus sign is displayed to maintain the display alignment and the value is continually divided to display each decimal place. The most complicated part of this function is updating the graphics history display. The characters for the 16x2 LCD that were chosen for this reference design are 8x5 pixels by default. Therefore, each special character that is created will be able to display 5 water level readings. Since the height of the special character is 8 pixel, each vertical pixel position will represent a water level in increments of 20mm. Resolution = (H1 – H0) / D where H1 and H2 are the maximum and minimum water levels respectively and D is the possible datapoints available per character. Resolution = (160mm – 0mm) / 8 = 20mm / data point. The graphical history is displayed using the 8 special characters. To update the graphics, all the characters have to be updated. The characters are updated by first positioning a pixel for the most recent water level reading in the first column of the first character. Then the four right columns of the first character are shifted to the right. The pixel in the last column of that character is then carried to the first column of the next character. This column shifting is continued until all 40 data points have been updated in the 8 special characters. LfNx Function The LfNx function calculates the water level from the current A/D pressure reading. The A/D Pressure value is stored in Register A before this function is called. Using the A/D value and the calibration values stored in the flash, the water level is calculated from the following function: RBRA: = (NX – N1) * 160 / (N2 – N1), where NX is the current A/D Value N1 is the A/D Value at 0mm H20 N2 is the A/D Value at 160mm H20 To simplify the calculation, the multiplication is done first. Then the function “NdivD” is called to divide the values. NdivD Function The “NdivD” function performs a division by counting successive subtractions of the denominator from the numerator to determine the quotient. The denominator is subtracted from the numerator until the result is zero. If there is an overflow, the remainder from the last subtraction is the remainder of the division. wrflash and ersflsh Functions The “wrflash” and “ersflsh” functions are used to write to and erase values from the flash. For more information regarding flash functionality, refer to Section 4. Flash Memory from the MC68HC908QY4/D Databook. Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |