The report .

 

The program in assembler language was divided in 3 parts.

            - Initiation-part.

            - Reading.

            - Writing on the display.

 

            The initiation is only used in the beginning of the program, while the two other parts are repeated. The initiation consists of the initiation of the display, what must be done in a certain order, the initiation of the interrupts and the 2 serial ports. (SCI and SPI)

 

            The reading part consists for starters of  the reading of 1024 values of the torque through the AD Converter. We knew that this number of points was easier to handle afterwards , namely for dividing them after with the hexadecimal number 400. When we read this number of points, we calculate the sum of it in the mean while . This sum was necessary to calculate the average. In the mean time, we needed to save all the points in the memory, to calculate the deviation afterwards . Our values were 12-bit values (12-bit ADC), so we saved them in a 16-bit memory.

            For the sum, we knew that 1024 values of a 12-bit would give us a sum in 24 bit. By only taking the 16 most important bits, we had already divided it by $100. In the ‘gemmidelde’-procedure, we only divide the first two bytes by 4, what gives us the value of the average. This is saved under the name ‘admsb’ and ‘adlsb.

            In order to calculate the deviation, we simply took the difference between every measured value and the average of the torque.

Dev = ( S çvalue - average÷ ) /n

 

The problem in order to calculate this value , was the presence of negative values, that had to be made positive. In the assembler, you take the difference between $0001 and $0002, this gives $FFFF. We made a special procedure when the carry bit was activated, that gives us $0001 in this case. To make the sum, we took the same procedure as used for calculating the average. The solution has the form ‘devmsb’ and ‘devlsb’.

 

            For the speed, given in RPM, we used two interrupts. The first was a timer overflow interrupt. We putted the speed of the timer to an overflow of 0.5sec. We first wait for the timer to make a first overflow, as we don’t know were it is in the beginning. After that we wait for 2 overflows after quitting the procedure and stop the interrupts. So we count for a total of 1 sec. In the mean time, we have an input capture interrupt, that counts every time we have a new pulse. So, we can count the number of pulses during 1 second, which makes it possible to give the number of revolutions, because we receive 60 pulses per turn. The two values are given by ‘teller1’ and ‘teller2’.

 

After the reading process, we begin to write what we have measured on the screen. For this we used 4 outputs available on the port A. We have to send the symbol in ASCII-code , followed by a R/S and R/W code. This is given in the database of the display. To send it to it, we needed the digital/parallel transmitter. For every bit to send, we brought the port A4 to 0 or 1, and then set the clock (port A4) one time to 1, and afterwards back to 0. So the bit is sent. If we repeat this for every bit, by rotating the accumulator, we send the code through the transmitter. After writing the two bytes to the transmitter, we send it by enabling the display, and open the output of the transmitter. This way , we can write on the display whatever we want . We used this basic procedure called ‘WriteLcd’ to send everything to the display. When we had a value in the memory that we wanted to write on the display, we simply had to divide it by 1000, 100, 10 and 1, and send everything to the display in ASCII-code. That is written in procedure ‘Schrijf_koppel’ as example.

            For other instructions to send to the display, as an initiation for example, we always used the same procedure, by simply change the content of the code transferred to the display.