Considerations about Endstops
Some considerations about endstops
As discussed on the September page the issue about endstops had my interest. I dislike the carriages bumping into the mechanical endstops when homing but instead I prefer the effect of contactless homing. It is in my opinion more gentle and elegant.
It was indeed very tempting for me to investigate the cause why my original optical endstops did not work (apart from the inductive noise issue, which I clearly understood) and why they showed differences in the output (see my September page). Of course both effects (not working and different outputs) can be related, i.e. a bad design can cause unreliable results but also can lousy components.
The approach for my investigation was clear to me, despite the fact that I have little or no knowledge of electronics. Probably the best way for me was to use logical thinking and when that appeared to be insufficient, to ask help from one of the electronic nerds in my personal circle.
The best and easiest way to start in my opinion was to check each individual optical endstop printed circuit board (PCB) and compare the components to eliminate the possibility of differences in the values of components with identical values. Should I find a resistor with a value different from the printed value on the PCB than this could explain the difference in outputs when under operation. Should all components be equal and with values as indicated on the PCB than I had to take a look at the quality of soldering the components. Loose or cracky fits could mean another source of erroneous behaviour. An issue that I could not check was component variability. In order to check component variabilty I would have to isolate (de-solder) each component and individually check its parameters. Too much for me!
When the cause of malfunction was not clearly explained from the hardware my next step should be to evaluate the circuit diagram and check if each component had been designed correctly concerning their values and functions. For me absolutely the most difficult part of the job.
Step 1: Hardware check
I took a closer look at the three optical endstops. All resistors for R3 (see image 4) had the correct value of 10k; the resistors for R1 were all with the correct value of 1K and all resistors for R2 had the correct value of 470R. No problems with the choice of components!
Next step was a visual check of the solder joints through a magnifying glass. One PCB had good refluxed solder joints, but the two other ones had both a lousy solder joint on the same spot: where R2 meets R3 on the 5V power line. It should be noted that the PCB's have a different component layout compared with image 4: R2 is connected to the power line and the red LED is connected to the collector of the photo transistor in the photo interrupter. This has no consequences for the functioning of the circuit; the places of a LED and its current-limitting resistor are interchangeable.
The following step now will be a fucntion test of the optical endstops by powering them at a stable 5V power and measuring the voltages over signal and ground at triggering and in the non-triggered state. This test will be repeated after I have resoldered the apparently lousy solder joints. By comparing the results before and after soldering we will know if refluxing the solder joints matter in the operation of the endstops or not.
Table 1: Results of measurements on optical endstops
Refluxing the solder joints had no noticeable effect; small differences are explained by slight changes in power supply and by using flags of different materials (plastic credit card versus cardboard sheet).
The repeated results on the workbench, compared to my measurements in situ on the RepRap (see the September page), prove that only one endstop (no. 3) is usable and the other two are junk. Most probably these endstops suffer from a relatively large inter-component variability, located in the photo-interrupters. In conclusion I therefore consider the design as insufficient and quality control before releasing the product as inadequate. The supplier and probably the designer of these particular optical endstops, Andromedabot in Celje, Slovenia, should be ashamed for bringing this to market!
The endstop PCBs draw less than 10 mA which is in line with the expectations knowing that the relatively high resistor values will reduce current consumption through the circuit. Moreover, this is quite desirable knowing that each endstop is directly connected to a pin of the Arduino MEGA 2560 microcontroller board. It is commonly known that Arduino input/output pins have maximum DC current of 40 mA. In developing circuits attached to I/O pins it is generally advised to draw low currents.
Step 2: Design check and evaluation
I took a close look at my original optical endstops and noticed that the photo interrupter was a Honeywell HOAO865L51. The internal layout of a photo interruptor is shown in image 1. Inside the photo interrupter are two parts: an IR LED and a photo-transistor. The two parts are lined up in such a way that the LED shines through a slot on the photo transistor and the light beam can be interupted by blocking the slot with a flag, any piece of non-transparant material that blocks the light beam.
Image 1: Photo interrupter (image: Capolight)
Image 2 shows the standard wiring diagram for a photo interrupter. R1 limits the current of the LED to 20mA. The output is a open collector stage so a pull-up resistor is needed. The output is LOW when the IR light of the diode shines on the phototransistor. So nothing is in the gap. When you put an obstacle into the gap the transistor goes in the off state and so the output goes HI. The output can directly be put to a digital input of a microcontroller or other logic device as long as the transition from HI to LOW or LOW to HI is not too slow.
Image 2: Standard wiring of the photo interrupter (image: heliosoph.mit)
The physical form of photo interupters can be with no ears, one ear or two ears. With "ears" I mean the extending parts with the holes at each side of the "towers" of the photo interrupter. Image 3 shows a photo interrupter with two ears.
Image 3: Photo interrupter (image: supplier China)
The photo interrupter HOAO865L51 has the following electrical characteristics:
Table 2: Electrical characteristisc for HOAO865L51
Image 4: Circuit for optical endstop (image FRS)
Image 4 shows the actual electrical circuit of my (unfortunately no longer in use) optical endstops with the values for the resistors as read from the circuit boards. Due to the malfunctioning of my optical endstops I just wonder if these resistor values are correct.
The functions of the different parts are as follows:
R1 is a current-limiting resistor between power and the input of the LED in the photo interrupter.
R2 is a current-limiting resistor between signal and the input of the LED D1 which indicates the HI status of the optical endstop when the slot is blocked.
R3 is a pull-up resistor on the signal line. The pull-up resistor is needed to make the output of the photo-transistor a logical HI when the slot is blocked and the LED is not shining on the photo-transistor, connecting it to ground.
Looking at the electrical circuit and than only considering the IR LED and its resistor R1, connected between +5V and GND, we can calculate that for a LED with a Vf of 1.6 V and an If of 20 mA the calculated value for R1 should be (R= V/I) or (5 - 1.6)/0.02 = 170Ω and not 1000Ω as is the case in my commercially bought endstops.
When we take a look at the published schematic diagram of a typical optical endstop (image 5, see also my September page) we notice that the value for R1 is 150Ω, which is more in line with the calculated value, and likewise is the standard wiring schematic of image 2 showing a resistor of 180Ω. It should be noted that for image 5 the type of photo interrupter has not been indicated and it may have different characteristics requiring a different value for R1. However, I expect that IR-LEds in photo interrupters more or less have the same electrical characteristics and therefor require current-limiting resistors with a value around 170Ω. The resistor with a value of 1k in image 4 (my currently no longer used endstops) will limit the current through the LED at about 3.5 mA. This value of 3.5 mA will still make the LED shining but at a very dim level. I cannot predict which effect a dim LED wil have in making the phototransistor properly functionning, but I have my doubts about side effects relating e.g. to switching time. However, surprisingly this practice of a low current throug the photo interrupter LED is not uncommon as we will read below.
Image 5: Schematic diagram for optical endstop from literature (image: Capolight)
The exact values needed to make the photo-interrupter work are not easy to find. Theoretically it should be possible to calculate them. Usually the process of trial and error is used by trying different values of both resistors to get a good response. The general principle is to find a high enough voltage when the slot is blocked to register as a HI input, but also be close to ground when the slot is not blocked. If it doesn't get to ground, then either the current-limiting resistor is too strong or the pull-up resistor is too weak. If the signal line doesn't get high enough, it may be necessary to lower the resistance on the pull-up resistor. All these uncertainties require in my opinion a different approach for establishing a correctly and reliably working optical endstop.
The following evaluation of establishing correct resistor values in a photo interrupter set-up was taken from the internet (heliosoph.mit):
For the following evaluation we refer to the schematic in image 2. All resistor references refer to this image 2 schematic as shown below.
Copy of Image 2: Standard wiring of the photo interrupter (image: heliosoph.mit)
The suggested LED current is 20mA and the LED voltage is 1.1V. So when Vcc = 5V choose R1 = 180Ω and R2 = 2.2kΩ and you will get safe operation. The total current will be 22mA for your photointerrupter. What we will do here is to reduce current consumption in order to make the circuit more suitable for direct connection to microprocessors.
The maximum current the phototransistor in the output stage can drive depends on how much light comes from the LED. So the first idea was to reduce the current through R2 as much as possible and then reduce LED current so that the transistor still gets enough light. As the logic inputs of CMOS devices need only some μA I thought about reducing LED current accordingly and saving energy this way. Then I did some testing and it turned out that there was a problem with the switch off time of the transistor. Switch off time increases very much when the transistor current is low. When Vcc = 5V and R2 = 10kΩ the current is 460μA and the switch off time of the transistor is around 200μs. When you make the LED current as low as possible then switch on time of the phototransistor is in the same region. So your maximum pulse frequency is around 1kHz. If you have a higher frequency R2 must be smaller to decrease switch on and off times. If you reduce the current more, e. g. 46μA with R2 = 100kΩ then swith off time is 1.5ms. Here R1 = 10kΩ is a good choice with Vcc = 5V. LED current is now 0.4mA. This is way below the suggested 20mA!
It is not advised to increase R2 to more than 100kΩ as you can get additional noise problems because of the high impedance of the circuit.
In the real application think about increasing LED current about 30% … 50% to be on the safe side. In reality you have different performance of individual photointerrupters even if they are the same type. And performance also changes with temperature and time.
So far the trial and error methods.
From literature I have understood that photointerupters during their rise time - i.e. the time between LOW and HI logic levels - wander up and down instead of jumping to the proper level. This effect is clearly demonstrated in image 7 where we see the input signal coming from the photointerrupter as the sinusoidal red line. This effect creates an avalanche of interrupts though we just want one sharp interrupt. A solution to create one single, sharp interrupt is by integrating a Schmitt-trigger into the circuit. The Schmitt-trigger can be made traditionally with two transistors. Another possibility is to use an inverter (74LS14) or an Op-Amp (LM741).
Image 6: Schematic diagram of optical endstop improved and extended (image FRS)
In image 6 an Op-Amp (LM741) has been introduced, connected as a Schmitt-trigger. The schematic diagram is a bit difficult to read (my fault) but it should be understood that resistors R4 and R5 are connected to input 3 and cross the input line 2 (not connected to 2). Resistor R6 is connected to input 3 and crosses the power line from input 7 to +5V (not connected to 5V). Similarly capacitor C2 is connected between input line 3 and ground and crosses input line 2 (not connected with input line 2).
Resistors R4, R5 and R6 have values of 10k Ω. These three resistors act as a voltage divider with two 10k resistors connected to the 5V supply (R4 and R6) and one 10k resistor connected to ground (R5). When the minus input 2 is 3.3V the output of the Op-Amp goes LOW and it remains LOW until the output drops to less than 1.6V. The 1.6 V voltage on the plus input 3 is realised by the three 10k resistors. When the output is LOW, one 10k resistor is connected to the 5V supply and two 10k resistors are connected to ground. This puts 1.6V on the plus input 3.
The Schmitt-trigger operation can be seen graphically in image 7.
Image 7: Schmitt trigger signals (image: talkingelectronics)
In the improved schematics of image 6 in addition two (ceramic) capacitors, C1 and C2, have been introduced as decoupling capacitors with a value each of 100 nF. The function of the decoupling capacitors is to redirect noise through the capacitor and away from the circuit.
Coming at this point of my endstop investigations I realised that optical endstops for proper functioning needed to be improved as shown in image 6. However, by doing that we have transferred the original optical endstops from a 5 component PCB into a 11 component PCB; more costly and more complicated and the concept as such with a photo interrupter still remains a pain in a certain place.
Apart from the fact that photo-interrupters within a single batch of product are notorious for the high component variability another disadvantage of photo interrupters is that they react to ambient light. When exposed to daylight they draw current, in direct sunlight up to 10 mA and in daylight in a room up to 100µA. In developing an electronic circuit the operating conditions in the environment need also to taken into account.
Probably it was better to abandon the concept of optical endstops and to look for a different type of contactless endstop. Therefore I decided to investigate the concept of (magnetic) hall sensors as endstops. In that case I would prefer an electronic circuit that showed the LOW status as well as the HI status with different coloured LEDS.
The new concept mini-project started with ordering some cheap hall sensors and some duo-LEDS. Then I started waiting for their delivery.
|Last Updated on: Mon Nov 10 22:00:11 2014|