Development of a Resistance Tester for Production Tests
Content
Introduction---------------------------------------------------------------------------------------3
Chapter 1 State Diagram------------------------------------------------------------------------5
Chapter 2 C Programming ---------------------------------------------------------------------8
Chapter 3 Circuit Diagram & Simulation---------------------------------------------------14
Conclusion---------------------------------------------------------------------------------------22
Reference----------------------------------------------------------------------------------------22
1. Introduction
A Factory Goods Inspection Department needs to test large numbers of 1000-ohm resistors to an accuracy of ±5%. To save time, a PIC microcontroller based Resistance Tester is to be designed to do this job. In this essay, it provides a state diagram of the system, a circuit diagram which draw by Proteus and a C programming to show how it works.
The basic design is to be based on a PIC16f818 which has a 10 bit Analogue to
Digital Converter (ADC) that can be used to measure the resistor being tested.
One way to measure resistance is to use a constant current generator to force a known current through the resistor and measure the voltage across the resistor to obtain the voltage equivalent of the resistance under test value.
The resistors to be measured are incorporated in a Bandoleer that is mounted onto the drum of the tester by the user.
A Stepper Motor can rotate the drum, so as to move each resistor under the Test Probes.
The Stepper Motor is rotated by the PIC by providing a pulse to the Stepper Motor four windings in a manner that will cause the Stepper Motor to rotate. You will need to do a Google search to find a suitable Stepper Motor step sequence. This should follow the ‘Full Step’ sequence. Details of this Stepper Motor sequence must be included in this assignment report.
Once the first resistor has been set up to lie under the Test Probes by the user, four steps of the stepper motor will move the next resistor to be tested under the test probes.
The tester can be started by pressing the Start switch, and stopped by pressing the
Stop switch. When stopped, the Start switch can be used to re-start the tester again so as to continue testing.
When the tester is first started, if the first five resistors that are tested are found to be outside the ±5% limit a warning LED indicator is to be turned on to indicate that the bandoleer may contain the wrong resistors. Otherwise all resistors are to be tested, and a count of all resistors that fail the test kept. There is an Ink Jet Solenoid to squirt an ink mark onto all faulty resistors for identification purposes. In the event that the first 5 resistors are read as faulty the tester stops and a separate ‘back’ switch can be used to move the resistor reel back to the first resistor so that the resistor bandoleer can be replaced with correct resistor values.
The tester is to make use of the LCD display to indicate "Tester Ready", "Testing in
Progress", "Tester Stopped", and "Resistors Failed is" followed by the number of failed resistors.
2. Chapter 1 State diagram
As can be seen from Fig.1, the program has 7 states. S0 is the initialization which shows “Tester Ready” on the first line of LCD display and “Fail count:” on the second line. S1 is the detection of resistors. S2 is the pre-warning. S3 shows the test processing (ADC) which includes the following steps: compare the ADC, rotation and delay. In this state, warning LED and ink probe will enable. S4 is another test which will stop rotating the motor and show “Tester Stopped” on the LCD display. S5 is the stop state which start detect if only ’EOD’ is pressed. Then back to S2. If the ‘BACK’ is pressed, it will be a rotate back pre-warning and step into S6. S6 is the reel back state. The C program details will be shown as follows (Fig.2~Fig5).
Fig.2 shows that the state0 is an initialization. And in state1, when the ‘START’ button is pressed, it enters the state2, otherwise it repeats state1.
Fig.3 presents how state3 works. At first it compares the values. When it is larger than 4.9875 or smaller than 4.5123, the Warning LED and ink probe will enable. Then fail resistors will be counted on the LCD display. According to the previous situation, when ‘EOD’ or ‘STOP’ is pressed, it will come to state4 otherwise into the beginning of state3 again.
In state4 which mentioned in Fig.4, the display shows ‘Tester Stopped’ (16 bits) and then steps into the next state. The next state is the stop state which could detect start as long as EOD is disabled. Then press ‘START’ button to get to state2 or press ‘BACK’ button to step into the final state.
Fig.5 is the final state which is known as Reel Back. This state6 delays the operation counter in 100ms then shows ‘**Reeling Back**’ on the first line of LCD and ‘**In Progress**’ on the second line.
3. Chapter2 C Programming
#include <system.h>
#pragma DATA _CONFIG, 0x3F38
// internal OSC, I/0 on RA6&RA7, WDT disabled
// PWRT disabled, RA5 MCLR, BOR disabled
// RB3 I/O, CPD off, WRT off, CCP1 on RB2, CP off
#pragma CLOCK_FREQ 4000000
// FREQ setting, would be applied to delay function.
#define uchar unsigned char
#define uint unsigned int
// define I/O
#define start porta.1
#define EOD porta.2
#define BACK porta.3
#define STOP porta.4
#define INK porta.6
#define LED porta.7
// define ports for LCD communication
#define SI portb.0
#define SCL portb.1
#define RS portb.2
#define EN portb.3 void config(void); void interrupt(void); //the interrupt service routine.
// NOTE that the interrupt service routine MUST be called
// interrupt. void init(void); void pos_rotate(void); void neg_rotate(void); void ADC(void); void display_1602(uchar col,uchar ln, uchar *p,uchar num); void LCD_INIT(); void LCD_WRITE(uchar data,uchar com); void send_data(uchar byte); void state0(void); void state1(void); void state2(void); void state3(void); void state4(void); void state5(void); void state6(void); void bit_cal(uint num); uchar NUM[5]={0}; uchar state=0; uchar nxtstate; uchar fullstep_pulse=0;
//fullstep initial value should be 0000 1001 uint fail_count=0; unsigned long operation_counter=0; void main()
{
config(); do{ switch(state){ case 0: {state0(); state = nxtstate; break;} case 1: {state1(); state = nxtstate; break;} case 2: {state2(); state = nxtstate; break;} case 3: {state3(); state = nxtstate; break;} case 4: {state4(); state = nxtstate; break;} case 5: {state5(); state = nxtstate; break;} case 6: {state6(); state = nxtstate; break;} default: {state0(); state = 0;} } }while(1);
}
void state0(void){
// initialization and LCD welcome display init(); LCD_INIT (); display_1602 (0,1,"Tester Ready ^_^",16); display_1602 (0,2,"Fail count:",11); display_1602 (11,2,NUM,5); nxtstate = 1;
}
void state1(void){
// state1: start detection if (start){ nxtstate = 2; } else nxtstate = 1;
}
void state2(void){
// state2: Test processing pre-warning, clear fail counter display_1602 (0,1,"Test in Progress",16); nxtstate = 3;
}
void state3(void){
// state3: Test processing
// ADC -> COMPARISON -> POS_ROTATE -> DELAY //ADC measurement ADC(); //comparison 4.5123->4.9875 if( ((adresh*256+adresl)>1021) || ((adresh*256+adresl)<924) ){ LED = 0; // enable warning LED INK = 0; // enable ink probe fail_count++; bit_cal(fail_count); display_1602(11,2,NUM,5); } // pos_rotate and delay delay_s(1); // rpm related need to be changed // according to the rpm INK = 1; // disable ink probe pos_rotate(); operation_counter++; if (EOD||STOP) nxtstate = 4; else nxtstate = 3;
}
void state4(void){ display_1602(0,1," Tester Stopped ",16); nxtstate = 5;
}
void state5(void){
// stop state, detect start if only '~EOD' if (start && (!EOD)) nxtstate = 2; if (BACK){ //rotate back pre-warning display_1602(0,1,"**Reeling Back**",16); display_1602(0,2,"**In Progress**",16); nxtstate = 6; }
}
void state6(void){
// Reel Back while(operation_counter){ neg_rotate(); operation_counter--; delay_ms(100); // rpm related need to be changed // according to rpm } display_1602(0,1,"**Reeling Back**",16); display_1602(0,2,"*^_^* DONE *^_^*",16); delay_s(3); nxtstate = 0;
}
void init(void){ fail_count = 0; operation_counter=0; fullstep_pulse = 0x01; bit_cal(fail_count); set_bit(porta,6); // switch warning LED off set_bit(porta,7); // switch off INK probe
}
void bit_cal(unsigned int num){ char i; for(i=0;i<5;i++){ NUM[4-i] = num%10; NUM[4-i] = NUM[4-i]+0x30; // convert to ASCII code num = num/10; } for(i=0;i<5;i++){ if( (NUM[i]==0x30) && (i!=4) ) NUM[i] = 0x20; // convert high bit 0 t 'space' else break; }
}
void pos_rotate(void){ fullstep_pulse <<= 1; if (test_bit(fullstep_pulse,4)) set_bit(fullstep_pulse,0); fullstep_pulse &= 0x0f; portb = (fullstep_pulse<<4)+ (portb&0x0f);
}
void neg_rotate(void){ if (test_bit(fullstep_pulse,0)) set_bit(fullstep_pulse,4); fullstep_pulse >>= 1; fullstep_pulse &= 0x0f; portb = (fullstep_pulse<<4)+ (portb&0x0f);
}
void ADC(void){ adcon0 = 0xc1; //set ADC internal clock input on ch0 and enable ADC delay_us(10); //wait a while for ADC to settle set_bit(adcon0,GO); //start ADC do{ //do nothing }while(test_bit(adcon0,NOT_DONE)); //keep reading the adccon0 until done 0
}
// display module void display_1602(uchar col,uchar ln, uchar *p,uchar num){
// main subroutine for display
// num is the length of input string uchar count; if(ln==1) { LCD_WRITE(0x80+col,0); } if(ln==2) { LCD_WRITE(0xc0+col,0); } for(count=0;count<num;count++) { LCD_WRITE(*p,1); // send data p++; // read data from next address }
}
void LCD_INIT(){ EN = 0; delay_ms(15); //delay for more than 15ms //for LCD boot-up LCD_WRITE(0x03,0); delay_ms(5); // wait for more than 4.1ms LCD_WRITE(0x03,0); delay_us(105); // wait for more than 100us LCD_WRITE(0x03,0); delay_ms(1); // set up time 4 bit initialization done LCD_WRITE(0x02,0); delay_ms(1); // set up time LCD_WRITE(0x28,0); // 4 bit mode, double display LCD_WRITE(0x01,0); // clear screen LCD_WRITE(0x0c,0); // screen on, cursor off LCD_WRITE(0x06,0); //shift right side delay_ms(1); // set up time
}
void LCD_WRITE(uchar data,uchar com){
// write data, com = 1, write data; com = 0, write command EN = 0; // disable RS = com; asm nop // wait for RS settle send_data(data);
}
void send_data(uchar byte){
//send data Parallel to Serial, read from MSB char i; for(i=0;i<4;i++){ SI = (byte&0x80)?1:0; // read MSB 4 bits SCL = 0; asm nop // wait for SCL settle SCL = 1; // generate a clock byte<<=1; } EN = 1; delay_ms(1); // set up time // at least 37 us EN = 0; for(i=0;i<4;i++){ SI = (byte&0x80)?1:0; // read LSB 4 bits SCL = 0; asm nop SCL = 1; byte<<=1; } EN = 1; delay_ms(1); EN = 0;
}
// End of LCD Module void config(void) { osccon = 0x64; //set internal osc 4M adcon1 = 0x8e; //enable AN0 (RA0) analog rest digital, no reference voltage trisa = 0x3f; //RA0-RA5 input; RA6,RA7 output trisb = 0x00; //portb output portb = 0x00; state = 0;
}//end of config.
4. Chapter3 Circuit Diagram and Simulation
This is the circuit diagram which illustrated by Proteus. Due to copyright of source boost plugin I decide to simulate the program with Proteus. The details of simulation will be shown as follows with screenshots and corresponding comments.
Fig.7 shows the simulation of initial state. As can be seen from the graph, all buttons are not pressed, LEDs of warning and ink are disabled either. Only LCD display works which gives sign as “Test ready ^_^” and “Fail count:” on the screen.
As can be seen from the Fig.8, the “START” button is pressed and LCD display shows “Test in Progress” on the first line and “Fail count:” on the second line. And the motor starts rotate while the button is pressed.
This Fig.9 shows the fail resistors counted state. Obviously VIN (5.0349) >4.9875, so the warning LED and INK PROBE LED enable. The LED display shows the number of failed resistors. The following graphs will show more changing details of VIN.
Fig.14 shows that when “STOP” button is pressed, the wholes system will be stopped as well and the display appears that “Tester Stopped”.
When “EOD” is pressed, the situation will be the same as previous one shows which is shown in Fig.15.
In this graph, it shows that even “START” is pressed; it won’t start with another pressed button “EOD”. This simulation describes the C program in the previous chapter: void state5 (void) {
// stop state, detect start if only '~EOD' If (start && (! EOD)) nxtstate = 2;
Fig.17 and Fig.18 are a comparison example which shows that when the resistor is modified, warning LED remains while ink LED disables.
The simulation above shows that when “EOD” and “BACK” buttons are pressed, the motor will rotate back. Also the screen shows “**Reeling Back**” and “**In Progress** at the same time.
When reel back is done, it shows on the screen as can be seen in Fig.20.
After 100ms delay while the reeling back is finished, the LCD display shows that “Tester Ready ^_^” and “Fail count:” Which means it comes back to state0—initialization.
5. Conclusion
In order to finish this essay, we learnt more about C program with Source Boost. With depth studies in boost c, it helps us better understand how to write C program about PIC16F818, LCD display and stepper motor. Proteus, which stands for a marvelous single chip simulation software, could better help us simulate the system. Although the tasks request us to test 100 resistors, we thought more tests could better present the feature of this system. For example the reel back state could have more angles to rotate back which was convenient for us to watch how it works and recorded data and did simulation screenshots. In general, with these two tools, we were able to learn more about computer programming and digital system.
Reference
1. PIC16f818 datasheet [Online]
Available at http://ww1.microchip.com/downloads/en/DeviceDoc/39598F.pdf
2. HD44780U datasheet [PDF]
Available in “C Assignment” folder
3. Boost C [PDF]
Available in “Boost C Compile Help”
You May Also Find These Documents Helpful
-
3. Use the breadboard to construct the circuit above. Measure and record the value of each resistor with the handheld DMM. Remember that you should remove the resistor from the circuit to obtain an accurate reading. Connect the input of the circuit to the variable positive supply connections on the power supply. Set the DC power supply to +10 volts. Use the handheld DMM to verify the input voltage is +10 V. Measure and record each voltage listed below with the handheld DMM. Measure the current last. Have the professor verify the connections before applying power.…
- 279 Words
- 2 Pages
Satisfactory Essays -
A multimeter or a multitester, also known as a VOM (Volt-Ohm meter), is an electronic measuring instrument that…
- 607 Words
- 3 Pages
Satisfactory Essays -
5. Construct the circuit above on the breadboard. Have the professor verify the circuit. Using the handheld DMM and ELVIS DMM (if you are using ELVIS), measure each resistor value and the total resistance. Record the values in the table below. Compare the measurements and verify that they are within acceptable range.…
- 256 Words
- 2 Pages
Satisfactory Essays -
7. Construct the circuit above on the breadboard. Do not connect the power supply. Using the handheld DMM, measure the total resistance of the circuit.…
- 284 Words
- 2 Pages
Satisfactory Essays -
11. Measure and record the current between the positive terminal of the power supply and the resistor. (Note: You must break the circuit and insert the handheld DMM.) __88µA______…
- 954 Words
- 5 Pages
Satisfactory Essays -
Once all the samples have been loaded into the wells, the chamber is connected to a power supply and…
- 304 Words
- 2 Pages
Good Essays -
5. Construct the circuit above on the breadboard. Have the professor verify the circuit. Using the handheld DMM and ELVIS DMM (if you are using ELVIS), measure each resistor value and the total resistance. Record the values in the table below. Compare the measurements and verify that they are within acceptable range.…
- 274 Words
- 2 Pages
Satisfactory Essays -
* Special resistors, such as thermistors and light-dependent resistors (LDRs): Thermistors change resistance as temperatures change. Most thermistors have a negative temperature coefficient, meaning their resistance falls as temperature increases. Thermistors are used in temperature-sensing circuits. Light-dependent resistors (LDRs) change resistance as light levels change. The light levels are detected by a photo-sensitive plate on the resistor. Most LDRs have a negative light coefficient, meaning that their resistance falls as the amount of light falling on them increases. LDRs are used in light-detection circuits.…
- 5705 Words
- 23 Pages
Good Essays -
Digital circuits can easily distinguish between two voltage levels, which can be related to the binary digits 1 and 0. Therefore, the binary system can easily be applied to PLCs and computer systems.…
- 818 Words
- 5 Pages
Powerful Essays -
Resistors are coated with paint or enamel, or covered in molded plastic to protect them. Because they are often too small to be written on, a standardized color-coding system is used to identify them. The first three colors represent ohm value, and a fourth indicates the tolerance, or how close by percentage the resistor is to its ohm value. This is important for two reasons: the nature of its construction is imprecise, and if used above its maximum current, the value can change or the unit itself can burn up.…
- 916 Words
- 4 Pages
Good Essays -
THIS simple PIC-based unit was designed to measure and display the values of inductors and capacitors.As a by-product of the technique used.it can also display the frequency of an external 0V/ +5V signal source The ranges are approximately:…
- 310 Words
- 2 Pages
Satisfactory Essays -
Contents 1. Introduction 1 1.1 Problem Statement 1 1.2 What Is Security? 1 1.3 OS Protection and Security 2 1.4 Assets and their Vulnerabilities 2 1.5 Protection 3 1.6 Intruders 3 1.7 Malicious Software 3 1.8 Trusted Systems 4 1.9 Protection and Security Design Principles 4 1.10 The Unix/Linux Security Model 5 1.10.1 Properties of the Unix Superuser 5 1.10.2 The Unix Security Model — Groups 6 1.10.3 Protection For Unix Files and Directories 6 1.10.4…
- 7689 Words
- 31 Pages
Powerful Essays -
The resistance of a resistor depends on both the material the resistor is made of and the geometry of the resistor. The longer the resistor the greater the distance electrons must travel and the more times they can collide with other objects. The longer the material the greater the resistance. The wider the resistor the larger the path. A wider resistor is like a wider road or a larger pipe it allows more room and easier flow. The resistance is inversely proportional to the cross-sectional area of the resistor. The resistance is equal to the resistivity of the material, times the length of the resistor, divided by the cross-sectional area of the resistor. ρ∗ l R= A…
- 875 Words
- 4 Pages
Better Essays -
Copyright Copyright © 1998 by National Instruments Corporation, 6504 Bridge Point Parkway, Austin, Texas 78730-5039. Universities, colleges, and other educational institutions may reproduce all or part of this publication for educational use. For all other uses, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation. Trademarks LabVIEW™ and The Software is the Instrument™ are trademarks of National Instruments Corporation. Product and company names listed are trademarks or trade names of their respective companies.…
- 17276 Words
- 70 Pages
Powerful Essays -
In this episode, students learn how and why the resistance of a wire depends on the wire’s dimensions. They learn the definition of resistivity and use it in calculations.…
- 2813 Words
- 12 Pages
Powerful Essays