Jump to content

Headache


esaj

Recommended Posts

16 minutes ago, Cranium said:

You will be very pleased with the Rigol!  Did you get a 2 or 4 channel model?  Mine is two but for the motor controller, I could see where 4 would be very helpful.  At some point you may want to look into a logic analyzer as well.

It's the 4-channel model (DS1054Z: http://www.batronix.com/shop/oscilloscopes/Rigol-DS1054Z.html ), should be delivered by monday afternoon. :)  2-channel model (DS1052E) would have been about 100€ cheaper, but like you said, 4 channels might come in handy with motor-stuff (and otherwise too). There's also I2C/RS232/SPI -decoder, that has about 30hrs of "trial-time", but can be unlimitedly unlocked either by buying the option or getting a serial-number based unlock-code from a site like http://www.gotroot.ca/rigol/riglol/ (although rumor is that these don't work with newer firmware-versions, but likely someone will hack them again). Other time-limited options are the full memory (24 MSamples, without the option it's "only" 12MSamples) and the full 100MHz bandwidth (50MHz default). Funny that they put the hardware in, but then limit it by software. :P  Also comes with a set of 4 x 150MHz probes, so I should get started right away with no need to get accessories separately.

There are more expensive 4-channel models that come with logic analyzer + waveform generator (like DS1074Z-S PLUS) built-in, but the price about doubles there ;) 

 

16 minutes ago, Cranium said:

I use those wire jumpers as well.  They are very helpful but the spaghetti mess can still occur.  lol  This is from a LED stairs project I did. I mocked up a prototype before making the circuit boards.

z8DkcPR.jpg

 

Wow, finding a missing or a wire in a wrong place can be pretty painful with that :D  I still might try to "debug" the current version of the H-bridge, but likely will have to rely on dismantling & rebuilding, as it's hard to get the clips in without accidentally shorting something :P

  • Upvote 1
Link to comment
Share on other sites

Time to ramble about electronics again... I know this is the wrong forum (in general) for it, but at least this is in off-topic and people who don't care don't get it thrown in their faces ;)

So, monday came and went, and no scope. Today, it finally arrived. After finishing with my work, and before unpacking it, I decided to clean up all the clutter & mess that had accumulated on my desks. And get rid of the linux-box & speakers taking space, as I nowadays rarely use it anyway (plus I could take another monitor from it for my "work machine"). I didn't take a "before"-shot (you've probably seen the one in this thread, but now it was actually much, much worse since I've ordered so much stuff from Aliexpress and have lots of projects in breadboards scattered around :P). But here's the end result:

xM9DmBw.jpg

So much more desk space, nice. :) I'm going to get a third component cabinet to get things tidied up a bit more + probably need some small shelf for all the bigger stuff to further clean up the clutter. Hopefully I didn't leave anything too incriminating or embarrassing in view ;) (Well, there's a dirty platter on one of the desks...). Some projects lying around are three motor drivers (3-phase, H-bridge with mosfets, H-bridge with BJTs, the self-balancing robot's out of view), and the thing I'm measuring with the Rigol (actually, it's more testing & learning to use the Rigol than actually measuring the project).

The project being measured there is something new to me: first of all, it's not a motor driver :P, and secondly it's something I actually have use for as soon as it's finished. Simply put: it's a night light. Not the kind to keep some illumination in a room at night though, like kids might have.

I have a bit of a peculiar problem. although not really a big one, but something that gives me a nice project to work on. Usually my girlfriend goes to sleep before me. So, when I'm going to sleep, I turn off all the lights and sneak into the bedroom in the dark, trying not to bump into anything so I don't wake her up. Also a couple of light switches in the house are stupidly placed, so I need to navigate a bit troublesome route in the dark. What I need is a light that won't be too bright, but placed properly, will trigger on movement and illuminate my path without bothering my better half, then turn off automatically.

Sure, you can probably get lights like that from a store, but where's the fun in that? So I decided I would build one myself. I was first thinking I could use a passive infrared-sensor ("pyroelectric sensor") that notices motion. Then I thought it might be troublesome if the dog triggers it, as she can wonder around the house at night. The infrared obstacle sensors I had turned out to be no good for this; they only trigger some centimeters away from an object. Lastly, I had something interesting: ultrasonic range sensors. They look like this:

HC-SR04-Ultrasonic-Sensor.jpg

I had earlier ordered a bunch of those, and tested them with the Arduino & an example code (just to see that they work). While I had skimmed through the example, I wasn't exactly sure how they work. Of course, it sends an ultrasonic sound pulse and then measures the time it takes for it to bounce back from something, but how does it tell that to the microcontroller? During sunday, after looking at the codes and quickly measuring a bit with the cheap DIY-scope, it was pretty clear; you give a trigger pulse to the "Trig"-input, and then the "Echo"-output will send a pulse. The pulse length will tell how long it took for the sound to come back (btw. sound moves about 340 meters per second or about 1115 feet per second). So for a distance of 3.4 meters, it takes about 10 milliseconds. Of course, since the time measured is the time it takes to first travel to an object, and then travel back, the time will be twice the actual distance in this case.

Ok, I can get the distance based on the pulse-length. The examples actually use a function that measures the pulse duration that's included in the basic Arduino libraries. I want to trigger the lights only when there's something in front of the sensor that's close enough (it will be placed on a wall, and I don't want it to trigger when the pulse bounces back from the opposing wall). Easy as pie, with a microcontroller. Actually, it's so simple, that using a microcontroller seems like overkill...

I then decided to design it entirely with the basic components I have, no microcontrollers, no complex ICs (well, except for the ready-made sonar sensor module). Doing with an Arduino would be a breeze, but it would be too easy, and I wanted a challenge. I want to learn electronics, dammit, not coding, I already "get" to code all day at work :P 

I won't go much into the details of my "design process" (which mostly includes simulation with LTSpice and looking at simpler circuit examples from the web to get ideas) After figuring out how I could trigger on short pulse only, the rest was pretty much breeze. I did first build it around a 555-timer giving the trigger-pulse to the sonar-module, but after reading it needs about 10mA of current, and this thing's supposed to run on small batteries, I settled for a basic "astable multivibrator" (oscillator). After getting the measuring & light triggering working, I added a LDR (Light Dependent Resistor) to shut it off while it's otherwise illuminated enough (just need to take care on placing the leds & the LDR so that the leds won't shut it down by lighting the LDR :D). Here's the (more or less final) design:

Xwd5Nbm.png

In the upper half, there's a 5V power source (from batteries, actually if I use 5 NiMH's it will be more like 5 to 7V depending how full they are), an unnecessarily complex set of transistors (I wanted to minimize the voltage drop, that's why it's not taken directly from the collectors of the Q6 & Q7 -darlington pair ;)) and a simple voltage divider made by the LDR and a megaohm resistor (R16, in PCB I'm going to use a trimmer so I can adjust the point where it's "dark enough" for things to start happening). The LDR will go from about a 1k (kilo) in bright conditions to around 5M (mega) ohms in very dark (almost pitch black).

Once the LDR has dropped enough voltage, the transistors Q6-Q9 will start giving power to the rest of the circuit. When it's not giving enough voltage drop, there will only be small current going through the divider and some leakage in the transistors. I haven't measured it with the breadboard-version, but the simulation suggests around 60 microamps (6 µA) of current, which is good for battery operated device, as it won't suck the batteries empty when it's supposed to be "sleeping".

One the far left is the oscillator circuit, it gives out a pulse roughly every 0.9 seconds (I was aiming for one second, but that was close enough ;)). In a later picture I have of measuring the actual breadboard-circuit with Rigol, it's not actually giving out a square wave, but more like a "quarter sine" or something :P Probably due to the very large resistor values, usually oscillators like that run at much higher frequencies and can give (fairly) square output. 

I've simulated the sonar-pulse as a signal source in the simulation, giving a 5 millisecond pulse every second. As I want to trigger the leds only when the pulse is SHORT, but not when it's long, I've chosen to do it by charging the capacitor C1 slowly through a 20k resistor, and each time the sonar sends a pulse, for the duration of the pulse, the capacitor is being discharged through Q1 and a small resistor. So longer pulses = the capacitor voltage stays lower as it's being discharged for a longer while (and faster than it's being charged). Short pulse will still cause it to discharge a bit, but not as much.

Here's a screenshot of one the simulations I did in the early phase of the design:

ypzCcV0.png

Here, I'm stepping a parameter called "on" from 1m (milli) to 15 millis, 1 milli at a time. Then I run a simulation, where it will actually run it once for every value "on" will get (from 1m to 15m), using the "on"-parameter as value for the signal length (look at the PULSE -command of the signal-source). As a small sidenote, @Jason McNeil was asking me about electronics simulation software before, and I mentioned that I don't know if LTSpice can simulate sweeping or stepping values in single simulation; it can, actually it can do pretty useful things, but I've only scratched the surface. The above STEP-parameter usage is explained in this short video:  http://www.linear.com/solutions/1089

So the curves above are the the measured voltage from C1/R2/R1 -node (the voltage of the capacitor) over time with different lengthed pulses. Towards the end of the simulation, all the voltages go up, because I've set the signal source only to give 25 pulses (the last value) at 0.5s intervals, and then stop, so it stops discharging the capacitor. But as you can see, the peak (and minimum) voltage of the capacitor is lower the longer the pulse is.

So, back to the schematic. Based on the pulse length, the voltage at capacitor C1 is lower or higher, and I'm then using an op-amp to compare it against a set voltage (probably need to make it adjustable with a trimmer again, so I can set it correctly once the final "product" is in place). When the voltage of the capacitor goes above the set voltage, the op-amp will start conducting, and charge capacitor C2 (actually 1000uF is way too large, when testing with the breadboard circuit, it would burn for over 15 minutes :D, although the simulation suggested around 80 seconds). The capacitor is then discharged towards the last two transistors (the diode D3 prevents it from discharging towards the op-amp), that will allow the current to pass through the leds, and light them (until the capacitor discharges enough, so that the voltage drops below the junction biases of Q2 & Q3, and the leds turn off).  C2 seems to charge pretty quickly, so even after the sonar no longer gives a short pulse (I've passed the sensor and it's bouncing off a wall again), the capacitor is already charged and takes care of keeping the leds lit (and eventually turns them off after discharging enough). And it actually works (it never ceases to amaze me when my own designs work :P)!

So, yesterday (monday), I built that breadboard-version of the design, tested it a bit (and measured with the diy-scope). Today, now that I got the scope, I wanted to see it really in action.

0UPsl1t.jpg

This is a photo (there's a screenshotting option somewhere there, but I've yet to learn use it :D) of the Rigol measuring the circuit using all 4 channels simultaneously. I've only scratched the surface on using this thing, but I'm getting there. Here you can't really tell the actual voltages, as I've adjusted the vertical positions so that I see all the signals "separately" (not on top of each other), and they use varying vertical scales (50mv up to 5V per grid square). The time-base is fairly large, 1 grid square in X-direction is 0.5 seconds.

The top most (red/magenta/whatisthat) signal is simply the voltage between the Rldr and the 1M resistor near the voltage source (actually, here I've used a 330K resistor instead of the LDR, as the voltage wouldn't drop enough with the LDR with the lights on in the room ;)). Nothing that interesting there, except that there seems to be quite some ripple (maybe from the regulators of the breadboard-power source I use). Didn't investigate it now further, as it shouldn't matter much, and I was more interested in learning to use the Rigol.

The bluish (that "hue" is not seen in real life, it's the camera) signal is the C2 capacitor voltage, which is staying pretty near fully charged (it's only 50mV per grid square), as this was in a position where the sonar is giving short enough pulse to keep the op-amp conducting all the time.

The whitish signal is the voltage at capacitor C1. I've just moved my hand away from the sensor, and the voltage is dropping (remember, there's a pulse coming from the sonar about every 0.9 seconds), as the capacitor is discharged for a longer while (while simultaneously being charged all the time). So you can see it drop fast when the pulse comes, then build up voltage a bit, then drop again, build up voltage etc.

In hindsight, I probably should have measured the sonar echo-pulse instead of the voltage at the LDR/R16 divider, as that might have been more interesting, but probably would have just shown one pixel wide spikes (if that) at this time-base, as the signals are in the millisecond range (sound travels about 0.34m per millisecond, so 17cm would give 1ms pulse, as the sound must travel it back and forth).

That's it for now. I should head to bed (without the nightlight, yet, so something might go bump in the night ;)), but will finally try to get SOMETHING more or less finished during this week. Probably I'll first play around with the scope, then finish this project, and then (finally) get back to building (more) motor drivers for the balancing robot. Also, I should really start hurrying with getting a wheel for next summer, as you never know with the delivery delays... :P

 

  • Upvote 3
Link to comment
Share on other sites

Great writeup @esaj!

I like the simple design approach you used to time the length of the LEDs being on to the charge in a capacitor.  I've said it before and I'll say it again...I really need to put some time into using LTspice.  How long does it take that capacitor to charge back up fully?

I like this design for an AC light sensitive circuit (and enjoy the vlogger).

http://www.electroboom.com/?p=736

 

 

Link to comment
Share on other sites

3 hours ago, Cranium said:

Great writeup @esaj!

I like the simple design approach you used to time the length of the LEDs being on to the charge in a capacitor.  I've said it before and I'll say it again...I really need to put some time into using LTspice.

Thanks! I already feel like I understand electronics better than even during school back in the day, not that I really know that much yet, it's more trial & error still :P 

LTSpice is really handy (the best I could find from the free ones I tried), it has pretty nice GUI, is fairly straightforward to use (well, for an engineering tool ;)) and works quite OK (for the most part). Here's a bit from the messages I sent to Jason McNeil earlier:

-----

A couple of quick notes about LTSpice and it's quirks:

Assuming you're using Windows, I don't remember for sure, but it might have required to be run as Administrator on first start to setup some stuff, if it does complain, right-click the icon/executable and select "Run as Administrator". After that, you should be able to run it ok as normal user, although the schematics need to be saved somewhere else than the program directory (as that's usually under Program Files and requires admin-privileges).

If you're like me, and like to use short-cut keys to speed up your work, check through the menus in the program, the keys aren't what you typically find in most software (for example, undo & redo are F9 & shift-F9, not ctrl-Z / ctrl-Y as in most other programs).

If you want to rotate/mirror a component that's already placed, you first must select it either with "move" or "drag" tool, and then click the rotate/mirror-buttons (moving the mouse outside the work area, the component gets "stuck" in the corner) or use ctrl-R / ctrl-E. A bit unintuitive, but you get used to it.

Anything else except very basic components like resistors, diodes, capacitors and inductors are under the "components"-button in the tool row. Some stuff might be a bit hard to find at first, for example to simulate PWM-signals, use the signal voltage source which is found under components -> [Misc]/signal.

For pretty much everything else except resistors and capacitors, I suggest using "real" component models. By default if you add, for example, a NPN-transistor to the schematic, it will use some "ideal" model that simplifies the simulation and leaves out real-world stuff. The simulation can then sometimes result in weird results vs. real-world circuits. Right-clicking on top of the placed component gives you menu for modifying it, under which there's a button for "Pick New <Component Type", which will then give you a list of all the real components available. In many cases, if you have specific component in mind (like, say, 75NF75-mosfet), you won't find it in the list, but pick something with closely same values (like Rds-resistance and/or max voltage) to get "more correct" results. The simulation will never be 100% accurate compared to real world, as there are lots of things that cannot be simulated properly (stray capacitance from wiring and such) and values you don't know (like voltage source internal resistance in some cases, for example, although with li-ion packs you will know it if you know what the cells are).

When running a transient simulation, if there's something wacky happening in your circuit (like high-frequency oscillation / resonance occurring at some point), the simulation speed can drop to really low (like few microsends per real-time second), leading to really long simulation times. In worst case, the simulation seems to stall completely (it doesn't advance at all and won't respond to Halt-command under the menu). In such cases, only closing & reopening the whole program seems to be an option. It might be a good idea to save your work before running a simulation, if you've made such changes that you want to surely keep after last saving ;)  I don't think this ever happens with voltage-sweep -simulations.

About the above: the simulation "freezing" -problem can occur every now and then with more complex circuits, and if it does, it usually happens right at the start of the simulation (ie. it won't advance at all from 0ms or might advance a few µs and then stall). You can actually save your circuit even if it freezes, but you might need to restart LTSpice if you cannot halt the simulation. This has only happened to me with a more complex circuits, especially when there's lots of oscillating / ringing occurring or if I restart the simulation multiple times in a row within a very short time span.

Lastly, unfortunately there seems to be no way to do resistance-sweep simulation (like simulating turning a potentiometer knob), so only way seems to be changing the value by hand and re-running the simulation to see how it effects.  <-- WRONG, there are all sorts of instructions you can add to the simulation, I just haven't used most of them yet now that I found them. ;)  In the overcurrent-limit circuit I posted earlier, I just did a few simulations with different values, and the screenshot shows a 500K resistance for the potentiometer, but in the end I used a 10K potentiometer in the real circuit

Oh, and you can use short-hand values like k (kilo), m (milli), u (micro), p (pico) for entering values, so instead of writing a 470uF capacitance as 0.00047 you can just use 470u.

That's all I can think of right now, hopefully the above will help you get started a bit faster than I did at first

-----

I even found a large component library for it on monday night:  http://ltwiki.org/?title=Components_Library_and_Circuits  Haven't used those yet (the night light circuit was designed using the components that come with "vanilla" LTSpice, so for example the op-amp is a different type than what I actually use), but in future designs I can probably find the correct component-models from the library and don't need to use something that's just "close" to some values.

3 hours ago, Cranium said:

How long does it take that capacitor to charge back up fully?

If you mean the C1-capacitor (the one that's being discharged by the sonar-pulse), it might take a few cycles for it to reach full voltage it can (about source-voltage minus voltage drops in the Q9-transistor and the diode), but as I can adjust the comparison voltage for the op-amp, I can set it to trigger at much lower, so I can adjust the distance needed to trigger the lights. If you meant C2-capacitor, it seems to charge more or less fully whenever the op-amp triggers to conducting state, but I haven't actually measured it precisely yet.

If going by theoretical RC-value, C1 charging side is

20000ohm * 100uF = 2 seconds

And about 3-5 times that before it's more or less full:

t = 1/3RC → I = 75%, V = 25%
t = 1/2RC → I = 60%, V = 40%
t = 2/3RC → I = 52%, V = 48%
t = 1RC → I = 37%, V = 63%
t = 2RC → I = 14%, V = 86%
t = 3RC → I = 5%, V = 95% - practically fully charged
t = 4RC → I = 2%, V = 98%
t = 5RC → I = 0.7%, V = 99.3%

For discharging (and as the C2 charging uses also a 100ohm resistor and in real circuit I use 100uF there too, C2 charging):

100ohm * 100uF = 0.01 seconds (10 milliseconds)

Of course, in reality, there are other factors at play: the transistor Q1 will likely limit the current a bit (I havent measured how much current there actually is in the base when the pulse triggers, so it might not be fully conducting), the op-amp cannot source but maybe something like 20mA (at around 5V supply, 100ohm resistor should allow 50mA), I have used "ideal" capacitor-models in the simulation (no serial resistances and such) etc. I might still have to tweak some values before it's working fully as intended in real-life, but that's why I'm going to use the 

3 hours ago, Cranium said:

I like this design for an AC light sensitive circuit (and enjoy the vlogger).

http://www.electroboom.com/?p=736

I still don't feel comfortable working with AC-power (although if using premade-wallwarts, it should be pretty safe). Maybe later on... ;)

I actually found yet another project I need (actually, want :P) to do some time: http://www.zen22142.zen.co.uk/Circuits/Testgear/funcgen.htm

That should come in handy, and the 8038-voltage controlled oscillator chips cost like 3€/5 pieces from Aliexpress.

And, I've still got the PSU-project (also :D) coming, but it's currently waiting for something: momentary buttons for the front panel & one of my orders was messed up and I didn't receive the 0.01ohm power resistors, only 0.05ohms (0.01ohms are needed for high current-versions of my overcurrent protection) . I have lots of buttons, but they're either too small or too large for my liking/front panel design, so I had to order some more :D

  • Upvote 1
Link to comment
Share on other sites

6 hours ago, lizardmech said:

They finally arrived.

 

Nice!  I want to see a picture once you have it all soldered up.  Are you hand soldering it?  Hot air soldering?  Or reflowing it?

Link to comment
Share on other sites

6 hours ago, Cranium said:

Nice!  I want to see a picture once you have it all soldered up.  Are you hand soldering it?  Hot air soldering?  Or reflowing it?

I bought a soldering station with a standard soldering iron and hot air tool. Most of it is easy enough to hand solder, I just have to work out how to do a few difficult parts that don't have pins sticking out.

Link to comment
Share on other sites

A slight deviation from earlier plans... I didn't have time to work on anything since tuesday-night, and just now got back on track. But then my desk light gave up, and it's hard to work on soldering etc. with not enough light.

So get a new bulb? Yeah, I'll get to that some day, but in the meantime, I figured that I have power leds: 3W, with choices of either 2...2.5V / 700 mA or 9V / 300mA, the difference is that the 9V ones have actually three 1W leds in series, thus the difference in voltage / amps.

Well, of course I don't have a spare 9V/12V AC/DC -transformer ("wall wart") right now. So batteries it is for now then. Next problem: the battery cases I have are a bit of "wrong size" (too many / too few batteries) for such voltages, without excessive power losses in the forward resistor / too low current once they're more empty. But maybe I could pump up a 4-battery (around 4...6V with rechargeable NiMH, depending on the charge state) to 9V? I did stumble upon "joule thieves" by accident last year when I was disassembling a broken garden light (the kind that charges a one NiMH cell with solar cell, and yet somehow manages to light up 3V led with only 1...1.5 volts).

I dug up a 2-transistor / 1 inductor design for such device:

2-TrJouleThief.gif

While I do understand the basic idea (the resistors/capacitor/transistors form a self-oscillating circuit, that switches the coil between ground and the load, essentially charging up its magnetic field and then discharging it through the led), unfortunately I'm not quite clear how the values for the components should be picked, so I fooled around with it until I had something that worked in LTSpice and at least some idea how the component values affect the end result (I also added a resistor before the led to limit the current, which seems to also affect the voltage).

After getting it to work in general (giving out about 10-12V to the load, forward resistor would drop the "excess" before the leds), I then built a the simple circuit on a breadboard and tested it using just a resistor as a load. After fiddling for a while with it, I measured the voltage after the coil with the oscilloscope to see the values... peak voltage 54V. Wait, 54V? Something smells like burning (it was causing about 30W of power being dissipated by a 100ohm 1/4W resistor :D)... Well, that's actually useful: if it really can get that high voltage from batteries around 6V (I was using 4 x non-rechargeable AA's which have about 1.5V nominal voltage), I do have one larger power-led I ordered among the others, although I had already dismissed I'd ever use it: it's 15 x 1W power leds on a 90mm circular heatplate, requiring about 48V of voltage. So does it work? Had to try:

 

JNRLJFs.png

In this test-setup, it's actually powered through a 4 ohm / 100W power resistor (just in case), over which the voltage drop is 0.047V (47 millivolts), so it's being fed only about

0.047V / 4ohm = 0.01175A = 11.75mA

of current (on average, as the voltage drop was measured only with the multimeter). It's rated for 300mA, so this is still a far cry from the full brightness (it looks brighter than it is in the picture, it's bright enough that I don't want to stare at it all day, but I want it brighter to actually use it as a desk lamp). Probably need a lower resistor, unfortunately, between 10ohm and 0.1ohm, I don't have much. Maybe I'll just try it with the 0.1 ohm / 5W resistors... ;)

Another thing that might become problematic is that the power inductor (6x8 220uH, btw, I don't even now what the current rating for it is, around 1A?) I'm using gets pretty hot, as the "charging" current is about 1.2A, so I'mot sure if it can take it in the long run. Well, guess I have only one way to find out... ;)  The NPN-transistor is a TIP41C, which should handle up to 6A continuous / 10A peak (plus I've added a heat sink specifically meant for TO-220 -packages to it), so that's not really a problem.

EDIT: Tried it with 0.1ohm resistor, not much change: voltage drop over the resistor was 1.5mV, giving a current of 15mA. I then measured the battery voltages (5.6V without load, around 4.85V under load) and current coming from batteries (500+mA, don't remember the exact value anymore). So the issue could actually be that batteries cannot give out enough current (as power doesn't come from thin air, they actually have to give out a lot more current than 15mA because the voltage is pumped up by about 10 times and there are losses on the way). The current reading isn't actually that trustworthy, as the hook clips I used on the multimeter are just crap (something like 0.2 ohm resistance from them alone).

Edited by esaj
  • Upvote 1
Link to comment
Share on other sites

That took a lot longer than I expected... While the "joule thief"-oscillator kind of worked, it would stop oscillating after about a minute or so  (I could see the frequency starting to drop in oscilloscope, then it would stop oscillating and the light would go out). As it didn't start oscillating again even turning the power off & back on, I suspect it had to do with the components warming up and some values changing with temperature. I spent quite a while testing different component values and other things, and over time, the (more or less) final result was making it basically a simple boost converter:

mk36Syp.png

There's a simple oscillator ("astable multivibrator" again, I just love that name :D) that drives a 2N2222 (Q2), that then in turn drives the power BJT (Q1). Reason I'm using another transistor in between is that the power-BJT can have fairly low current gain (hFE = 30), so it needs quite a lot of juice to make sure that "enough" current is flowing through the inductor to "charge" the magnetic field. After the TIP41C stops conducting, the magnetic field collapses and the voltage raises higher to pass through the leds (and charge the capacitor C3). The "funny" thing is that the voltage in simulation is much lower than in real life, but that could (maybe) be due to the LEDs I've used in the simulation (I don't know if they have lower forward voltage or something, the spice-model doesn't tell it directly). There been some other weirdness too (related to the oscillator frequency etc), but I think that's due to things that aren't simulated here (stray capacitances, component tolerances, values changing as things heat up, battery internal resistance etc).

Here's the waveforms on an earlier "model", at this point there wasn't that diode D17 or the capacitor C3, just a 0.1ohm power resistor sitting before the leds (and maybe some other valued components than in the schematic, don't remember ;)):

aYysNne.png

The highest (yellow) curve is the oscillator, the pinkish one was probably battery voltage (maybe? It's been a couple of days and I didn't write them down) and the lowest is the voltage going to the leds. The frequency is lower than currently (around 35kHz), as I was "only" using 4 batteries (you can see that the voltage has sagged to around 4V). I later on used 8 batteries in series to get it brighter.

1IJrhns.png

Circuit under test, I later on went and added the diode + capacitor, as testing on breadboard, I could see that the light becomes more brighter that way.

Testing with more batteries (still before the diode & capacitor), I got some weirdness happening:

1wFX2NJ.png

That's from the same channel, there's some persistence added so I can see the waveforms from a longer while, and it seems the voltage over the leds comes in "two waves" (those aren't occurring at the same time, but that smaller "blip" happens somewhere in between). There's also that "squiqqly" wave after the shorter wave drops down, the whole thing is actually working in "discontinous" mode, but I don't know if it's necessarily a bad thing (as I don't need to get a stable voltage out of it)?

Testing with more batteries, that second "spike" is still tehere, but things seem working fine still.

nx7Nz0w.png

 

Here are the measurements from the soldered version with the diode and capacitor in place.

VG6r7QZ.png

There's again persistence used here to see the changes in waveforms over time. The yellow line is the voltage at the TIP41C (Q1) base, pinkish one is the oscillator pulse, blue is the voltage at the capacitor (channel 4, some statistics values also shown below the graphs), and the lowest light blue/whitish line is the voltage from between the coil and the power-BJT (before the diode going to the leds).

The voltage over the leds now stays between about 40 and 43-44V (it does "wander" a bit over time though, but not much). The heat sink on the power-BJT and the inductor itself do get fairly warm (I tried running it for a good 20 minutes), reaching temperatures of about 70-80 Celsius and 50-60 Celsius, respectively. The batteries started around 10.8V, dropped fast to around 8.9V and then (slower) settled at about 7.8V (and drop from there slowly, as the batteries are drained). Likely I cannot run it for hours on end on batteries only, so I'll have to see if I can hook it up to the PSU. Right now there's no resistor before the LEDs, but that might then become necessary to limit the current (the batteries can't push out that much, especially as the voltage is pumped up about 5-6 times higher, but things will change with 12V input and much higher current sourcing capacity ;)). But, it was fun to make (or sometimes frustrating, as I couldn't put much trust on the simulation results :D), I found some use for that big ass led-light and learned to use the features of the scope (although there's still lots I haven't even tried).

Now, I can (finally) get back on the nightlight-project... :P

 

 

 

Edited by esaj
  • Upvote 1
Link to comment
Share on other sites

Finally my flu gave up (plus today was holiday, of course), so I got to working on the night-light -project again.

BWJASOK.jpg

I built the "final" version into a matrix(?)-board. In hindsight, I should have used a bigger board, it got really crowded but I managed to cram everything except the trimmer for controlling light burn time (so now the capacitor C2 feeding current to the transistors controlling the leds only discharges until the voltage hits the junction forward voltage and they stop conducting). The C2 capacitor is connected to a 2P-row connector (so I can change the size if I need to, like I did later on), same for the LDR (so I can take it off for testing to let it turn the LEDs on even when it's bright) and the LEDs (so I can wire them away from the board).

This is schematic for the final version, not much change to the earlier:

Up13gaX.png

C2 is still marked as 1000uF, but in reality, I use much smaller capacitor (I'll get to that in a bit). I changed all the 20k's to 22k's, because of a mix up in one of my orders, I ended up with 200 extra pieces of 22k resistors :D  Doesn't matter much here. Q6 & Q7 are actually a single Darlington in the board-version.

I also did a very stupid mistake while building. For some reason, I put 1uF capacitors on the oscillator instead of 10uF (C3 & C4) I used in the schematic/simulation and on breadboard. I did do some quick measurements (with just a multimeter) while soldering it together, and since everything seemed to be conducting right / giving correct resistances, I didn't check it further. Only during the first test did I notice something's wrong, getting the lights to come on was really hard. The oscilloscope showed the reason: the sonar was triggered 10 times per seconds instead of once per second, and the capacitor C1 was discharged so fast that the voltage couldn't get higher until there was an obstacle less than 10cm away from the sensor. I didn't take a picture of it, but I fixed it by soldering 10uF capacitors in parallel with the existing 1uF capacitors, straight to the existing capacitors legs :D  Not pretty, but hey it works (the capacitors in question are right next to the sonar-sensor in the board, very cramped place to go soldering anything afterwards ;)).

After some more testing, I soldered wires & Dupont-pins for the LEDs and the LDR, and then built a "prototype"-casing from Lego again:

sD2dQmp.jpg

Btw, did you know that the 5mm LEDs fit perfectly inside the holes of the "Technic"-Lego blocks? :P

u19by.jpg

I used the holes to put the leds facing in different directions (I need light to two directions, towards the bedroom & the hallway) and another hole facing away from the lights for the LDR (so it won't get enough light from the LEDs themselves to shutoff).

2wooplA.png

 

It took quite some fiddling with the two trimmers (another controlling the LDR-voltage divider and another one controlling the comparison voltage where the lights should trigger).

First off, I still should have gone with more resistance for the "low side" of the LDR / R16 / R18 -voltage divider. With 470k resistor + 1M trimmer turned to maximum resistance, it could still start working even when there's little light around and the LDR is partially shaded. That can be remedied by bringing out the LDR further out (right now it's partially inside the casing, where it's a bit darker than outside). 

Getting the comparison voltage "correct" takes quite a lot of testing. I should have used a 500 ohm or 1k trimmer for the discharge-resistor (that would make it possible to adjust how fast the pulses drain the capacitor), but that whould have needed a larger board (I couldn't even fit the trimmer for fine-tuning the burning time :P). I later on changed to 4-battery case, as I seemed to get better results with that. It helps to be able to take the LDR out (without the LDR, the Q7 base is connected to ground through the resistors and the rest of the circuitry gets power) to fiddle with the values and follow the voltages with a scope or a multimeter (you can get semi-sensible readings just with multimeter, the voltages don't change that fast with around 1Hz pulses, although reading maximum/minimum values is hard of course). All in all, once I found the correct comparison voltage-setting, I also changed the C2 capacitor to a smaller one, still need to test a bit what would be "perfect" regarding burning time, but it's likely something like 33-47uF (for my uses). 

I do intend to build a more "final" casing for this later on (and attach it to a wall, now It's just sitting on a bench ;)):

SFP98PG.png

Sorry for the crappy picture, iPhone camera suck in low light conditions... it looks like there's just the spot caused by the LEDs & it's otherwise completely dark, but that's not really how it looks in reality.

 

 

 

  • Upvote 1
Link to comment
Share on other sites

A couple of pics of the PSU-project, I tried to turn it on with the actual computer ATX-PSU for the first time today... didn't blow any fuses (at least yet).

The innards are pretty messy at this point, plus I'm still missing a whole bunch of stuff. It's just (unconnected) +5V steady output and adjustable (something like) 1.2V - 11V output, both with adjustable overcurrent protections (here adjustable up to 4.5A + I have 5A fuses there just in case ;)). No power-button yet, so I have to power it by shorting the PS_ON and ground with a jump wire:

o1e3HLv.jpg

 

1s5fabB.jpg

1THtHYN.jpg

 

This is the schematic for the overcurrent protection (it will just cut power if the current exceeds the limit, not limit it):

overcurrent_limit.png

"Power_On_Led" is named a bit wrongly, it actually lights up when there's any load connected to the terminals... ;) There's a reset-switch added in parallel with the Q3 (bypassing it when pressed), those are the red-buttons in the front-panel (to cut power manually). And I had to use three feedback-diodes in the latching op-amp, two wouldn't drop the voltage enough for the reset to always work :P And I left the Q4 out in the versions built on the board (there are two similar circuits there).  Other than that, I think it's pretty much up-to-date.

Edited by esaj
Link to comment
Share on other sites

I figured earlier that making a current-limited ("constant current") source would be beyond my skills, but it wasn't as bad as I was afraid of. Mostly it's based on this:  http://electronics.stackexchange.com/a/84544

 

kgOPDWU.png

I've replaced the 1.25V -reference with TL431, I've got like a hundred of those, don't know why I ordered them in the first place, but here it's really useful. Think of it as a very stable (temperature & input voltage -wise) zener, holding the reference voltage steady. The R3 & R4 -resistors are there just to "bias" the reference, might have been enough simply to connect it directly to it's own cathode. From there, the reference voltage (around 2.53V with the real component & those resistors) is divided to "low enough" value-range over the pot U4 (yeah, it's marked with "U" although it's a resistors, that's a custom-potentiometer -component I found from the custom libraries, pretty handy actually) to give a comparison voltage for op-amp U7 (the numberings are all messed up, because I've added & deleted lots of components ;)). The basic idea is fairly simple: U7 will control the voltage at the gate of M1 (a power mosfet). The feedback to U7 comes from a current-sensing resistor R2 (a 0.1ohm/5W resistor), and if the current tries to rise too high, the op-amp will change the voltage of the gate to keep it within the limit. The voltage-drop over R2 will be  U = I * 0.1ohm, so basically 1A = 0.1V (100 millivolts). The adjustable range for the compared voltage is about 0V -0.6V or so, corresponding to 0-6A. That's good enough range, as the power dissipation over R2 will start to climb pretty high at 6A (6A * 0.6V = 3.6W), but I still might tweak that a bit. I've already built one on a breadboard and tested that it works in general, but still need to make more measurements before building the actual thing.

Beyond the basic control, it's useful to see what the values actually are. U8 & U9 are two op-amps used as non-inverting amplifiers, with amplification of about 10: Vout = Vin * (1 + 20k / 2.222k) = Vin * (10.0009..). Of course I don't have 2.222k resistors, but I use 2.2k + 22ohm in series, just haven't drawn those as separate resistors in the schematic. So the output voltage is 10 times higher than the measured voltage, so it also happens that 0.1V (1A measured / set current) becomes 1.0V. I can then use a ready-made voltage-display to show the value, and actually see the maximum amperage value I've set & what is currently being drawn. Of course it won't be 100% precise, as the voltage displays aren't that accurate (they only show 1 decimal) and the power resistor probably has some tolerance (it's not exactly 0.1ohm and I don't have a precise enough multimeter to know better).

There's also an overload-indicator led, that lights up when the measured voltage drop is near the set voltage (ie. real amperage vs. set amperage limit). I had to add that voltage divider (R8 / R15), because while the simulation says that the led should stay lit when the current is being limited, in reality it only blinks once when the limit is hit and the limiting begins. Dropping the set voltage a bit should make that go away (I didn't actually test the divider yet in real-life, so I might have to tweak the values a bit). 

The last part is the temperature protection. That power mosfet has to dissipate some serious wattage if there's really low impedance load and the current is being limited. I plan to put a 100k NTC touching the heatsink of the mosfet, and if the temperature rises too high, the voltage divider between the NTC and Temp_Calib_10kTrim (for adjusting the temperature where it will happen) will make M2 conduct, which will do two things: ground the mosfet gate through the diode D1 and light up a warning light (Overheat_LED). The gate voltage will drop low enough to stop the mosfet from conducting and the load power is cut.

There's an arrow and text "To fan control" in the left side. That leads to this circuit. At first I tried to add this to the original schematic, but kept getting errors like "too small timestep" trying to simulate it, so I made it a separate schematic (as it's actually independent of the rest of the circuit). 

gtbYdYV.png

It's a bit messy, as I did that fast just using some pre-made schematics, sligthly altering the resistor and capacitor values to better fit my case. This is basically a simple PWM-driver for a fan; when the NTC (note: it's different NTC, here a 10k one) resistance drops, it will start to produce a much higher duty cycle and frequency (simulations suggest between around 16kHz and 65kHz going from 10k to 1k for the NTC). I tested this with a real 12V case fan & 555, works just like it's supposed to. Basically this will kick in before the overtemperature protection will cut the power, the fan will run faster the hotter the mosfet gets (again, this NTC too will be placed next to the power mosfet controlling the load current).

That's a pretty fast run through of what I'll be working on next. As usual (if anyone actually even reads these :P), I'd like to hear any comments or suggestions for improvements (or even questions, although I'm still such a novice with electronics that I'll probably have hard time answering those :D), or any clear errors or mistakes I've made.

  • Upvote 1
Link to comment
Share on other sites

I still added some changes into the above circuitry:

IMk3cMe.png

Namely, the voltage divider at the overload indicator was causing a voltage drop (acting as a voltage divider) with the U4 potentiometer. Upped the values so they won't affect it (at least as much). Also, I realized that the overtemperature protection could let the load get power again once the NTC cools down, so it could go back on after the overtemperature protection triggers. I then decided I need a latch-circuit there, so the overtemperature protection has to be reset manually by a momentary switch.

At first I tried to do a latch using 4011B (a quad NAND-chip), but couldn't get it to work in the simulation properly (the simulation-models could have been bad though) with it feeding the M2 -mosfet gate or controlling a transistor that would "charge" the gate (I got some pretty weird voltage results, it wouldn't ever go up further than about 5V or so, and the feedback to the second NAND wouldn't then trigger, as it needs around 7V with 12V VCC). Testing the gate "separately" it worked just fine, maybe an issue due to the chip not being able to supply much current (around 1mA or so).  So I ended up using a similar two op-amp setup as with the earlier current limiter (that just cuts power once the current goes too high), which is fine; I can use a single LM358 (dual) op-amp, and as the circuit needs both the op-amps, I won't be left dealing with unused op-amp that would have to be separately terminated (There's a good article about properly terminating unused op-amps here:  http://www.electronicproducts.com/Analog_Mixed_Signal_ICs/Amplifiers/Properly_terminating_an_unused_op_amp.aspx ).

The simulation picture probably does look a bit weird due to the U5. It's a time-based switch used in the simulation, I was testing to see how the switch would work and trying to find values that would work so that you couldn't reset the overtemperature protection if the NTC was still too hot (so the signal from the NTC-measurement should override the switch, even holding down the switch shouldn't activate the power to the load if it's still too hot). Probably I'll have to tweak around with them still in the real life...

I also had a version which had LM317 for controlling the output voltage, but I think it's a better idea to have this as a separate "module" with input & output for the actual power. I can then add input- and output banana terminals into it, and use it "in-between" the actual voltage source (which can be a fixed voltage or adjustable voltage source or whatever, within limits of the M1-mosfet, which will probably be 75NF75). I think it's more useful that way than doing the actual voltage regulation within this same circuit.

Does anyone know if I need filter/bypass/decoupling/whatevertheyrecalled capacitors somewhere? I figured that that should maybe be dealt with in the power input or by the circuit under test (load)? Not that sure if there can be noise somewhere that could affect the working of the current source and should be filtered out. What about inductive loads? Do I need something here to prevent backwards spikes, maybe I should put a 75V transient suppression diode in parallel with the power input  load and ground?

Edited by esaj
Link to comment
Share on other sites

After slight changes, adding filtering capacitors (I simulated it with noise and it does affect the op-amps) and then 4.5 hrs of drawing & erasing later, I have some sort of component placement that fits into the board I picked... here's to hoping I didn't make any mistakes ;)

5xRADSV.png

 

 

  • Upvote 1
Link to comment
Share on other sites

  • 2 weeks later...

Long time, no post, but I haven't been completely idle (although I've mostly been busy with whole other stuff than EUCs and electronics, like that pesky thing called "work" that gets in the way of your hobbies).

I did finish building the above constant current source, and it seems to work ok. Currently my problems with the PSU-project are mostly related to casing, as the PC-case isn't as convenient as I had hoped. It takes too much space in my desk, and could be made much smaller (and I'd need to encase the boards inside the case too to prevent any shorts and such). So, have to take step back and look for other options. Something like 15x15x30cm or thereabouts (could be wider for more outputs) should be enough, whereas the pc-case is many, many times larger (and mostly just empty).

I was looking for some smaller casings meant as a house group center (don't know if that's the correct english term, it's a plastic or metal cabinet usually filled with DIN-rails for fuses, overvoltage protectors and whatnot, "electric cabinet" might be more correct term). Typically they are fairly large (and made of metal), but there are smaller ones made from plastic available that don't cost a fortune (something like 20-30e a piece), and those could be pretty useful as general casings for different projects (assuming the DIN-rails can be removed), but for the PSU, the cheaper options have inconvenient dimensions (usually too little space in some direction, width/height/depth-wise). The ATX-PSU alone needs at least 15x15x9cm, probably more on one of the 15cm sides, as the wires need to have some room also.

But to get correct sized casing for the PSU, It's starting to look like that I'll have to build it myself. Maybe I'll go with something like aluminum frame & using the same old floor-laminate (yeah, still got some of it left :P), but then, people have made really nice looking cases from acrylic:

acrylic-case-UV-1.jpg

Not that I'd put any extra led lights or such in it (other than indicator lights & voltage meters), but as a material, that'd be nice. Cutting the acrylic can be a pain (although doable by hand), but that actually led me to a (yet) another project: hot-wire cutter. :D

So far, I've mostly just played around with design ideas, the electronics side of the whole thing is (at least so far) really simple: a basic 555-based PWM-duty cycle controller to drive a mosfet, which is placed between ground and Kanthal-wire (can withstand up to around 1400-1500 Celsius) used to make the actual cutting.

uqTd0FL.png

It's a slightly modified version of what I used for fan-control in the constant current source, namely the pulse comes from the discharge-pin of the 555 (it seems this "configuration" gives a more stable frequency than the earlier, which used the output-pin), and using a push-pull -kind of control for driving the mosfet-gate. The simulation gives about 20kHz frequency for the PWM, and using that mosfet-model (STB120NF10, which has similar gate capacitance as 75NF75), the gate wouldn't charge / discharge fast enough (or it would put too much stress to the 555). The BJTs Q1 & Q2 are used to charge and discharge the gate faster without overloading the 555.

The 3-ohm value for the wire is taken from using a 26-gauge Kanthal that has resistance of around 3.3ohms per feet (30cm), I used a slightly shorter piece for testing and measured it with the multimeter (although I don't trust my cheap multimeter to be very precise at such low ohm-values ;)). 

I built a small prototype today to see how well the cutting works in general:

lfOiEYv.jpg

It's just a couple of pieces of metal (left-over aluminum bar on top from the frame-project and nail plate below) on a simple wooden frame, without the control electronics (just wanted full power out of it). The groove on the lower side is meant for running the cabling, once there's a "table" on top for easier working. A simple lever mechanism and a bunch of rubber wires keep the wire tight, as it contracts & expands with the changing temperature, although the rubber bands must be replaced with a metal spring later on to get enough tension. The wiring is just quickly slapped on (not even actually fixed in anyway :P).

I was using a 7.2V nominal / 3.6Ah NiMH-battery for testing, and at first it seemed it would get pretty hot:

iGG7KLT.jpg

 

Unfortunately it just won't give enough power. It glows red hot for a little while, before it already starts to cool. Testing the actual cutting:

 

It does cut through styrofoam (styrox) like it's nothing (off-camera, I tried slicing it a lot faster, and no problems there), but with that piece of sewer pipe (it's actually polypropylene, don't know if it has higher or lower melting point than acrylic), it just wouldn't cut it. The wire cools off too fast and gets stuck in the material. Mostly I believe the problem is simply that the battery cannot give high enough wattage to the wire, so it won't get (and stay) hot enough for really cutting through fast enough.

Measuring the voltages & amperages, the battery was at around 8.5V when I started, and during use it drops to around 7.3V. The amperage was about 2.7A, giving a total of 2.7A * 7.3V = 19.71 watts of power. Don't know how much of that is dissipated in the battery internal resistance.

Nevertheless, since other people have successfully built such cutters before (for more "sturdy" materials than just styrofoam), it should be easily doable, but I'll need a more powerful power source for it (not that I was planning to run it off batteries anyway in the long run ;)). Maybe a foot switch for turning it on/off could be useful too, and of course the table-part so you can use it more like a table jigsaw. 

Another part I'll probably need (or mostly just want :P) sooner or later:

http://www.wa4dsy.com/robot/hot-wire-plastic-bender

 

Edited by esaj
Link to comment
Share on other sites

I finished building the simple PWM-controller and took some measurings. The adjustable range is between 0 and 98.5% duty cycle, and the frequency is between 21 and 17kHz (the frequency drops a bit with higher duty cycle). All in all, it works pretty well. I did change the resistors above the mosfet gate (in vcc-side) to 47 ohms, so they're both now 47 ohms. This gives pretty much straight up ramps on the pulse going up and down, and should both the transistors be open at the same time for some reason, it should limit the current to about 12V / 94ohms = 0.1277 = about 128mA.

I tested the cutter today using the controller and the ATX-power supply (straight up 12V from one of the power lines without overcurrent protection/constant current, although it does have 5A fuse there just in case).

KXDyvpg.jpg

 

At first, it seemed that the wire wasn't getting hot (I was using a low duty cycle), so I pushed it straight to max. The wire broke almost immediately :P  Upon further inspection, it cut right next to the top aluminum bar, so probably there was a too large temperature difference between the bar and the wire, and the wire couldn't take it. I cut it a bit shorter (measuring later on, the resistance of the wire itself was around 2 ohms) and tried ramping up the duty cycle much slower.

VZjgPjC.jpg

It does get glowing red hot, but I don't have any tools to actually measure the temperature. My connections weren't that good (that's just a banana clip in one of the holes of the makeshift-bed), so probably they also add unneeded resistance in the circuit. Also note how close the wire is to the aluminum bar on the top, I need some other way of fixing it to the lever. The best I can do with the temperature is try to compare it to a metal color temperature chart (this one's for steel, though):

GlowChart-sm.gifGlowChart-sm.gif

Hard to say for sure, maybe 800 celsius or so? There's still the problem that the wire cools off rapidly when the object to cut is touching it. It cuts away the polypropylene pipe for a couple of millimeters, before the temperature drops too much to keep going (stopping for a few seconds, it does get warmer again, but cutting is very sloooow). 

Since the power supply can give lots of amperes without dropping the voltage, I'm suspecting (but didn't measure, I didn't have the multimeter with me in the garage) that the voltage isn't dropping (also, AFAIK, the ATX-supply protections should shut it down if the voltage drops too much), but the extra resistance in the circuit prevents the current from going as high as the wire alone would allow (otherwise the 5A fuse should have popped, as 12V / 2ohm = 6A).

After testing it for a while, I tried to more forcefully cut the pipe, again causing the wire to snap next to the aluminum bar:

DsnVkdw.jpg

So, I either need even lower resistance (making the connections better could help with that alone), and maybe more voltage. Using a shorter wire should also help, at least I have control over the power with the PWM-controller, so even if the wire would allow it, I don't have to burn it with full blast. It's also unnecessary for the wire to be hot for the entire length, as only a smaller portion of it will actually be used for cutting, but at least for now, I'll go with this kind of setup. Last but not least, I could also use a step up boost-converter to use higher voltage, which should allow more current to pass (as long as the PSU can keep up, but it's a high quality 450W model, so it shouldn't be too big of a problem unless it turns out I need hundreds of watts :P).

Another thing that came up when I was talking about this with a friend of mine was that one way to approach this could be using a more "smart" controller. The resistance of the wire changes slightly as it heats up (it goes up around 5% from room temperature up to 1400 Celsius). I don't have tools or sensors to read that high temperaturs, but (at least in theory) the rising resistance could be (somewhat) measured by monitoring the current (the current should go slightly up as the wire cools and slightly down when it's hot). The problem is that the changes are pretty minimal.

A couple of ways to measure it I could quickly come up with were using a basic shunt resistor (I have some 50milliohm and 10milliohm 5W ceramic power resistors), but those probably aren't precise enough (don't know the tolerances, don't have tools to measure that small resistances & the resistances probably wander about with temperature). In theory, it could still be possible to measure the very small voltage drop over the resistor and then scale it up with an op-amp for ADC-input to a microcontroller. 

A bit more realistic option could be using ACS712 -chip (I have the 5A and 30A versions, but not 20A). ACS712 uses 5V supply and gives out a voltage reading that's half the supply (2.5V or so), and then drops towards zero or raises towards the supply voltage based on the direction and magnitude of the current. Placing the in such a way that the voltage starts to drop as the current raises, it could be possible to get a "reasonably good" measurement from the 10-bit ADC of Arduino by using an external ARef of 2.5V, which would give steps of

2.5V / 1024 = 0.00244140625 = about 2.44 millivolts per step.

The 5A ACS712 probably doesn't cut it, as I'll likely need more current. The 30A version has a scale of about 66mV per amp, the 20A has about 100mV per amp and the 5A about 185mV per amp.

So, assuming I'd need to use 10A of current (a value I just pulled out of my hat), and the resistance would RAISE about 1% as the portion of the wire cools down during cutting, I would have following values:

10A would give about 2.5V - 10 * 66mV = 1.84V or 1840mV

Dropping that by one percent (as the resistance rises but the voltage stays the same), the current would be roughly 10A * 0.99 = 9.9A. This would give a voltage reading from the ACS712 of about

2.5V - 9.9 * 66mV = 1.8466V or 1846.6mV

The difference that would need to be detected would be about 6.6mV or little less than 2 steps in the ADC. So the 30A version might not cut it, as the differences may be too small to measure. 5A is likely too little, and I don't have the 20A version. But this is in theory anyway.

If the changes could be measured precisely enough, the idea would be to control the PWM duty cycle based on the set current, and tracking changes around it, driving more or less current (higher or lower duty cycle) to keep the power more constant (a basic PID-control could probably keep things in check pretty well), so when the wire cools down during cutting, the controller would compensate it by upping the power, and when not cutting anything, it would ease up a bit. But it's all theoretical, I haven't tried it in practice. :P

 

Link to comment
Share on other sites

I'm hopping between projects, which might not be that efficient in the end, but took last night and today to get back on track with the robot-project. Earlier I planned simple(ish) H-bridges using BJT's and Mosfets, and now got around to refine the design a bit and make the BJT version first on breadboard and then solder one on an actual board:

hmOxe0O.png

It's pretty "normal" H-bridge, I think. The "direction" -inputs are used to pick the lower or upper side as active (ie. where the PWM goes), and the PWM gives the pulses to drive the motor by switching the power-BJTs (Fairchild TIP41C/TIP42C) on and off. Incidentally, the ready-made dual half-bridge that tends to overheat has similar inputs, so I should be able to use it without code or wiring changes. ;)

It's slightly changed from the first version, as I found out that I didn't need a darlington-connection for transistors on the lower side, and also switched to 1/2W resistors for the power-BJT base currents. The power-BJTs have low hfe (15-75, typically around 30-40?), so a larger base current is needed to drive them, and that causes a lot of power dissipation in the resistors. I also added plenty of filtering capacitors on the battery power and single capacitors for the bases, and the "reversed" Schottkys between the motor phases and the battery voltage/ground, as I was getting wild voltage transients between -20...20V with a around 8-9V input when testing on breadboard. Even in the final version, there's still lots of noise and interference from the motor in the circuit, but the voltages stay in check. The capacitor values were pretty much picked at random (well, I did simulate them and check the bandwidths with FFT) & with what I had lots of left :P  I've understood that in filtering, the actual values don't matter that much, as long as you have a large bandwidth attenuated (for the battery, as no voltage swings/transients are wanted there). With the bases, I did try some different values (in simulation) to see how they affect the voltages etc, and of course didn't want to attenuate the PWM-signal (<40kHz or so?) much, so no large capacitors there (I used 10kHz in simulation, in reality I used 20kHz and around 5kHz, and in the robot, I use the Arduino PWM-outputs, so it will still be different). They do attenuate around the PWM-frequency, but the PWM and the harmonics show as spikes in the LTSpice FFT with 10Khz PWM:

OjHdgdD.png

In hindsight, I maybe should have gone for even lower values (single nanos or even picofarads?), as the attenuation starts to get larger already around 100Hz, but still the PWM-frequency itself & harmonics shows as a clear spikes. Well, at least the real world end result seems to work just fine, no more large voltage spikes at the bases ;)

 

2H0mJg5.jpg

Last night, I built the circuit on a breadboard and did tests and measurements. I also did a stupid mistake of connecting the other half-bridge low-side BJT's emitter to battery power instead of ground. Took a few hours(!) to figure out why the motor would only run in one direction and why I was getting very "weird" voltage values :P  That large black blob at the lower end of the board with letters "CA" is a 12V/1.5kW transient suppression diode. It's not shown in the schematic and I didn't add it directly to the soldered board, if need be, I'll probably solder them straight at the motor leads.

Today, I built the actual thing on a dot-matrix board. I did have some preliminary drawings of how the components should be placed and where to make the "rails", but in the end, it of course didn't work out that easily and I had to partially "play it by ear". First half-bridge took a good time to make, but the latter one was much quicker (although it was a sort of a "mirror image", and I had one row less, so I had to change the placement a bit). Still, in total it took about 8-9 hours to design the component positions and put this together:

GAAJNTC.jpg

SWdqi15.jpg

Not enough room to heatsink the BJTs with TO-220 sinks I have, hopefully they won't get too hot (the motor I tested drew around 0.4-0.5A at 98% duty cycle, but had no load at all). I could always of course cut smaller heatsinks from aluminum bar or use the "self-adhesive" sinks I have for some smaller chips. Time will tell, I still need to build a whole another one, as the robot has two motors (this only drives one).

Didn't get to measure the soldered version that much yet, as my GF has a friend visiting, who went to bed next room, and I don't want to keep her awake with the motor (it makes a lot of noise even when rolled inside some foam :P). But since it seems to work ok (luckily, it would have really sucked if it didn't after all that work :D), I could probably go ahead and start building the second one...

Edited by esaj
Link to comment
Share on other sites

Well, I derailed (yet another) topic in the main-forums with electronics stuff:

Whoops. 

Anyway, I (of course) ended up trying a few things and came up with this "discrete gate driver" for a spot-welder:

FveNIhd.png

Arduino gives out only 5V -signal, and to be sure the mosfet is fully conducting, it's better to use more like 10V or so. The car battery is at 12V, so it's pretty logical to take voltage from there. Since BJTs cause voltage drops, I needed to come up with a way to get around this. It's really not that complicated in the end:

Arduino gives out a signal, that makes NPN-transistor Q1 conduct. When it conducts, it pulls down the PNP-transistor Q5's base to ground, making it conduct. From the collector of Q5, a signal goes to a push/pull -connection made with Q2 & Q3, which will charge/discharge the mosfets (M1) gate, causing it to conduct (when Q5's base is pulled to ground) / stop conducting (when Q5 isn't conducting). The resistor values might need some tweaking, but in general, the idea seems to work (in simulation ;)).  Of course, for the welding currents, a lot more mosfets and drivers are needed. Now, all I need is some time, a 12V car battery and maybe get shitfaced to be stupid enough to try this in reality... :D

In other news, I still haven't finished that second H-bridge for the robot I was supposed to. But I did build a rail-splitter (the kind of circuit that "splits voltage in half", ie. creates a "virtual ground" between input voltage and 0V, like 12V -> +6V, 0V and -6V), does that count? :D  It's meant for a ICL8038 (a voltage controlled oscillator chip) -based function generator, that I'm ALSO building on the side of all of my gazillion other projects :P  Also finally got a bunch of electronics casings, unfortunately, the only really large one I got (a junction box for house mains) was still too small to fit the PSU into...

EDIT: Btw, in the above schematic, I've used IRF3717, but it's not really good for this (only rated for 20A, only available in SO-8 -package...). So if anyone tries to build this (which I doubt ;)), use some better mosfets with low Rds(on), low gate charge, 15V or more Vds and high current rating.

Edited by esaj
Link to comment
Share on other sites

I did finally finish the second BJT-H-bridge and installed them into the robot:

KdfOA80.png

Unfortunately, while they work otherwise ok, I had no room for heatsinks in the board layout... and guess what? They overheat :D  Not with non-loaded motor & 9V battery, but when they have to start moving the actual robot with a battery-pack that gives much more "oomph", they go nuts after a while... Well, maybe I'll find some other use for them. Next up, mosfet-H-bridges...

 

  • Upvote 1
Link to comment
Share on other sites

Can anyone help me with dc-dc converters? I'm having trouble getting the needed voltages to test my motor controllers while keeping a common ground.

I bought some premade dc-dc converters but I can't get them to work.

mouser.com/Search/ProductDetail.aspx?R=ESTW004A2C41Zvirtualkey61920000virtualkey894-ESTW004A2C41Z

mouser.com/Search/ProductDetail.aspx?R=PG02S1205Avirtualkey59090000virtualkey108-PG02S1205A

mouser.com/Search/ProductDetail.aspx?R=CC3-1203SR-Evirtualkey57750000virtualkey967-CC3-1203SR-E

The larger GE 70V one just shorts anything plugged into Vi+/- melting wires when connected to batteries, and switching off any power supply connected

The other 2 I can't get any output from Vo+/- though they get a little warm so they must be doing something.

  • Upvote 1
Link to comment
Share on other sites

5 hours ago, lizardmech said:

Can anyone help me with dc-dc converters? I'm having trouble getting the needed voltages to test my motor controllers while keeping a common ground.

I bought some premade dc-dc converters but I can't get them to work.

mouser.com/Search/ProductDetail.aspx?R=ESTW004A2C41Zvirtualkey61920000virtualkey894-ESTW004A2C41Z

mouser.com/Search/ProductDetail.aspx?R=PG02S1205Avirtualkey59090000virtualkey108-PG02S1205A

mouser.com/Search/ProductDetail.aspx?R=CC3-1203SR-Evirtualkey57750000virtualkey967-CC3-1203SR-E

I have no experience with such converters, I've used the (cheap) no-name buck/boost converters I've ordered from Aliexpress (which have so far worked just fine).

5 hours ago, lizardmech said:

The larger GE 70V one just shorts anything plugged into Vi+/- melting wires when connected to batteries, and switching off any power supply connected

Sounds like the input-side is somehow short-circuited. Maybe a faulty unit, or did you plug it wrong way around at some point?

http://power-topics.blogspot.fi/2007/10/isolated-non-isolated-dc-dc-converters.html

Below are four scenarios, be aware - figures 3 & 4 will result in failed converters! Most DC-DC converters cannot withstand reversed input connections.

figures-4.gif

5 hours ago, lizardmech said:

The other 2 I can't get any output from Vo+/- though they get a little warm so they must be doing something.

How are you testing them, outputs floating (and measuring with a multimeter) or connected to some circuit? If the circuit on the output-side is in short-circuit, they could have some protections that shutdown the output when a short-circuit is detected? Also take look at the datasheets, for example the sheet for PG02S -series mentions required start up -voltages and limits where the circuit will shutdown due to undervoltage. http://www.mouser.com/ds/2/632/DS_PG02S%20series_03152012-349324.pdf

Link to comment
Share on other sites

On 30.4.2016 at 0:06 AM, esaj said:

I did finally finish the second BJT-H-bridge and installed them into the robot:

...

Unfortunately, while they work otherwise ok, I had no room for heatsinks in the board layout... and guess what? They overheat :D  Not with non-loaded motor & 9V battery, but when they have to start moving the actual robot with a battery-pack that gives much more "oomph", they go nuts after a while... Well, maybe I'll find some other use for them. Next up, mosfet-H-bridges...

 

You could have good luck and just vertical, square aluminium plates could be enough - The TIP 41c/42C have a CE saturation voltage of 1,5 V (which you hopefully reach in your bridge), maximum continous Ic is 6A so you should have a maximum power dissipation of 6*1,5=9W per BJT.

Rth JC from the T220 TIP 41C is 1,67 K/W, some insulation between up to the same -> so we start with ~3 K/W without the heatsink. In (http://www.changpuak.ch/electronics/downloads/BerechnungKuehlkoerper.pdf - sorry is in german ;) ) i found a nice formula to calculate the thermal resistance of an (aluminium) plate by size: Rth=50/sqrt(A) .. with A in cm².

So for 9W an ambient temp of 30°C, max Junction temp of 150°C one gets a thermal resistance of 13,3 K/W ( =(150-30)/9). Subtracting the 3K/W from the casing and insulation leaves ~10 K/W for the heatsink. With the forula Rth=50/sqrt(A) this gives a minimum area of ~15cm² or ~4cm sidelength of a square plate, which could be in a range that could fit on your dot matrix board and robot...

 

  • Upvote 1
Link to comment
Share on other sites

28 minutes ago, Chriull said:

You could have good luck and just vertical, square aluminium plates could be enough - The TIP 41c/42C have a CE saturation voltage of 1,5 V (which you hopefully reach in your bridge), maximum continous Ic is 6A so you should have a maximum power dissipation of 6*1,5=9W per BJT.

Rth JC from the T220 TIP 41C is 1,67 K/W, some insulation between up to the same -> so we start with ~3 K/W without the heatsink. In (http://www.changpuak.ch/electronics/downloads/BerechnungKuehlkoerper.pdf - sorry is in german ;) ) i found a nice formula to calculate the thermal resistance of an (aluminium) plate by size: Rth=50/sqrt(A) .. with A in cm².

So for 9W an ambient temp of 30°C, max Junction temp of 150°C one gets a thermal resistance of 13,3 K/W ( =(150-30)/9). Subtracting the 3K/W from the casing and insulation leaves ~10 K/W for the heatsink. With the forula Rth=50/sqrt(A) this gives a minimum area of ~15cm² or ~4cm sidelength of a square plate, which could be in a range that could fit on your dot matrix board and robot...

Might be worth trying, I have some 4mm thick aluminum flat left (don't remember how wide it is, 40mm maybe?), maybe if I cut pieces from that and groove it with a saw to get more surface area and drill holes for screwing them into the TO-220's... but it's going to be tight, the screw ends might touch :mellow:

EDIT: After some measurements, no go, the 4mm thick aluminum is too thick to fit there... bad board layout :P

Edited by esaj
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...