Closed gergelytakacs closed 4 years ago
@erik1392 @KuboJakub
We have decided to go ahead and re-design the power part of the shield, thus making R3 necessary.
Here is an idea for @KuboJakub - look at some basic tutorials to learn LTSpice and then try to simulate our problem. I'd model the analog part starting from the signal leaving from the DAC (the 0-5V) signal. You should include our electromagnet, the diode on it, the capacitor on it and then attempt to test a couple of possible solutions (JFET?) to upgrade the control of the magnet.
I have just tried LTSpice with another problem (related to opamps of @EvaVargova ) and it was really-really helpful.
So far i tried to model our issue in LTspice but results i get were not very satisfying - with pJfet i am able to close "big" circuit but i cant get more than 7V by opened one and with the nJfet i cant close the circuit (nJfet works reversely 5V=closed) , but the problem can be also in my model... I asked on StackOverflow for an advice. If you know somebody who could help you can share the link https://electronics.stackexchange.com/questions/467892/how-to-get-an-analog-signal-0-to-12v-dc-based-on-reference-0-to-5v-dc
The solution they suggested there with oamp and NPN transistor looks quite good. I was also thinking about something like that in case the Jfet won't work.
But I suggest to simulate it with circuit we have ( inductor, cap, diode...) not just some arbitrary resistance.
I measured the inductance of the electromagnet with method 1 from here. I tried electromagnets on 4 different shields and the results were in the range of 240-260 uH.
@KuboJakub Thanks for the question on StackExchange. I have no beef with the opamp-transistor configuration, actually - so that is a good possibility and the author of the original comment is kind of right about building feedback into the loop like this. This is a good idea, thank the man:)
Also, you have mentioned that you had no success with the JFETs in simulation. It would be also good to put a couple of screenshots here that illustrate us what you meant, since it is a bit hard to imagine that by words only.
The nice gentleman also offered a link on buffering opamps with BJTs, be sure to have a look at it and try to simulate the circuit with our inductor. It is a neat tutorial!
@erik1392 Good job with the inductance. I have failed miserably then before, since did not know the correct method:) However, the multimeter (benchtop one) in the lab as far as I remember has direct inductance measuring options. Also there is an LCR meter in my office. Can you confront your measurements with those ones? It's not that I don't believe your results are fine but I am thinking what are we doing wrong with the instruments.
So i checked the possibility to use JFET a little bit more (sorry for the previous status) and based on the video https://www.allaboutcircuits.com/video-lectures/jfet-amplifiers/ I made a simulation which was quite satisfying (common source amplifier). The circuit is not totally the same because the JFET amplifier in the video is arranged for signal amplification with minimum current but we need the current (minimally this is my conclusion... there is possibility i understood it wrong).
Some notes how does it works:
From the simulation i get the result: If we would use N-JFET, we are able to get 0V on the electromagnet quite easy. The small problem is, if we want to have JFET fully opened (means that we would require 12V on electromagnet). Probably because of the internal resistance of the FET and limitation of the maximum current which can flow through the JFET. I got the best result with JFET 2N4391 and I got around 10V on the electromagnet. I was able to increase the voltage on the electromagnet when i added a small resistance between the 12V source and the coil. But the result was higher voltage on the electromagnet but with smaller current and for electromagnetic force more important thing is the current.
Here is a description of the graph: V(ref) = voltage from arduino V(in_shifted) = somehow capacitor C2 is shifting the voltage into range (0 to -5V) what we need for the closing of the N-JFET. V(12-Vmag) = 12V - voltage on the electromagnet I(L1) = current on the electromagnet
I found the JFET 2N4391 on Mouser webside...it is not so cheap, but if you also think, this could be the solution i can make an order and we can try it https://www.mouser.sk/Search/Refine?Keyword=2N4391 The idea which proposed the guy from the StackExchange i have to try. So far I didn't do that.
I tried the idea from StackExchange. As the first thing, i tried the circuit just with suitable op-amp (so opamp which is rail to rail, can be supplied by 12V and can provide output current around, or more than 50 mA). The results were very nice (see below) but as the gentleman said for exact 12V we would need a supply bit bigger than 12V, but thanks to rail to rail we are able to set exact 0V and to be very close to 12V... it is around 11.7 V.
The second possibility is to take some opamp which can be supplied by 12V but the output current is smaller than needed one. The output from opamp is connected to NPN transistor. I this way i was able to produce an output voltage around 11.2 V. It is a bit smaller than in the previous example, probably because of the resistance on the transistor.
If i compare these 2 solutions with the previous one with the JFET, here is the problem that "the control part" is supplying the electromagnet on the + sign. The version of MagnetoShield is constructed that we regulate the voltage of electromagnet on the - sign. So this 2 solutions require new design of the circuit.
I am personally for the JFET solution because we don't need to change the whole circuit so radically and it is still providing quite satisfying results (we don't have to design whole PCB). On the other hand, our maximum voltage on the electromagnet will be around 10V (i hope).
Here are my circuits which i used for the simulations. VolrageRegulation.zip
Great job @KuboJakub , really useful stuff. First of all I am sorry for the slow response time, I was out of the office from Fri-Mon (inlcuding). I am going to respond to your latest post in single comment.
N-JFET needs an opposite sign of the voltage on the gate, so we are regulating "big circuit " with voltage 0 to -5V. For this conversion is responsible capacitor C2 (not sure how does it work) right behind Arduino voltage source (DAC). So if we send 5V from Arduino on the gate appears 0V, if we send 0V on the gate appears -5V.
Yes, but don't forget this is the same thing as you've done with the MOSFET. Ground is relative, so essentially you've been feeding your MOSFET negative voltages (compared to 12 V). So there is nothing new. The capacitor is not the one responsible for this, I'm not sure about its role actually.
I got the best result with JFET 2N4391 [...]
This looks like somehting from a 1950's movie:)
We are feeding the coil from the opamp. It should be able to produce 70mA on output but i don't know exactly how much current the coil needs (I made measurements just through the current observer, which is on the shield).
I think it should be under 100 mA, I have used the current sensor onboard as well. Shall we decide to only use an opamp, we should have some headroom because there might be some voltage peaks, and we don't want to fry our opamp (and board) at the first trial. This is why I'm thinking its a safer choice to go with opamp+transistor. The one you have suggested has it only to 70 mA. That's only so and so, I don't trust it. Are there any more "powerful" rail-to-rail opamps that can be powered directly by 12 V?
more components so in the conclusion, this way can be a little bit more expensive
Yes, but still cheaper than using a weird / specific JFET or OPAMP. I think, purely from the viewpoint of price, opamp+transistor should be the cheapest option. And I think there is plenty of space to put that on the PCB! (Don't forget, we can put components on the bottom too!:)
So this 2 solutions require new design of the circuit. I do not think that should be such an issue.
The redesign could be done in a couple of hours...
I am personally for the JFET solution because we don't need to change the whole circuit so radically and it is still providing quite satisfying results (we don't have to design whole PCB).
We already have it design, we only need to change it. As I said, it is not a big deal.
My preference is to go with the opamp-transitor combination It also touches the point what the guy on StackExchange said. This is closed loop, not open-loop! What is your opinion @erik1392 ?
Here is a couple of facts / questions I'd like you to consider and try.
Here is the model: TLC2272.ZIP
@erik1392 @KuboJakub
I am (trying to:) order some parts and I have included these two SMD transistors, that are more or less equivalent to the 2N2222:
You could (and should) use these parts in simulation, if you find a model for them. If you do a quick lab test with the TCL2272, you can safely use the 2N2222 as a replacementl
@gergelytakacs I have already tried the BC817 but the ON Semi .. version i sent you. So far, it was the same as 2N2222.
@KuboJakub i sugest to tweek the oamp ratio pull the voltage is not clipped that much. And it would be nice to use precise resistors for that feedback loop so amp ratio between different shields will be the same.
Meeting 27.11.2019
I augmented the simulation scheme that it is closer to our real scheme. There is also an additional almost 1V voltage drop on the 10-ohm resistor for current measurement.
@erik1392
Awesome job. Love it.
g.
@gergelytakacs
@erik1392 @KuboJakub The TLC2272's have arrived:
I appologyze i did not answer earlier because i am abroad. I already made the experiment but without the current measurements. I will try to complete it till monday but so far it looks quite nice. Supply voltage from Vin in arduino was around 11.4V and i get on electromagnet something above 10.5V
So i made the measurements. The measurement i made is based on a schematic below (instead of coil I have used a resistor) I have considered:
I think the best ratio between resistors is R1/R2 = 6/5 kOhm. This results into the gain which amplifies the DAC voltage on maximum 10.3-10.4V (the measured one, theoretically we should get 10.56V from 4.8V). Ratio 6.2/5 (or bigger) is from calculation more suitable, but because of the voltage drops on the transistor the top of the signal is cut off.
I would maybe prefer to use 5 kOhms for R2 resistor as a fixed one and as R1 transistor i would use some accurate potentiometer. The reason is, as @gergelytakacs discovered by improving the library for MagnetoShield, every board provides a bit different supply from Vin, which could cause cutting off the top of the signal. I am also not sure about the resistance of electromagnets if they are the same or different. Also in the library, if we describe the curve characterizing the voltage on the electromagnet some boards can have the top cut off and maybe the accuracy of the regulation will be worse (maybe not...still it is just top values which are not used so often). If we use the potentiometer we can tune the gain as we need in ratio var./5 kOhm. Otherwise, the best results were with 6 and 5 kOhm resistors... on the load, I got around 10.3 V as the maximum value.
5 kOhm resistor: https: //www.tme.eu/sk/details/ar0805-5k-0.1%25/presne-rezistory-smd-0805/viking/ar05btcw5001/ 6 kOhm resistor: https://www.tme.eu/sk/details/era6aeb6041v/presne-rezistory-smd-0805/panasonic/ 6.2 kOhm resistor: https://www.tme.eu/sk/details/era6aeb622v/presne-rezistory-smd-0805/panasonic/ potentiometer -This one is +-10% I could find no more accurate potentiometer on TME in SMD package (there are +-3% but are super expencive and big). Maybe we could use the one we have or this one: https://www.tme.eu/sk/details/1806wsmd-10k/potenciometre-viacotackove-smd/sr-passives/
@erik1392 Please also review @KuboJakub 's latest results, they seem to be good judging by the first look...
First of all, great job @KuboJakub ! Thank you. Before we proceed, I have a couple of notes / questions.
@erik1392 @KuboJakub
I made measurements with a new, more precise LCR meter, according to which at f=100 Hz, L=263.1 mH (so the cheap Chinese meter was allright), and Q=0.72 - where is the ratio of the inductance L to the resistance R of a coil at a given frequency and this defines the efficiency of inductor, e.g. the higher Q factor of the inductor, the closer the inductor to be ideal without losses. source Also, look at WikiPedia
@erik1392 @KuboJakub
Ok, let's go with the potentiometer. The small one by erik seems to be fine.
@erik1392 @KuboJakub
I would also like to change the DAC to mcp4725 - I have a couple of them bought. This shouldn't be too hard.
@erik1392 @KuboJakub
Xmas has come!
You can find the parts in the lab in your drawer.
Where have you exactly got the figure 11.5 V for the supply? Although this seems, correct - just curious if you measured or assumed this.
Supply voltage from arduino is around 11.4-11.5V. I have measured it.
I might have forgotten, but why is the input voltage going only to 4.8 V? Is that happening in reality as well? Why?
Honestly I also dont know but in my opinion, it has something to do with that the supply of DAC is 5V and intern circuit consumes some voltage too so probably that is the reason for voltage drop on 4.8V. The value is also measured.
- You don't need to simulate the coil (your assumptions were correct though) by a resistor, there is a free standing extra solenoid - just ask Erik. Either he has it in his office or it's in the lab.
So i made an experiment with real electromagnet and 10-ohm resistor. The voltage drop is luckily bit smaller than 1V. I got 9.96V directly on the electromagnet. So I think this works quite well. The resistors i used were as priviously - 5k for R2 and potentiometer as R1.
@KuboJakub thanks for the experiments. We will discuss the next steps in person today, I hope @erik1392 can be also present.
As I said, I'd prefer to exchange the 8-bit DAC to a 12-bit more advanced one too. As far as I know @erik1392 is already on the process of re-designing the PCB - this should be our first and foremost priority.
@gergelytakacs @KuboJakub Here is almost finished PCB (some text and logos are missing). Check it, if you can find any mistakes.
As we spoke with @KuboJakub here is also the second version of PCB where the 3D printed part should have legs only from one side and would enable a more clean view of the magnet.
Excellent job @erik1392 I will start reviewing it right away.
There is a mistake in gain resistors. They are switched, we want to have R3 like potentiometer and R10 fixed one. Gain is like 1+Rpot/Rfix = 1+0to10kOhm/5.04kOhm. Theoretically, it can be like this but i think to have the denominator fixed is much better for tuning of the gain. ![Uploading opamp gain.png…]()
The current sensor is this one? http://www.ti.com/product/INA169 I didn't find anyone with the name INA149
@KuboJakub Sorry for the late reply. Yes, the current sensor is INA169, that was misspell in the paper. I haven't had the chance to go through the PCB as of yet. I am hoping I will have the time to do that today.
@erik1392 Can you address an review Jakub's note on the potentiometer issue?
@gergelytakacs sure, I'll change it.
@KuboJakub maybe you have written ti wrongly
The resistors I used were as previously - 5k for R2 and potentiometer as R1.
@KuboJakub The new PCB has been ordered, the fixed / variable resistors for the opamp gain have been flipped. I think (and hope) that the PCB could be here before x-mas but we'll see.
@KuboJakub The parts have been ordered. We should have enough material to complete about 5 pcs of R3 MagnetoShields.
Update: The components have arrived, I can bring them to the lab tomorrow.
Update: PCB is on its way.
@erik1392 @KuboJakub
Santa has came early. All will be in your drawer in your lab. Note that some components are shared between Magneto and Link, you might need to check that too. (I don't want to split the contents, because it would be hard to identify some components without the original bag.)
@KuboJakub I have ordered the 5 kOhm resistors just now. They've cost a lot more than they should've :)
I have some unpleasent news:
Unfortunately, you are right... there was a stupid mistake in the scheme with overlapping lines....
For the purpose of testing, we can correct it by cutting the incorrect traces and running thin wires from traces to correct pins.
But still it is switched also on 2. fig. Pin number 8 on the scheme is in the reality Vdd and pin number 4 on the scheme is in reality GND. Like it can be switched but in that case we get oposite amplification. But yes i think it schould work with that pins. I can come to do that today latest tomorrow.
Ou of course now i get it what u meant. Sorry, yes it switching the pins should work.
@KuboJakub @erik1392
Thanks for the news, even though they were less than pleasant. In any case, please try to "patch" the problem to see if the shield is otherwise healthy. As soon as you get it working, we'll order a new PCB. But in any case, we should catch the rest of the mistakes.
I can't believe that neither of the three of us caught this in time:)
Okay i repaired the mistake with GND and Vdd, unfortunately i cut one way i should not. But i repaired that one too. But something is wrong with the transistor. When i pluged in 12V the collector start to burn... Right now i have no idea why that pin. DAC works. When i send 4095 output from it is approximately 4.9V. Output from OPamp is in than 4V. This dropp could be caused because of my mystake (maybe not) but still cant see the reason of burning transistor. It is so also when i send 0V from DAC, so Transistor has some intern problem.
@erik1392 @KuboJakub
Okay, so as we have discussed here in the lab, you have soldered the protection diode the wrong way, so shorted the high voltage part... (Besides the issue with the OP-amp).
:fire:
Now i have just finished the new shield. It is without the part of circuit for measurements of the current and voltage and so far it works. So i hope the only issues were that one we discussed. Next week i will solder the rest.
@KuboJakub
All right, awesome. Let's hope the rest works as expected, then we'll order the corrected board and you can continue working on software/examples using the "patched" prototype.
For the next release of the MagnetoShield: