G+_Chris O'Riley Posted January 2, 2018 Share Posted January 2, 2018 Happy 2018 Everyone! I'm wondering if anyone who ACTUALLY knows electronics Fr. Robert Ballecer, SJ @smittyhalibut ? can tell me if this is how it's done, or if I'm just lucky (so far). I kinda, sorta know what basic components do, can kinda, sorta make sense of some of the stuff found in data sheets, and can hobble together a circuit that seems to do what I want it to. But I occasionally release the magic blue smoke, and I'm always surprised when something actually works! Basically, my modus operandi is: Get it to work on as little current as possible. If it's working and nothing is getting hot, I consider it a success! But I know there's a lot more to it than I'm currently able to grasp. My latest "success" is an optical limit switch for my CNC mill. I wanted to trigger it from an indicator on the lead screw vs. just a mechanical switch on the table itself. I picked up an IR line sensor and breadboarded a circuit. A transistor wouldn't activate the pin on the control box, the pin has 12 volts and needs to be pulled to ground, normally through a mechanical switch or inductive proximity sensor. Not exactly sure why the transistor doesn't work (this is where my reach exceeds my grasp), but I figured a relay might. The IR sensor alone wouldn't activate the relay, but I figured a transistor might (this is where my asshackery makes up for my lack of grasp!). So the IR sensor activates the transistor which activates the relay, all is powered from the 12v line from the CNC controller, regulated down to 5 volts for the IR sensor, transistor and relay, and against all odds, it actually works! The whole thing only draws about 13 milliamps and only the voltage regulator gets slightly warm, which is to be expected. I don't have the free time to learn electronics the right way, i.e. starting from square one. I'm learning bit by bit, but is this basically how it's done - get it working without pulling too much current through anything? I know that's vastly oversimplified, but for the range of things I've been making, it.... seems to be working. Here's a photo of my breadboarded switch and my sloppy proof-of-concept circuit. Now that I know it works, I'll make a two-sided board to get the overall size down. Link to comment Share on other sites More sharing options...
G+_Paul Hutchinson Posted January 2, 2018 Share Posted January 2, 2018 I was looking for a relay in your pictures and not seeing one. Then I looked up the optocoupler's data sheet and saw that Toshiba made up it's own marketing name, photorelay. The circuit should work very well and is actually better than if you had gotten it to work with the transistor only. This is because the optocoupler isolates everything from the potentially very electrically noisy CNC mill switching line. The total current you measured is right where I would expect it to be for that circuit so I give it a big thumbs up. Also, the PCB looks very well designed and built, good job! In case you're interested, the reason the optocoupler worked when the basic transistor didn't is because the optocoupler has a MOSFET which can sink far more current than a typical small signal transistor. To make it work without the MOSFET optocoupler you could have used a discrete MOSFET, or maybe a high power bipolar transistor, to sink the switching line from the CNC mill. However, as I said above, that would be a little less robust because it wouldn't have the optical isolation. Link to comment Share on other sites More sharing options...
G+_Chris O'Riley Posted January 2, 2018 Author Share Posted January 2, 2018 Wow, thanks! I was far more expecting a "yea, it may work, but it's definitely not the right way to do it"! ;) I figured the reason the transistor didn't work was along the lines of what you described. That's what led me to look for mechanical relays, and noticed DigiKey had a section for "solid state relays". I noticed from the datasheet that it did look like a normal optocoupler, but I figured there was some distinction beyond marketing! And thanks on the PC board. I finally learned a proper design program (KiCad) and that was my second attempt at making one using the normal etching process. I had previously been milling them and, wow, this is so much quicker! Now that I know the circuit works and there aren't any glaring errors, I'll design a 2 sided board and maybe have a few made through OSH Park. Thanks again for looking it over and giving it a thumbs up! Now I'll go off all cocky and release some blue smoke! ;) Link to comment Share on other sites More sharing options...
G+_Chris O'Riley Posted January 3, 2018 Author Share Posted January 3, 2018 Oh, and I'll give everyone a laugh at my one big mistake on the board. For some reason (need to check why for future reference), the footprint I used for the transistor had the base and the emitter reversed. When I made the board up and it didn't work, I started poking around with my meter and noticed the transistor seemed to be the culprit. I double checked the datasheet and noticed the discrepancy. In a ultimate example of hackery skill, I removed the transistor, carefully bent the pins up instead of down and resoldered it upside down reversing those pins, or as I prefer to call it: inverted surface mount - iSMD! Link to comment Share on other sites More sharing options...
G+_John Sullivan Posted January 3, 2018 Share Posted January 3, 2018 Instead of a voltage regulator, Padre recommends a UBEC (universal battery eliminator controller) like this one: https://www.banggood.com/Hobbywing-3A-UBEC-5V-6V-Switch-Mode-BEC-For-RC-Models-p-915037.html You can input anywhere from 5.5 to 26 volts and get a steady 5 v out, without wasting power by generating heat. (KH Ep 360 about 44:35). Be sure to have the load applied before hooking up the power. Link to comment Share on other sites More sharing options...
G+_John Sullivan Posted January 3, 2018 Share Posted January 3, 2018 As for a relay, Padre recommends something like this: https://www.amazon.com/SunFounder-Channel-Optocoupler-Expansion-Raspberry/dp/B00E0NTPP4/ref=sr_1_1 He would probably use an Arduino instead of the transistor that you used, but your transistor saves a lot of space, and some cost. Link to comment Share on other sites More sharing options...
G+_Paul Hutchinson Posted January 3, 2018 Share Posted January 3, 2018 cosmic Ray With only a 13 mA current draw a simple small linear regulator generates very little heat while wasting less than 0.1 Watt of power. Now if it had 10x or more the current draw then I'd look at using a switching regulator like in those UBECs. Link to comment Share on other sites More sharing options...
G+_Chris O'Riley Posted January 3, 2018 Author Share Posted January 3, 2018 Hmmm, I hadn't considered stepping the voltage down once and then running it @ 5 volts the rest of the way. That's definitely worth some thought. To do it closer to the control box would mean the lines would be 3 to 4 feet into the enclosure and ultimately to each stepper motor which could result in some losses and/or interference along the way. Regulating it down at each sensor ensures I have a solid, relatively clean 5 volts. But yea, I'll think about that. I'm not really worried too much about the losses from the regulator, like I said, it's only drawing 13 milliamps, and they'll only be active when I'm zero'ing the mill. My plan is to mount a white plastic ring on each lead screw with a black band. There's an opening in each stepper motor mount where I'll be able to mount the sensor. I'll have a mechanical switch on the table that will feed the sensor the 12v (or 5v) when tripped. This will be about 1/2 or 3/4 of a revolution of the lead screw before I want the sensor to read. So the sensor will get power and on the next revolution of the black band, it'll activate the relay and register on the control box. From the tests I did with my breadboarded sensor, it should be accurate to within a step or two, which is more than enough for my needs. Before I rolled my sleeves up and worked out the current circuit, I did consider reading the sensor with an ATtiny85 and using that to activate the relay... but I thought that would be a bit overkill. One possibility of doing that would be to make a ring with fine index lines, counting and keeping track of each step with the Arduino, but then it gets involved storing the information and relaying it to the control software which already does as much, albeit in an open-loop manner - it keeps track of how many steps it's told the stepper motors to go, and just assumes they actually got there. Maybe a future project, but for now, just getting the limit switches working is going to be enough for my skills! Link to comment Share on other sites More sharing options...
G+_Chris O'Riley Posted January 3, 2018 Author Share Posted January 3, 2018 Paul Hutchinson I'm definitely interested in making a switching regulator circuit at some point, probably for something quadcopter related where you really want the efficiency, but yea, for this, the linear is fine. Stepping regulators are quite a bit larger, have 8 pins usually, need an inductor, etc. I used an MCP1702, which can provide 250ma, so even that's overkill, but it's what I had on hand. And I figured the extra size would help dissipate any heat. But good to know that 100-150mA is where I should start considering a switching regulator. I have lots of things I'd like to build, and one of them is probably going to be in that range. On that subject, is it dependent on how much the voltage is being stepped down? Would a linear regulator be ok with a 100-150mA if it was only reducing the voltage 2 or 3 volts, vs 7, coming from 12 to 5? Link to comment Share on other sites More sharing options...
G+_Paul Hutchinson Posted January 3, 2018 Share Posted January 3, 2018 It based on wattage/heat, so it's both. Dropping too much voltage e.g instead of 12V in you had 80V in @ 13mA you would waste ~1W. Having 12V in and 130mA you also waste ~1W and in both cases there would be heat that you would feel. A general rule I use is, if I can't hold my finger on the part indefinitely either a heat sink or changing to a switcher should be considered. Except of course when I'm doing extreme parts cost sensitive design and then I'll do all the math, and hard core measuring to push things to the limit of specs but no further. Link to comment Share on other sites More sharing options...
G+_Chris O'Riley Posted January 3, 2018 Author Share Posted January 3, 2018 Thanks so much for all the information and feedback. I definitely feel less in the dark than I did this morning. I wish I had the time to learn all this the right way, but it's really just a hobby for me and between work and family, time is limited. I can either take a class or start reading introductory books, or just try to build something and learn along the way. So far, I seem to know just enough to keep the successes outnumbering the failures! Thanks again, it's been a big help. Link to comment Share on other sites More sharing options...
G+_John Sullivan Posted January 4, 2018 Share Posted January 4, 2018 Paul Hutchinson You'll notice I said what "Padre recommends" not what "I recommend". As to the merits of what you would use over what he would use, I guess you'll need to discuss that with him. thanks. Link to comment Share on other sites More sharing options...
G+_Chris O'Riley Posted February 10, 2018 Author Share Posted February 10, 2018 So just an update on this. After confirming that the circuit worked, I redesigned the board in KiCad not limiting myself to what I could realistically make at home through the normal PCB etching process. The only change being adding a small LED so I could see the status on the board itself as opposed to having to look at the CNC control program (Mach III) UI, which will make adjusting it a lot easier. I uploaded it to OSH Park and just received the boards back today. The cost of the 3 boards was $2.20! Just received them today, soldered the components onto two, and they work perfectly in testing (Mach III detects them as active/not active). Now I just need to make up some mounts and connect them into the rest of the mill wiring. Really happy with how these turned out. https://plus.google.com/photos/... Link to comment Share on other sites More sharing options...
G+_Paul Hutchinson Posted February 11, 2018 Share Posted February 11, 2018 Nice design! Amazing price from OSH Park, that's be cheaper than home made for me and you get solder mask and silkscreen. Link to comment Share on other sites More sharing options...
G+_Chris O'Riley Posted February 11, 2018 Author Share Posted February 11, 2018 Thanks! Yeah, OSH Park is so cheap, I almost feel guilty paying so little. Even the shipping was free. I might still etch or mill a board just to test that a circuit works, but the only consideration would be time, not cost. Here's another board I ordered for something else I've been working on. Now if I could just keep the smaller components from twisting slightly as the solder paste melts, these boards would easily pass my OCD ?.> Link to comment Share on other sites More sharing options...
Recommended Posts