<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://hades.mech.northwestern.edu//api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MaxWiller</id>
	<title>Mech - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://hades.mech.northwestern.edu//api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MaxWiller"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php/Special:Contributions/MaxWiller"/>
	<updated>2026-05-26T02:38:43Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17228</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17228"/>
		<updated>2010-03-17T04:47:28Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board: [[Introduction to the PIC32]] &lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
[[Image:circuit_diagram.png]]&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
&lt;br /&gt;
===Summary of Parts===&lt;br /&gt;
&lt;br /&gt;
*Electrical&lt;br /&gt;
&lt;br /&gt;
The electric circuit was fully functional at the end of construction, with each solenoid responding to a high or low signal coming from where the PIC output would enter the NAND chip. If a 3.3 V signal came from the PIC output, 12 V would go across the solenoid. If a 0 V signal came from the PIC, a -12 V signal would go across the solenoid.&lt;br /&gt;
&lt;br /&gt;
*Mechanical&lt;br /&gt;
&lt;br /&gt;
The mechanical setup was also fully functional at the end of construction. Each solenoid fit snugly into their insert with the leads coming out in a shrink-wrapped conduit. The polycarbonate container was bent and sealed with epoxy and there was a wooden base so that the electronics would be housed conveniently under everything.&lt;br /&gt;
&lt;br /&gt;
*Coding&lt;br /&gt;
&lt;br /&gt;
The attempted Fast Fourier Transform coding was working by the end of construction, lighting up LED lights when certain frequencies were active. Our idea for the music response mode was to have the FFT recognize the melody and output the musical note to the corresponding solenoid on the outside diameter of the hexagon. The middle solenoids would be activating at random.&lt;br /&gt;
&lt;br /&gt;
The user interface was also working. The Processing application&#039;s solenoid control buttons were functional and sent data over the RS232 cable to the PIC. The final idea was to have it as a user option whether to go into music response mode or manually control the solenoids.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Combining the Parts===&lt;br /&gt;
&lt;br /&gt;
*Combining Electrical with Mechanical&lt;br /&gt;
&lt;br /&gt;
While all of the solenoids fit snugly into their inserts, we found that the magnets were interfering with each other from their positions. We had all of the cylindrical magnets facing the same polarity (all of the north ends of the magnets faced up). Because of this arrangement, the magnets felt a repulsive force from the other magnets. We found we were able to push the solenoids up (boosted by the magnetic force from the other magnets) but we were unable to bring them down due to the extra force overcoming the force from the solenoid&#039;s pull. Since we had tested the forces on the solenoids separately, we did not think to check the forces on them when in the arrangement, but it made for a project that was only half functional.&lt;br /&gt;
&lt;br /&gt;
In addition, we attempted to help overcome the extra force in two ways. First, by increasing the padding space between the bottom of the ferrofluid container and the magnets. This way the solenoid would be more in its most efficient spot, and the magnetic force from the ferrofluid would be less. Second, we removed one of the magnets from each solenoid arrangement (only one magnet instead of two) to try and lessen the magnetic forces between the magnets. Not only did this not work, but it made it so that the magnets then had little effect on the ferrofluid (slight bumps instead of spiky designs).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Combining Electrical with Coding&lt;br /&gt;
&lt;br /&gt;
Had we been able to take more time with this interface, the problems would have been easy fixes. As it was though, the wires of the solenoids coming down from the hardware enclosure got mixed up when getting connected to the H-bridge outputs. This made it so the NAND inputs did not match up with the PIC outputs they should have. &lt;br /&gt;
&lt;br /&gt;
Another small problem we had was that the solenoids enabled time was too low. Since each solenoid takes around .2 A at 12 V, it would take a lot of power to power all 19 solenoids at once. So we used an enable pin to enable and disable all the H-Bridges at once. This way, we could use only one pin for each solenoid, and the power wouldn&#039;t be on at all times, only when solenoids needed to change positions. Since the time we had the enable pin set to high was too short, the solenoids didn&#039;t have enough time to push up the magnets. This was a programmed constant and could have been optimized with more testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Combining the Coding with the User Interface&lt;br /&gt;
&lt;br /&gt;
While the FFT code worked in concept, in reality it took too long to compute the main frequencies of a song that was playing. Without some sort of buffer or faster code, the melody might be recognized, just too late.&lt;br /&gt;
&lt;br /&gt;
The User Interface worked on the PC through a Processing program and indicated what mode the user was in as well as which solenoids were up or down. The problem came in when sending user orders across the RS232 cable to the PIC. The RS232 cable was fine, as well as the Processing program, since if we looped the circuit back to the PC, each command was read. The problem was somewhere in the PIC, possibly with a hardware error or interrupt interference.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17227</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17227"/>
		<updated>2010-03-17T04:42:43Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Combining the Parts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board: [[Introduction to the PIC32]] &lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
[[Image:circuit_diagram.png]]&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
&lt;br /&gt;
===Summary of Parts===&lt;br /&gt;
&lt;br /&gt;
*Electrical&lt;br /&gt;
&lt;br /&gt;
The electric circuit was fully functional at the end of construction, with each solenoid responding to a high or low signal coming from where the PIC output would enter the NAND chip. If a 3.3 V signal came from the PIC output, 12 V would go across the solenoid. If a 0 V signal came from the PIC, a -12 V signal would go across the solenoid.&lt;br /&gt;
&lt;br /&gt;
*Mechanical&lt;br /&gt;
&lt;br /&gt;
The mechanical setup was also fully functional at the end of construction. Each solenoid fit snugly into their insert with the leads coming out in a shrink-wrapped conduit. The polycarbonate container was bent and sealed with epoxy and there was a wooden base so that the electronics would be housed conveniently under everything.&lt;br /&gt;
&lt;br /&gt;
*Coding&lt;br /&gt;
&lt;br /&gt;
The attempted Fast Fourier Transform coding was working by the end of construction, lighting up LED lights when certain frequencies were active. Our idea for the music response mode was to have the FFT recognize the melody and output the musical note to the corresponding solenoid on the outside diameter of the hexagon. The middle solenoids would be activating at random.&lt;br /&gt;
&lt;br /&gt;
The user interface was also working. The Processing application&#039;s solenoid control buttons were functional and sent data over the RS232 cable to the PIC. The final idea was to have it as a user option whether to go into music response mode or manually control the solenoids.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Combining the Parts===&lt;br /&gt;
&lt;br /&gt;
*Combining Electrical with Mechanical&lt;br /&gt;
&lt;br /&gt;
While all of the solenoids fit snugly into their inserts, we found that the magnets were interfering with each other from their positions. We had all of the cylindrical magnets facing the same polarity (all of the north ends of the magnets faced up). Because of this arrangement, the magnets felt a repulsive force from the other magnets. We found we were able to push the solenoids up (boosted by the magnetic force from the other magnets) but we were unable to bring them down due to the extra force overcoming the force from the solenoid&#039;s pull. Since we had tested the forces on the solenoids separately, we did not think to check the forces on them when in the arrangement, but it made for a project that was only half functional.&lt;br /&gt;
&lt;br /&gt;
In addition, we attempted to help overcome the extra force in two ways. First, by increasing the padding space between the bottom of the ferrofluid container and the magnets. This way the solenoid would be more in its most efficient spot, and the magnetic force from the ferrofluid would be less. Second, we removed one of the magnets from each solenoid arrangement (only one magnet instead of two) to try and lessen the magnetic forces between the magnets. Not only did this not work, but it made it so that the magnets then had little effect on the ferrofluid (slight bumps instead of spiky designs).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Combining Electrical with Coding&lt;br /&gt;
&lt;br /&gt;
Had we been able to take more time with this interface, the problems would have been easy fixes. As it was though, the wires of the solenoids coming down from the hardware enclosure got mixed up when getting connected to the H-bridge outputs. This made it so the NAND inputs did not match up with the PIC outputs they should have. &lt;br /&gt;
&lt;br /&gt;
Another small problem we had was that the solenoids enabled time was too low. Since each solenoid takes around .2 A at 12 V, it would take a lot of power to power all 19 solenoids at once. So we used an enable pin to enable and disable all the H-Bridges at once. This way, we could use only one pin for each solenoid, and the power wouldn&#039;t be on at all times, only when solenoids needed to change positions. Since the time we had the enable pin set to high was too short, the solenoids didn&#039;t have enough time to push up the magnets. This was a programmed constant and could have been optimized with more testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Combining the Coding with the User Interface&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17226</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17226"/>
		<updated>2010-03-17T04:40:43Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board: [[Introduction to the PIC32]] &lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
[[Image:circuit_diagram.png]]&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
&lt;br /&gt;
===Summary of Parts===&lt;br /&gt;
&lt;br /&gt;
*Electrical&lt;br /&gt;
&lt;br /&gt;
The electric circuit was fully functional at the end of construction, with each solenoid responding to a high or low signal coming from where the PIC output would enter the NAND chip. If a 3.3 V signal came from the PIC output, 12 V would go across the solenoid. If a 0 V signal came from the PIC, a -12 V signal would go across the solenoid.&lt;br /&gt;
&lt;br /&gt;
*Mechanical&lt;br /&gt;
&lt;br /&gt;
The mechanical setup was also fully functional at the end of construction. Each solenoid fit snugly into their insert with the leads coming out in a shrink-wrapped conduit. The polycarbonate container was bent and sealed with epoxy and there was a wooden base so that the electronics would be housed conveniently under everything.&lt;br /&gt;
&lt;br /&gt;
*Coding&lt;br /&gt;
&lt;br /&gt;
The attempted Fast Fourier Transform coding was working by the end of construction, lighting up LED lights when certain frequencies were active. Our idea for the music response mode was to have the FFT recognize the melody and output the musical note to the corresponding solenoid on the outside diameter of the hexagon. The middle solenoids would be activating at random.&lt;br /&gt;
&lt;br /&gt;
The user interface was also working. The Processing application&#039;s solenoid control buttons were functional and sent data over the RS232 cable to the PIC. The final idea was to have it as a user option whether to go into music response mode or manually control the solenoids.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Combining the Parts===&lt;br /&gt;
&lt;br /&gt;
*Combining Electrical with Mechanical&lt;br /&gt;
&lt;br /&gt;
While all of the solenoids fit snugly into their inserts, we found that the magnets were interfering with each other from their positions. We had all of the cylindrical magnets facing the same polarity (all of the north ends of the magnets faced up). Because of this arrangement, the magnets felt a repulsive force from the other magnets. We found we were able to push the solenoids up (boosted by the magnetic force from the other magnets) but we were unable to bring them down due to the extra force overcoming the force from the solenoid&#039;s pull. Since we had tested the forces on the solenoids separately, we did not think to check the forces on them when in the arrangement, but it made for a project that was only half functional.&lt;br /&gt;
&lt;br /&gt;
In addition, we attempted to help overcome the extra force in two ways. First, by increasing the padding space between the bottom of the ferrofluid container and the magnets. This way the solenoid would be more in its most efficient spot, and the magnetic force from the ferrofluid would be less. Second, we removed one of the magnets from each solenoid arrangement (only one magnet instead of two) to try and lessen the magnetic forces between the magnets. Not only did this not work, but it made it so that the magnets then had little effect on the ferrofluid (slight bumps instead of spiky designs).&lt;br /&gt;
&lt;br /&gt;
*Combining Electrical with Coding&lt;br /&gt;
&lt;br /&gt;
Had we been able to take more time with this interface, the problems would have been easy fixes. As it was though, the wires of the solenoids coming down from the hardware enclosure got mixed up when getting connected to the H-bridge outputs. This made it so the NAND inputs did not match up with the PIC outputs they should have. &lt;br /&gt;
&lt;br /&gt;
Another small problem we had was that the solenoids enabled time was too low. Since each solenoid takes around .2 A at 12 V, it would take a lot of power to power all 19 solenoids at once. So we used an enable pin to enable and disable all the H-Bridges at once. This way, we could use only one pin for each solenoid, and the power wouldn&#039;t be on at all times, only when solenoids needed to change positions. Since the time we had the enable pin set to high was too short, the solenoids didn&#039;t have enough time to push up the magnets. This was a programmed constant and could have been optimized with more testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Combining the Coding with the User Interface&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17225</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17225"/>
		<updated>2010-03-17T04:39:42Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board: [[Introduction to the PIC32]] &lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
[[Image:circuit_diagram.png]]&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
&lt;br /&gt;
Before we combined the parts of the project, this is a summary of what we had.&lt;br /&gt;
&lt;br /&gt;
*Electrical&lt;br /&gt;
&lt;br /&gt;
The electric circuit was fully functional at the end of construction, with each solenoid responding to a high or low signal coming from where the PIC output would enter the NAND chip. If a 3.3 V signal came from the PIC output, 12 V would go across the solenoid. If a 0 V signal came from the PIC, a -12 V signal would go across the solenoid.&lt;br /&gt;
&lt;br /&gt;
*Mechanical&lt;br /&gt;
&lt;br /&gt;
The mechanical setup was also fully functional at the end of construction. Each solenoid fit snugly into their insert with the leads coming out in a shrink-wrapped conduit. The polycarbonate container was bent and sealed with epoxy and there was a wooden base so that the electronics would be housed conveniently under everything.&lt;br /&gt;
&lt;br /&gt;
*Coding&lt;br /&gt;
&lt;br /&gt;
The attempted Fast Fourier Transform coding was working by the end of construction, lighting up LED lights when certain frequencies were active. Our idea for the music response mode was to have the FFT recognize the melody and output the musical note to the corresponding solenoid on the outside diameter of the hexagon. The middle solenoids would be activating at random.&lt;br /&gt;
&lt;br /&gt;
The user interface was also working. The Processing application&#039;s solenoid control buttons were functional and sent data over the RS232 cable to the PIC. The final idea was to have it as a user option whether to go into music response mode or manually control the solenoids.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we combined the parts, however, they did not work as expected.&lt;br /&gt;
&lt;br /&gt;
*Combining Electrical with Mechanical&lt;br /&gt;
&lt;br /&gt;
While all of the solenoids fit snugly into their inserts, we found that the magnets were interfering with each other from their positions. We had all of the cylindrical magnets facing the same polarity (all of the north ends of the magnets faced up). Because of this arrangement, the magnets felt a repulsive force from the other magnets. We found we were able to push the solenoids up (boosted by the magnetic force from the other magnets) but we were unable to bring them down due to the extra force overcoming the force from the solenoid&#039;s pull. Since we had tested the forces on the solenoids separately, we did not think to check the forces on them when in the arrangement, but it made for a project that was only half functional.&lt;br /&gt;
&lt;br /&gt;
In addition, we attempted to help overcome the extra force in two ways. First, by increasing the padding space between the bottom of the ferrofluid container and the magnets. This way the solenoid would be more in its most efficient spot, and the magnetic force from the ferrofluid would be less. Second, we removed one of the magnets from each solenoid arrangement (only one magnet instead of two) to try and lessen the magnetic forces between the magnets. Not only did this not work, but it made it so that the magnets then had little effect on the ferrofluid (slight bumps instead of spiky designs).&lt;br /&gt;
&lt;br /&gt;
*Combining Electrical with Coding&lt;br /&gt;
&lt;br /&gt;
Had we been able to take more time with this interface, the problems would have been easy fixes. As it was though, the wires of the solenoids coming down from the hardware enclosure got mixed up when getting connected to the H-bridge outputs. This made it so the NAND inputs did not match up with the PIC outputs they should have. &lt;br /&gt;
&lt;br /&gt;
Another small problem we had was that the solenoids enabled time was too low. Since each solenoid takes around .2 A at 12 V, it would take a lot of power to power all 19 solenoids at once. So we used an enable pin to enable and disable all the H-Bridges at once. This way, we could use only one pin for each solenoid, and the power wouldn&#039;t be on at all times, only when solenoids needed to change positions. Since the time we had the enable pin set to high was too short, the solenoids didn&#039;t have enough time to push up the magnets. This was a programmed constant and could have been optimized with more testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Combining the Coding with the User Interface&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17224</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17224"/>
		<updated>2010-03-17T04:14:59Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board: [[Introduction to the PIC32]] &lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
[[Image:circuit_diagram.png]]&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
&lt;br /&gt;
As seen from our videos, we were able to get all of the parts of our project working, but when put together, they did not work as expected.&lt;br /&gt;
&lt;br /&gt;
*Electrical&lt;br /&gt;
&lt;br /&gt;
The electric circuit was fully functional at the end of construction, with each solenoid responding to a high or low signal coming from where the PIC output would enter the NAND chip. If a 3.3 V signal came from the PIC output, 12 V would go across the solenoid. If a 0 V signal came from the PIC, a -12 V signal would go across the solenoid.&lt;br /&gt;
&lt;br /&gt;
*Mechanical&lt;br /&gt;
&lt;br /&gt;
The mechanical setup was also fully functional at the end of construction. Each solenoid fit snugly into their insert with the leads coming out in a shrink-wrapped conduit. The polycarbonate container was bent and sealed with epoxy and there was a wooden base so that the electronics would be housed conveniently under everything.&lt;br /&gt;
&lt;br /&gt;
*Coding&lt;br /&gt;
&lt;br /&gt;
The FFT coding was working by the end of construction, lighting up LED lights when certain frequencies were active. The user interface was also working. The Processing application&#039;s solenoid control buttons were functional and sent data over the RS232 cable to the PIC. The final idea was to have it as a user option whether to go into music response mode or manually control the solenoids.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17149</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17149"/>
		<updated>2010-03-17T00:59:36Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board: [[Introduction to the PIC32]] &lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
[[Image:circuit_diagram.png]]&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Circuit_diagram.png&amp;diff=17148</id>
		<title>File:Circuit diagram.png</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Circuit_diagram.png&amp;diff=17148"/>
		<updated>2010-03-17T00:59:13Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: uploaded a new version of &amp;quot;Image:Circuit diagram.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Circuit Diagram&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17147</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17147"/>
		<updated>2010-03-17T00:56:41Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board: [[Introduction to the PIC32]] &lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
Circuit Diagram:&lt;br /&gt;
&lt;br /&gt;
[[Image:circuit_diagram.png]]&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17146</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17146"/>
		<updated>2010-03-17T00:56:09Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board: [[Introduction to the PIC32]] &lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
[[Image:circuit_diagram.png]]&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Circuit_diagram.png&amp;diff=17145</id>
		<title>File:Circuit diagram.png</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Circuit_diagram.png&amp;diff=17145"/>
		<updated>2010-03-17T00:55:19Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: Circuit Diagram&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Circuit Diagram&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17134</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17134"/>
		<updated>2010-03-17T00:20:34Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board: [[Introduction to the PIC32]] &lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17133</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17133"/>
		<updated>2010-03-17T00:19:36Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One [[Introduction to the PIC32]] NU32 board&lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17132</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17132"/>
		<updated>2010-03-17T00:17:28Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board&lt;br /&gt;
*19 solenoids: [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges: [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits: [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17131</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17131"/>
		<updated>2010-03-17T00:16:53Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board&lt;br /&gt;
*19 solenoids [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293NDE Quad-half-bridges [http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293DNE.shtml Datasheet]&lt;br /&gt;
*5 SN74HC00N NAND Integrated Circuits [http://www.chipsinfo.com/TI/SN74HC00N.htm Datasheet]&lt;br /&gt;
&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17130</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=17130"/>
		<updated>2010-03-17T00:14:34Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board&lt;br /&gt;
*19 solenoids [https://www.jameco.com/webapp/wcs/stores/servlet/OrderItemDisplay?langId=-1&amp;amp;storeId=10001&amp;amp;catalogId=10001&amp;amp;krypto=WUgCYelA18EFMkT03NuyYowmviur5pLw5O7ybblUbPU1s%2BE5iJH6qHHMpTSj4RJNARBe7J9MvmE%3D&amp;amp;ddkey=https:OrderItemUpdate Jameco Part #262271]&lt;br /&gt;
*10 L293N Quad-half-bridges (insert part # + datasheet here)&lt;br /&gt;
*5 SN7... NAND Integrated Circuits (insert part # + datasheet here)&lt;br /&gt;
&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16820</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16820"/>
		<updated>2010-03-15T05:24:05Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
*One NU32 board&lt;br /&gt;
*19 solenoids (insert part # + datasheet here)&lt;br /&gt;
*10 L293N Quad-half-bridges (insert part # + datasheet here)&lt;br /&gt;
*5 SN7... NAND Integrated Circuits (insert part # + datasheet here)&lt;br /&gt;
&lt;br /&gt;
*Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
*The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
*The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16819</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16819"/>
		<updated>2010-03-15T05:23:49Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
Our electronics system consisted of:&lt;br /&gt;
**One NU32 board&lt;br /&gt;
**19 solenoids (insert part # + datasheet here)&lt;br /&gt;
**10 L293N Quad-half-bridges (insert part # + datasheet here)&lt;br /&gt;
**5 SN7... NAND Integrated Circuits (insert part # + datasheet here)&lt;br /&gt;
&lt;br /&gt;
**Inputs came from twenty of the PIC&#039;s digital output pins. 19 of those went to the NAND logic chips while the last one went to a hub controlling the enable pins of the H-Bridges. &lt;br /&gt;
&lt;br /&gt;
**The NAND&#039;s were set up so that the input from the PIC went to both pins of the input so that the opposite signal would come out of the output. Both the input and the output of the NAND chip would then go to 2 inputs of the quad-half-bridge. &lt;br /&gt;
&lt;br /&gt;
**The H-bridge would then output either a +12V or a -12V (forward or reverse) across the solenoid dependent on a high or low output from the PIC. &lt;br /&gt;
&lt;br /&gt;
**The H-bridge is also connected to the enable voltage. Controlled by the PIC, the enable voltage, when high, would allow current to flow through the half-bridges. When low, no current would flow. This made it so that current would not flow at all times, just when the solenoids were switching position.&lt;br /&gt;
&lt;br /&gt;
Picture of circuit for 4 solenoids goes.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16818</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16818"/>
		<updated>2010-03-15T05:12:41Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
Max&lt;br /&gt;
[[Image:ELECTRONICS.JPG|thumb|150px|Final Electronics Setup.|right]]&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:ELECTRONICS.jpg&amp;diff=16817</id>
		<title>File:ELECTRONICS.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:ELECTRONICS.jpg&amp;diff=16817"/>
		<updated>2010-03-15T05:05:14Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: Picture of our final electronics setup.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Picture of our final electronics setup.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16816</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16816"/>
		<updated>2010-03-15T05:04:18Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
Max&lt;br /&gt;
[[Image:ELECTRONICS.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:ELECTRONICS.JPG&amp;diff=16815</id>
		<title>File:ELECTRONICS.JPG</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:ELECTRONICS.JPG&amp;diff=16815"/>
		<updated>2010-03-15T05:03:14Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: Picture of final electronics setup.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Picture of final electronics setup.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16810</id>
		<title>Ferrofluid Art Display</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Ferrofluid_Art_Display&amp;diff=16810"/>
		<updated>2010-03-15T04:54:59Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: /* Team Members */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
The goal of this project was to create an interesting display using [http://en.wikipedia.org/wiki/Ferrofluid Ferrofluid], which is composed of ferrimagnetic particles suspended in a carrier fluid. The project was inspired by the work of artists such as Sachiko Kodama and Yasushi Miyajima, shown in this [http://www.youtube.com/watch?v=me5Zzm2TXh4&amp;amp;feature=related video] of their installation &amp;quot;Morpho Towers&amp;quot;. Our display consisted of a hexagonal array of solenoids used to actuate magnets towards or away from the fluid, allowing us to control which regions were smooth and which displayed corrugations. The display could then be controlled via a user interface with the PC. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Todd H. Poole (Mechanical Engineering &amp;amp; Electrical Engineering, Class of 2010)&lt;br /&gt;
* Katy Powers (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Max Willer (Mechanical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
Todd&lt;br /&gt;
An evolution of concepts.&lt;br /&gt;
-Early sketches&lt;br /&gt;
--Pros &amp;amp; Cons&lt;br /&gt;
Decision of&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
The code for the display setup consists of a GUI on the PC allowing the user to select which solenoids to turn on and off and code on the PIC to control the solenoids.&lt;br /&gt;
&lt;br /&gt;
===Processing===&lt;br /&gt;
[[Image:Kpmw_userinterface.png|thumb|180px|Screenshot of User Interface. Green circles represent solenoids that are up while blue circles represent solenoids that are down.|right]]&lt;br /&gt;
The PC side of the user interface was created with [http://processing.org/ Processing], an open source programming environment with many options for interesting visual display. This code creates a display of circles arranged in the same way as the solenoids in our hardware, which will change from blue to green when clicked and output a character via RS232 to the PIC. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 //Katy Powers&lt;br /&gt;
 //3/11/2010&lt;br /&gt;
 //ME 333 Ferrofluid Art GUI&lt;br /&gt;
 //Lots of code taken from processing website and previous ME 333 labs..thanks!&lt;br /&gt;
 &lt;br /&gt;
 // add the serial library&lt;br /&gt;
 import processing.serial.*; &lt;br /&gt;
 Serial[] myPorts = new Serial[1];&lt;br /&gt;
 &lt;br /&gt;
 //setup parameters for hexagonal array&lt;br /&gt;
 //cx,cy define center position, rc is circle radius, sp is how far apart they are&lt;br /&gt;
 int cx = 250;&lt;br /&gt;
 int cy = 250;&lt;br /&gt;
 int rc = 50;&lt;br /&gt;
 int sp = 10;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //circleX and circleY store center locations of every circle in array&lt;br /&gt;
 //solenoidON stores state of solenoid&lt;br /&gt;
 //chararr stores characters corresponding to each solenoid&lt;br /&gt;
 int[] circleX = {cx, cx + rc + sp,cx + 2*(rc + sp),cx - (rc + sp),cx - 2*(rc + sp),cx + rc/2 + sp/2,&lt;br /&gt;
 cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx,cx+rc+sp, cx - (rc+sp),&lt;br /&gt;
 cx + rc/2 + sp/2, cx + 3*rc/2 + 3*sp/2,cx - (rc/2 + sp/2),cx - (3*rc/2 + 3*sp/2),cx, &lt;br /&gt;
 cx + rc + sp,cx-(rc + sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] circleY = {cy,cy,cy,cy,cy,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + rc +sp,cy + 2*(rc+sp),&lt;br /&gt;
 cy + 2*(rc+sp), cy + 2*(rc+sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),cy - (rc +sp),&lt;br /&gt;
 cy - 2*(rc+sp),cy - 2*(rc+sp),cy - 2*(rc+sp)};&lt;br /&gt;
 &lt;br /&gt;
 int[] solenoidON = new int[19];&lt;br /&gt;
 char[] chararr = {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;};&lt;br /&gt;
 PFont font;&lt;br /&gt;
 PFont smallfont;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
 InitSerial();&lt;br /&gt;
 background(0);&lt;br /&gt;
 font = loadFont(&amp;quot;FangSong-48.vlw&amp;quot;);&lt;br /&gt;
 smallfont = loadFont(&amp;quot;FangSong-16.vlw&amp;quot;);&lt;br /&gt;
 size(500,500);&lt;br /&gt;
 textAlign(CENTER);&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){ //zero array of solenoid values, mouse state data&lt;br /&gt;
   solenoidON[i] = 0;&lt;br /&gt;
 }&lt;br /&gt;
 rectMode(CENTER);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void draw()&lt;br /&gt;
 {&lt;br /&gt;
   fill(0,0,255);&lt;br /&gt;
   textFont(font, 48);&lt;br /&gt;
   text(&amp;quot;Ferrofluid Art&amp;quot;, cx, cy-200);&lt;br /&gt;
   textFont(smallfont, 16);&lt;br /&gt;
   text(&amp;quot;Click a circle to make patterns in the Ferrofluid&amp;quot;, cx, cy + 200);&lt;br /&gt;
   hexagon(cx,cy,rc,sp, solenoidON);&lt;br /&gt;
     &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void hexagon(int cx, int cy, int rc, int sp, int[] sols) //draws hexagon of cirlces&lt;br /&gt;
 {&lt;br /&gt;
 for (int i = 0; i &amp;lt; 19; i = i+1){&lt;br /&gt;
   if(sols[i] == 0) {fill(0,0,255);}&lt;br /&gt;
   else {fill(0,255,0);}&lt;br /&gt;
   ellipse(circleX[i], circleY[i], rc, rc);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void mousePressed() //executes when mouse is pressed, much like an interrupt routine&lt;br /&gt;
 {&lt;br /&gt;
   float disX, disY;&lt;br /&gt;
   for (int i = 0; i &amp;lt; 19; i = i+1){ //see where mouse is&lt;br /&gt;
     disX = circleX[i] - mouseX;&lt;br /&gt;
     disY = circleY[i] - mouseY;&lt;br /&gt;
     if(sqrt(sq(disX) + sq(disY)) &amp;lt; rc/2 ) { //if mouse is in circle, toggle state and send character&lt;br /&gt;
       solenoidON[i] = 1 - solenoidON[i];&lt;br /&gt;
       myPorts[0].write(chararr[i]);&lt;br /&gt;
       println(chararr[i]); //to debug&lt;br /&gt;
        }   &lt;br /&gt;
     } &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===PIC===&lt;br /&gt;
The PIC side of the code runs an infinite while loop, executing an interrupt routine every time a character is received from the RS232. The &lt;br /&gt;
PIC then updates the state of all the solenoids.&lt;br /&gt;
&lt;br /&gt;
 /**Ferrofluid Art Project Code**********************************/&lt;br /&gt;
 /* Katy Powers Winter 2010 */	 &lt;br /&gt;
 &lt;br /&gt;
 /** INCLUDES ***************************************************/&lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot; //needed for Delayms&lt;br /&gt;
  &lt;br /&gt;
 /** Constants **************************************************/ &lt;br /&gt;
  &lt;br /&gt;
 #define TRUE 		1&lt;br /&gt;
 #define FALSE		0&lt;br /&gt;
 &lt;br /&gt;
 #define ENABLE1 LATDbits.LATD1 //Enable pins for H bridge circuit&lt;br /&gt;
 #define ENABLE2 LATDbits.LATD2&lt;br /&gt;
 #define OUT1   LATBbits.LATB11 //Output pins for solenoid control&lt;br /&gt;
 #define OUT2   LATBbits.LATB10&lt;br /&gt;
 #define OUT3   LATBbits.LATB9&lt;br /&gt;
 #define OUT4   LATBbits.LATB8 &lt;br /&gt;
 #define OUT5   LATAbits.LATA10&lt;br /&gt;
 #define OUT6   LATAbits.LATA9&lt;br /&gt;
 #define OUT7   LATBbits.LATB7&lt;br /&gt;
 #define OUT8   LATBbits.LATB6&lt;br /&gt;
 #define OUT9   LATBbits.LATB0&lt;br /&gt;
 #define OUT10  LATBbits.LATB1 &lt;br /&gt;
 #define OUT11  LATBbits.LATB2&lt;br /&gt;
 #define OUT12  LATBbits.LATB3&lt;br /&gt;
 #define OUT13  LATBbits.LATB5 &lt;br /&gt;
 #define OUT14  LATEbits.LATE9&lt;br /&gt;
 #define OUT15  LATEbits.LATE8&lt;br /&gt;
 #define OUT16  LATGbits.LATG9 &lt;br /&gt;
 #define OUT17  LATGbits.LATG8&lt;br /&gt;
 #define OUT18  LATGbits.LATG7&lt;br /&gt;
 #define OUT19  LATGbits.LATG6 &lt;br /&gt;
 &lt;br /&gt;
 #define DESIRED_BAUDRATE    	(19200)      // The desired BaudRate &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 /** Function Declarations **************************************/&lt;br /&gt;
 void initInterruptController();&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk);&lt;br /&gt;
 &lt;br /&gt;
 void sendDataRS232(void);&lt;br /&gt;
 &lt;br /&gt;
 void setSols(void); //sets solenoids on and off depending on global variable sols&lt;br /&gt;
 &lt;br /&gt;
 /** Global Variables *******************************************/&lt;br /&gt;
 &lt;br /&gt;
 int sols[19]; //vector to store if solenoids are on or off	&lt;br /&gt;
 &lt;br /&gt;
 /** Main Function **********************************************/&lt;br /&gt;
 &lt;br /&gt;
 int main(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int	pbClk;&lt;br /&gt;
 	int i;&lt;br /&gt;
 	// Configure the proper PB frequency and the number of wait states&lt;br /&gt;
 	pbClk = SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 	AD1PCFG = 0xFFFF; //this line sets up the B bits as digital outputs&lt;br /&gt;
 &lt;br /&gt;
 	TRISAbits.TRISA10 = 0; //set all solenoid and enable output pins to output&lt;br /&gt;
 	TRISAbits.TRISA9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB11 = 0;&lt;br /&gt;
 	TRISBbits.TRISB10 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB9 = 0;&lt;br /&gt;
 	TRISBbits.TRISB8 = 0;&lt;br /&gt;
 	TRISBbits.TRISB7 = 0;&lt;br /&gt;
 	TRISBbits.TRISB6 = 0;	&lt;br /&gt;
 	TRISBbits.TRISB5 = 0;&lt;br /&gt;
 	TRISBbits.TRISB3 = 0;&lt;br /&gt;
 	TRISBbits.TRISB2 = 0;&lt;br /&gt;
 	TRISBbits.TRISB1 = 0;	&lt;br /&gt;
 	TRISEbits.TRISE9 = 0;&lt;br /&gt;
 	TRISEbits.TRISE8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG8 = 0;&lt;br /&gt;
 	TRISGbits.TRISG7 = 0;	&lt;br /&gt;
 	TRISGbits.TRISG6 = 0;&lt;br /&gt;
 	TRISBbits.TRISB0 = 0;&lt;br /&gt;
 	TRISGbits.TRISG9 = 0;&lt;br /&gt;
 	TRISDbits.TRISD1 = 0;&lt;br /&gt;
 	TRISDbits.TRISD2 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	OUT1 = 0; //initialize outputs to low&lt;br /&gt;
 	OUT2 = 0;&lt;br /&gt;
     	OUT3 = 0;&lt;br /&gt;
 	OUT4 = 0;&lt;br /&gt;
         OUT5 = 0;&lt;br /&gt;
 	OUT6 = 0;&lt;br /&gt;
         OUT7 = 0;&lt;br /&gt;
 	OUT8 = 0;&lt;br /&gt;
 	OUT9 = 0;&lt;br /&gt;
 	OUT10 = 0;&lt;br /&gt;
 	OUT11 = 0;&lt;br /&gt;
 	OUT12 = 0;&lt;br /&gt;
     	OUT13 = 0;&lt;br /&gt;
 	OUT14 = 0;&lt;br /&gt;
 	OUT15 = 0;&lt;br /&gt;
 	OUT16 = 0;&lt;br /&gt;
         OUT17 = 0;&lt;br /&gt;
 	OUT18 = 0;&lt;br /&gt;
 	OUT19 = 0;&lt;br /&gt;
 &lt;br /&gt;
 	//also initialize sols array to 0&lt;br /&gt;
 	for(i = 0; i &amp;lt; 19; i++){&lt;br /&gt;
 	sols[i] = 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	setSols(); //this is probably redundant&lt;br /&gt;
 		&lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 		&lt;br /&gt;
 		&lt;br /&gt;
 	initUART2(pbClk);&lt;br /&gt;
 	INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 &lt;br /&gt;
 	while(1)&lt;br /&gt;
 	{&lt;br /&gt;
 	  1;//just keep going and wait for interrupts from RS232&lt;br /&gt;
 	} //end main&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 /** Interrupt Handlers *****************************************/&lt;br /&gt;
 		 &lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	int i;&lt;br /&gt;
        unsigned char data2; //store character received from PC&lt;br /&gt;
 	char chararr[19] =  {&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;,&#039;f&#039;,&#039;g&#039;,&#039;h&#039;,&#039;i&#039;,&#039;j&#039;,&#039;k&#039;,&#039;l&#039;,&#039;m&#039;,&#039;n&#039;,&#039;o&#039;,&#039;p&#039;,&#039;q&#039;,&#039;r&#039;,&#039;s&#039;}; //array of characters for comparison&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data2 = ReadUART2(); //get character&lt;br /&gt;
 &lt;br /&gt;
 		// Toggle LED to indicate UART activity&lt;br /&gt;
 		mLED_1_Toggle();&lt;br /&gt;
 &lt;br /&gt;
 		for(i = 0; i&amp;lt;19; i++){&lt;br /&gt;
 		if (data2 ==(int) chararr[i]){ sols[i] = 1 - sols[i];} //toggle solenoid  corresponding to character received&lt;br /&gt;
 		}&lt;br /&gt;
 		setSols(); //update all solenoids&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	// We don&#039;t care about TX interrupt&lt;br /&gt;
 	if ( mU2TXGetIntFlag() )&lt;br /&gt;
 	{&lt;br /&gt;
 		mU2TXClearIntFlag();&lt;br /&gt;
 	}&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /** Other Functions ********************************************/&lt;br /&gt;
 &lt;br /&gt;
 void initUART2(int pbClk)&lt;br /&gt;
 {&lt;br /&gt;
 	 // define setup Configuration 1 for OpenUARTx&lt;br /&gt;
 		// Module Enable &lt;br /&gt;
 		// Work in IDLE mode &lt;br /&gt;
 		// Communication through usual pins &lt;br /&gt;
 		// Disable wake-up &lt;br /&gt;
 		// Loop back disabled &lt;br /&gt;
 		// Input to Capture module from ICx pin &lt;br /&gt;
 		// no parity 8 bit &lt;br /&gt;
 		// 1 stop bit &lt;br /&gt;
 		// IRDA encoder and decoder disabled &lt;br /&gt;
 		// CTS and RTS pins are disabled &lt;br /&gt;
 		// UxRX idle state is &#039;1&#039; &lt;br /&gt;
 		// 16x baud clock - normal speed&lt;br /&gt;
 	#define config1 	UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE |  UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_DIS_BCLK_CTS_RTS| UART_NORMAL_RX | UART_BRGH_SIXTEEN&lt;br /&gt;
  	 &lt;br /&gt;
  	 // define setup Configuration 2 for OpenUARTx&lt;br /&gt;
 		// IrDA encoded UxTX idle state is &#039;0&#039;&lt;br /&gt;
 		// Enable UxRX pin&lt;br /&gt;
 		// Enable UxTX pin&lt;br /&gt;
 		// Interrupt on transfer of every character to TSR &lt;br /&gt;
 		// Interrupt on every char received&lt;br /&gt;
 		// Disable 9-bit address detect&lt;br /&gt;
 		// Rx Buffer Over run status bit clear&lt;br /&gt;
 	 #define config2		UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE |  UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR	&lt;br /&gt;
  &lt;br /&gt;
 	// Open UART2 with config1 and config2&lt;br /&gt;
 	OpenUART2( config1, config2, pbClk/16/DESIRED_BAUDRATE-1);	// calculate actual BAUD  generate value.&lt;br /&gt;
   		&lt;br /&gt;
 	// Configure UART2 RX Interrupt with priority 2&lt;br /&gt;
 	ConfigIntUART2(UART_INT_PR2 | UART_RX_INT_EN);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void setSols(){&lt;br /&gt;
 	OUT1 = sols[0]; //set all outputs to correct value&lt;br /&gt;
 	OUT2 = sols[1];&lt;br /&gt;
 	OUT3 = sols[2];&lt;br /&gt;
 	OUT4 = sols[3];&lt;br /&gt;
 	OUT5 = sols[4];&lt;br /&gt;
 	OUT6 = sols[5];&lt;br /&gt;
 	OUT7 = sols[6];&lt;br /&gt;
 	OUT8 = sols[7];&lt;br /&gt;
 	OUT9 = sols[8];&lt;br /&gt;
 	OUT10 = sols[9];&lt;br /&gt;
 	OUT11 = sols[10];&lt;br /&gt;
 	OUT12 = sols[11];&lt;br /&gt;
 	OUT13 = sols[12];&lt;br /&gt;
 	OUT14 = sols[13];&lt;br /&gt;
 	OUT15 = sols[14];&lt;br /&gt;
 	OUT16 = sols[15];&lt;br /&gt;
 	OUT17 = sols[16];&lt;br /&gt;
 	OUT18 = sols[17];&lt;br /&gt;
 	OUT19 = sols[18];&lt;br /&gt;
 	ENABLE1 = 1; //turn on enable pins&lt;br /&gt;
 	ENABLE2 = 1;&lt;br /&gt;
 	Delayms(500); //wait for half a second for solenoids to change position&lt;br /&gt;
 	ENABLE1 = 0; //turn off enable pins&lt;br /&gt;
 	ENABLE2 = 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Max&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Todd&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16302</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16302"/>
		<updated>2010-02-16T18:40:31Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
==Circuit==&lt;br /&gt;
&lt;br /&gt;
The circuit used for testing consisted of connecting the oscilloscope to the output pin (in this case, pin A2) in order to view the waveform.&lt;br /&gt;
&lt;br /&gt;
[[Image:Kp_mw_tp_benchmarkingcircuit2010.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Here is the Excel file with the full results, in nanoseconds and normalized. [[Media:Lab5.xls]]&lt;br /&gt;
&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test01-high-duration.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Test (a): Time required to throw an output pin high&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test01-low-duration.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Test (b): Time required to pull an output pin low&lt;br /&gt;
&lt;br /&gt;
 | image3    = Test01-full-while-loop.png&lt;br /&gt;
 | alt3      = Test (c): Time required to execute 1 empty while loop cycle&lt;br /&gt;
 | caption3  = Test (c): Time required to execute 1 empty while loop cycle&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test02-parta.png&lt;br /&gt;
 | alt1      = Test (a): Time required to subtract two constant chars&lt;br /&gt;
 | caption1  = Test (a): Time required to subtract two constant chars&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test02-partb.png&lt;br /&gt;
 | alt2      = Test (b): Time required to subtract two ints cast into a char&lt;br /&gt;
 | caption2  = Test (b): Time required to subtract two ints cast into a char&lt;br /&gt;
&lt;br /&gt;
 | image3    = Test02-partc.png&lt;br /&gt;
 | alt3      = Test (c): Time required to subtract two random chars&lt;br /&gt;
 | caption3  = Test (c): Time required to subtract two random chars&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test03-parta.png&lt;br /&gt;
 | alt1      = Test (a): Time required to add two constant chars&lt;br /&gt;
 | caption1  = Test (a): Time required to add two constant chars&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test03-partb.png&lt;br /&gt;
 | alt2      = Test (b): Time required to add two ints cast into a char&lt;br /&gt;
 | caption2  = Test (b): Time required to add two ints cast into a char&lt;br /&gt;
&lt;br /&gt;
 | image3    = Test03-partc.png&lt;br /&gt;
 | alt3      = Test (c): Time required to add two random chars&lt;br /&gt;
 | caption3  = Test (c): Time required to add two random chars&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test04-parta.jpg&lt;br /&gt;
 | alt1      = Test (a): Time required to multiply two constant chars&lt;br /&gt;
 | caption1  = Test (a): Time required to multiply two constant chars&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test04-partb.jpg&lt;br /&gt;
 | alt2      = Test (b): Time required to multiply two ints cast into a char&lt;br /&gt;
 | caption2  = Test (b): Time required to multiply two ints cast into a char&lt;br /&gt;
&lt;br /&gt;
 | image3    = Test04-partc.jpg&lt;br /&gt;
 | alt3      = Test (c): Time required to multiply of two random chars&lt;br /&gt;
 | caption3  = Test (c): Time required to multiply of two random chars&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test05-parta.jpg&lt;br /&gt;
 | alt1      = Test (a): Time required to divide two constant chars&lt;br /&gt;
 | caption1  = Test (a): Time required to divide two constant chars&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test05-parta.jpg&lt;br /&gt;
 | alt2      = Test (b): Time required to divide two ints cast into a char&lt;br /&gt;
 | caption2  = Test (b): Time required to divide two ints cast into a char&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to divide two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to divide two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to divide two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test06-parta.jpg&lt;br /&gt;
 | alt1      = Test (a): Time required to sqrt() a constant char&lt;br /&gt;
 | caption1  = Test (a): Time required to sqrt() a constant char&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test06-partb.jpg&lt;br /&gt;
 | alt2      = Test (b): Time required to sqrt() an int cast into a char&lt;br /&gt;
 | caption2  = Test (b): Time required to sqrt() an int cast into a char&lt;br /&gt;
&lt;br /&gt;
 | image3    = Test06-partc.jpg&lt;br /&gt;
 | alt3      = Test (c): Time required to sqrt() a random char&lt;br /&gt;
 | caption3  = Test (c): Time required to sqrt() a random char&lt;br /&gt;
}}&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test06-partd.jpg&lt;br /&gt;
 | alt1      = Test (d): Time required to ^(1/2) a constant char&lt;br /&gt;
 | caption1  = Test (d): Time required to ^(1/2) a constant char&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test06-parte.jpg&lt;br /&gt;
 | alt2      = Test (e): Time required to ^(1/2) an int cast into a char&lt;br /&gt;
 | caption2  = Test (e): Time required to ^(1/2) an int cast into a char&lt;br /&gt;
&lt;br /&gt;
 | image3    = Test06-partf.jpg&lt;br /&gt;
 | alt3      = Test (f): Time required to ^(1/2) a random char&lt;br /&gt;
 | caption3  = Test (f): Time required to ^(1/2) a random char&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test07-parta.jpg&lt;br /&gt;
 | alt1      = Test (a): Time required to take the sine of a constant char&lt;br /&gt;
 | caption1  = Test (a): Time required to take the sine of a constant char&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test07-partb.jpg&lt;br /&gt;
 | alt2      = Test (b): Time required to take the sine of a constant int cast into a char&lt;br /&gt;
 | caption2  = Test (b): Time required to take the sine of a constant int cast into a char&lt;br /&gt;
&lt;br /&gt;
 | image3    = Test07-partc.jpg&lt;br /&gt;
 | alt3      = Test (c): Time required to take the sine of a random char&lt;br /&gt;
 | caption3  = Test (c): Time required to take the sine of a random char&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test08-parta.jpg&lt;br /&gt;
 | alt1      = Test (a): Time required to take the cosine of a constant char&lt;br /&gt;
 | caption1  = Test (a): Time required to take the cosine of a constant char&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test08-partb.jpg&lt;br /&gt;
 | alt2      = Test (b): Time required to take the cosine of a constant int cast into a char&lt;br /&gt;
 | caption2  = Test (b): Time required to take the cosine of a constant int cast into a char&lt;br /&gt;
&lt;br /&gt;
 | image3    = Test08-partc.jpg&lt;br /&gt;
 | alt3      = Test (c): Time required to take the cosine of a random char&lt;br /&gt;
 | caption3  = Test (c): Time required to take the cosine of a random char&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the cosine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to take the cosine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to take the cosine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = test09-parta.png&lt;br /&gt;
 | alt1      = Test (a): Time required to subtract two constant shorts&lt;br /&gt;
 | caption1  = Test (a): Time required to subtract two constant shorts&lt;br /&gt;
&lt;br /&gt;
 | image2    = test09-partb.png&lt;br /&gt;
 | alt2      = Test (b): Time required to subtract two random shorts&lt;br /&gt;
 | caption2  = Test (b): Time required to subtract two random shorts&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test (a): Time required to subtract two constant shorts (may be pre-computed) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 25 ns&lt;br /&gt;
*Test (b): Time required to subtract two random shorts (guaranteed not to be pre-comp) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 62 ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Actual waveforms as seen on the output pin.&lt;br /&gt;
&lt;br /&gt;
 | image1    = Test10-parta.png&lt;br /&gt;
 | alt1      = Test (a): Time required to add two constant shorts&lt;br /&gt;
 | caption1  = Test (a): Time required to add two constant shorts&lt;br /&gt;
&lt;br /&gt;
 | image2    = Test10-partb.png&lt;br /&gt;
 | alt2      = Test (b): Time required to add two random shorts&lt;br /&gt;
 | caption2  = Test (b): Time required to add two random shorts&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test (a): Time required to add two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test (b): Time required to add two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to multiply two constant shorts (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24ns&lt;br /&gt;
*Test b: Time required to multiply two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to divide two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 28ns&lt;br /&gt;
*Test b: Time required to divide two random shorts (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8674ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the sine of a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13014ns&lt;br /&gt;
*Test b: Time required to take the sine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12174ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to subtract two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to subtract two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to add two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 26ns&lt;br /&gt;
*Test b: Time required to add two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instructions:&lt;br /&gt;
**Time: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to multiply two constant ints (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to multiply two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to divide two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to divide two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8737ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random int (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the sine of a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19488ns&lt;br /&gt;
*Test b: Time required to take the sine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 20324ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
A long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to subtract two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 186ns&lt;br /&gt;
*Test b: Time required to subtract two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to add two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
*Test b: Time required to add two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to multiply two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
*Test b: Time required to multiply two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to divide two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
*Test b: Time required to divide two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant long long (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 87ns&lt;br /&gt;
*Test b: Time required to sqrt() a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 16311ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant long long (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 188ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to sqrt() a constant long long (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 23837 ns&lt;br /&gt;
*Test b: Time required to sqrt() a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 29898 ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to take the sine of a constant long long (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24611ns&lt;br /&gt;
*Test b: Time required to take the sine of a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 30623ns&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
A float data type, in ANSI C, is a single-precision value represented by 4 bytes, consisting of a sign bit, an 8-bit excess-127 binary exponent, and a 23-bit mantissa. This roughly corresponds to a range of approximately 3.4E–38 to 3.4E+38 for unsigned floats. Signed floats are more complex to understand, but are covered in depth here: http://msdn.microsoft.com/en-us/library/hd7199ke%28VS.80%29.aspx. In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to subtract two constant floats (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 100ns&lt;br /&gt;
*Test b: Time required to subtract two random floats (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to add two constant floats (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 124ns&lt;br /&gt;
*Test b: Time required to add two random floats (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to multiply two constant floats (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 124ns&lt;br /&gt;
*Test b: Time required to multiply two random floats (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to divide two constant floats (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 99ns&lt;br /&gt;
*Test b: Time required to divide two random floats (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant float (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 99ns&lt;br /&gt;
*Test b: Time required to sqrt() a random float (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8636ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant float (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: N/A&lt;br /&gt;
*Test d: Time required to ^(1/2) a random float (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to take the sine of a constant float (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19574ns&lt;br /&gt;
*Test b: Time required to take the sine of a random float (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant float (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 20311ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random float (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 20297ns&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
A double data type, in ANSI C, is a double-precision value represented by 8 bytes, consisting of a sign bit, an 8-bit excess-1023 binary exponent, and a 52-bit mantissa. This roughly corresponds to a range of approximately 2.22E–308 1.79E+308 for unsigned doubles. Signed doubles are more complex to understand, but are covered in depth here: http://msdn.microsoft.com/en-us/library/hd7199ke%28VS.80%29.aspx. In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC. &lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 8-bit number (a double).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (b): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to add two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (c): Time required to add of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1236 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to multiply two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 188 ns&lt;br /&gt;
* Test (b): Time required to multiply of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1438 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to divide two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 187 ns&lt;br /&gt;
* Test (b): Time required to divide of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 3184 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root a 64-bit number (a double). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant double (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 188 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a double (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 7998 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: N/A ns *&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: N/A ns *&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had some difficulty in trying to test these particular operations. It seems that the PIC32 is not capable of raising doubles to the 1/2 power.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 20299 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 20624 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to take the cosine of a constant double (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 19762 ns&lt;br /&gt;
* Test (c): Time required to take the cosine of a random double (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 20011 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is a c file for each test that was performed. They are included in a .zip at the bottom of this section. and can be downloaded for further review. Below is an example of the code, in this case, for testing multiplication of two chars.&lt;br /&gt;
 /*******************************************************************************&lt;br /&gt;
 * PIC32 Benchmarking Test Suite&lt;br /&gt;
 * &lt;br /&gt;
 * Test 4 - char Multiplication Duration&lt;br /&gt;
 * Version 1.0&lt;br /&gt;
 * Copyright (C) 2010 Todd H. Poole, Katy Powers, Max Willer&lt;br /&gt;
 * &lt;br /&gt;
 * This test determines the length of time required by the PIC32 chip to multiply&lt;br /&gt;
 * one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
 * &lt;br /&gt;
 * A char data type, in ANSI C, is a value holding one byte, or one character&lt;br /&gt;
 * code. The actual number of bits in a char in a particular implementation is&lt;br /&gt;
 * documented as CHAR_BIT in that implementation&#039;s limits.h file. In practice,&lt;br /&gt;
 * it is almost always 8 bits, corresponding to a decimal range of 0 to 255,&lt;br /&gt;
 * inclusive.&lt;br /&gt;
 *&lt;br /&gt;
 * Given that there are many different ways to multiply one char by another,&lt;br /&gt;
 * we&#039;ve done our best to include several different multiplication methods that&lt;br /&gt;
 * we feel are representative of normal coding practices. Depending on how the&lt;br /&gt;
 * source code is compiled, these different methods may or may not produce&lt;br /&gt;
 * different results.&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
  &lt;br /&gt;
 	 #include &amp;quot;HardwareProfile.h&amp;quot; &lt;br /&gt;
 	 #define PIN_A2 LATAbits.LATA2 //Define the specific pin we&#039;ll use for our tests&lt;br /&gt;
 &lt;br /&gt;
 	char ascii_225;&lt;br /&gt;
 	char ascii_200;&lt;br /&gt;
 	char random_char;&lt;br /&gt;
 &lt;br /&gt;
 	float zero_to_1;&lt;br /&gt;
 	float zero_to_15;&lt;br /&gt;
 	int int_zero_to_15;&lt;br /&gt;
 	int random_int1;&lt;br /&gt;
 	int random_int2;&lt;br /&gt;
 	char random_char1;&lt;br /&gt;
 	char random_char2;&lt;br /&gt;
 	char larger;&lt;br /&gt;
 	char smaller;&lt;br /&gt;
 &lt;br /&gt;
  	int main(void)&lt;br /&gt;
 	{&lt;br /&gt;
 		SYSTEMConfigPerformance(SYS_FREQ);&lt;br /&gt;
 		TRISAbits.TRISA2 = 0; //Setting our testing pin to be an output&lt;br /&gt;
 	&lt;br /&gt;
 	/*Seed the random number generator so we don&#039;t get the same &#039;random&#039;&lt;br /&gt;
 	* numbers over and over again. This is just to ensure that our&lt;br /&gt;
 	* C-compiler doesn&#039;t try to pull any optimization tricks on us.&lt;br /&gt;
 	*/&lt;br /&gt;
 		srand(time(NULL));&lt;br /&gt;
 	&lt;br /&gt;
 	//Finding our first random char&lt;br /&gt;
 	&lt;br /&gt;
 	/*Take the output of rand() - which is a number [0,RAND_MAX] - and&lt;br /&gt;
 	* divide that output by RAND_MAX+1. We now have a number that ranges&lt;br /&gt;
 	* from [0,1). Multiply this result by 16. This will give us a random&lt;br /&gt;
 	* number in the range of [0,16). (I chose 16 because the maximum value&lt;br /&gt;
 	* a char can be is 255. Having our range run from 0 to 16 exclusive will&lt;br /&gt;
 	* ensure that our ints - and, later, our chars - will range from [0,15].&lt;br /&gt;
 	* Thus, regardless of what values our two ints/chars take, the final &lt;br /&gt;
 	* multiplication will fit in a char, which range from 0 to 255 in decimal).&lt;br /&gt;
 	* Cast this result into an int, which will truncate (cut off) the digits&lt;br /&gt;
 	* after the decimal. Thus:&lt;br /&gt;
 	* 0.00001 through 0.99999 will cast to 0.&lt;br /&gt;
 	* 255.00001 through 255.99999 will cast to 255.&lt;br /&gt;
 	* Then, cast our int from an int into a char.&lt;br /&gt;
 	* PS: Yes, I know this doesn&#039;t give us a uniform probability distribution, but&lt;br /&gt;
 	* we&#039;re not too concerned with true randomness... just enough to ensure nothing&lt;br /&gt;
 	* is computed ahead of time by the C-compiler. &lt;br /&gt;
 	*/&lt;br /&gt;
 &lt;br /&gt;
 		zero_to_1 = rand() / RAND_MAX+1; //float that ranges from [0,1)&lt;br /&gt;
 		zero_to_15 = zero_to_1 * 16; //float that ranges from [0,16)&lt;br /&gt;
 		int_zero_to_15 = zero_to_15; //int that ranges from [0,15]&lt;br /&gt;
 		random_int1 = int_zero_to_15; //our first random int&lt;br /&gt;
 		random_char1 = int_zero_to_15; //our first random char&lt;br /&gt;
 &lt;br /&gt;
 	//Finding our second random char &lt;br /&gt;
 	&lt;br /&gt;
 		zero_to_1 = rand() / RAND_MAX+1; //float that ranges from [0,1)&lt;br /&gt;
 		zero_to_15 = zero_to_1 * 16; //float that ranges from [0,256)&lt;br /&gt;
 		int_zero_to_15 = zero_to_15; //int that ranges from [0,255]&lt;br /&gt;
 		random_int2 = int_zero_to_15; //our second random int&lt;br /&gt;
 		random_char2 = int_zero_to_15; //out second random char&lt;br /&gt;
 	&lt;br /&gt;
 	/*By forcing all of our operations to depend on the results of randomly&lt;br /&gt;
 	* generated numbers, we&#039;ve guaranteed that our C-compiler won&#039;t be able to&lt;br /&gt;
 	* interfere with our benchmarks by trying to compute our results in advance.&lt;br /&gt;
 	* This ensures that all operations are performed on the fly by the PIC, and&lt;br /&gt;
 	* that it&#039;s performance will be similar to what one might encounter in other&lt;br /&gt;
 	* projects where all variables and data are not completely known in advance.&lt;br /&gt;
 	*/&lt;br /&gt;
 	&lt;br /&gt;
 	//Time to start the actual benchmarking&lt;br /&gt;
 	&lt;br /&gt;
 		while(1)&lt;br /&gt;
 		{&lt;br /&gt;
 		/*We start our while loop off like this so that we can create an easily&lt;br /&gt;
 		* recognizable pattern on the oscilloscope. We need to be able to&lt;br /&gt;
 		* differentiate between the various tests, and so, after seeing this unique&lt;br /&gt;
 		* pattern, we&#039;ll know that next test to follow will be the first test, the&lt;br /&gt;
 		* test after that will be the second, etc.&lt;br /&gt;
 		*/ &lt;br /&gt;
 		&lt;br /&gt;
 		PIN_A2 = 1;&lt;br /&gt;
 		PIN_A2 = 0;&lt;br /&gt;
 		PIN_A2 = 0;&lt;br /&gt;
 		PIN_A2 = 0;&lt;br /&gt;
 		PIN_A2 = 1;&lt;br /&gt;
 		PIN_A2 = 0;&lt;br /&gt;
 		&lt;br /&gt;
 		//Test 4(a) - Multiplication of Two Constant chars (may be pre-computed)&lt;br /&gt;
 		PIN_A2 = 1;&lt;br /&gt;
 		ascii_225 = &#039;K&#039;*&#039;?&#039;; &lt;br /&gt;
 		PIN_A2 = 0;&lt;br /&gt;
 		&lt;br /&gt;
 		//Test 4(b) - Multiplication of Two ints Cast into a char (may be pre-computed)&lt;br /&gt;
 		PIN_A2 = 1;&lt;br /&gt;
 		ascii_200 = 100*2;&lt;br /&gt;
 		PIN_A2 = 0;&lt;br /&gt;
 		&lt;br /&gt;
 		//Test 4(c) - Mulitplication of Two Random chars (guaranteed not to be pre-comp)&lt;br /&gt;
 		PIN_A2 = 1;&lt;br /&gt;
 		random_char = larger*smaller;&lt;br /&gt;
 		PIN_A2 = 0;&lt;br /&gt;
 		PIN_A2 = 1;		&lt;br /&gt;
 		}&lt;br /&gt;
  	}&lt;br /&gt;
&lt;br /&gt;
[[Media:Kp_mw_tp_ME333PIC32Benchmarking.zip‎]]&lt;br /&gt;
[[Media:Example.ogg]]&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Lab5.xls&amp;diff=16301</id>
		<title>File:Lab5.xls</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Lab5.xls&amp;diff=16301"/>
		<updated>2010-02-16T18:35:27Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: A summary of all test results, in nanoseconds and normalized.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A summary of all test results, in nanoseconds and normalized.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16186</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16186"/>
		<updated>2010-02-16T08:12:29Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to divide two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to divide two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to divide two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the cosine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to take the cosine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to take the cosine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to subtract two constant shorts (may be pre-computed) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 25ns&lt;br /&gt;
*Test b: Time required to subtract two random chars (guaranteed not to be pre-comp) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to add two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to add two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to multiply two constant shorts (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24ns&lt;br /&gt;
*Test b: Time required to multiply two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to divide two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 28ns&lt;br /&gt;
*Test b: Time required to divide two random shorts (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8674ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the sine of a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13014ns&lt;br /&gt;
*Test b: Time required to take the sine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12174ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to subtract two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to subtract two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to add two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 26ns&lt;br /&gt;
*Test b: Time required to add two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instructions:&lt;br /&gt;
**Time: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to multiply two constant ints (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to multiply two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to divide two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to divide two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8737ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random int (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the sine of a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19488ns&lt;br /&gt;
*Test b: Time required to take the sine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 20324ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to subtract two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 186ns&lt;br /&gt;
*Test b: Time required to subtract two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to add two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
*Test b: Time required to add two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to multiply two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
*Test b: Time required to multiply two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to divide two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
*Test b: Time required to divide two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant long long (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 87ns&lt;br /&gt;
*Test b: Time required to sqrt() a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 16311ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant long long (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 188ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to take the sine of a constant long long (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24611ns&lt;br /&gt;
*Test b: Time required to take the sine of a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to subtract two constant floats (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 100ns&lt;br /&gt;
*Test b: Time required to subtract two random floats (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to add two constant floats (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 124ns&lt;br /&gt;
*Test b: Time required to add two random floats (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to multiply two constant floats (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 124ns&lt;br /&gt;
*Test b: Time required to multiply two random floats (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to divide two constant floats (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 99ns&lt;br /&gt;
*Test b: Time required to divide two random floats (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant float (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 99ns&lt;br /&gt;
*Test b: Time required to sqrt() a random float (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8636ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant float (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: N/A&lt;br /&gt;
*Test d: Time required to ^(1/2) a random float (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to take the sine of a constant float (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19574ns&lt;br /&gt;
*Test b: Time required to take the sine of a random float (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant float (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 20311ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random float (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 20297ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 8-bit number (a double).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (b): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to add two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (c): Time required to add of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1236 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to multiply two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 188 ns&lt;br /&gt;
* Test (b): Time required to multiply of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1438 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to divide two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 187 ns&lt;br /&gt;
* Test (b): Time required to divide of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 3184 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root a 64-bit number (a double). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant double (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 188 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a double (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 7998 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: N/A ns *&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: N/A ns *&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had some difficulty in trying to test these particular operations. It seems that the PIC32 is not capable of raising doubles to the 1/2 power.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 20299 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 20624 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to take the cosine of a constant double (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 19762 ns&lt;br /&gt;
* Test (c): Time required to take the cosine of a random double (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 20011 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16182</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16182"/>
		<updated>2010-02-16T08:05:12Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to divide two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to divide two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to divide two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the cosine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to take the cosine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to take the cosine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to subtract two constant shorts (may be pre-computed) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 25ns&lt;br /&gt;
*Test b: Time required to subtract two random chars (guaranteed not to be pre-comp) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to add two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to add two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to multiply two constant shorts (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24ns&lt;br /&gt;
*Test b: Time required to multiply two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to divide two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 28ns&lt;br /&gt;
*Test b: Time required to divide two random shorts (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8674ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the sine of a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13014ns&lt;br /&gt;
*Test b: Time required to take the sine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12174ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to subtract two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to subtract two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to add two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 26ns&lt;br /&gt;
*Test b: Time required to add two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instructions:&lt;br /&gt;
**Time: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to multiply two constant ints (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to multiply two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to divide two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to divide two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8737ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random int (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the sine of a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19488ns&lt;br /&gt;
*Test b: Time required to take the sine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 20324ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to subtract two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 186ns&lt;br /&gt;
*Test b: Time required to subtract two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to add two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
*Test b: Time required to add two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to multiply two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
*Test b: Time required to multiply two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to divide two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
*Test b: Time required to divide two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant long long (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 87ns&lt;br /&gt;
*Test b: Time required to sqrt() a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 16311ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant long long (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 188ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to take the sine of a constant long long (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24611ns&lt;br /&gt;
*Test b: Time required to take the sine of a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 8-bit number (a double).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (b): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to add two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (c): Time required to add of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1236 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to multiply two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 188 ns&lt;br /&gt;
* Test (b): Time required to multiply of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1438 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to divide two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 187 ns&lt;br /&gt;
* Test (b): Time required to divide of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 3184 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16180</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16180"/>
		<updated>2010-02-16T08:00:39Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to divide two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to divide two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to divide two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the cosine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to take the cosine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to take the cosine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to subtract two constant shorts (may be pre-computed) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 25ns&lt;br /&gt;
*Test b: Time required to subtract two random chars (guaranteed not to be pre-comp) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to add two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to add two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to multiply two constant shorts (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24ns&lt;br /&gt;
*Test b: Time required to multiply two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to divide two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 28ns&lt;br /&gt;
*Test b: Time required to divide two random shorts (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8674ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the sine of a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13014ns&lt;br /&gt;
*Test b: Time required to take the sine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12174ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to subtract two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to subtract two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to add two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 26ns&lt;br /&gt;
*Test b: Time required to add two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instructions:&lt;br /&gt;
**Time: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to multiply two constant ints (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to multiply two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to divide two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to divide two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8737ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random int (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the sine of a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19488ns&lt;br /&gt;
*Test b: Time required to take the sine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 20324ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to subtract two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 186ns&lt;br /&gt;
*Test b: Time required to subtract two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to add two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
*Test b: Time required to add two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to multiply two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
*Test b: Time required to multiply two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: Time required to divide two constant long longs (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
*Test b: Time required to divide two random long longs (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant long long (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 87ns&lt;br /&gt;
*Test b: Time required to sqrt() a random long long (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 16311ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant long long (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 8-bit number (a double).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (b): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to add two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (c): Time required to add of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1236 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to multiply two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 188 ns&lt;br /&gt;
* Test (b): Time required to multiply of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1438 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to divide two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 187 ns&lt;br /&gt;
* Test (b): Time required to divide of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 3184 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16179</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16179"/>
		<updated>2010-02-16T07:55:45Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to divide two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to divide two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to divide two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the cosine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to take the cosine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to take the cosine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to subtract two constant shorts (may be pre-computed) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 25ns&lt;br /&gt;
*Test b: Time required to subtract two random chars (guaranteed not to be pre-comp) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to add two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to add two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to multiply two constant shorts (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24ns&lt;br /&gt;
*Test b: Time required to multiply two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to divide two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 28ns&lt;br /&gt;
*Test b: Time required to divide two random shorts (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8674ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the sine of a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13014ns&lt;br /&gt;
*Test b: Time required to take the sine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12174ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to subtract two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to subtract two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to add two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 26ns&lt;br /&gt;
*Test b: Time required to add two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instructions:&lt;br /&gt;
**Time: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to multiply two constant ints (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to multiply two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to divide two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to divide two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8737ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random int (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the sine of a constant int (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19488ns&lt;br /&gt;
*Test b: Time required to take the sine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant int (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 20324ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random int (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 8-bit number (a double).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (b): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to add two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (c): Time required to add of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1236 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to multiply two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 188 ns&lt;br /&gt;
* Test (b): Time required to multiply of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1438 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to divide two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 187 ns&lt;br /&gt;
* Test (b): Time required to divide of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 3184 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16178</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16178"/>
		<updated>2010-02-16T07:50:52Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to divide two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to divide two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to divide two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the cosine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to take the cosine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to take the cosine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to subtract two constant shorts (may be pre-computed) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 25ns&lt;br /&gt;
*Test b: Time required to subtract two random chars (guaranteed not to be pre-comp) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to add two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to add two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to multiply two constant shorts (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24ns&lt;br /&gt;
*Test b: Time required to multiply two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to divide two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 28ns&lt;br /&gt;
*Test b: Time required to divide two random shorts (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8674ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the sine of a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13014ns&lt;br /&gt;
*Test b: Time required to take the sine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12174ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to subtract two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 38ns&lt;br /&gt;
*Test b: Time required to subtract two random ints (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: Time required to add two constant ints (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 26ns&lt;br /&gt;
*Test b: Time required to add two random ints (guaranteed not to be pre-comp) &lt;br /&gt;
**Instructions:&lt;br /&gt;
**Time: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 8-bit number (a double).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (b): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to add two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (c): Time required to add of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1236 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to multiply two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 188 ns&lt;br /&gt;
* Test (b): Time required to multiply of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1438 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to divide two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 187 ns&lt;br /&gt;
* Test (b): Time required to divide of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 3184 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16173</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16173"/>
		<updated>2010-02-16T07:46:40Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to divide two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to divide two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to divide of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the cosine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to take the cosine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to take the cosine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to subtract two constant shorts (may be pre-computed) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 25ns&lt;br /&gt;
*Test b: Time required to subtract of two random chars (guaranteed not to be pre-comp) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to add two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to add of two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to multiply two constant shorts (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24ns&lt;br /&gt;
*Test b: Time required to multiply of two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to divide two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 28ns&lt;br /&gt;
*Test b: Time required to divide of two random shorts (guaranteed not to be pre-comp) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: Time required to sqrt() a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to sqrt() a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 8674ns&lt;br /&gt;
*Test c: Time required to ^(1/2) a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test d: Time required to ^(1/2) a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the sine of a constant short (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13014ns&lt;br /&gt;
*Test b: Time required to take the sine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to take the cosine of a constant short (may be pre-computed)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12174ns&lt;br /&gt;
*Test b: Time required to take the cosine of a random short (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: 26ns&lt;br /&gt;
*Test b: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 8-bit number (a double).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (b): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
* Test (a): Time required to add two constant doubles (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (c): Time required to add of two random doubles (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 1236 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 1438ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 187ns&lt;br /&gt;
*Test b: 3184ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16168</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16168"/>
		<updated>2010-02-16T07:40:09Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to divide two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to divide two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to divide of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to subtract two constant shorts (may be pre-computed) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 25ns&lt;br /&gt;
*Test b: Time required to subtract of two random chars (guaranteed not to be pre-comp) &lt;br /&gt;
** Instruction: &lt;br /&gt;
** Time: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to add two constant shorts (may be pre-computed)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 50ns&lt;br /&gt;
*Test b: Time required to add of two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction: &lt;br /&gt;
**Time: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: Time required to multiply two constant shorts (may be pre-computed) &lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 24ns&lt;br /&gt;
*Test b: Time required to multiply of two random shorts (guaranteed not to be pre-comp)&lt;br /&gt;
**Instruction:&lt;br /&gt;
**Time: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 28ns&lt;br /&gt;
*Test b: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8674ns&lt;br /&gt;
*Test c: 50ns&lt;br /&gt;
*Test d: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 13014ns&lt;br /&gt;
*Test b: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 12174ns&lt;br /&gt;
*Test b: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: 26ns&lt;br /&gt;
*Test b: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 8-bit number (a double).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (b): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1236ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 1438ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 187ns&lt;br /&gt;
*Test b: 3184ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16166</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16166"/>
		<updated>2010-02-16T07:33:11Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: 25ns&lt;br /&gt;
*Test b: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 24ns&lt;br /&gt;
*Test b: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 28ns&lt;br /&gt;
*Test b: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8674ns&lt;br /&gt;
*Test c: 50ns&lt;br /&gt;
*Test d: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 13014ns&lt;br /&gt;
*Test b: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 12174ns&lt;br /&gt;
*Test b: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: 26ns&lt;br /&gt;
*Test b: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 8-bit number (a double).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 199 ns&lt;br /&gt;
* Test (b): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1236ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 1438ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 187ns&lt;br /&gt;
*Test b: 3184ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16128</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16128"/>
		<updated>2010-02-16T05:10:59Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below is the quick summary of the testing results comparing each data type and each operation. All results are normalized to 60ns (1.00 = 60ns).&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Char&lt;br /&gt;
| 1.87 || 1.65 || 2.28 || N/A || 34.78 || 116.03 || 98.93&lt;br /&gt;
|-&lt;br /&gt;
! Short&lt;br /&gt;
| 1.03 || 1.67 || 1.47 || 5.00 || 144.57 || 230.40 || 215.40&lt;br /&gt;
|-&lt;br /&gt;
! Int&lt;br /&gt;
| 1.07 || 1.00 || 1.43 || 8.10 || 145.62 || 316.43 || 330.62&lt;br /&gt;
|-&lt;br /&gt;
! Long Long&lt;br /&gt;
| 2.50 || 3.33 || 6.63 || 28.73 || 271.85 || 498.30 || 510.38&lt;br /&gt;
|-&lt;br /&gt;
! Float&lt;br /&gt;
| 15.00 || 17.07 || 12.27 || 27.90 || 143.93 || 326.03 || 338.28&lt;br /&gt;
|-&lt;br /&gt;
! Double&lt;br /&gt;
| 26.00 || 20.60 || 23.97 || 53.07 || 133.30 || 343.73 || 333.52&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: 25ns&lt;br /&gt;
*Test b: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 24ns&lt;br /&gt;
*Test b: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 28ns&lt;br /&gt;
*Test b: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8674ns&lt;br /&gt;
*Test c: 50ns&lt;br /&gt;
*Test d: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 13014ns&lt;br /&gt;
*Test b: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 12174ns&lt;br /&gt;
*Test b: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: 26ns&lt;br /&gt;
*Test b: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1560ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1236ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 1438ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 187ns&lt;br /&gt;
*Test b: 3184ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16127</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16127"/>
		<updated>2010-02-16T04:52:39Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: 25ns&lt;br /&gt;
*Test b: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 24ns&lt;br /&gt;
*Test b: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 28ns&lt;br /&gt;
*Test b: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8674ns&lt;br /&gt;
*Test c: 50ns&lt;br /&gt;
*Test d: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 13014ns&lt;br /&gt;
*Test b: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 12174ns&lt;br /&gt;
*Test b: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: 26ns&lt;br /&gt;
*Test b: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1560ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1236ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 1438ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 187ns&lt;br /&gt;
*Test b: 3184ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16017</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16017"/>
		<updated>2010-02-16T00:18:26Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Test a&lt;br /&gt;
| 50ns || 50ns || 49ns || 48ns || 48ns || 9963ns || 9111ns&lt;br /&gt;
|-&lt;br /&gt;
! Test b&lt;br /&gt;
| 50ns || 50ns || 48ns || 50ns || 48ns || 9550ns || 8724ns&lt;br /&gt;
|-&lt;br /&gt;
! Test c&lt;br /&gt;
| 112ns || 99ns || 137ns || N/A || 2087ns || 6962ns || 5936ns&lt;br /&gt;
|-&lt;br /&gt;
! Test d&lt;br /&gt;
| N/A || N/A || N/A || N/A || 48ns || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
! Test e&lt;br /&gt;
| N/A || N/A || N/A || N/A || 48ns || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
! Test f&lt;br /&gt;
| N/A || N/A || N/A || N/A || 75ns || N/A || N/A&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: 25ns&lt;br /&gt;
*Test b: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 24ns&lt;br /&gt;
*Test b: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 28ns&lt;br /&gt;
*Test b: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8674ns&lt;br /&gt;
*Test c: 50ns&lt;br /&gt;
*Test d: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 13014ns&lt;br /&gt;
*Test b: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 12174ns&lt;br /&gt;
*Test b: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: 26ns&lt;br /&gt;
*Test b: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1560ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1236ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 1438ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 187ns&lt;br /&gt;
*Test b: 3184ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16006</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=16006"/>
		<updated>2010-02-15T22:01:09Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
&lt;br /&gt;
The six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin high on the NU32 development board, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute an operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Several tests contained multiple procedures that explored various ways to carry out a given mathematical operation on a given data type. For example, in the multiplication tests, not only did we test the traditional multiplication operator (*), but also the bitwise left shift operator (&amp;lt;&amp;lt;). Our goal was to find out if one particular operator was faster than the other. Similarly, we also included procedures that performed the above operations on hard-coded numbers (such as 347) as well as randomly chosen numbers stored in variables (such as &#039;random_int1&#039;). We wanted to ensure that the compiler didn&#039;t compute the results of each operation in advance. While pre-compiling can indeed afford welcome increases in execution time, situations in which the compiler can&#039;t optimize the operations ahead of time (for example, situations where the data to be operated on is not known in advance) are still common occurrences and are worth benchmarking.&lt;br /&gt;
&lt;br /&gt;
Accordingly, several tests contain multiple procedures that not only account for multiple methods of performing a particular operation, but multiple sets of numbers to perform those operations on.&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each operation and data-type pair.&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are the results of each particular test we performed, coupled with a short explanation for each result. &lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) ===&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
* Test (a): Time required to throw an output pin high&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (b): Time required to pull an output pin low&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;PIN_A2 = 0;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 63 ns&lt;br /&gt;
* Test (c): Time required to execute 1 empty while loop cycle &lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;while(1){}&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 23 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
----&lt;br /&gt;
A &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s &amp;lt;code&amp;gt;limits.h&amp;lt;/code&amp;gt; file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255 inclusive. Unless otherwise noted, all (a) benchmarks are operations on two predefined (and mot likely pre-computed) ASCII letters, all (b) benchmarks are operations on two predefined (and most likely pre-computed) numbers in the range of 0 to 255, and all (c) benchmarks are operations on two random (and most likely &#039;&#039;&#039;not&#039;&#039;&#039; pre-computed) numbers. These multiple benchmarks per test exist to illustrate the differences in execution time between pre-compiled operations and operations the PIC must perform in real time. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! Subtraction !! Addition !! Multiplication !! Division !! Square Root !! Sine !! Cosine !!&lt;br /&gt;
|-&lt;br /&gt;
! Test a&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! Test b&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! Test c&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! Test d&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! Test e&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! Test f&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_capital_a = &#039;z&#039;-&#039;7&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 100-2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger-smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 112 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to add two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_a = &#039;)&#039;+&#039;8&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (b): Time required to add two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_b = 97+1;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to add of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = random_char1+random_char2;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 99 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to multiply two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_225 = &#039;K&#039;*&#039;♥&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 49 ns&lt;br /&gt;
* Test (b): Time required to multiply two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_200 = 100*2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to multiply of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger*smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 137 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = &#039;K&#039;/&#039;♥&#039;; //thp&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = 100/2;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 50 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = larger/smaller;&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; We had great difficulty in trying to test this particular operation. After some research with an oscilloscope and voltmeter, it seems that the PIC32 is not capable of dividing chars in this way. More specifically, every time the PIC32 attempts to divide one char by another, all output pins are immediately grounded. We&#039;ve tested this code in other C environments, and it works as expected, so the error must either lie somewhere within our specific PICs (which would be very unlikely - we tested 3) or the silicon architecture of the PIC32 itself (sill unlikely, but given the number of PICs we tested, more probable). If you absolutely need to divide chars, cast them to ints first, perform your division, then cast them back to chars.&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (c): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
&lt;br /&gt;
 | image4    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt4      = Test (d): Time required to throw an output pin high&lt;br /&gt;
 | caption4  = Caption4&lt;br /&gt;
&lt;br /&gt;
 | image5    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt5      = Test (e): Time required to pull an output pin low&lt;br /&gt;
 | caption5  = Caption5&lt;br /&gt;
&lt;br /&gt;
 | image6    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt6      = Test (f): Time required to pull an output pin low&lt;br /&gt;
 | caption6  = Caption6&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Benchmarks (a) through (c) use the &amp;lt;code&amp;gt;sqrt()&amp;lt;/code&amp;gt; function while benchmarks (d) through (f) raise the operands to the 1/2 power.&lt;br /&gt;
* Test (a): Time required to sqrt() a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sqrt(&#039;u&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (b): Time required to sqrt() an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = sqrt(100);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (c): Time required to sqrt() a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sqrt(random_char1);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 2087 ns&lt;br /&gt;
* Test (d): Time required to ^(1/2) a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = (&#039;u&#039;)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (e): Time required to ^(1/2) an int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;number_10 = (100)^(1/2);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 48 ns&lt;br /&gt;
* Test (f): Time required to ^(1/2) a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = (random_char2)^(1/2);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 75 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the sine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to take the sine of a constant char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = sin(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9963 ns&lt;br /&gt;
* Test (b): Time required to take the sine of a constant int cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = sin(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9550 ns&lt;br /&gt;
* Test (c): Time required to take the sine of a random char (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = sin(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 6962 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
{{multiple image&lt;br /&gt;
 | width     = 100&lt;br /&gt;
 | footer    = Execution waveforms as seen on the output pin&lt;br /&gt;
&lt;br /&gt;
 | image1    = test1-whileloop-onoff-timetogohigh.png&lt;br /&gt;
 | alt1      = Test (a): Time required to throw an output pin high&lt;br /&gt;
 | caption1  = Caption1&lt;br /&gt;
&lt;br /&gt;
 | image2    = test1-whileloop-onoff-timetogolow.png&lt;br /&gt;
 | alt2      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption2  = Caption2&lt;br /&gt;
&lt;br /&gt;
 | image3    = test1-whileloop-onoff-pair.png&lt;br /&gt;
 | alt3      = Test (b): Time required to pull an output pin low&lt;br /&gt;
 | caption3  = Caption3&lt;br /&gt;
}}&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to take the cosine of an 8-bit number (a char).&lt;br /&gt;
* Test (a): Time required to subtract two constant chars (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;ascii_25 = cos(&#039;K&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 9111 ns&lt;br /&gt;
* Test (b): Time required to subtract two ints cast into a char (may be pre-computed)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;letter_2 = cos(50);&amp;lt;/code&amp;gt;&lt;br /&gt;
** Time: 8724 ns&lt;br /&gt;
* Test (c): Time required to subtract of two random chars (guaranteed not to be pre-comp)&lt;br /&gt;
** Instruction: &amp;lt;code&amp;gt;random_char = cos(larger);&amp;lt;/code&amp;gt;*&lt;br /&gt;
** Time: 5936 ns&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;See Code section for a more details on how randomness was guaranteed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
----&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: 25ns&lt;br /&gt;
*Test b: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 24ns&lt;br /&gt;
*Test b: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 28ns&lt;br /&gt;
*Test b: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8674ns&lt;br /&gt;
*Test c: 50ns&lt;br /&gt;
*Test d: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 13014ns&lt;br /&gt;
*Test b: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 12174ns&lt;br /&gt;
*Test b: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
----&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: 26ns&lt;br /&gt;
*Test b: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
----&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
----&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1560ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1236ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 1438ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 187ns&lt;br /&gt;
*Test b: 3184ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=15587</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=15587"/>
		<updated>2010-02-10T06:06:09Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
* &amp;gt;&amp;gt;1&lt;br /&gt;
* &amp;gt;&amp;gt;4&lt;br /&gt;
&lt;br /&gt;
We six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin on the NU32 development board high, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute any specific mathematical operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each (operation, data-type) pair.&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
&lt;br /&gt;
A summary of what we determined in each test... (things like period, frequency, special notes, blah blah)&lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) === &lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
*Test a: Pin high. Time: 63ns&lt;br /&gt;
*Test b: Pin low. Time: 63ns&lt;br /&gt;
*Test c: While loop. Time: 23ns&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
A char data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s limits.h file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255, inclusive. Unless otherwise noted, all (a) is an operation with two predefined ASCII letters, all (b) is an operation with two predefined numbers in the range of 0 to 255, and all (c) is an operation with two random numbers. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 50ns&lt;br /&gt;
*Test c: 112ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 50ns&lt;br /&gt;
*Test c: 99ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
*Test a: 49ns&lt;br /&gt;
*Test b: 48ns&lt;br /&gt;
*Test c: 137ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
*Test a: 48ns&lt;br /&gt;
*Test b: 50ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Tests (a) thru (c) use the &#039;sqrt()&#039; method while tests (d) thru (f) use the char to the 1/2 power.&lt;br /&gt;
*Test a: 48ns&lt;br /&gt;
*Test b: 48ns&lt;br /&gt;
*Test c: 2087ns&lt;br /&gt;
*Test d: 48ns&lt;br /&gt;
*Test e: 48ns&lt;br /&gt;
*Test f: 75ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 8-bit number (a char).&lt;br /&gt;
*Test a: 9963ns&lt;br /&gt;
*Test b: 9550ns&lt;br /&gt;
*Test c: 6962ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 8-bit number (a char).&lt;br /&gt;
*Test a: 9111ns&lt;br /&gt;
*Test b: 8724ns&lt;br /&gt;
*Test c: 5936ns&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: 25ns&lt;br /&gt;
*Test b: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 24ns&lt;br /&gt;
*Test b: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 28ns&lt;br /&gt;
*Test b: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8674ns&lt;br /&gt;
*Test c: 50ns&lt;br /&gt;
*Test d: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 13014ns&lt;br /&gt;
*Test b: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 12174ns&lt;br /&gt;
*Test b: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: 26ns&lt;br /&gt;
*Test b: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1560ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1236ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 1438ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 187ns&lt;br /&gt;
*Test b: 3184ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 7998ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=15586</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=15586"/>
		<updated>2010-02-10T06:03:15Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
* &amp;gt;&amp;gt;1&lt;br /&gt;
* &amp;gt;&amp;gt;4&lt;br /&gt;
&lt;br /&gt;
We six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin on the NU32 development board high, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute any specific mathematical operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each (operation, data-type) pair.&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
&lt;br /&gt;
A summary of what we determined in each test... (things like period, frequency, special notes, blah blah)&lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) === &lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
*Test a: Pin high. Time: 63ns&lt;br /&gt;
*Test b: Pin low. Time: 63ns&lt;br /&gt;
*Test c: While loop. Time: 23ns&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
A char data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s limits.h file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255, inclusive. Unless otherwise noted, all (a) is an operation with two predefined ASCII letters, all (b) is an operation with two predefined numbers in the range of 0 to 255, and all (c) is an operation with two random numbers. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 50ns&lt;br /&gt;
*Test c: 112ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 50ns&lt;br /&gt;
*Test c: 99ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
*Test a: 49ns&lt;br /&gt;
*Test b: 48ns&lt;br /&gt;
*Test c: 137ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
*Test a: 48ns&lt;br /&gt;
*Test b: 50ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Tests (a) thru (c) use the &#039;sqrt()&#039; method while tests (d) thru (f) use the char to the 1/2 power.&lt;br /&gt;
*Test a: 48ns&lt;br /&gt;
*Test b: 48ns&lt;br /&gt;
*Test c: 2087ns&lt;br /&gt;
*Test d: 48ns&lt;br /&gt;
*Test e: 48ns&lt;br /&gt;
*Test f: 75ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 8-bit number (a char).&lt;br /&gt;
*Test a: 9963ns&lt;br /&gt;
*Test b: 9550ns&lt;br /&gt;
*Test c: 6962ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 8-bit number (a char).&lt;br /&gt;
*Test a: 9111ns&lt;br /&gt;
*Test b: 8724ns&lt;br /&gt;
*Test c: 5936ns&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a: 25ns&lt;br /&gt;
*Test b: 62ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 100ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 24ns&lt;br /&gt;
*Test b: 88ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a: 28ns&lt;br /&gt;
*Test b: 300ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8674ns&lt;br /&gt;
*Test c: 50ns&lt;br /&gt;
*Test d: 76ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 13014ns&lt;br /&gt;
*Test b: 13824ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a: 12174ns&lt;br /&gt;
*Test b: 12924ns&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 64ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a: 26ns&lt;br /&gt;
*Test b: 60ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 86ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a: 38ns&lt;br /&gt;
*Test b: 486s&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 50ns&lt;br /&gt;
*Test b: 8737ns&lt;br /&gt;
*Test c: 88ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 19488ns&lt;br /&gt;
*Test b: 18988ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a: 20324ns&lt;br /&gt;
*Test b: 19837ns&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a: 186ns&lt;br /&gt;
*Test b: 150ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a: 88ns&lt;br /&gt;
*Test b: 200ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 398ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a: 74ns&lt;br /&gt;
*Test b: 1724ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 87ns&lt;br /&gt;
*Test b: 16311ns&lt;br /&gt;
*Test c: 188ns&lt;br /&gt;
*Test d: 74ns&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 23837ns&lt;br /&gt;
*Test b: 29898ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a: 24611ns&lt;br /&gt;
*Test b: 30623ns&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a: 100ns&lt;br /&gt;
*Test b: 900ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 1024ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 124ns&lt;br /&gt;
*Test b: 736ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 1674ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a: 99ns&lt;br /&gt;
*Test b: 8636ns&lt;br /&gt;
*Test c: N/A&lt;br /&gt;
*Test d: N/A&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 19574ns&lt;br /&gt;
*Test b: 19562ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a: 20311ns&lt;br /&gt;
*Test b: 20297&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1560ns&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
*Test a: 199ns&lt;br /&gt;
*Test b: 1236ns&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 188ns&lt;br /&gt;
*Test b: 1438ns&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a: 187ns&lt;br /&gt;
*Test b: 3184ns&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c:&lt;br /&gt;
*Test d:&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 20299ns&lt;br /&gt;
*Test b: 20624ns&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a: 19762ns&lt;br /&gt;
*Test b: 20011ns&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=15585</id>
		<title>PIC32MX: Benchmarking Mathematical Operations</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Benchmarking_Mathematical_Operations&amp;diff=15585"/>
		<updated>2010-02-10T04:42:23Z</updated>

		<summary type="html">&lt;p&gt;MaxWiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Your assignment is to empirically test how long it takes to perform add, subtract, multiply, divide, sqrt, sin, and cos operations with the 80 MHz PIC32460F512L and our standard code optimization setting.  You will do these tests with chars (8-bit integers), shorts (16-bit), integers (32-bit), long long integers (64-bit), floats (32-bit single precision floating point), and double (64-bit double-precision floating point).  The integers can be unsigned or signed.  Your end result will be a table with the operation on one axis (likely the horizontal axis) and the kind of variable on the other axis, and each cell of the table will have a normalized duration for the operation.  The time will be normalized by the fastest operation, so the smallest number in the table will be 1.00.  All other numbers will indicate how many times longer that operation takes.  All numbers will have two decimal places, e.g., 2.57 or 24.72.  You will also give the time that 1.00 corresponds to in nanoseconds.&lt;br /&gt;
&lt;br /&gt;
Since bit-shifting left and right correspond to a version of multiplying and dividing, you should also include the operations &amp;gt;&amp;gt;1 and &amp;gt;&amp;gt;4 and &amp;lt;&amp;lt;1 and &amp;lt;&amp;lt;4.  (If the results are identical, you can eliminate shift left from your table.)&lt;br /&gt;
&lt;br /&gt;
To generate this table, you can set an output bit low before the operation, then high immediately after the operation, and measure the time on an oscilloscope.  Two things to consider:  (1) Time a single operation, over and over, with a short delay between the operation.  This should create a pulse train on your oscilloscope.  Can you get an accurate estimate of the time this way?  You could also try doing five or ten operations between changing the digital output.  See if this gives the same estimate.  (This estimate might be more accurate as you are essentially averaging over a number of operations.)  Avoid using arrays and for loops in your test, as indexing arrays and running the loop each take time.  (2)  Make sure the compiler doesn&#039;t compute the results in advance.  You could try testing operations with numbers generated randomly (don&#039;t time this operation!) vs. numbers that you just type in manually to make sure that both are giving you the same result.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
We were tasked with determining the real-time cost (measured in nanoseconds) of performing seven basic mathematical operations with each one of the six commonly used ANSI C data types.&lt;br /&gt;
&lt;br /&gt;
The mathematical operations we tested were:&lt;br /&gt;
* subtraction&lt;br /&gt;
* addition&lt;br /&gt;
* multiplication&lt;br /&gt;
* division&lt;br /&gt;
* square root&lt;br /&gt;
* sine&lt;br /&gt;
* cosine&lt;br /&gt;
* &amp;gt;&amp;gt;1&lt;br /&gt;
* &amp;gt;&amp;gt;4&lt;br /&gt;
&lt;br /&gt;
We six data types we tested each operation on were:&lt;br /&gt;
* char&lt;br /&gt;
* short&lt;br /&gt;
* integer&lt;br /&gt;
* long long&lt;br /&gt;
* float&lt;br /&gt;
* double&lt;br /&gt;
&lt;br /&gt;
Our testing procedure was simple: throw an output pin on the NU32 development board high, perform a mathematical operation with a given data type, and then pull the same pin low. &lt;br /&gt;
&lt;br /&gt;
Placing the above three steps in an infinite while loop afforded us the opportunity to use an oscilloscope to measure the duration between each high-low pair in the output waveform. After subtracting the time it took for the PIC to raise and lower the voltage on the output pin (something we previously measured), we were able to determine the amount of time required for the PIC32 chip to execute any specific mathematical operation with a high level of accuracy.&lt;br /&gt;
&lt;br /&gt;
With seven operations to perform on six different data types, we created the following table to help us assign and keep track of the various tests we planned to run:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right;&amp;quot; border=&amp;quot;0&amp;quot; CELLSPACING = &amp;quot;10&amp;quot; FRAME = &amp;quot;LEFT&amp;quot;&lt;br /&gt;
|+Operation vs. Data type&lt;br /&gt;
|-&lt;br /&gt;
!  !! char (8-bit) !! short (16-bit) !! int (32-bit) !! long long (64-bit) !! float (32-bit) !! double (64-bit)&lt;br /&gt;
|-&lt;br /&gt;
! subtraction&lt;br /&gt;
| Test 2 || Test 9 || Test 16 || Test 23 || Test 30 || Test 37&lt;br /&gt;
|-&lt;br /&gt;
! addition&lt;br /&gt;
| Test 3 || Test 10 || Test 17 || Test 24 || Test 31 || Test 38&lt;br /&gt;
|-&lt;br /&gt;
! multiplication&lt;br /&gt;
| Test 4 || Test 11 || Test 18 || Test 25 || Test 32 || Test 39&lt;br /&gt;
|-&lt;br /&gt;
! division&lt;br /&gt;
| Test 5 || Test 12 || Test 19 || Test 26 || Test 33 || Test 40&lt;br /&gt;
|-&lt;br /&gt;
! square root&lt;br /&gt;
| Test 6 || Test 13 || Test 20 || Test 27 || Test 34 || Test 41&lt;br /&gt;
|-&lt;br /&gt;
! sine&lt;br /&gt;
| Test 7 || Test 14 || Test 21 || Test 28 || Test 35 || Test 42&lt;br /&gt;
|-&lt;br /&gt;
! cosine&lt;br /&gt;
| Test 8 || Test 15 || Test 22 || Test 29 || Test 36 || Test 43&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Test 1 was used to determine the duration required for the PIC32 to throw a pin high and pull a pin low, while Tests 2 through 43 were used to measure the actual performance of each (operation, data-type) pair.&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
&lt;br /&gt;
A summary of what we determined in each test... (things like period, frequency, special notes, blah blah)&lt;br /&gt;
&lt;br /&gt;
=== Basic Timing Constants (Test 1) === &lt;br /&gt;
This test determines the length of time required by the PIC32 chip to push a given output pin high and pull the same pin low.&lt;br /&gt;
&lt;br /&gt;
=== char Performance ===&lt;br /&gt;
A char data type, in ANSI C, is a value holding one byte, or one character code. The actual number of bits in a char in a particular implementation is documented as CHAR_BIT in that implementation&#039;s limits.h file. In practice, it is almost always 8 bits, corresponding to a decimal range of 0 to 255, inclusive. Unless otherwise noted, all (a) is an operation with two predefined ASCII letters, all (b) is an operation with two predefined numbers in the range of 0 to 255, and all (c) is an operation with two random numbers. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 2) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 8-bit number (a char) from another 8-bit number (a char).&lt;br /&gt;
*Test a: &lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c: &lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 3) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 8-bit number (a char) to another 8-bit number (a char).&lt;br /&gt;
*Test a: &lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c: &lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 4) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
*Test a: &lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c: &lt;br /&gt;
&lt;br /&gt;
==== Division (Test 5) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 8-bit number (a char) by another 8-bit number (a char).&lt;br /&gt;
*Test a: &lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c: &lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 6) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to square root one 8-bit number (a char). Tests (a) thru (c) use the &#039;sqrt()&#039; method while tests (d) thru (f) use the char to the 1/2 power.&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c:&lt;br /&gt;
*Test d:&lt;br /&gt;
*Test e:&lt;br /&gt;
*Test f:&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 7) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 8-bit number (a char).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c:&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 8) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 8-bit number (a char).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c:&lt;br /&gt;
&lt;br /&gt;
=== short Performance ===&lt;br /&gt;
A short data type, in ANSI C, is a value that holds 2 bytes, or 16 bits. This corresponds to a range of 0 to 65535 (2^16 - 1). If the variable is signed (negative), then the range is from -32767 to 32767 (-2^15 + 1 to 2^15 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 9) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 16-bit number (a short) from another 16-bit number (a short).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 10) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 16-bit number (a short) to another 16-bit number (a short).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 11) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 12) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 16-bit number (a short) by another 16-bit number (a short).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 13) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 16-bit number (a short). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c:&lt;br /&gt;
*Test d:&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 14) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 16-bit number (a short).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 15) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 16-bit number (a short).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
===int Performance===&lt;br /&gt;
An int data type, in ANSI C, is a value that holds 4 bytes, or 32 bits. This corresponds to a range of 0 to 4294967295 (2^32 - 1). If the variable is signed (negative), then the range is from -2147483647 to 2147483647 (-2^31 + 1 to 2^31 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 16) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (an int) from another 32-bit number (an int).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 17) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (an int) to another 32-bit number (an int).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 18) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 19) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (an int) by another 32-bit number (an int).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 20) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (an int). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c:&lt;br /&gt;
*Test d:&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 21) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (an int).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 22) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (an int).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
===long long Performance===&lt;br /&gt;
An long long data type, in ANSI C, is a value that holds 8 bytes, or 64 bits. This corresponds to a range of 0 to 1.84467441 × 10^19 (2^64 - 1). If the variable is signed (negative), then the range is from -9.22337204 × 10^18 to 9.22337204 × 10^18 (-2^63 + 1 to 2^63 -1). In this series of tests, tests (a) are with a predefined number, and tests (b) are with a random number. This is in order to test times for pre-compiled operations and operations on the PIC.&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 23) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a long long) from another 64-bit number (a long long).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 24) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a long long) to another 64-bit number (a long long).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 25) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 26) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a long long) by another 64-bit number (a long long).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 27) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a long long). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c:&lt;br /&gt;
*Test d:&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 28) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a long long).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 29) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a long long).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
===float Performance===&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 30) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 32-bit number (a float) from another 32-bit number (a float).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 31) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 32-bit number (a float) to another 32-bit number (a float).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 32) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 33) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 32-bit number (a float) by another 32-bit number (a float).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 34) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 32-bit number (a float). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c:&lt;br /&gt;
*Test d:&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 35) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 32-bit number (a float).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 36) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 32-bit number (a float).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
===double Performance===&lt;br /&gt;
&lt;br /&gt;
==== Subtraction (Test 37) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to subtract one 64-bit number (a double) from another 64-bit number (a double).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Addition (Test 38) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to add one 64-bit number (a double) to another 64-bit number (a double).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Multiplication (Test 39) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to multiply one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Division (Test 40) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to divide one 64-bit number (a double) by another 64-bit number (a double).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Square Root (Test 41) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the square root of one 64-bit number (a double). Tests (a) and (b) use the &#039;sqrt()&#039; method, while tests (c) and (d) use a number to the 1/2 power.&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
*Test c:&lt;br /&gt;
*Test d:&lt;br /&gt;
&lt;br /&gt;
==== Sine (Test 42) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the sine of one 64-bit number (a double).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
==== Cosine (Test 43) ====&lt;br /&gt;
This test determines the length of time required by the PIC32 chip to get the cosine of one 64-bit number (a double).&lt;br /&gt;
*Test a:&lt;br /&gt;
*Test b:&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
===Test 1===&lt;br /&gt;
This is the first test.&lt;br /&gt;
&lt;br /&gt;
===Test 2===&lt;br /&gt;
This is the second test.&lt;br /&gt;
&lt;br /&gt;
Blah blah blah, I would really like to be watching the super bowl right about now. /sigh.&lt;/div&gt;</summary>
		<author><name>MaxWiller</name></author>
	</entry>
</feed>