-
I can only answer regarding analog circuitry such as the current measurement circuit I showed. the most important part is to connect to the sense resistor correctly, that is make connections directly to the pads of the resistor to avoid additional voltage drops in traces. you should be able to send the amplified analog signal through quite long wires from the opamp to the ADC. for example using the twisted pairs in an ordinary phone jack cable. adding an RC low pass filter at the input of the ADC will help to reduce noise.
The physical/geometrical properties - and the (interfering) environment - of a connection >are always part of communication reliability. Are there rules of thumb for determine for how >long the connecting cable can be and how it has be built?
-
-
-
-
if you are interested in measuring solar panel current you can just place the current sense resistor in series with the negative wire coming from the solar panel, because the solar panels are designed to float (up to 600V or 1000V from earth ground). solar panels usually have a ground connection, but that is connected to the metal frame. the solar cell package is floating.
you then just connect an opamp as an inverting amplifier with two resistors, to amplify the measurement signal 3.3/0.1 = 33 times, and connect the opamp output to the ADC pin. it is not necessary to place the sense resistor in the positive lead and level shift the signal when measuring solar panel current of a low voltage solar panel.it is different if you measure on a solar panel array that is connected to a nonisolated dc/ac inverter. then you need isolation for safety reasons. Avago has some good optoisolated current amplifiers, for example ACPL-782T can withstand 3750Vrms from sensor to output.
the reason why I am using a median filter is that I want a steady reading for display on an LCD alphanumeric display or on a computer screen, and I update the display at 1Hz so I can afford the computing delays. if I was to use the current measurement for charge controller function I think I would use less filtering on the signal that is used for the controller. in my power converter I am using the output from the LT1999-10 for the current limit function, so I cannot filter the signal too heavily before applying it to the controller. but this current control function is implemented by analog circuitry (opamps).
-
allObjects, I am using a sense resistor and a bidirectional current sense amplifier (Linear LT1999-10) that level shifts the current sense signal to 2.5V above ground and adds a gain of 10. if the voltage drop across the sense resistor is +100mV the output signal is 2.5V-1V=1.5V, if the voltage drop is -100mV (reverse current) the output signal is 2.5V+1V=3.5V, and I can either measure two signals: the 2.5V reference and the output signal from the current sensor and make a calculation. or I can add an inverting amplifier using an opamp, and add an offset to the noninverting input, and set the gain to make the output of the opamp swing from 0V (-100mV) to 3.3V (+100mV across sense resistor) so I can get a measurement signal that can be presented to a single ADC input. to get good accuracy one needs to do a calibration for offset and gain, and I use to take a series of readings, store them in an array and sort the array, then throw away the ten highest and the ten lowest readings, and average the remaining readings. kind of a median filter. the advantage is that the worst errors that are due to the high noise levels in a switching power converter are ignored, so the readings are fairly accurate and steady.
this gives enough accuracy for what I am doing (demonstrating how the power stage works and how it can be used in different configurations). the maximum input and output voltage level is 80V and I deal with current levels of up to 20A.
-
That would be great. I am working on a power converter that is used for many things such as battery chargers (using large 12V to 48V batteries), solar powered chargers, super cap holdup circuits and bidirectional control of a kW or more. I hope to share some more detail on the project as the work is finished, it probably would interest many people that are into solar power, building their own off grid systems or need a power converter that can control current flow in both directions
To save time during bench testing I am using an Espruino board to interface with my power controller. (it is really convenient to be able to interact with the Espruino while the power converter is running, many times I do not even have to power down the circuit when making changes to the function or flashing and saving new data.)I need a bit more speed to control an I2C Quad DAC (LTC2635CUD-LMI12) so I can more quickly reverse the direction of power flow. This type of DAC has two sets of registers. The data in the output registers shows up on the outputs as analog signals, and another register can hold new data ready to be instantaneously transferred to the output register when a hardware pin is pulled low. this allows the outputs of the four DACs to to change in an instance without need to wait for the I2C bus to transfer new data. but if it still takes time to write new data to be ready for next direction change, so faster I2C clock would definitely help in situations where the current direction must change frequently.
-
-
-
I was using analogWrite() with two outputs (C7 and C8) to create two analog control signals and noticed that if I change the frequency (or forget to specify the frequency) on one output, the duty cycle of the other output is affected.
So if I want to change the frequency, I have to specify the same frequency for both outputs, otherwise I will not get the correct duty cycle on both outputs..
This may be worth mentioning, as it can save someone else from spending time troubleshooting.
(I use LTC2645-12 to convert the PWM signal to a dc value, no low-pass filter is needed). -
I had a quick look at the data for the two different solid state relays just because I have looked at several relay boards off the internet and found them unsafe.
The smaller relay mentioned here (2A) could perhaps work for a max 300W load but I would not expect it to last very long because of voltage transients on the mains voltage. It really needs some overvoltage protection circuitry.The 25A relay should be able to handle larger loads but may need a heatsink as it drops about 1.6V. It needs 7.5mA drive current at 12V. There is no details on how to drive it from 5V. The safest approach would be to use 7.5mA constant current drive.
With both these relays it is important to remember that when they are not ON, there can be a substantial leakage current through the "contacts", so it is not safe to touch the wire coming from this type of relay if the other wire is connected to the mains voltage. There can be enough current flow to create a danger. Also, voltage transients can cause the relay to turn on briefly (a few ms) even if there is no drive current. So if one is used to mechanical relays it can be a surprise.
Also, both of these relays have relatively low isolation voltage between power side and drive side, and the driving circuitry should be grounded to avoid electrical shock if there is a large voltage transient on the mains voltage that is large enough to jump the isolation barrier. The most common path for a transient is usually across the surface of the relay or the circuit board. Where many of the internet relay boards fail is that there is not enough creepage distance between power traces and drive traces, and the most common type of relay has the pins placed so that it is necessary to mill a minimum 1mm wide slot in the circuit board between power traces and drive traces, to extend the creepage path and meet safety requirements.
Also, some of the relay boards that are offered cheaply on the internet contain relays that do not have enough isolation voltage between coil and contacts. Most users may not bother or simply are not aware of the danger, and that may be fine if all you do with the relay board is tinker in your lab. But if the board is installed and perhaps forgotten and somebody happens to touch the low voltage electronics circuitry during a thunderstorm and gets hurt then it is no fun. -
Manxome, I will generate a data file with readings so it is possible to apply different filtering algorithms and see the effect. I think that the noise can be very different in different applications.
The noise from switching regulators can be especially hard to filter as it contains both very large spikes and very high frequencies and also lower frequency ripple that contains the 100kHz or so basic frequency, plus perhaps other lower frequencies that come from load current variations etc. An algorithm that works well for a switcher application may be overkill if you only want a steady reading from a temperature sensor.
Some background to my experiments:
A good quality ADC with 16 bits or higher is definitely much better if measurement accuracy is important. The project I am working on right now will result in a demo board that demonstrates the characteristics of a power converter. The power converter can deliver output voltage that is lower than, equal to or higher than the input voltage. And it can run backwards. So I need a micro controller to make it possible to generate a number of control signals that control the power converter and to keep track of what is happening. Accuracy is not necessarily the top priority for this project. But it is nice to have steady voltage and current readings to display.
A few examples: the output voltage and current limit should be adjustable, operating temperature needs to be monitored so cooling fans can be controlled, different operating modes must be selectable - such as making the converter charge a battery or super capacitor, and then reverse the power flow and use the stored energy to power a load when the main power source fails.
Some people want to use the power converter with a solar panel as a power source to charge a battery. Other want to connect many power converters together to handle very large power levels. These functions can all be handled with analog and discrete logic, but a micro controller makes it possible to create a very flexible demo board that can do a lot of different tricks using the same circuit board, and without requiring hours of soldering and building prototype circuitry for each different configuration.
This is where I am using the Espruino. It allows me to quickly write demo programs without having to invest the time in C programming. Before a final product is made based on the demo board testing, a specific micro controller is usually selected by each customer, and it is programmed in C. But not by me. I just want to show that the power converter works and quickly write some code to make it do its tricks. I am a power converter guy and not a programmer. -
Manxome, you interpreted the graphs correctly. Each red dot is the result of capturing 100, 40 or 21 samples and crunching the readings into one single result.
I start at zero load, take a series of readings, save the result after filtering and increase the load by about 100mA, then repeat.
The blue dots are single readings from the 34401A multimeter. it contains its own filter so there is no need to do any processing on those readings. But this is a $700 instrument so one would expect accuracy.
The measurements are done by Excel. I wrote a VBA macro that controls the instruments and the Espruino.
The reason why the red line is above the blue line is that there is a small gain error. I need to adjust the program to correct. There is also a small offset error.
The reason why the voltage is drooping as load is increased is that there is a long cable from the bench power supply to the test object where I am measuring the input voltage. In this measurement, the output voltage is set at 15V, so the output power at 4A load is 60W. The test object is a buck-boost converter that handles input voltages to 60V (80V max). The output voltage of this particular setup is 12V to 60V but it can be much wider. It is also possible to control power flow in the reverse direction. I am using the Espruino in my test setup to generate signals that control the power converter. It also measures input and output current and voltage plus a number of other signals. And that is where I needed to filter out noise, as the power converter can handle 500W or more and this means a lot of noise on measurement signals.
I will see if I can capture some data without filtering so we can see the noise. I did not have time today. The reason why the last curve shows three samples with same value, then the next sample is 16.6mV lower, then comes four more samples that are 2*16.6mV lower is that the 12 bit resolution shows up. when you only have one sample and no averaging the value must always be n * 16.6mV. -
There are many ways to filter out noise. Here is a test that I did comparing the readings from Espruino with a system multimeter 34401A. I made the same test with three different settings of the filter, in the one with 21 samples where I only keep one single reading (the median) you can clearly see the effect of the 12bit resolution. I think the performance of the Espruino ADC is quite good even in this very noisy test setup (and using long wires to connect the Espruino to the switching converter I am working on). Using 100 samples the worst error was 20mV- with a measurement range of 68V that is not bad.
-
The expression will be different for Espruino vs Arduino because analogRead() gives a reading between 0 and 1.
If you have a resistive divider connected to the ADC input and the top resistor is 10k and the NTC resistor is the bottom resistor in the divider, the ADC reading (val) will be R/(10k+R). Where R is the resistance of the NTC. From this simple expression you derive the expression
ohms=10000*val/(1-val),
(ohms in this case is the same as R in the first expression).so by taking a reading we can calculate the resistance of the NTC resistor. then it is relatively straightforward to use the Steinhart-Hart equation to figure out the temperature.
I don't remember exactly how I got the coefficients, it was something I did about a year ago. I probably found some online calculator. I can look into that tomorrow. The NTC resistor I use has a characteristic as shown in this table
-20 68.915
-15 54.166
-10 42.889
-5 34.196
0 27.445
5 22.165
10 18.010
15 14.720
20 12.099
25 10.000
30 8.309
35 6.939
40 5.824
45 4.911
50 4.160
55 3.539
60 3.024
65 2.593
70 2.233
75 1.929
80 1.673You could try this online calculator, and plug in three values from the table.
http://www.thinksrs.com/downloads/programs/Therm%20Calc/NTCCalibrator/NTCcalculator.htm -
thanks Manxome, I will have to try the shorter version later.
Meanwhile, here is my code for reading temperature from a home made temp sensor.
I soldered an NTC resistor (size 0603) onto a small piece of circuit board, added wires and mounted it inside a stainless ring terminal of the type you crimp onto a wire, using epoxy. One of the two wires connect to GND, the other one to A1, with a 10k pullup to 3.3V.
I run the macro by typing "getTemp(A1);"function getTemp(pin){ var n=10; var val=medianRead(n,pin); var ohms=10000*val/(1-val); var A=0.00088607485; var B=0.00025169965; var C=0.00000019152452; var W=Math.log(ohms); var temp=1/(A+W*(B+C*W*W))-273.15; return temp.toFixed(3); } function CompareForSort(a,b) { if(a==b) return 0; if(a<b) return -1; else return 1; } function medianRead(n,pin){ var myarr = []; for (i=0;i<n;i++){ myarr[i]=analogRead(pin); } myarr.sort(CompareForSort); myarr.splice(n-2,2); myarr.splice(0,2); m=myarr.length; var sum = myarr.reduce(function(a,b) { return a+b; }); return sum/m; }
-
There will always be noise in analog readings. Taking a number of readings and calculating the average is an often used method. But it can still take a large number of readings to get a stable display.
A better way is to take a number of readings and throw away the highest and lowest values and average the rest. Perhaps someone has even better methods to share.Take n readings and save the data in an array.
Sort the readings from lowest to highest.
Throw away the two highest and the two lowest readings.
Calculate the sum of the remaining values in the array and divide by the number of data points to get the average.Run the code by typing in "MedianRead(n,Pin);" to capture five readings from pin A1,
or type in "MedianRead(10,A0);" to capture ten readings from pin A0. Use a minimum of five samples. The original samples will be printed, then the remaining and sorted samples, and finally the result. ( a return statement should be added).var n=5; var Pin=A1; function CompareForSort(a,b) { if (a == b) return 0; if (a < b) return -1; else return 1; } function MedianRead(n,Pin) { var myarr = []; for(i=0; i<n; i++){ myarr[i] = analogRead(Pin); } console.log(myarr); myarr.sort(CompareForSort); myarr.splice(n-2,2); myarr.splice(0,2); console.log(myarr); m=myarr.length; var sum=myarr.reduce(function(a,b) { return a+b; }); console.log(sum/m); }
-
Communication between Excel and my bench instruments is over GPIB but for the Espruino I am using the USB cable. It appears as COM12. In addition to Excel you will need to install IO Libraries from http://www.keysight.com/find/iosuite .
The attached screenshot shows data from Espruino on row 9 (cell A9,B9,C9,D9). Row 7 has data from my instruments. The graph in the lower right corner shows output voltage of the testobject as function of load current measured by a 34401 precision meter (blue) and same measurement from Espruino. I used a simple Median filter to remove measurement noise. You can see the 16.6mV steps caused by the 12 bit resolution when a measurement range of 68V is used. It should be possible to improve the Espruino filter to smooth the line.
The test object is a buck-boost converter that is capable of handling power flow in both directions, and I am adding digital control so I can demonstrate the function of the power stage. -
Today I was working on a power converter where I am using my Espruino board to measure input and output voltage and current and also to generate some project specific control signals that make the power converter behave as I want it to.
I have my lab bench set up so that I control my instruments with Excel. The instruments are talking over GPIB and the setup allows me to quickly repeat a measurement I did months ago, with exactly the same test setup. So I can compare test results in a repeatable way. I can return to a design I did long time ago and repeat the tests and continue improving the circuit and compare performance.
The project I am working on right now requires a micro controller and I decide to try Espruino. This far, my experience has been quite positive and I am continuing this path. I decided to see if I could include my Espruino board into the Excel test setup. This turned out to be quite simple. If anyone is interested I can perhaps write a tutorial on how to do this.
-
-
I am tinkering with a NEMA 23 stepper motor and a motor drive that has a pulse input, a direction input and an enable input. The motor is driving an indexing table with a 3M timing belt, with gears that give 8:1 reduction.
The drive can accept pulse frequency up to 200kHz. The motor is a common two winding bipolar with 1.8 degree step angle, and if not micro stepping I think that 1kHz frequency is fine. But I would like to take advantage of the micro stepping capability which means the pulse frequency must be much higher.
I expect that the mass that is mounted to the indexing table can be large, so to avoid problems with stalling, position errors etc I am trying to optimize the acceleration (ramp up and ramp down of the stepping frequency).
My question is what limitations I should expect from the changeInterval() function. I assume there is a 1ms resolution limit. is there a better way to control the pulse frequency accurately and with higher frequency than 1kHz? -
Thanks Gordon,
I was not able to press the buttons in the correct sequence obviously, so instead I used ST-Link to do a complete Chip Erase and Sector Erase.
As I was not sure how to proceed after that (the board was not detected by my Win 7 PC any more), I programmed the STM32F4 Discovery board for NETMF following the procedure in http://singularengineer.com/stm32f4-discovery-board-running-net-microframework/
and then re-flashed with Espruino 1v70 and after that the board works fine.And I also found one of my Espruino boards and managed to update it to 1v70. This board had stopped communicating so I thought it was dead, but it works after I managed to update it. Don't ask me how it was able to connect to the IDE.
I am tinkering with an index table using a 56.4mm (NEMA 23) stepping motor PK268-03A with a digital stepper drive CWD860. The drive has a pulse input and direction input so the Espruino code is a bit different than the example. I am scratching my head over how to accelerate and decelerate in an optimal way, as the motor will have to move a large mass. The motor is connected to the table with a 3M belt with 8:1 reduction.One strange problem I had was that the stepper drive had the wrong polarity indicated for the DC input, so when I connected a dc power supply to the drive it was current limiting and the voltage was only a couple of volts. the polarity on the drive electronics was wrong. I reversed the power supply leads and the drive worked. Apparently I was the first customer to notice the manufacturing error. The drive is supposed to work with both ac and dc, but the rectifier bridge had been removed and replaced with wires that had been wired backwards. Obviously nobody had tested the drive before shipping it to the distributor. Strange.
-
-
There is a simpler way. Use one of the two DAC outputs and connect a resistor to the Feedback pin of the voltage regulator. Keep the resistor divider that determines the output voltage. if you set the DAC output at the same voltage as the Feedback pin, the output voltage is unchanged. if you set the DAC voltage higher there will be a small current flowing into the Feedback node. so the current in the top feedback resistor must decrease by the same amount. That means that the output voltage must decrease. and the other way around.
I think that alternative #3 is a good choice. the input voltage range is interesting. I did not understand you warning about that Vout is 3.8V if Vin is above 3V. that is a misunderstanding. what the data sheet is talking about is that it can deliver up to 3A continuous current if Vin is at least 3V when Vout is 3.8V. if you have Vout set at 3.3V you will have 3A available even at much lower input voltage than 3V.