Bandolier

Bandellier resistor strip counter

Page content to be updated with the following notes:
  • Tx to a PC is re-instated as RB2 is now swapped with RA6.
  • RB7 is also fed through a nand gate to be inverted for use with the 74ls139.
  • RB4 and RB5 are to be used as the interrupt on change interrupt inputs for the IR resistor sensor.
  • This board circuit will be transferred to a separate bandolier circuit and this board will continue it's life as a PIC development board.
  • The Op-amp comparator will stay on the bandolier board as it is only one more chip for the counter to have, hence room on the PIC chip will not have to be found in order to use the PIC's comparators although it would have been nice to use them. Maybe in future.
  • Resistors for automated assembly lines often come in boxed reels in the form of resistors joined by a paper strip of paper or other material. For the purpose of counting out the correct quantity which could be hundreds or thousands, the following project is an automatic hand held counter. Although this type of counter is not new (http://www.iteco.it/en/county.html and Farnell counter), there is room for one more and it is an interesting starting project for a PIC chip and programming learning project. Iteco

    An algorithm will be used to save space (hopefully) in the PIC chip memory. Algorithm.

    Circuit diagram: The PIC (rated at 4MHz) is over-clocked at 6.144MHz for more accurate USART timing purposes (see USART, later). The PIC is interrupret from it's job of continually up-dating the seven segment display by an interrupt generated by the resistor detection circuitry. This is made up from an infra-red sensor from a mouse which feeds a signal into the LM358P duel op-amp, which was designed specifically for use with single voltage supplies (0v and 5v rather than say -12v, 0v and +12v).
    The op-amp compares the voltages from the detector with a reference voltage and switches high as soon as the input from the detector falls below the reference. This occurs when the resistor blocks the infra-red light from the light emmiting diode. The switching is not a clean definite transition. I had intended to clean the signal up with a de-bounce circuit but instead will try to get the PIC to allow the interrupt routine to determine what part of the interrupting signal is used. So long as the A and B waves are arranged to over-lap this should be possible. A software decision as to the direction of the resistor passing through the resistor detector can then be made.
    The hand held bandolier counter has it's handle to the left. The infra-red led diode and receiver are in the 'hinged' right portion in these photos. The PIC and other components including battery will be in the space in the handle (shown in the photo to the right. There is a sliding piece to adjust for different bandolier widths and a sliding metal piece to adjust the IR diode strength. This piece will be adjusted to ensure there is an over-lap of A and B signals for resistor motion direction detection.
    The 74HC138 selects up to 8 separate devices depending on the output of Port A lines RA2, RA1 and RA0. The PIC displays the number of resistors counted on the 3 seven segment displays on by selecting each one in turn and writing the relevant digit to the Port B bus. The time interval between each segment display update is so small that the persistance of vision of the human eye fills in for the gaps in-between.
    An LCD panel will be used soon instead of the segment display units at which point there will be 7 free device select lines free, as the 7 seg display units will be redundant, although will remain on the development board. The LCD panel will not need up-dating continually and will take much less power, while also allowing more versatile use with menu system etc..
    RS 232 5v to +-10v PIC to PC serial interface circuit for use on the development board. The PIC 627 on the bandolier/dev board is a 4MHz on which I am over-clocking at 6.144 MHz for easier more accurate baud rate generation. In the manual for the PIC it lists various pre-scaler BGR file register values to achieve certain baud rates. With the 6.144 MHz clock these all work out much better. The equation given for the baud rate is ( using a PIC operating at 16MHz):
    Desired Baud rate, DB = Fosc / (64 * (X + 1)) i.e. 64 * (X + 1) = Fosc/(64 * DB)

    where X is the SPBRG integer value. X must therefore be calculated first:

    X + 1 = Fosc/(64 * DB) = 16 * 10^6/ (64 * 9600) = 26.0416667

    X = 25.0416' the nearest whole number is 25. Which produces the error:

    Actual Baud rate AB = 16 * 10^6 / (64 * (X + 1)) = 9615.384615

    Error = (9615.38 - 9600) / 9600 = 0.16%

    from which the error between the desired baud rate and the actual baud rate can be calculated by percentage. The 4MHz table in the manual and the newly calculated 6.144MHz values are shown table below:

    6.144Mhz crystal baud rates.
    BRGH=1
    9600: X+1 = 6.144 x 10^6/(16 * 9600) = 40. Therefore: X = 39 exactly
    19.200 k: X+1 = 20. Therefore X = 19 exactly
    38.400 k: X = 9 exactly
    The hardware (and software) contents of this bandolier counter development circuit will soon be moved to a separate hand held device. This board is also the PIC development board listed in the 'Projects' page. This page will document further PIC projects such as a PIC USART 'register-insertion' based network and a SCUBA diving sonar 'dive team recall' communications device.
    Program to follow !