Means of
Measurement --- Data into
Numbers
|
How the chips turn data into numbers
Detection: The data is turned into numbers within a microcontroller. One of many intrinsic features of the PIC family is Timers. The Timer's asymmetric nature grants the controller the ability to perform multiple task at the same time. In this application, 2 task running in tandem are detection loops and counter incrementation. Beginning with the detection loop. The first line of the assembly routine test the logical HI-LOW state on the first sensor SENSOR_1. As long as the sensor returns a logic LOW, the test will fail and the controller continues to process the following line. What places these two lines into a loop is the value of the GOTO statement: $ - 1. This says to jump from present location back up to the first line. When the sensor does return a logic HIGH, the test passes and the controller continues to process not the following line but the next line. In this application, when an object blocks the first InfraRed line of sight, the test passes, loop ends, and counter incrementation begins. ;DETECTION AND TIMING OF PROJECTILE GET_VELOCITY: ;DUAL SENSOR DETECTION. BTFSS SENSOR_1 ;AWAIT DETECTION: ACTIVE HI. GOTO $ - 1 CLRF TMR1L ;THEN, START TIMING. CLRF TMR1H CALL USEC_10 BTFSS SENSOR_2 ;NEXT, AWAIT DETECTION: ACTIVE HI. GOTO $ - 1 MOVF_F TMR1L, TIME_LO ;FINALY, COPY TIMER1 INTO LO/HI BYTES. MOVF_F TMR1H, TIME_HI RETURN |
How the chips turn data into numbers
Counter: Clearing TIMER1 begins the counter incrementation of a 16-bit register. Due to the PIC16F628 being an 8-bit controller, TIMER1 is composed of (2) 8-bit registers, TMR1H / TMR1L designated for the high and low bytes. From the perspective of the assembly code, clearing TIMER1 is all that takes place and execution follows through. Now in the background, while the code follows through to process the status of sensor 2, TIMER1 is actually increment inside the PIC. The incrementation starts from hex 0x0000 to a maxium of 0xFFFF (65,535). The rate of incrementation is based on the formula: Frequency(instruction) = Clock / 4, Clock = 4MHZ Time(increment) = 1 / Frequency (instruction) ~~> 1 microsecond Back to the foreground, just as the first line did its test, another detection loop processes a logical HI-LOW test on the second sensor SENSOR_2. Apon a passing test, object blocks the second IR line of site, the loop terminates and execution follows through onto copying the measured time. The variables TIME_LO and TIME_HI now hold the recorded time between two detectors in microseconds. ;DETECTION AND TIMING OF PROJECTILE
GET_VELOCITY: ;DUAL SENSOR DETECTION. BTFSS SENSOR_1 ;AWAIT DETECTION: ACTIVE HI. GOTO $ - 1 CLRF TMR1L ;THEN, START TIMING. CLRF TMR1H CALL USEC_10 BTFSS SENSOR_2 ;NEXT, AWAIT DETECTION: ACTIVE HI. GOTO $ - 1 MOVF_F TMR1L, TIME_LO ;FINALY, COPY TIMER1 INTO LO/HI BYTES. MOVF_F TMR1H, TIME_HI RETURN Next ~~> Display Page <~~~ 1, 2, 3, ~~~> |
How the chips turn data into numbers
Display: Ok thats done. So how does one extricate a 16-bit representation of time from the PIC into a form visually recognizable? Here is a list of methods with increasing complexity: * 16 binary LED * 7 Segment LED * Liquid Crystal Display * PC download to program LED and 7 segment LED are both good practicing excercises. However, these two method are limited in their display. Here is where an LCD takes preference. LCD does not require the user to convert binary into decimal. LCD conveys more information within one glance, no need to scroll/shift digits. LCD allocates less controller input/output lines. LCD displays measured time and velocity simultaneously and may include basic graphics. And it simply looks better. With or without and LCD, a PC program completes the ensemble. I designed a coilgun acquisition program using Visual Basic. From one location you can view times, velocities, and efficiencies after every test shot. Projectile properties are saved in a projectile list database. Tools are also at the user's disposal impowering the prediction of results from manually entered values. Page <~~~ 1, 2, 3 ~~~> |
Navigation | ||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|