View Full Version : Discussion DIY in-flite motor current data logger ... Pic Picaxe-08M
barb wire
Mar 17, 2007, 07:46 AM
hi ,
a basic question to consider is the motor current draw during flite.
with this piece of info you can better match prop to motor.
and be sure the motor is not over-drawing the battery pack 'C' rating
my bread-board version has been working well. it is based on a pic-axe -08M uC chip. the motor is a Hacker A20, 150 watts. so the current is in the range of 1 to 15 amps.
this uC chip has 256 ml's of memory space for both code and EE. and the code for now uses 231 of them. leaving only 25 ml's for EE data. that's enough for now as all i want to know is the max current during flite. the readings are taken every 5 seconds. until the last datum. if the new data is larger than the last it gets saved in EE. there are many ways to code this.
the sense resistor is 20 milli-ohms. and the voltage across it is connected to a diff'l amp . it has a fixed gain of 10. the signal needs filtered due to the pulse-y nature of bm's. easily done. with the right choice of amp chip
this combo of resistor and gain means each amp generates 200 mV. the -08M adc input accepts from 0-5V. so 5V / 200mV = 25 amps of input current range.
and the -08M adc converts this 0-5V signal into an 8-bit binary value. such that you can easily deduce the current. ex. the datum is 105. just multiply this by one tenth 105 x 0.1 = 10.5 and that is the base-10 amps value. with you having to do the 0.1 conversion in your head saves on code space.
a simple slide switch lets you select between 'read' and 'write' data.
back on the ground a separate LCD module will be connected to the circuitboard. and the switch moved to 'read' position. then the stored motor current data is sent to the LCD for display. the data will have the appearance of ex. 57 , 88 , 105 , 123 , 136 , 154 ... depending on how you code it to appear on the LCD. getting fancy uses up valuable code space
the next step for me is to re-create the b-bd ckt on a piece of circuit board and get it wired for in-flite data logging. this is going on today.
once it is flite tested and de-bugged the results will be posted here.
for now i was wondering who else may have had success with their
DIY in-flite motor current data logger. there are some technical issues
to decide upon. and i wish to talk with you about how you dealt with them.
regards,
bw
addition : 3-24-07
today the circuit diagram is posted here.
and a picture of the almost complete circuit board.
next is to take a VOM and check every socket location before
any of the IC's are inserted .
the code needs some editing & testing before being posted
bw
orraman
Mar 21, 2007, 05:44 PM
Greetings barb wire,
I have not yet got going on current recording, but over on the Arial Photography forum I have been trying to get people interested in using Picaxe 08m but without much success. http://www.rcgroups.com/forums/showthread.php?t=645737
I have now gone on to make a couple of 08m surface mount boards measuring 3/8" wide by 1 1/16" long plus a set of 3 rc pins above and below at one end. The other end has 3 sockets soldered above and below that are within the board area. These sockets have been removed from machined pin IC sockets and accept the standard solid connecting wire for solderless breadboards. A servo lead is soldered to the underside leaving 3 sets of power connections, 2 for the servo plugs and 1 that allow spare pins to be to be jumpered for function selection in use. The fitted resistors allow in circuit programming, all picaxe pins connect off-board.
Very interested in your project and if you think that one of these boards would save you time I would be happy to send a bare board as a small gift or a populated board on loan.
Regards
Dave
PDK
Mar 21, 2007, 06:20 PM
Hi,
I have been thinking of doing a similar project but have not started yet. The picaxe sound like a good choice but I am more comfortable with the PIC's so I would go that way for my version. The output signal for mine will be a PWM of the supply so that I can use a normal multimeter (that sits in my flight box all the time) rather than have a separate LCD just for the meter. Was just going to PWM a reference (supply 5V) so that I would have a range of 0 - 50A (rough enough anyway ;) ).
Good luck
Phil
birdofplay
Mar 21, 2007, 06:26 PM
I got the BNB DPR-100 for a little over $60 Plus some added accessories.
It works great !
For that cost I couldnt justify digging out the development stuff
let alone buying the parts doing the PCB and then doing the PC side programming .
I'd rather be flying :-)
Blue Sky
Mar 22, 2007, 03:18 AM
You just gotta love the Picaxe chips.
You could also use debug or sertxd to read the memory locations over the programing
cable. You could do this on a laptop or at home on your PC.
-Dave
barb wire
Mar 24, 2007, 03:42 PM
hi, 3-24-07
a note to let you all know of todays upload additions:
a. the picture of the circuit board in an almost complete condition
b. a sketch of the circuit diagram
they were attached to the original posting of a week ago.
and to thank those of you who have taken the time to write.
thanks , your ideas are welcome.
orraman - thanks for the pc board offer. for now for a board
of this size, dip-ic's work ok. i would like to know if
you use the commercial pc bd mfg'rs , you know , those
guys that advertise 3 boards for $50 . i've often had
a desire to design and have them build some generic
boards for soic and tssop ic pkg's
pdk - i like your idea of an alternative way to see the data.
later on i expect to build a newer version of this circuit
with a uC having more memory and code space. then
all of the data can be shown and trends observed. my lcd
is 4 lines by 20 characters. coming up is having to figure
out how to get the data to march across the display and
jump to the next line ... as the memory contents get dumped
birdofplay - your sentiments about build vs buy are understood.
have you posted any user comments for this device ?
i am very interested in the technical side of its design.
as well as how it has served you in terms of what you wanted
bluesky - yes , a laptop would open the way for some handy collecting
and saving of the data. first things first. a lcd serves
my purposes for the time being. plus i already had it built
and its portable too. if you do something with yours and
use a version of basic to crunch and display the data i would
very much like to be kept up to date with your efforts
ok , time to think , here is a question or two for you about the design :
a. what sort of accuracy do you expect with its readings ?
b. the claim was made of being able to take the uC 8-bit adc data
and divide it by 10 and come up with a base-10 current value.
how can that be ? uC's work in binary
c. the design has an obvious 'fault' ... what is it ?
bw
PDK
Mar 24, 2007, 07:09 PM
Hi bw,
Good to hear your project is progressing. Look forward to the results.
Regards
Phil
orraman
Mar 25, 2007, 01:26 PM
Greetings bw,
Thank you for the further information on your project.
For some years I made pre-production prototype boards for Z80 and then Z8 controllers and still use the equipment so I have no personal knowledge of board makers but these folk seem to offer good prices.
http://www.futurlec.com/index.shtml
Your questions,
a. You are using an 8 bit ADC rather than the 10 bit so that restricts you to 256 steps that you are apportioning to 25A of which you will be using 15A which gives you about 150 steps. There will be % errors in all the devices that could be offset to some extent by fiddle factors if you had more programming space. But if you managed 5% accuracy you would have a very useful device. 18X Picaxe? SM?
b. I started programming in Octal (base 8 machine code) and I am so grateful for inbuilt software conversions.
c. Pin 2 nc = instability.
An interesting project.
Dave
vintage1
Mar 25, 2007, 02:57 PM
I got the BNB DPR-100 for a little over $60 Plus some added accessories.
It works great !
For that cost I couldnt justify digging out the development stuff
let alone buying the parts doing the PCB and then doing the PC side programming .
I'd rather be flying :-)
Thats the point isn't it? what is fun for YOU?
I used to like doing electronics..these days I am more your side of the fence, BUT if SOMEONE wouldn't be fiddling with PICs we wouldn't be able to spend $60 and 'just buy one'..
birdofplay
Mar 25, 2007, 09:16 PM
Well I figured my comment would start up a furror !
Didnt intend to Dis anyone or their efforts.
Just figured that this kinda thang had been done several times
so Why Fling yet Another Cow, ya know ?
I've done my share of embedded coding. Assy et al !
I'm of a mind that I'd rather be Flying.
My BnB DPR-100 has performed well for me.
Mostly I use it on a motor test stand. ( Dons lil 18mm motors et al )
I got the "works" but havent tested or used the Temp sensors yet.
I really wanted the Tach feature to evaluate my Motor winding efforts.
They supply some tiny little disc magnets but you dont really need them
if you can position the sensor close to the can.
The PC side software allows you to select How Many Magnets in your can
so you get the right RPM readout.
They provide Low High and Avg numbers for you.
Or you can pick anyplac on the graph and just get that part displayed
graphicly as well as digitaly.
I had to get used to Waiting for the unit to settle down before attempting to read
or write to it. Must be a USB thang !
I figured that my 2.26Ghz Alien should have been fast enough.
The PC sw provides either display of mission data
or Real Time display if you can get your PC close enough to the Test stand
of vice versa.
I dont have any other equipment to Judge or calibrate by
SO, I'm just trusting the data as received.
You can also Save data from your testing or Flight missions.
In several styles ( comma , tab, etc delimited )
I use a screen grabber for sharing here in the forums.
They have a fairly informative website too.
bnbproducts.com as I recall.
And I hear that my purchase may be obsoleted by the next update :-(
Lets hope not.
I'd like to know what type of Hall effect sensor they use ?
So I can mount one in my planes without having to BUY another $10 sensor
for every plane.
barb wire
Mar 27, 2007, 02:47 PM
hi guys, ..... 3-27-07
while testing the circuit board earlier today an error was discovered.
the schematic is updated and shown below. the wire at the top
labeled 'black' needs to be have a jumper to the circuit board ground.
without this jumper the 5 volt reg'r doesnt work and neither IC is powered.
the other picture shows the circuit board being tested with
a load of 12 volt car tail lite bulbs. the meter on the left
shows current in amps. the right meter shows the 626:5 milli-voltage
output for this current as sensed by the 20 milliohm resistor.
remember reading above that each amp should yield 200 mV
after going thru the gain=10 '626 stage ? well here we have
1113mV / 5.05 amps = 220 mV / amp
which shows we are in the ball park
there is still a significant error with the circuit. keep looking .
you will find it with some thought. this saturday it will be pointed out.
meanwhile the ckt bd will be tested as is with a bm/prop load.
this type of 'error' is new to me. and i want to do some run tests
and see just what happens.
note too that for indoor bench tests the -08M code does not
have to be concerned with storage space like for in-flite data collecting.
in fact instead of samples every 5 sec they will be taken
every second and sent to the lcd.
then they can be compared with the amp meter reading.
here is a new problem to think about : the meter only goes to 10 amps.
and the motor can run to 15 amps. how would you measure motor current
from 10 to 15 amps so that you can verify what the ckt bd is telling you ?
regards,
bw
PDK
Mar 27, 2007, 09:31 PM
Hi BW,
I don't know what your 'significant' error is, but would have put the sense resistor in the neutral line and if possible would have use a much smaller value. As it is at the moment drawing 5A it will be dissipating P=I^2*R which is 5^2*0.02 = 0.5W. When you run at 25A it will be 25^2*0.02 = 12.5W. Way too much for a 1W resistor. You might have to look for something like a 1milli ohm sense resistor and increase your gain stage.
Just my ramblings
All the best
Phil
alexcmag
Mar 27, 2007, 11:10 PM
I use a 1 miliohm resistance (actually 6 centimeters of 1.5sq.mm copper wire), and read current on the 200mV scale of my multimeter.
I liked your idea, will make something like, but using PIC12F683 (same as your Picaxe 08M), programming in C language, so I will have all 256 bytes of EEPROM to store data.
Will use a shunt current monitor chip from Texas Instruments. It works like the AD626 but is cheaper and have two choices for gain, 20V/V and 100V/V fixed.
barb wire
Mar 28, 2007, 02:47 PM
hi guys,
the picture below is using this code in a pic-axe -08m uC . the code is tested , ready and posted here. the code is every bit as important for overall success as the circuit elements. and it will serve as the basis for what is to come when the circuit board goes airborne. there are lots of comments
as an aid to understanding for both experienced pic-axe BASIC and those of you who are new to it.
the left meter shows 7.48 amps. the right shows 1647 mV
together they give 1647/7.48 = 220 mV/amp . this is 10% higher
than expected. but still leves plenty of room for the 15 amps my
bm is expected to max out at. (5V / 0.22 V = 22.7 amps ) i.e. the
adc's built into the -08m accept signals from 0 to 5 volts.
the -08m uC takes the sense resistor reading into one of its adc's and converts it into a number. this number represents some value of current. then the -08m sends that number to the lcd for display.
the load is, again , some 12 volt car tail lite bulbs off to the right.
assuming the amps meter is correct then 7.48 plus 10% high
is 7.48 + 0.75 = 8.23 amps
the lcd shows 8.2 amps
so far so good
next is to change the load from lite bulbs to a brushless motor.
reading its chopped-up / pulse-y current will be the real test.
regards,
bw
first here is the -08m code w/o any rem statements :
pause 100
main: readadc 2,b0
let b1 = b0/10
let b2 = b0//10
serout 1,0,(" ",#b1,".",#b2," amps","?n")
pause 1000
goto main
now here is the -08m code with all the comments :
rem file = 08M_adc_9.bas 3-28-07 wed
rem improve adc_8.bas format display by showing
rem tenths of an amp & adding units label
rem now change it to accept an adc datum from the '626 chip
rem this code will run the bench tests ...
rem it reads the current thru .020 W sensor and displays it on lcd
pause 100
main: readadc 2,b0 rem read pin 5/8 , d2, a voltage
rem signal from the 626 chip is there
let b1 = b0/10 rem returns qutotient
rem see the "let" command syntax
let b2 = b0//10 rem returns remainder
serout 1,0,(" ",#b1,".",#b2," amps","?n")
rem the lcd uses a pha #108 chip
rem the '?n' advances to the next line and clears it
rem see www.phanderson.com site for details
rem lcd connects to -08m pin 6/8 , d1
pause 1000 rem get a new sample every second
goto main
rem code uses 40 of 256 bytes
barb wire
Mar 29, 2007, 03:28 PM
Hi BW,
I don't know what your 'significant' error is, but would have put the sense resistor in the neutral line and if possible would have use a much smaller value. As it is at the moment drawing 5A it will be dissipating P=I^2*R which is 5^2*0.02 = 0.5W. When you run at 25A it will be 25^2*0.02 = 12.5W. Way too much for a 1W resistor. You might have to look for something like a 1milli ohm sense resistor and increase your gain stage.
Just my ramblings
All the best
Phil
Phil / PDK
hi. that's a good trick you did. making changes in red to the circuit. they sure show up better that way. and erasing the original parts ... how did you do that too?
ok, as to the changes themselves ... i count 4 of them that you propose :
a. moving the sense resistor to the 'neutral' line
b. reducing its value from 20 to 1 milliohm
c. changing the '626 gain from 10 to 100
d. making the ground connection from the neutral wire to the circuit be on
the battery side of the sense resistor.
you write some about watts created at different levels of current. could you tell me more about what your reasons are for that change and the others. and which of these changes reflects on information you have on the sensor itself and the ad626 chip. and how you might go ahead and use the circuit as is anyway.
regards,
barb
barb wire
Mar 29, 2007, 03:42 PM
please see newer msg. i messsed up. the posting was on page 2.
and not seeing that thought it got lost on the way
barb wire
Mar 30, 2007, 11:22 AM
I use a 1 miliohm resistance (actually 6 centimeters of 1.5sq.mm copper wire), and read current on the 200mV scale of my multimeter.
I liked your idea, will make something like, but using PIC12F683 (same as your Picaxe 08M), programming in C language, so I will have all 256 bytes of EEPROM to store data.
Will use a shunt current monitor chip from Texas Instruments. It works like the AD626 but is cheaper and have two choices for gain, 20V/V and 100V/V fixed.
hi alexcmag,
thanks for your comments. i have a few questions for you at this time.
a. how accurately is your .001 ohm resistor known to be ? like 1% or 5%
or 10% ....???
b. i dont understand how your multimeter is being used. other than
for tests on the bench. how will you read the data logged during flite ?
c. what part number is the TI chip ? i want to give it a close look
plus i am pleased to learn you are taking on a similar project. you have
my full support. and i look forward to swapping results and ideas w/ you.
with the exception i dont know a thing about the C language.
thanks,
bw
PDK
Mar 30, 2007, 11:11 PM
Hi BW,
All I did was open your drawing in Paint (Start->all programs->Accessories->Paint). You can rub out sections and draw lines as much as you like.
My reasoning for putting the sense resistor in the neutral was that if the resistor was in the positive the inputs of the 626 would be at the battery voltage (V+) and at (V+ - Imax*R). This would be much higher than the supply. I originally thought that the 626 input voltage might limit the usefull range of the meter but I have read up a little more on the 626 and it seems it can handle 60V. No problem.
Reducing the value of the sense resistor will reduce the power dissipation at that current. Power = Current * Current * Resistance. You have nominated that it is a 1W resistor and you want to have a range of 0-25A. So rearranging to find the resistance
R = Power/ (Current* Current) = 1W/(25*25) = 0.0016ohms.
This dissipation will only be possible with really good airflow so you should aim for a lower resistance to be on the safe side. Also the actual resistance will change as it heats up which will give you errors. That's why I said 0.001
Reducing the resistance of the sense resistor will reduce the voltage drop across the resistor. If you used a 0.001 ohm resistor at 25A you would have V = I*R = 25* 0.001 = 0.025V. Your amplifier will increase this to 0.25V and using an 8bit ADC with a supply reference of 5V you only have a resolution of 20 steps. By using an amplifier of 100 you will be able to increase that to something usable.
Putting the ground connection on the battery side of the sense resistor was part of moving the sense resistor. It would allow a normal opamp to be used to amplify the signal on the motor side of the resistor (using the ground as the reference). You could also use the Vref of the micro and set this to 1/10th the supply voltage and not use the 626 at all.
Good luck
Phil
AndyKunz
Mar 31, 2007, 01:08 PM
You will do much better by reducing the common mode. Put the sense on the bottom, not up high.
Andy
barb wire
Mar 31, 2007, 01:32 PM
hi guys,
here is -08m uC code for a flite test. with lots of remarks. it uses most of the 256 ml's available for code/EE. and leaves just enough EE space to collect some motor current data. its written in pic-axe basic ver. 5.07
next i want to write about the circuit. the 20 milliohm sense resistor in particular. see the scan from the digikey catalog. the p/n for this 20 milliohm resistor is 610HR020
phil/PDK from australia had the idea that its 1 watt rating is way too low. and he is right. by the scan of page 1518 you can see that they are rated 5X overload for 5 sec. but when you run it this hard it overheats and the resistance value drops. it does so linearly but unless you include a thermocouple with the sensor you have no way of knowing its temperature. the 626 will still spit out a current value. but it will have no accuracy. the smart move would be to use a resistor with a higher watts rating of 3 or 5 watts. so that heating up is a non-issue.
for now i plan to use the circuit as is. 1 watt in 20 milliohms does allow 7 amps of motor current. i looked at my air force and picked a plane that can fly on 7 amps. and that is the plane that will be used to flite test the circuit.
for the sake of following through with this design i want to push on. and learn all i can from the effort. you know , like finishing what you start.
later on a better design can be built and flown with the hotter 10-15 amp planes.
next take a look at the scan from the ad626 data sheet. fig. 33 where it says to have an average of 100 mV across the resistor diff'l inputs. i wish they had said more about this. like how it relates to accuracy. so it leaves me having to make a guess as to how to proceed. my hacker a20 runs over a range of currents , from 5 amps in slow cruise to 15 amps for those vertical climbs. for a 0.020 ohm resistor this means from 100mV to 300 mV across the sense resistor.
do you pick a sense resistor to favor 100 mV at 5 amps or 15 amps ?
i dont know. but there is a fabulous bonus for choosing 100 mV at 5 amps.
when you select a 20 milliohm resistor and set the 626 for a gain of 10 ...
the result is 200mV per amp. and divided into the -08m's adc input range of 0-5V you get a current range of 0-25 amps. now it so happens that the s/w gives you back numbers in decimal, 0-255 , that represent this 0-5V adc 8-bit input range. 25 goes into 255 almost exactly 10 times. what this means is the number the uC gives you on the LCD plugged into the circuit board can be made sense of as-is if you simply do a divide-by-10 in your head.
for example the plane flies with 5 amps of motor current. 5 x 200 mV/amp= 1000 mV. this is 1000/5000 of the input range so 1/5 x 255 = 51 . 51 is the number stored in the 'b' register and sent to the lcd. 51 becomes 5.1 amps after doing the mental arithmetic.
any other sense resistor value will need code space for the math. and for this -08m uC application code space is already at a premium
there is lots more to say. but this is enough for now.
at the moment i am having trouble getting the code to work in the circuit board . it does fine in the bread board setup. but the switch is not being read. and of all things there is 5.75 volts on pin 3 instead of the regulator output of 5.07 V. this has me stumped. i'm going to 'scope the -08m pins and V+ bus and look for ringing. once i get this licked it will be put in a plane for flite tests.
comments invited.
regards,
bw
note - the circuit for this code is the one posted on 3-27-07
rem file = 08M_adc_11.bas 3-31-07 10:30 am
rem this code is for flite test ... uses 'blink' subroutine for led
rem 1'st read the switch to know to read the stored EE data or log new data to EE
main: if pin4 = 0 then writ ' if pin4 = 1 then flow is to reed: sub'
reed: serout 1,0,( "sw open READ EE data","?n") 'READ = EE stored
i-data being read
pause 2000
goto blink 'add r=150 , led pin 7/8 d0 to +5V
for b2 = 0 to 15 ' loop value is dependent on
( 256 - ml's of code used )
read b2,b3
serout 1,0,("data ",#b2," is ",#b3,"?n") 'follow along with
data as its read
pause 1500
next b2
serout 1,0,( "16 data read","?n")
pause 1000
goto main
writ: serout 1,0,( "sw close WRITE to EE","?n") ' WRITE = log i-data to EE
pause 1000
for b2 = 0 to 15 ' 0-9 allows for 10 data total to be stored in EE
adc: readadc 2,b0 ' by reading the adc each pass you get
the latest datum
goto blink
if b0 < 50 then goto adc ' skip current values less than 4.9 amps
write b2,b0 ' b2 is address of EE where the datum in b0 is stored
'd0 is pin 6/8 'show datum stored each EE location
serout 1,0,(#b0," to"," EE ",#b2,"?n")
pause 2000
next b2
goto blink
serout 1,0,( "16 data written","?n")
pause 2000 ' 1000 + 2000 + 2000 = 5000 or 5 sec per sample
goto main 'done here ... go back and check switch position
blink: low 0 ' a led simply gives a visual cue that the code is running
pause 200 ' indoors i prefer a piezo buzzer
high 0 ' but it is to big and heavy for flite
pause 200 ' compared to a led
return
rem code uses 240 of 256 ml's ... thus there are 16 EE addresses avail
rem at 5 sec/sample this is 16 x 5 = 80 sec of flite time being logged
PDK
Mar 31, 2007, 09:09 PM
Hi BW,
Back again to try to convince you to try a smaller sense resistor :D . (persistent aren't I?)
anyway the resistors ability to dissipate heat is only part of the problem. Going to a higher power rating will not solve the situation. Have a look at the A20 specifications (http://www.hackerbrushless.com/motors_a20constants.shtm). The motor internal resistance values range from 0.232ohms to 0.02ohms depending on the model. When a motor runs the current consumed will be determined by the applied voltage across this resistance. If we compare your sense resistor to the motor specs you can see that the resistance is very high in comparison. This will dramatically effect the performance of your system. A lot of the systems power will be absorbed in the sense resistor rather than making a contribution to the output.
If you move the resistor to the common mode position you can use any amplifier to increase the voltage value and not worry about the 100mV specification of the 626.
Best of luck
Phil
alexcmag
Apr 06, 2007, 01:32 PM
hi alexcmag,
thanks for your comments. i have a few questions for you at this time.
a. how accurately is your .001 ohm resistor known to be ? like 1% or 5%
or 10% ....???
b. i dont understand how your multimeter is being used. other than
for tests on the bench. how will you read the data logged during flite ?
c. what part number is the TI chip ? i want to give it a close look
plus i am pleased to learn you are taking on a similar project. you have
my full support. and i look forward to swapping results and ideas w/ you.
with the exception i dont know a thing about the C language.
thanks,
bw
Sorry for the delay and thanks for your support.
The shunt was only a suggestion to check the current. I use it just for measuring resistance on the bench, I will make a logger soon.
It is not really a commercial resistor, but a piece of wire. When I don't need too much precision I just use some inches of hard copper wire (like that used on home electrical system). Cut to the correct size. Usually 6cm of 1sq.mm wire does the work.
Nickel-Chromium wire is a better since the the resistance is more constant with temperature.
After mounting I just calibrate it at low currents by shortening or increasing length if needed, using the multimeter (previous calibrated) to compare. It will something around 2% error, depending on the multimeter used.
I started to use it when current consumption of my motors get over 6A and the multimeter does not get good readings. My first 400-sized motor give a reading of 8A on multimeter, instead of the actual 12A. With the shunt, the multimeter is used to read the voltage drop, at 1mV / A, so it is easy to measure higher currents. A picture of it is attached.
Back on the logger, the TI chips are the INA193 to INA198 family: http://focus.ti.com/docs/prod/folders/print/ina193.html
They are made for shunt current monitoring, like you're doing, but cheaper and with fixed gain (20V/V, 50V/V or 100V/V).
Other good choice for current monitoring is the Allegro current sensors ( http://www.allegromicro.com/en/Products/Part_Numbers/0750/ )
They have a family of hall sensors with very low internal resistance (130microOhms on ACS750-050) and good accuracy.
I like to use C language on microcontrollers because it gives more control then Basic but have some portability, so I can for example develop and test a function on my PC and later reuse it on PIC. This is specially useful on communication or more complex algorithms.
In this case, the main advantage is using compiled code I can get all 256 bytes of EEPROM to store data.
barb wire
Apr 08, 2007, 05:50 PM
hi alexcmag,
ok , i get that you use the multimeter for your bench tests.
and you will be doing something else for your plane flight logger.
that is some shunt. house wiring copper. now that's gotta have
at least 2 or 3 watts heat dissipation ability . 14 gage wire
is good for 15 amps of AC current. is that why you left the
insulation in place on the wire ?
and your experience with using the multimeter for motor current
shows the meter to give false low readings as the current increases.
what do you think is going on inside ? could it be the sense resistor
is heating up and its resistance value decreasing ? if it is 10 mOHM
cool and 8 mOHM hot then the voltage across it will be less for the
same level of current.
the same thing happened to me. and like you did ,
by removing the multimeter and using the shunt
to measure current the battery could deliver maximum amps to
the motor. and no more false ammeter readings
for your airplane data logger what size of a sense resistor will you use ?
in the picture i notice the sense resistor is placed in the high side.
along the red wire. is there some reason you put it there and not
along the black wire path ?
both you and another ezone-r , PDK , favor low value sense
resistors. if you stick
with one that gives you 1 mV / A then for a motor using 20 amps
size of Vs on the sense resistor will only be 20 mV.
below is a graph from one of the TI chips you wrote to me about.
remember my comment a week ago that for the AD626 chip they
recomend that Vs be typically 100 mV ? they didnt say why.
but the TI people do. in graphical form. would you please take a look
at it and let me know what you think
on another topic ... you mention the pic being able to hold
256 bytes of data. have you given any thought to just what
data you will store ? amps , i know, but what i am asking is
what part of the planes flight do you want data for ?
regards,
bw
barb wire
Apr 08, 2007, 06:15 PM
Hi BW,
Back again to try to convince you to try a smaller sense resistor :D . (persistent aren't I?)
anyway the resistors ability to dissipate heat is only part of the problem. Going to a higher power rating will not solve the situation. Have a look at the A20 specifications (http://www.hackerbrushless.com/motors_a20constants.shtm). The motor internal resistance values range from 0.232ohms to 0.02ohms depending on the model. When a motor runs the current consumed will be determined by the applied voltage across this resistance. If we compare your sense resistor to the motor specs you can see that the resistance is very high in comparison. This will dramatically effect the performance of your system. A lot of the systems power will be absorbed in the sense resistor rather than making a contribution to the output.
If you move the resistor to the common mode position you can use any amplifier to increase the voltage value and not worry about the 100mV specification of the 626.
Best of luck
Phil
hi phil / PDK
your comments are most welcome. yes , you are persistent.
and that's ok, it pushes me to think. and to review the reasons
behind choices made.
you are right. the sense resistors can both limit current and dissipate
power that the motor would otherwise use. once they exceed some
value of milliohms these effects can occur. and thus the need
to experiment. the battle cry of DIY'rs.
in my view the loss may be 3 to 5 watts with the size of sense
resistors (.050 ohm) i plan to use with a future version of the design.
and given the motor runs on 100 to 150 watts most of the time
i'm not real concerned with the loss. what i am after mainly is
the motor current with some propellor.
also be aware these data loggers will be used for a 5-minute
flite per propellor and then either the prop will be changed or the
data logger removed. 5 minutes is plenty of time to get all the
data i need for how that combo of prop-battery-motor does.
and if i then see the plane flies noticably better with the data
logger removed then i can see about making Rs smaller.
besides, a too-large Rs works in our favor. it will keep
us from exceeding the 'C' battery rating.
i think each flite should have its throttle increased
gingerly, get the data. then land and attach the LCD and
see what the amps are.
what is your data / experience to make the statement ...
"...dramatically effect the performance ... " ? i'd like to
know all there is about the current levels involved and how
the plane flew. and your overall approach to testing.
also i dont understand "...move the resistor to the common
mode position ... " . what is this thing you call a common-mode
position ? could you clarify ? i thought common-mode had
to do with other voltages across the sense resistor besides
the current that is to be measured. like from the magnetic
field of those 12 amps of motor current , zooming through
wires only inches from the instr'n amp. and rf noise like
from r/c Tx's , cell phones and the like. by how you write
i am led to believe com-mode has something to do with location.
something else ... about Rs placement in the 'neutral' line.
this refers to your circuit change ideas in red on 3-27-07 .
the '-' input to the instr amp will be at the Li pack '-' too.
which is 0 Volts. now , given that each + and - IA input needs
to have a bias current flow into it ... how do you get a bias
current to flow into the '-' pin with 0V. on it ? for the '626
the Rin is 200K. and 0V. across 200K is 0 nano amps.
oddly, nothing in the '626 data is said about input bias
currents. it is mentioned in the '623 and '627 data. do you understand
if the '626 somehow doesnt need any , or was it just left out
of the data ? i'm confused about this.
regards,
bw
ps did you see the graph just above with the reply to alexcmag ?
i'd like to have your thoughts about it too
alexcmag
Apr 09, 2007, 07:12 AM
hi alexcmag,
ok , i get that you use the multimeter for your bench tests.
and you will be doing something else for your plane flight logger.
that is some shunt. house wiring copper. now that's gotta have
at least 2 or 3 watts heat dissipation ability . 14 gage wire
is good for 15 amps of AC current. is that why you left the
insulation in place on the wire ?
I left the insulation in place to avoid short circuits.
This wire is good for 15A in a closed duct, but in open air even with insulation it don't get hot even with 25A (never tested more), so the copper resistance don't change too much. Of course it is not perfect, but is better then the Amp reading of my multimeters.
and your experience with using the multimeter for motor current
shows the meter to give false low readings as the current increases.
what do you think is going on inside ? could it be the sense resistor
is heating up and its resistance value decreasing ? if it is 10 mOHM
cool and 8 mOHM hot then the voltage across it will be less for the
same level of current.
I didn't measured, but internal shunt resistor used to sense current must have over 0,1ohm. In high voltage applications it is not a big trouble, but at low voltages it is enough to give false readings since part of power will not reach the motor.
the same thing happened to me. and like you did ,
by removing the multimeter and using the shunt
to measure current the battery could deliver maximum amps to
the motor. and no more false ammeter readings
Exactly. Hobby power analyzers like E-meter, Medusa and others always have a very low resistance internal shunt.
for your airplane data logger what size of a sense resistor will you use ?
One choice is to use around 3cm of thick NiCr wire, making a 0,001ohm shunt. At 50A it will give a 0,05V dropout, so I will need a 100V/V gain to a good reading with PIC ADC.
Other choice is to use one of the Allegro hall current meters, they have a very low internal resistance.
in the picture i notice the sense resistor is placed in the high side.
along the red wire. is there some reason you put it there and not
along the black wire path ?
The reason is that I want to measure voltage after shunt, to a more precise voltage reading. Both TI and Allegro chips allow it since they are differential. Your AD chip don't.
both you and another ezone-r , PDK , favor low value sense
resistors. if you stick
with one that gives you 1 mV / A then for a motor using 20 amps
size of Vs on the sense resistor will only be 20 mV.
below is a graph from one of the TI chips you wrote to me about.
remember my comment a week ago that for the AD626 chip they
recomend that Vs be typically 100 mV ? they didnt say why.
but the TI people do. in graphical form. would you please take a look
at it and let me know what you think
The error of TI chip at very low voltages is up to 3.8%, this means a read error of up to 0.2A.
My motors have an internal impedance of 150miliOhm or less. Using a 1miliOhm shunt the error on reading due to the shunt will be around 0,66%. Adding with 3.8% gives an overall error of 4.5% (this numbers are estimates, to get the exact error rate some more complex math is needed).
If I use a 10 miliOhm shunt, the reading error will increase to around 6,2% plus the chip error, this is greater then the error with low impedance shunts.
on another topic ... you mention the pic being able to hold
256 bytes of data. have you given any thought to just what
data you will store ? amps , i know, but what i am asking is
what part of the planes flight do you want data for ?
regards,
bw
I am planning to store up to 4 variables: Amps, Volts, RPM and Temperature, so I can know exactly what is going with my motor. But Amps and Volts are enough for first tests.
In the future a more complex data logger can be funny, storing acceleration (with accelerometer), speed (differential pressure sensor with pitot/static tube), altitude (absolute pressure sensor), position (GPS). Of course it will be not with a 8 pin PIC...
barb wire
Apr 10, 2007, 12:51 PM
hi guys,
the original circuit design is not working at a circuit board level.
the initial first try layout has the following problems :
1. the switch is not being read reliably.. its position tells
the uC to READ data from the EE or WRITE data to it.
the switch is working ok, and puts a 0V or 5V on pin 3.
what , besides fluctuations on the gnd or V+ bus could
be causing this ? 'this' being a time-out or reset of the
cpu
2. the Vo of the '626 is erratic and jumpy and tends to drift to V+
this is usually a sign that the input bias currents to the +/- stage
of the diff'l amp are not finding their way back to where they came
from. but are acting like stray charge raising the voltage on any
capacitors at the input. this is a sign of a grounding problem
3. the led draws 10+ times the current of
the '626 and -08M combined ( 1.5 ma). this is a poor mix of
current levels to be moving inside the uC. and for now the
led is being omitted. the way to include an led is to have it
Q-driven. and have the uC
send a signal to the Q to turn it off or on. the 'signal' will
provide the base current, maybe 200 uA. and the 20 mA the led
uses will pass thru the Q and not the uC.
4. signal paths for the circuit are 0.1" wide traces on a perf board.
the 2 IC's V+ current path overlapped and the GND paths
overlapped too. the '626 is an analog amplifier. the -08M uC
is digital with an analog ADC contained within. when there is
overlap of the V+ or GND current paths cross coupling of
signals into the other IC can occur.
the first circuit board had its parts salvaged. and was then tossed.
now i am starting over with a new circuit board layout. paying
particular attention to using a 'star' layout for the V+ and GND lines
this circuit board is your basic 'perf-board' with holes on 0.1" centers.
the board lacks a proper gnd plane. and has only skimpy, narrow traces.
see foto below.
good grounding occurs best when lots of wide copper traces are used.
with a good 'star' layout and lots of 0.1uF bypass cap's it could work.
and so i will try this first before going to a copper clad layout design.
i.e. a PC board with one side entirely covered with copper.
one other thing i thought of to do is use a 12" piece of
2-wire shielded cable
from the Rs to the input of the diff'l amp. the benefit of doing this
is being able to have the Rs separate and away from the circuit board.
with no added noise penalty. (long leads act like antennas and
pick up rf noise). it will have the shield grounded at the circuit
board end. 'mike' cable is being used for this purpose.
also indicated is a visit the microchip website. and a look at the
tech doc for the -08M / 12f683 for what they recomend as good
circuit layout practice . given that this chip is being used in
both an analog and digital manner. the -08M chip does not have
a separate analog ground.
the other foto is a visual guide to the gnd bus layout plan
comments invited
regards
bw
alexcmag
Apr 11, 2007, 07:38 AM
There is no need to use a transistor to drive a LED. PIC IO ports can handle 25mA without any trouble.
Adding a 100nF cap is a good idea. Without it there is a little high frequency ripple between VDD and VSS. It is not problem with some designs, but it is a good idea to use then. Install these caps as near as possible from pins 1 and 8 (when using a socket, I install the cap under the PIC.
Also, most Vreg needs a cap on the output (10uF is enough for this circuit). Last week I was trying an Low-Battery alarm circuit and forgot the cap. With the PIC running from internal oscilator the ripple at 5V line was as big as 1V!!!! As the current is less then 1mA, just adding the .1uF cap killed the ripple.
As the measured current can have a ripple too, there is a good idea to add a 1Kres and between the AD and the PIC, as filter.
Other things I learned with these PIC ADC's is you must take a lot of care with input impedance (never over 10K, 1K is better), and to wait 10ms after enabling ADC or changing channel.
AndyKunz
Apr 11, 2007, 08:11 AM
If you are using the PIC ADC, you probably want to use a transistor to drive the LEDs. While the individual pins may drive the LEDs directly just fine, doing so will affect the ADC's precision as the high current affects the Vref- within the chip.
Some PICs are better than others. The PIC24's (stripped down dsPIC's) are much better, and the higher pin count PIC18's aren't too bad. But the little guys like he's using just aren't going to be able to do both well.
That said, you can improve the situation quite a bit if you turn off the LEDs, allow a little settling time (several ms), then start the ADC conversion. After it completes, you can drive the LEDs again. If you are driving a set of LEDs, you can use the conversion time (several us) to calculate what you'll be displaying next.
Read up on the ADC vs. clock operations for your particular chip also. If you can sleep you might help things out.
Andy
barb wire
Apr 11, 2007, 02:22 PM
guys -
a look at the '683 doc for the chip reveals there is indeed no separate
pin for analog ground . nothing was found either on the matter
of the only ground pin , Vss, having to share both digital
and analog currents. and how that fact may affect accuracy.
the '683 doc also did not include any info on circuit layout. for that
you have to hunt thru the library of AN's. AN007 & AN688 look
promising. yet in neither is there any comment found addressing
this exact -08M/'683 uC condition of there only being one ground pin.
the diagram shown below has a Vref on pin 6/8 . i had a hope there
may be some way this can be grounded and function as an analog
ground. nothing read or seen supports such an idea though.
in fact picbasic does not allow you to select any Vref other than Vdd.
this underscores the importance of having a regulated Vdd .
on visiting the picaxe forum and doing a search '08m adc ground'
turned up some relevant info. others too have stumbled over this same
matter. one person , ylp88, wrote that "unless you are after
real accurate adc measurements separate rails are not necessary."
that is good enough for me. the statement went un-challenged.
so for now i am going to move on and focus on providing the best
ground possible on perf board for the IC's.
( there was also mention of a problem with the chip itself when
2 adc's are used .... the workaround was to do a
'dummy' conversion followed at once by the one to keep )
andy , alex - your comments are very welcome. the idea
of using the pic to drive a led is prefered over an extra Q part.
and coding in some settling time is a teriffic approach.
the '683 doc spec did say 10k was a max adc source res,
but no min was spec'd. its good to read that 1k is ok.
and to be reminded it will reduce the ripple . there is a lot
of ripple noise ( about 50 mS at 10 amps) on the Vs signal
coming out of the '626, even with its LPF. adding delay
after an adc conversion sounds like a good idea too.
thanks,
bw
Gary Warner
Apr 11, 2007, 03:54 PM
1. the switch is not being read reliably.. its position tells
the uC to READ data from the EE or WRITE data to it.
the switch is working ok, and puts a 0V or 5V on pin 3.
what , besides fluctuations on the gnd or V+ bus could
be causing this ? 'this' being a time-out or reset of the
cpu
Switch bouncing. Does the code have a de-bounce routine, or if already using one, is the pause time adjustable?
AndyKunz
Apr 12, 2007, 09:38 AM
You really want much less than 10K if you can do it. As standard practice I put a good opamp (or inamp) in front of the PIC analog inputs.
Read and understand the entire PIC ADC section (the big "family" book, not just the datasheet on one part) so that you have a firm grasp of how it should work. Understand the math and the circuit description. If you want good results, that is.
If you have a chip with a Vref, and the language doesn't give you access to the Vref, then you need to use a different language. There are plenty of free C compilers that will work well.
Andy
barb wire
Apr 13, 2007, 02:49 PM
hi guys,
at last the circuit is behaving well. and at the point where moving on from the breadboard circuit to a 2'd try at one on a PC board is indicated.
first though , today i want to look at the topic of filtering. the '626 takes the signal from the Rs and boosts it with a gain of 10. thus 1 amp of motor current will produce 200 mV of output signal at 626 pin 5 , using a Rs of 20 milliohms.
maybe you have never seen a 'scope scene of a brushless motor in action. it is a mess. you have read the esc programming instructions how you have the choice of 8k , 16k or 32K for a switching speed. those switchings make for a lot of 'noise' on the line carrying current. the '626 ampliifies them too.
my Phoenix-25 is factory set at 11 khz
ideally the adc in the uC sees a steady DC voltage. like 3 amps would result in a flat 600 mV DC signal. and the adc would take that and give out a 3.0 amp result with no flicker. from the Li battery the current is switched off and on from one motor coil to the next , in rotation. thousands of times a second. all this off-and-on of each coil disturbs the even-ness of the current flow thru the Rs
pin 4 of the 626 allows you to hang on a cap to filter the output voltage.
by experimenting with caps, from small pF to larger nF, you can see all the narrower the noise band was reduced to. not quite the 'line' hoped for. the internal 626 filter is a 1'st order low-pass. once i got to a filter cap size of 100 nF larger ones made no difference.
the 3'd foto scope picture is with the filter cap removed. doing that has the 626:5 signal all over the place up and down .... well the uC's adc will still sample it .... and the output amps reading moves up and down as does the input signal voltage . you will see ... 0.6 , 1.1 , 3.6 , 1.4 , 0.9 ... etc. on the LCD. the 1'st horiz line up from the bottom is 100 mV or 0.5 amps. the top-most horiz line is 800 mV or 4.0 amps. and the signal cam be seen off - scale above that. thus the adc can be justified in out-putting 0.5 to 4.0+ amps for this one input signal that represents just one gas-stick position of the Tx. this is the worst case, the un-filtered one. and its clear that the
results w/o a filter are of doubtful use. but , who knows. maybe this is grist for some simple averaging, or some DSP. and another person familiar with those methods wouldnt miss a beat.
for a rough idea of the filtering factor in decibels lets do some math ...
call the foto 3 noise spread to be 800 mV , and by foto 2 it is , by filtering ,
reduced to 50 mV. dB=20log(Vout/Vin) ... log is base 10
dB = 20 log (0.063) ... -24dB . now you already know that a 1'st order
LPF has a roll-off of -20 dB per decade. the '626 data
says that the -3dB frequency is 1/(2_pi_RC) with R=100k , the value
of the chips internal resistor. C is user-supplied. here its 0.1uF .
doing the math gives (freq -3dB) = 16 hz. now , just just how you
place this 16 hz and the 11khz switching speed meaningfully on a bode
plot is not known.
16 to 160 to 1600 to 11000 is between 2 and 3 decades. making the LPF 24 dB reduction look like something way less than -20dB / decade roll-off. which could indicate we are not getting all the filtering we are due.
ok . pop quiz time. here is a question for you .
1. you see the 2'd picture with the narrow band of noise.
the adc will spit out some number no matter what you give it for an input signal. the question is about how to interpret the number it gives us .
lets just look at the right half of the scope crt. pretend its exactly a 600 mV DC signal with 50 mV of AC noise riding along on top. now this is what the adc has to take a sample of. in terms of accuracy can't this be seen as a 650 mV signal having 50 mV of noise ? this is 1 part in 13. or 7.7% of uncertainty. (12/13 of the 3-amp signal is good DC, the rest, 1/13 , is a grey area as to what the adc will do with it ).
and does this noise then become the over-riding accuracy factor and
trump all other the error sources ? that a "3.0 amp" signal is really somewhere in the range (3 x 0.923 = 2.77) to (3.0 x 1.077=3.23) ?
for those among you who plan to make your own current data logger ,
is this enough filtering for you ? or will you try for more , with a 2'd order LPF ? what sort of accuracy do you expect to get doing this ? doing some more math ... -40dB reduction on 500 mV of noise gives 5 mV of noise for the same 500 mV signal w/ noise. which is then roughly a 1% error.
doing this then could be well worth the bother of adding the extra parts.
a few readers indicate they will go with a smaller Rs, of a few milliohms and amplify it more than the G=10 of my circuit. now i'm wondering if they know this to be an improvement to the matter of filtering / accuracy. or are they
just looking only at saving a few watts of power.
there are so many possibilities with the choices for these part values. here is where i sometimes wish someone who knows what is best would step forward and just tell us what to do.
by the way, about the left half of that 2'd picture. why the 'stacked' blur band ? one possibility is that the gas stick position was advanced one click and we are seeing both the old and new stick positions. as the horizontal sweep takes place. the alert reader will ask how can one both move the stick and take a picture at the same time .
the "pul=133" seen on the LCD will be covered with the next posting.
you can probably guess what its all about
comments welcome
regards
bw
the 1'st foto is with the motor drawing about 3 amps
Gary Warner
Apr 13, 2007, 04:20 PM
by the way, about the left half of that 2'd picture. why the 'stacked' blur band ? one possibility is that the gas stick position was advanced one click and we are seeing both the old and new stick positions. as the horizontal sweep takes place. the alert reader will ask how can one both move the stick and take a picture at the same time .
That looks like an AC component to the signal. The traces are displayed side-by-side (or better stated Over-Under) as one O-scope sweep is showing one of the two, the next trigger sweep is showing the other. Look at the waveform at a slower sweep speed and you'll identify a low frequency AC component to the signal.
AndyKunz
Apr 13, 2007, 09:26 PM
When you're looking at these screens, don't forget our buddy Nyquist.
You look to be picking up some noise there. Make sure your probe is securely attached and isn't getting bounced around itself.
Andy
barb wire
Apr 14, 2007, 12:53 PM
That looks like an AC component to the signal. The traces are displayed side-by-side (or better stated Over-Under) as one O-scope sweep is showing one of the two, the next trigger sweep is showing the other. Look at the waveform at a slower sweep speed and you'll identify a low frequency AC component to the signal.
gary, you are on to something. thanks for your ideas.
when observing the signals on the scope they were moving slowly up and down like a wave. at the time the circuit was giving me good data so i didnt think much about it.
what you see on the 1'st foto is a clue. the 'pul' value changes w/o any stick position movement. i took this to mean the Tx is outputting a jitter-y gas PWM signal. and as the pulse width changes the P-25 esc changes the current more or less depending on the change. and any change in current is represented on the screen by the noise blur moving up or down. so that is all i made of it. with the discovery that the Tx output pulses may well have jitter.
a new idea is that the AC is 60 cycle and is coming in from my PC. the pic-axe uC bread-board circuit uses in-circuit-programming for all the code downloads and code changes. this makes for great convenience. no having to swap the chip out of the circuit to a programmer board and back.
yes the circuit shares the ground bus of the PC via the rs-232 cable.
and come to think of it the 'scope is grounded to the local AC line too.
and then its probe gnd is clipped to the pic-axe circuit ground.
so that makes 2 connections to the circuit from the local AC gnd ref'ce.
the rs-232 cable can be un-done after downloads. and the scope can
be plugged into a variac transformer and be isolated from the AC ground.
for now i dont know that the AC getting into the pic-axe circuit will matter much. even for bench tests. if you do would you mind letting me know how.
regards,
bw
barb wire
Apr 14, 2007, 01:09 PM
When you're looking at these screens, don't forget our buddy Nyquist.
You look to be picking up some noise there. Make sure your probe is securely attached and isn't getting bounced around itself.
Andy
andy, ok , i need some more input from you about what our "buddy Nyquist" is and how it matters here. the adc is taking a sample once a loop. and by the code posted a week back it can be seen that a loop occurs every 5 seconds. now , given that, how do you think Nyquist is affecting the screen images ?
you make a point about the probe connections. at the sensor end the wires are soldered. at the bread-board end they are soldered to pins that push in to the sockets adjacent to the 626 pins 1 & 8.
ealrier tests were showing the Vo of the 626 to be both jumping around and drifting towards V+. its maddening when this happens,. and loose probe connections could have explained that. or corrosion on the pins. for bench testing the motor is made to run in reverse. so the wind blows towards the wall . and not at the circuit and all its wires. in flite all will be soldered, except the IC's , which will be in a single Augat DIP-16 socket. the Augat brand socket gives the best grip that i know of. during flite wind could be a factor . and efforts will be made to be mindful of its influence
can you think of a reason how wind on the circuit would be welcome ?
regards,
bw
Gary Warner
Apr 16, 2007, 11:32 AM
Barb Wire,
The AC component may be from the AC (household 120V AC) interference, from a poor ground(s) or variations produced from the sensed appliance.
If the problem in grounding you should see it on the scope with everything on but idling. If it's from the appliance being measured, it would show up only when it's running.
Check the frequency of the AC too. 60Hz would indicate poor grounds or radiated interference.
I haven't looked up what Nyquist is all about, but I do know that vibrations on an O-scope probe can introduce unwanted signals. For and example of this, set you vertical gain high (sensitive voltage scale) and tap the probe on a table. You'll 'see' the tap on the scope. I don't really know why this is, but many scope probes do this - even my $300 set of probes do this.
After looking closely at the image, the AC component looks more like a result of a load. I say this because the non-sine shape, noting the nearly flat right side of the trace. Something is bouncing the signal, the power supply current/voltage or something like that. You may want to scope the B+ and the ground at the processor to see if either of them ‘look’ similar to the unwanted AC component of the trace.
BTW, I had a poorly designed AD converter circiut pickup and read the effects of a blinking LED running on the same PIC (older 16C71) many years ago. I had to improve the regulator to stop it from being picked up in the AD of the PIC. I noticed your circiut has an LED.
AndyKunz
Apr 17, 2007, 12:37 PM
andy, ok , i need some more input from you about what our "buddy Nyquist" is and how it matters here. the adc is taking a sample once a loop. and by the code posted a week back it can be seen that a loop occurs every 5 seconds. now , given that, how do you think Nyquist is affecting the screen images ?
You're working with an ADC and don't know about Nyquist?!?!? Try Wikipedia for starters:
Nyquist the man: http://en.wikipedia.org/wiki/Harry_Nyquist
The sampling theorem: http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem (also, look up the other links at the bottom of the personal info page)
I can't read the scale on the pictures, so I don't know what kind of scan you are looking at. Is it digital? (Then think about Nyquist frequency - another thing to Wiki for) An analog scope? It makes a difference.
When you sample waveforms, you have to sample them fast enough to get an idea of what's really happening. Sampling once every 5 seconds is useless if you don't have some sort of filter (with a 10-second period, according to Nyquist) in front of it.
Instead of reading once per 5 seconds, re-write your program so that it is sampling continuously (100Hz, with a 20ms filter in front), and stick the results into a buffer which is low-pass filtered (another thing to Wiki, but an average will get you started), then once every 5 seconds you can pop out your status.
you make a point about the probe connections. at the sensor end the wires are soldered. at the bread-board end they are soldered to pins that push in to the sockets adjacent to the 626 pins 1 & 8.
If you have low-level signals, do yourself a favor and make sure you have good gold contacts and soldered-to-signal connections for the probe. The scope probe itself may be part of the problem - how is the ground connection made? Some cheap probes do not make a good ground.
Also, solder the sampling wires to the socket holding the micro - don't rely on friction-fit connections.
When you're playing with low-amplitude analog, there are all kinds of ways to screw things up. The more connections you make "permanent" the fewer possibilities there are for transients to cause you problems.
in flite all will be soldered, except the IC's , which will be in a single Augat DIP-16 socket.
You will save yourself a lot of trouble if you solder everything now, and if you tack down your wires on the breadboard so that vibration is not an issue.
can you think of a reason how wind on the circuit would be welcome ?
If you have the wrong size/rating resistor, it might be quite helpful ;)
Andy
AndyKunz
Apr 17, 2007, 12:44 PM
PS - do you have an updated schematic with actual values?
Andy
barb wire
Apr 17, 2007, 02:00 PM
hi guys,
this is the latest circuit drawing. version 3. it shows all the changes based on your input ideas
and some of mine over the past several weeks.
the drawing represents the circuit being assembled today on
some perf board.
now that the V+ is coming from the Phoenix-25
esc's BEC the Rs sensor can work on the 'low side' . the big advantage of doing this is the Rs bare
metal (at 10-12 volts ) is no longer exposed to an accidental short circuit. this ruins Li packs in an
instant. positioned at the 'low side' still allows cooling air to flow over the Rs sensor and keep its temp steady.
also the code flow-chart is being posted today too. it is likely to undergo further refinement. both the code and data all have to fit into
256 ml's of memory space. so the less code used means more data can
be saved. i am shooting for at least 24 data. half of that will be actual amps. with each amps datum will be the corresponding pulse width.
at 5 second sample intervals this is about a minutes worth of flite.
the gas pulse that the Rx sends to the P-25 esc is also going to
the uC pin 4. there its width is measured. in units of 10uSec.
what use can you make of this piece of information ?
regards,
bw
ps after posting this an error was noticed. its in the code flow chart.
left out is provision for the WRITE-ing to stop after the available
EE's are filled up . or else they get over-written. and then one cant
tell when in that 1-minute flight the data was recorded at.
mattijs321
Apr 19, 2007, 09:44 AM
haven't read thread but quickly looked over and saw you fighting with space to put data in.
Why not log to mmc sd card? They're super cheap, light and they are real easy to use with the SPI peripheral on the PIC
kfong
Apr 19, 2007, 02:13 PM
Moved
barb wire
Apr 19, 2007, 09:44 PM
mattijs321 - good idea. yes, those cards are quite amazing with all the data they can hold. this option will be considered.
for now though a I2C memory chip will do. the next version of this
current / data loggger will use the pic-axe -18X. and this uC is easily
interfaced with I2C EE. there are already instructions for this step.
the editor s/w for the pic-axe line of uC's is always undergoing evolution.
there may well be now or coming soon an instruction to i/o w/ SD.
bw
barb wire
Apr 19, 2007, 10:06 PM
kfong -
please start your own thread . this one will go on for some time.
and become very large in the process. and i dont want it cluttered up
with what others have done & their designs and pictures .
my wish is that those who submit a reply here in this
thread focus on what i am trying to do. instead of what they have done or think i should be doing.
all that is really just a distraction. every day that i work on it
i am faced with new problems and challenges. all for what on paper
looks like it should be a snap to build and test.
if your thread title says something about 'motor current' & 'data logger' then
it will turn up in a search . that way others who are interested in the
topic can see that many have given it a go and there are a number
of designs to consider.
whatever you have done will make a difference here in this DIY forum..
since your design is operating in the same current range as my design i am very interested to learn all i can of it.
bw
barb wire
Apr 25, 2007, 03:18 PM
HI GUYS ,
A LESSON LEARNED FROM BUILDING THE 1'ST CIRCUIT BOARD LAST
MONTH IS TO TEST IT EVERY STEP OF THE WAY DURING
CONSTRUCTION. THIS ADDS A LOT OF TIME. THE OFFSET
BENEFIT IS
HAVING REAL CONFIDENCE IN THE CIRCUIT BOARD WORKING.
THE ALTERNATIVE IS NOT KNOWING IF THE CIRCUIT WORKS
UNTIL IT IS ALL ASSEMBLED. WHEN YOU GO THIS ROUTE AND
THEN FIND THAT SOMETHING IS NOT WORKING RIGHT IT CAN BE
QUITE A PROBLEM TO FIGURE OUT WHAT IS WRONG. EVEN FOR
SO SIMPLE LOOKING A CIRCUIT.
DURING THIS STAGE IT WAS DECIDED TO BUILD THE -08M uC
SECTION FIRST. AND ADD THE '626 AMPLIFIER LAST. ONE FACT
THAT FAVORS THIS APPROACH IS THAT THE 626'S OUTPUT TO
THE uC'S ADC INPUT CAN EASILY BE SIMULATED WITH A PIECE
OF JUMPER WIRE. GROUND AND V+ ARE 2 VALID INPUT SIGNALS.
AND WILL YIELD 0.0 AMPS AND 25.3 AMPS ON THE LCD.
SOMETHING ELSE OCCURED TO ME . THAT IS THAT THE
BOARD CAN BE TESTED IN THE PLANE, ON THE BENCH, WITHOUT
THE 626 OR THE Rs CURRENT SENSOR. AND STILL ADD TO THE
BOARD OPERATION CONFIDENCE.
THE PICTURE SHOWS THE CIRCUIT BOARD LAYING ON THE
TEST PLANE FUSELAGE WITH THE WING REMOVED. A 'Y' CABLE
SPLITTER CONNECTS THE BOARD TO THE Rx - ESC ALONG
CHANNEL 3, THE 'GAS' SIGNAL. THE BOARD DRAWS ABOUT 2 mA
THE MOTOR IS 'BM2410-12' FROM
AERO-NUTS.COM WITH A 9x7 PROP.
THE KNIFE-SWITCH IS A HANDY WAY TO ADD OR REMOVE
POWER FROM THE Li PACK TO THE SYSTEM DURING TESTS.
ON THE LCD CAN BE SEEN 'AMP=13.5' THIS NUMBER IS
AN ARTIFACT OF THE ADC INPUT PIN 'FLOATING'. AND IS NO
CAUSE FOR CONCERN.
'PULSE=136' IS A REAL PULSE WIDTH NUMBER, SHOWING
GOOD CIRCUIT OPERATION.
THE PLANE IS MTN MODELS 'SMOOTH-E' AND SHOULD
FLY OK ON (7 AMPS ) X (11 VOLTS ) = 77 WATTS , 14 OZ RTF.
KEEPING IT AT OR BELOW 7 AMPS WILL KEEP THE 0.020 OHM
CURRENT SENSOR RESISTOR COOL. ITS RATED AT 1 WATT
AT PRESENT I AM DEBATING WHETHER IT IS WORTH THE
BOTHER TO FLY THE CIRCUIT BOARD AS IS NOW. OR TO GO
AHEAD AND CONNECT UP THE Rs AND GET BOTH PULSE DATA
AND AMPS DATA DURING FLIGHT.
BW
mattijs321
Apr 25, 2007, 07:40 PM
mattijs321 - good idea. yes, those cards are quite amazing with all the data they can hold. this option will be considered.
for now though a I2C memory chip will do. the next version of this
current / data loggger will use the pic-axe -18X. and this uC is easily
interfaced with I2C EE. there are already instructions for this step.
the editor s/w for the pic-axe line of uC's is always undergoing evolution.
there may well be now or coming soon an instruction to i/o w/ SD.
bw
working on a pic18 too...i can store 4000 samples per second at 16bit per sample. The files it logs too can be read by windows and i use matlab to plot the results.
At the start it reads in a configuration file 'config.txt' to know what it needs to sample at what speed for how long etc....
I think the card with a 1 dollar card connector + the logic buffer ic and some smd resistors probably wheigh less than 5 grams (MMC card weighs 1.6 grams)
I got the eagle tree system birthday present half a year ago...which i haven't actually put to use because i don't really have much time for heli's lately...but i guess i might not even get to use it that much...seeing how nice it would be to just pull out the little card and put that in your computer instead of taking the complete system off :/
I wonder what sensing element the eagle tree uses...if it's some hall sensor or somthint with really low impedance or a simple resistor like your design.
I'll have to take a good look at it...maybe there's a number on it.
What i wanted to say actually was...if you want to use mmc at some point...feel free to take a look at my code...it'd be nice if it'd help somebody
mattijs321
Apr 26, 2007, 08:51 AM
I think this is the sensor eagle tree uses (130 micro ohms)
http://www.allegromicro.com/en/Products/Part_Numbers/0750/
If i had know what i know now....i wouldn't have the eagle tree system :/
barb wire
May 15, 2007, 05:24 PM
hi guys,
a key question when doing the code is how do you make sure
the data being stored does not over-write good data already there ?
this concept troubled me for some time. thinking about how to do this
and trying some ideas eventually led to an elegant and simple solution.
on the flow diagram can be seen a decision diamond at the
bottom right side. when the loop to write new data is complete
the switch condition is 'read'. if it is still in the zero state (closed)
then the code stays in a do-nothing loop . until the switch is opened
indicating someone wants to read the data that was stored
it only takes one line of code. " cond: if pin4=0 then cond "
during flight the amps and pulse data is stored in the EE ml's.
this uC has 256 ml's for both code and EE data. thus the less code
the more flight data you can store.
the write loop count is matched to the available number of EE ml's.
once the loop counter max # is reached then further write-ing stops.
this code is not fool-proof. if you get some data and land the plane
then cycle power off-on w/o removing the 'J' on the circuit board
another write cycle will begin. and it will over-write good data.
the trick is to remember to remove the 'J' when the plane lands.
do this first thing and you'll be ok. then the read cycle will begin.
it will repeat endlessly in case you missed reading some data at the start.
no problem tho as to read EE does not destroy what is in it.
the 'J' is a black rectangular plastic thing that you've seen on mother
boards of PC's. it is being used as a switch on the circuit board.
when its in place for flight it jumpers two pins 0.1" apart. this is the same
as a closed switch. when removed the pin 4 of the uC is pulled
up to V+. to remove it a needle nose pliars is necessary.
the circuit board has passed all tests. both with DC currents
of 12 volt lite bulbs as a load. and with a 150 watt BM as the load.
at currents up to 7 amps. the 0.020 ohm sense resistor is rated at 1 watt.
when it has to dissipate more than 1 watt it gets hot and the resistance is no longer a known quantity.
next is to trim the board down in size. then rig it to fit in the plane it will be flown in.
oh , the code will need some last tweeking before flight.
all 3 'serout' lines in the write loop can be rem'd out. they are there for bench testing convenience.
doing this will free up another 80 ml's of EE space.
and that "pause 1000" line can be adjusted too for a different sample rate.
something else you will notice is the decision diamond for " i > 3 ? " this was added to keep "0.0 amps" data from being
stored during that 30 seconds of time between when you
connect the Li battery to the Phx-25 esc and actually launch the plane. it screens out all motor current values less than 3 amps from being logged.
the alert reader may wonder why the write loop count doesnt get
messed up while waiting for amps to exceed 3.
and who can tell us about the line of code "if b0<30 then cur" ...
how is it that 30 represents 3 amps ? why isnt it '60' ? the adc
input range is 0-5V. and one amp is scaled to 200 mV
bw
note - the circuit diagram is the same one as on the p.3 4-17-05 post
mattijs321
May 16, 2007, 01:26 AM
...
barb wire
Jun 15, 2007, 07:59 PM
hi guys
some work was done to tie up a loose end.
in order to have confidence in the numbers some
calibration testing was necessary.
here is what was done and the results
bw
barb wire
Jun 23, 2007, 07:09 PM
hi guys,
the first attempt at gathering flite data was a success.
the numbers looked good at the field. the data was sampled at
2 second intervals and saved to EE-memory. but you will see gaps
in what i wrote down while out there . the plane motor is rather
weak on power and
was flown at or near WOT the whole time. so the amps numbers didnt
change much. in fact since WOT is a known pulse width the code
can easily be changed to not save PUL data. and thereby save twice
as much current data.
a new idea for pulse width is to make marks on the Tx box itself.
and align the gas stick with them. say a flite at 1/2 throttle. and
another at 5/8 , 3/4 etc. knowing the gas stick position is necesary
for making comparisons with the prop, batt pack and type of flying variables.
doing it this way while the uC is a -08m will save on valuable memory space.
for now i want to get all the performance possible from the -08m .
later on , like next winter, a new design using the -18x is planned
one other thing that will change now is the shielded cable to the sense
resistor. it is too stiff. and caused problems when i tried to scotch
tape the circuit card to the wing underside. it will be replaced with
something flimsy.
next i plan to fly it some more with different props at marked stick
positions and WOT. plus do the same thing with a Thunder Power lipo pack.
(on the bench a TP pack provided more amps than the A-N pack)
and learn if the prop that uses the most amps flies any different.
plus i want to be looking at the current draw while climbing
and descending for the same throttle position. i am curious is all.
up or down , to the plane it is always flying into the wind.
there is so much to learn. and every time i do anything i think of
something else to try. recently here in colorado its been breezy,
and that is forcing me to take a long-view position for testing out
all these ideas. i'll be letting you know what i find out.
on top of that a recent order to Digi-Key arrived .(shipping was $2.83)
in it are some 3 watt sense resistors. now i can go beyond the 7-amp limit
of the existing 1 watt sense resistor. and test the hotter 150 watt park flier
and my 2m glider. which are the original reasons for doing this project.
to learn if the 17 amp limit of the TP1320 pack is being exceeded.
regards,
bw
barb wire
Feb 05, 2008, 01:47 PM
fliers -
the present sense resistor , Rs, is limited to motor currents of 7 amps.
it is being replaced with a larger one that will allow up to 22 amps.
the new Rs is made up of 2 each 0.025 ohm , 3-watt resistors.
the Digi-Key p/n is 630HR025E-ND
one new benefit of this upgrade is by using 2 sense resistors
they each act as a backup for the other should the wire-bond of Rs
break. if that happens the max current is then 15.5 amps not 22.
until the failed Rs is replaced.
this change will allow the circuit board with the picaxe -08M uC
to be placed into my 30 ounce 2m glider. it has a 150 watt BM.
recently i have been getting altitude data with a ZLOG altimeter.
with motor current for each ascent it will become possible to
compare the ft-lb / sec needed to lift that mass up in a gravity field
to the amount of power the battery outputs.
this will be the last effort using the -08M uC. then the airborne
circuit will be re-designed using the -18x uC. this will allow for
more sensors than just for current. plus lots more memory to
store the data.
the -08M is a fabulous device. and this project shows a good
example of how much can be gotten out of it with some effort.
bw
barb wire
Feb 18, 2008, 12:25 PM
the following is the next step after the last posting for
getting the new sense resistor flight ready.
barb wire
Mar 07, 2008, 11:49 AM
hi fliers
the updated circuit version needs posted.
here is a history of them : ver 1 3-24-07
ver 2 3-27-07
ver 3 4-17-07
ver 4 3-7-08
the new circuit ver shows the change in the Rs sense resistor.
the curent handling capability was increased. 7 to 22 amps
also added was a note that pin 7/8 of the '626 when left
open provides a built-in G=10 . this is very handy. with that same
pin grounded the G=100 , a useful fact to know. but not here for
this circuit
the gas width pulse was omitted. this info is being supplied
my making marks on the Tx. by keeping track yourself of the gas
stick position for each flite valuable code space is saved. this
results in more room in memory for current data to be stored.
the context for a fixed-position gas stick is electric gliders.
ex. with the plane in my right hand and the Tx in my left i will
use my thumb and move the gas stick to a mark = 1/2 + 2 ticks then hand launch.
the gas stik position will remain the same for 30 , 45 or 60 seconds.
by then the plane will be somewhere between 300' and 700' up.
coming up in april is an updated page of uC code .
a new approach to sampling the current data is being tried out.
it will involve taking a bunch of samples and then averaging them.
this is suppose to negate a fault of the old code. the old code
is able to sample at random in the 'voltage noise blur' and treat that
sample as being representative of the current at that instant.
for an image of the 'voltage noise blur' see posting #32 on
4-13-07 the 2'd foto of an oscilloscope CRT
most of the time the old code is doing nothing anyway.
like 99% or so. so asking it to gather a handful of samples each time you want to
know the current only changes that by a percent or two.
bw
barb wire
Apr 17, 2008, 05:52 PM
hi flyers,
getting from where this project has been to where it is going contains
many intermediate steps. the one posted here is of some code work in that direction.
the previous code only took one sample every few seconds. there is an
inherent problem in doing this. even with filtering the current voltage signal is noisy.
and one cant be sure that the voltage sampled represents the motor
current or the current offset by some degree of noise.
the old code is being changed to reflect a different sense resistor. now
currents up to 20 amps or so can be safely sampled. this is a good time
to fix the nature of how the code deals with the sampling.
the new idea is to take a bunch of samples , add them all up and take an
average. this example of code takes 16 samples. and does so with
a variable amount of delay between each one. this simulates getting
numbers that are not all too close together.
one thing learned during testing is that when the code runs you can rapidly twist
the pot back and forth and see on the PC screen how closely the average
number is to the single sample number . by varying the pause value for each code run here is the result :
the difference between 1-sample and a 16-sample average
pause = 0 difference = 9
pause = 3 difference = 21
pause = 6 difference = 33
pause = 9 difference = 42
once you stop turning the pot the numbers quickly approach each other exactly or differing by only 1
the next step is to add the AD626 signal to the -08m with the
BM running at 10 plus amps . then play with the code. and strive to
get the 1-sample and 16-sample numbers to match.
one possible strategy will be to save all the data and cut+paste it
into a spread sheed program. then graph it. and look at how changes
to the code show up in getting a smoother plot. all that is needed is
a number of samples that looks good. any more than that is a waste
of resources.
you will notice something new in this code. there is no 'serout' line
sending data to a LCD. instead there is a 'sertxd' line of code. what this
does is send the data to the host PC to have it put on the crt.
this is a much cleaner way to develop the code.
also the led shown on the circuit has an internal current-limit resistor.
they came from .phanderson.com the same place that sells the -08m's
bw
barb wire
Apr 21, 2008, 04:26 PM
hi flyers,
a few days ago some averaging code was posted. here is a sample
of the data that code generates. once the -08m PIC uC has this code
loaded and you add power to it then press the F8 key the data is
sent to the PC and logged. the logging is automatic. and the
great thing is that it can be easily saved. when the 'serial terminal'
window is open go to Edit --> 'copy Input Buffer' . now the data is on
the PC system's clipboard. then open Wordpad
-->edit --> paste and the logged data appears on the screen. now you
can give this file a name and save it.
also i want to emphasize this code is but an intermediate step along
the way to getting the airborne current data logger updated. the voltage
off the pot in this
circuit has no bothersome noise. while the real voltage signal from the motor
when it runs has lots of noise. and averaging a bunch of ADC samples of this
noisy signal is one method of dealing with that noise.
for this circuit the 1-sample and 16-avg numbers converge. for the
airborne circuit they wont. the 1-sample can be anywhere in the noise.
and the 16-avg will be at or close to the middle of the noise.
and it needs to be clarified that for this test the uC is connected to the
PC at all times. the link is the same -232 3-wire cable that sends the
code from the editor s/w in the PC to the uC. the 'sertxd' command
uses that same serial -232 link to send data back to the PC for logging.
a sketch of the circuit including these wires is shown below
bw
vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.