Connect with us

Optical Encoder Issue

Discussion in 'General Electronics Discussion' started by MihirS, Jun 13, 2016.

Scroll to continue with content
  1. MihirS

    MihirS

    11
    0
    Jun 13, 2016
    Hello friends this is my first post on this forum!

    I have built a coordinate measuring and display unit with the help of optical encoder, raster strip, Arduino Nano, and MAX7219 LED display module.

    The number displayed on the LED module should increment or decrement depending on the direction of motion of the encoder strip between the optical encoder. When the strip is not moving, the value displayed on the LED module should remain the same.

    The problem is that the value displayed on the LED module keeps on incrementing and decrementing randomly even when the strip is stationery.

    The only way I found out to prevent this is to touch any part of the circuit. If I touch the pcb with just my fingertip, the fluctuations reduce but don't stop. However, if I hold the pcb tightly or if the area of contact is sufficiently large then the value remains still and everything works well.

    I dont think this is a grounding issue because it works perfectly even if I touch the +ve pin or ANY other pin for that matter. It works even when I hold the insulated power cable in my hand AND press tightly.

    Touching a large metallic object to the pins also solves the problem.

    Please take a look at this video that I have uploaded to youtube.

     
  2. donkey

    donkey

    1,289
    56
    Feb 26, 2011
    post complete circuit diagram and code if you want an informed answer, if you want just a normal answer then...
    you have a magical touch and should be used in all appliances
     
    hevans1944 and MihirS like this.
  3. BobK

    BobK

    7,682
    1,686
    Jan 5, 2010
    My guess would be that you don't have a common ground between the encoder and the Arduino.

    Bob
     
    MihirS likes this.
  4. Minder

    Minder

    2,981
    631
    Apr 24, 2015
    I too would say a grounding issue, I see you are using a Wall Wart, try it with a battery.
    Also if it persists, try an earth ground to supply common.
    Also try local de-coupling, place a small electrolytic across the supply terminals.
    M.
     
    Last edited: Jun 13, 2016
    MihirS likes this.
  5. MihirS

    MihirS

    11
    0
    Jun 13, 2016
    Thankyou for your reply Bob. Ill post the schematic for you. There is a common ground between the two.
     

    Attached Files:

  6. Minder

    Minder

    2,981
    631
    Apr 24, 2015
    Is this an off the shelf board or your own?
    M.
     
  7. MihirS

    MihirS

    11
    0
    Jun 13, 2016
    Thankyou for posting Mr.Minder! I would like to know whether it can be a grounding issue even when the problem solves when I touch the +ve pin, not just the grround pin.

    Since it is a two pin power supply I couldnt use the ground wire but like you suggested, I tried touching a ground wire from the power socket to the USB jack and the value stabilizes. But the same thing happens when I touch a large metallic object to the pins...it works even then

    I tried adding various capacitors across the power supply but they dint seem to affect it at all.
    I tried 1uF and 10uF among others.

    Like you said, I tried running it off batteries and it WORKS flawlessly! :)
    But I would really like to supply it via an adapter or a power supply unit for future use..

    I have attached a link to another video I took
     
  8. MihirS

    MihirS

    11
    0
    Jun 13, 2016
    I have made it.. except for the encoder, LED module and Arduino Nano
    So basically, I designed the PCB
     
  9. Minder

    Minder

    2,981
    631
    Apr 24, 2015
    With earth grounding it does not matter if you earth ground the +ve or the common, they are identical as far as noise is concerned. Especially when de-coupled by a large Cap.
    It does seem like radiated noise from the external AC.
    I assume that P.S. is a SMPS supply, I would bet it may not happen with a small linear P.S. that has better galvanic isolation.
    M.
     
  10. MihirS

    MihirS

    11
    0
    Jun 13, 2016
    I got your point regarding the grounding..

    P.S. is just a cheap 5V cell phone charger.. The white device it is attached to is the extension cable...
    I have attached a pic of the insides of the charger
     

    Attached Files:

  11. MihirS

    MihirS

    11
    0
    Jun 13, 2016
    Would this issue solve if I use a good quality switching power supply?
    Can the problem be solved by making changes to the cell phone charger circuit?
    I notice that it has a transformer with a floating neutral.. Can that be the cause of the noise?
     
  12. Minder

    Minder

    2,981
    631
    Apr 24, 2015
    Not quite sure what you mean by 'floating neutral' but the live and N are normally isolated from the output, but in some cases input filter components can be also be connected from AC to output.
    Only a test would find out if a better SMPS supply would work.
    I don't there would be any future in trying to modify the existing supply.
    M.
     
  13. MihirS

    MihirS

    11
    0
    Jun 13, 2016
    By floating neutral I meant that the output neutral of the transformer isnt connected to the input neutral..( I actually tried doing this and got a mild shock on touching the encoder wire! )

    Alright, Ill invest in a SMPS dual power supply then. 5V for the arduino and 24V to run the stepper motors. (To run the gantry)
    But I still haven't understood what is causing the problem. Can you confirm that it is a power supply noise problem?
    Is this a common problem and can it be solved by using decoupling caps? How can their values be determined?
     
  14. Minder

    Minder

    2,981
    631
    Apr 24, 2015
    Without having the unit to test I can neither confirm or deny it is P.S. or other noise.
    It is mainly a question of taking one of the actions shown above in order to eliminate it.
    There is a part of the circuit that appears susceptible to radiated (AC) noise.
    If you post the circuit, it may be evident where sensitive part of the circuit may be.
    M.
     
  15. BobK

    BobK

    7,682
    1,686
    Jan 5, 2010
    Tell us about the encoder. Is it mechanical? If it is, and it simply closes a switch periodically when you rotate it, have you used a pull-up or pull-down resistor on the input to the Arduino? If not, the input is floating whenever the encoder switch is open and could cause this behavior.

    Bob
     
  16. Minder

    Minder

    2,981
    631
    Apr 24, 2015
    The 'Encoder' appears to be a home made slot opto and a quadrature strip, If so for bi-direction you need two detectors.
    But these usually have fairly low in/out impedance, did you provide a suitable value for pull up on the output?
    I am guessing that your problem lies in this area, still no schematic?
    M.
     
  17. hevans1944

    hevans1944 Hop - AC8NS

    4,518
    2,102
    Jun 21, 2012
    It is an Agilent HP 9730 with two quadrature-spaced detectors and a single LED illumination with integrated lens. This is to be used with a "bar and window" strip of appropriate cycles per unit length to create quadrature outputs on two channels. It is also suitable for use with a rotary encoder of appropriate "bar and window" spacing. The outputs feature integrated pull=up resistors, so it can be connected directly to Arduino digital inputs for direction decoding and position incrementing or decrementing.

    @MihirS appears to have this decoded and displayed properly, and is only having problems with exterior coupling of interfering nearby mains wiring, probably from the "cheap" cell phone recharger. It would be nice if he uploaded the schematic instead of just the board layout, along with the code he wrote for the Arduino. :D
     
    MihirS likes this.
  18. MihirS

    MihirS

    11
    0
    Jun 13, 2016
    Thankyou for replies.. for some reason, I did not get an email notification about newer replies so I did not check this forum.

    hevans 1944 is correct, I have used an Agilent H9730 quadrature optical encoder. The encoder and the strip which has 180 lines per inch resolution has been purchased from China.

    The schematic is very straight forward.
    The inputs of the encoder A and B have been attached to the two interrupts of the Arduino and are triggered on 'CHANGE' in state. I have programmed it in 4x decoding mode. The LED module pins (DIN, CS and CLK) are attached to pins 10 11 and 12 of Arduino.
    Thats all there is to it. The GND is common for Arduino, Encoder and MAX7219 LED Module.

    As Minder had suggested, when I tried running it off four 1.5V AA batteries in series, it worked perfectly. However, I have 3 such similar units, one for X, Y, and Z axis (see attached image). When I powered all the units with the batteries (all connected in parallel), I again got the same problem, but this time I suspect it was due to insufficient current supply by the batteries. It works fine if I take out two of the LED modules. Should I try with higher capacity batteries? But still it wont be a permanent solution....

    Schematic is finally attached! :)

    Update: The whole unit (X, Y, and Z) consumes 520mA at 5V.
     

    Attached Files:

    Last edited: Jun 24, 2016
  19. MihirS

    MihirS

    11
    0
    Jun 13, 2016
    Thanks for explaining :)
     
  20. hevans1944

    hevans1944 Hop - AC8NS

    4,518
    2,102
    Jun 21, 2012
    This is clearly a shielding and power supply problem. The switch-mode power supply is probably responsible for the interference. Try wrapping the sensor ribbon cable in aluminum foil and, using a short jumper wire with alligator clips on each end, connect the end of the foil farthest from the sensor module to circuit common. Do the same thing for the DC power cord from the "wall wart" power supply. If this "fixes" the problem you can replace these two cables with shielded cable.

    Also, viewing the second video,I didn't see a single by-pass or power supply filtering capacitor on the main circuit board! What were you thinking? Do you have an oscilloscope you can use to look for this "noise" that is ruining an otherwise fine project? Nice circuit board construction, BTW.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-