587,997 active members*
1,868 visitors online*
Register for free
Login
Results 1 to 14 of 14
  1. #1
    Join Date
    Sep 2009
    Posts
    7

    Opto Couplers

    Hi guys. This is my first posting to this forum and I apologize if this is not a suitable place to ask my question.

    I am building a simple 2-axis plotter based around the components extracted from a craft-robo cutter. The hardware is complete and now I am half way through building the stepper controller to drive it all.

    As the local electronics store here doesn't supply any bipolar stepper driver chips I decided it would be fun just to do it all using power transistors so I built an h-bridge that runs on 24 volts using TIP31C and TIP32C transistors.

    I just sort of hacked my way through that and it seems to work great. Drives a stepper coil backwards and forwards no problem.

    However I am up to the last part of the h-bridge which is the interface to the parallel port and I have run in to one snag and I do believe it is in my choice of optocouplers.



    I picked triac ones and I can now see this was a mistake as the MOC3020 series turn on but not off!

    I understand now that these were not really designed to run off a parallel port but for AC applications.

    But I figure I got this far and the rest of the board looks good so one more little hack might just do the trick for me.

    Anyway my question was if any trick exists to turn these opto couplers on/off via a parallel port.

    I was thinking perhaps by putting a cap across the led side to force them to pulse?

    As you may have gathered I am not an electronics Guru.

    I just cobbled this together and am happy I got this far!

  2. #2
    Join Date
    Dec 2003
    Posts
    24220
    For the price, rather than try to commutate them off, buy transistor output type.
    Also if you are going to drive a load from a parallel port, the convention has usually been to sink the load rather than source, as usually a parallel port has higher current capability in this mode.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  3. #3
    Join Date
    Aug 2009
    Posts
    127
    You need to add a pull down resistor on the base of the transistor to pull the voltage low to turn it off.

    Also most opto couplers take 5-10mA per LED. That is too much current for the parallel port which is speced for 2mA.

    For a simpler solution, go with a Silicon Labs Si8460. It is a digital coupler and can drive up to 10mA off the output and takes 0mA on the FET inputs.

    If you need to build a PCB, check out this tutorial http://www.fullspectrumengineering.com/tutorial.html

  4. #4
    Join Date
    Sep 2009
    Posts
    7

    Pull Down Resistors

    For the pull down resistors should these between each base and each collector on the transistors in the bridge?

    Also what size would they be. I am thinking about 10k?

    My local electronics shop is called jaycar and they do not have the Silicon Labs Si8460 but they do have these smaller opto couplers which are also a good deal cheaper.

    http://www.jaycar.com.au/products_uploaded/ZD1928.pdf

    I know I could just go for some solid state relays but those look to be a tad expensive.

  5. #5
    Join Date
    May 2008
    Posts
    142
    Hi maybe this site can help you,
    They use the 4n25 optocoupler to control a 24volt relay coil


    http://forum.allaboutcircuits.com/sh...ad.php?t=14812

    Michael

  6. #6
    Join Date
    Dec 2003
    Posts
    24220
    Also see this recent posting.
    http://www.cnczone.com/forums/showthread.php?t=88715
    Also, if you end up driving a relay, there is no need for opto isolation, the relay can be driven off the PC 12v supply using 2N7000 or the drivers in the link.
    The relay IS the isolator.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  7. #7
    Join Date
    Oct 2008
    Posts
    116
    Hi,
    A couple of things come to mind from looking at your schematic.

    It does not look like there is enough current gain on the transistors. I looked at the data sheet on the TIP31C and they spec a current gain of 10 - 50. If you wanted to drive 1 Amp across the coils, you would need 100 milliAmps of base drive capability to insure that the transistor stayed saturated. I would probably want at least 500 milliAmps of base drive capability just to deal with unexpected loads. If you run short of base drive current, the transistor starts to dissipate a LOT of power and smokes pretty quickly. A darlington setup will give you the base drive you need at the expense of another smaller transistor. Ascii art does not work here, so I won't try to sketch one. Another choice would be to find Darlington transistors instead of the TIP31C and TIP32C.
    Beta or hfe is the name of the parameter for current gain to look for. Take the Base drive current available x hfe (or Beta) and you get the absolute maximum collector current that you can handle without pulling out of saturation.

    Look at the TIP122 for an NPN Darlington. It has a current gain of 1000 compared to 10 - 50. The TIP125 would be the corresponding PNP.

    There is no interlock to prevent the high and low side transistors from being switched on at the same time. The parallel port does unpredictable things during switch-on and operating system booting, so this is kind of important. It should be possible to set up the transistors so that one opto controls both the high and low side transistors and there would not be a way to have both switched on at the same time.

    You should have diodes protecting the transistors from the inductive kick when the coil switches off. On the low side transistors (-24V), put a diode with the cathode tied to the emitter and the anode to the collector. On the high side (+24V) tie the anode to the emitter and the cathode to the collector.

    There are not really any graceful ways that I can think of to switch a TRIAC opto off in a DC powered circuit. I would replace the TRIAC optocouplers with darlington optocouplers.

    Good Luck and keep asking questions!
    BobH

  8. #8
    Join Date
    Sep 2009
    Posts
    7
    ___

    There is no interlock to prevent the high and low side transistors from being switched on at the same time. The parallel port does unpredictable things during switch-on and operating system booting, so this is kind of important. It should be possible to set up the transistors so that one opto controls both the high and low side transistors and there would not be a way to have both switched on at the same time.
    ___

    I had thought about this as well since the parallel port can often just flash up random states when the computer is booting up and so on. For the final design I was going to put a little bit more npn/pnp transistor logic in between the opto couplers and the bridges or maybe a trigger somewhere between the parallel port and the couplers. I was also aiming to reduce the pins used on the port to because at the moment driving two steppers will use all eight pins!
    ___

    Look at the TIP122 for an NPN Darlington. It has a current gain of 1000 compared to 10 - 50. The TIP125 would be the corresponding PNP.
    ___

    Brilliant. This would explain why the transistors were getting so hot when they began to pull load through a coil. I just thought it was because I had not put the paste on them and heat sinked them yet. It can't hurt at all to go for some bigger ones. I did try to do the math around the hfe value from the sheet but I had not realised the coils were going to pull quite so much current. I hooked up one of the coils from the stepper to my MM and put the power supply through it to see what sort of current it was pulling and just sort of eye balled it. I think I got the math wrong though. But then I figured if the transistors were not big enough they would just explode and I would replace them.....

    ___

    You should have diodes protecting the transistors from the inductive kick when the coil switches off. On the low side transistors (-24V), put a diode with the cathode tied to the emitter and the anode to the collector. On the high side (+24V) tie the anode to the emitter and the cathode to the collector.

    ___

    Great. That is exactly what I was going to do as well. 4 diodes across the bridge in the right places to deal with the kick back from the coil.

    ____

    There are not really any graceful ways that I can think of to switch a TRIAC opto off in a DC powered circuit. I would replace the TRIAC optocouplers with darlington optocouplers.

    ____

    Ok cool. This is really the critical bit I was missing. So I will dump the MOC3020's and go for a 4n28/4n25 instead.

    I think I will go and buy a couple and try them today. When my final circuit is done I will post it up as it might be useful to somebody. Even if it is just as an abject lesson in how NOT to design a circuit!

    Thanks everyone for your help. If all goes well I should be driving a stepper by this evening.

  9. #9
    Join Date
    Oct 2008
    Posts
    116
    I was thinking about your project and some questions came up.

    What is the DC resistance of the step motor coils?
    What is the maximum current that they are rated to handle?
    The reason that I am asking, is that 48 volts is pretty high for the type of drive that you are building. There are step motors designed for this high of a voltage, but most of the ones I have seen are designed for a much lower voltage. Usually high voltages in step motor drivers are used in some kind of a chopper drive circuit, where the motor current is sensed and when it reaches the desired value, the power is switched off and the current allowed to circulate until it gets too low or a new step comes along. This sensing is done in hardware, because it is pretty fast and can never be allowed to stop.
    The safe way to pick the supply voltage for the driver circuit that you are building is:

    (Power supply voltage - 2xVCEsat) / coil resistance < max rated coil current

    VCEsat it the voltage across the collector to emitter when the transistor is saturated and it 2x because there are two transistors in the path. The transistor spec sheet lists it, but for the TIP31/32, you can probably assume 0.5 Volts. The TIP122/125 will be more like 1.2 to 1.5 Volts.



    How fast do you want to step your motors?
    The driver circuit you have sketched will not allow you to move very fast. With this circuit, the torque falls off with motor speed very fast. The chopper drive allows much faster step rates (maybe 10X to 30X). For information on chopper drives, look at the ST web site and search on the L297 and L298 chips. These are old parts, but still availible and pretty simple to undestand.

    Good Luck,
    BobH

  10. #10
    Join Date
    Jun 2007
    Posts
    3735

    Jaycar.

    I see you purchase goods from Jaycar.
    A simple solution is a ready made product, to save pulling out your hair.
    You won't learn as much, but you will be up to speed (well rotating at least) with this.
    AA-0352
    http://www.jaycar.com.au/productView...2&form=KEYWORD
    Software link available too.
    Split rail supply required, so BEWARE, if you want to run from single supply.

    Some bed side reading....
    http://www.jaycar.com.au/productView...0&form=KEYWORD
    Super X3. 3600rpm. Sheridan 6"x24" Lathe + more. Three ways to fix things: The right way, the other way, and maybe your way, which is possibly a faster wrong way.

  11. #11
    Join Date
    Sep 2008
    Posts
    142
    You cannot use Triacs (meant for AC loads) on DC, they lock on. They need the AC crossing over zero to allow them to turn off....There is NO WAY to change this. Replace the Otocouplers with transistor ones....

    Look for optocouplers that run with 6ma or less LED current, so that the load on the printer port is reduced. Size the series resistor accordingly. Some printer ports cannot supply more than 6ma, so be careful.

    In a worst case situation, you will have to buffer the new optocouplers with a transistor or chip to make a reliable system.

    Its not a simple problem. You have done REALLY well to get so far with such limited knowledge, congratulations for hard work. New optocouplers are cheap, do not be dismayed. Keep the Triac ones for later control of your spindle motor!!!

    Think about the maximum frequency you need before buying any new optocouplers, if you wish, I can post some data sheets for you, just ask if you need them.

    I am a bit late with my answers sorry.

  12. #12
    Join Date
    Sep 2009
    Posts
    7

    It works somehow ....

    Hey guys just thought I would follow this up. IT WORKS!!!!! I have no idea how or why my rube Goldberg madness of many wires works without the magic smoke escaping but it does!!

    I hooked it all up this evening to one of the steppers from the savaged remains of the Craft Robo and the stepper runs in both directions at a very decent speed quite happily.

    I would say based on this observation that speed isn't actually a problem with this sort of design for the average home hacker and that this is an ok approach if you want to drive a bigger motor and your stupid local electronics shop does not supply bipolar chips!

    Also I looked at all the Jaycar kits available and none of them were quite right or were just to expensive. Building this out of transistors was a lot more fun.

    The spindles seem to turn just as fast as they did when driven by the board from inside the Craft Robo. I am not sure what will happen to the transistors under load but the basics seem sound. Parallel port has not exploded. Transistors have not exploded. But they do get very hot fast. I think I will need some big heat sinks.

    Anyway in the final synopsis I would say you can indeed build a stepper controller this way and that it can work and that the opto couplers in this instance seem nice and fast for switching.

    For future reference I used 4N25 couplers. Also here is my python code for driving the parallel port. I hope something in this post helps someone else out in the future.

    # Damien Vincent Towning
    # 2009
    # Driving a stepper from the parallel port isn't hard

    import binascii
    import serial
    import string
    import time
    import datetime
    import win32api
    import array
    import subprocess
    import os
    import shutil


    from ctypes import *

    #################################################
    # convert binary string to dec
    #################################################

    def bin2dec(val):
    return sum(int(i) << k for k, i in enumerate(reversed(val)))


    ################################################## ####
    # Write out data to para
    ################################################## ####

    def write_paraport(port) :

    i = 0
    ii = 0

    forwards = [[0,0,0,0,1,0,1,0],
    [0,0,0,0,0,1,1,0],
    [0,0,0,0,0,1,0,1],
    [0,0,0,0,1,0,0,1]]

    #backwards = [[0,0,0,0,1,0,0,1],
    # [0,0,0,0,0,1,0,1],
    # [0,0,0,0,0,1,1,0],
    # [0,0,0,0,1,0,1,0]]


    paraport = windll.inpout32

    while ii == 0 :
    for i in range(0,4) :
    paraport.Out32( port , bin2dec(forwards[i]) )
    time.sleep(0.01)

    write_paraport(0x3BC)

    Of course I am sure you can guess what the next problem is. Having built my stepper driver this way I have now consumed all output pins on my parallel port.

    What I need to find now is some sort of decimal to binary chip I think. Something that will let me load up a nibble on one side and have it come out the other side as binary.

  13. #13
    Join Date
    Sep 2008
    Posts
    142

    Interfacing Stepper Motors to a Parallel Port

    Hi, you just need to use one of the modern chips around that is specially made for driving stepper motors. I would personally recommend the SLA7062 or SLA7067 as a good starting place if your requirements are to use motors upto 3 amps. I will post some attachments that you need to look at, all found on the web and copied. I you need further tips just ask.
    The data sheet has a schematic, or I can post you one from the May 2009 EPE magazine.
    You do not need to use the M0 signal, or the Sync signal, or the sleep signal...
    Its quite easy to find 8 inputs and 8 outputs (I will attach a diagram for this as well), so you will be able to easily interface 4 stepper motors using 2 signals per motor, one for step, one for direction. Then you also have still 8 inputs for switches for limits for upto 4 axis.....should be enough...
    If you need more inputs and outputs after that, just add another printer port to your PC.
    I hope this all helps.
    Attached Thumbnails Attached Thumbnails parallel04.jpg   Parallel06.png   parallel_input.gif   ParPortInterfacing.gif  

    Attached Files Attached Files

  14. #14
    Join Date
    Sep 2008
    Posts
    142
    Some further infos that you may need that I could not attach to the first post.
    Attached Thumbnails Attached Thumbnails ParPortInterfacing.gif   Softwarepinout.png  
    Attached Files Attached Files

Similar Threads

  1. Which Couplers?
    By caleb105 in forum Benchtop Machines
    Replies: 3
    Last Post: 02-23-2009, 03:49 AM
  2. stepper couplers
    By corrie in forum Stepper Motors / Drives
    Replies: 6
    Last Post: 06-03-2008, 05:45 AM
  3. Do the jaw couplers on MSC have backlash?
    By radicooldude in forum Benchtop Machines
    Replies: 6
    Last Post: 03-17-2006, 09:37 PM
  4. shaft couplers
    By dgalaxy in forum Benchtop Machines
    Replies: 4
    Last Post: 02-01-2006, 06:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •