SMALL - espritmodel.com SMALL - Telemetry SMALL - Radio
Reply
Thread Tools
Old Sep 17, 2012, 01:37 PM
Registered User
mklinker's Avatar
Joined Jun 2011
471 Posts
Thank you!

can someone explain what the voltage divider is? I have the current sensor wired up to 5v, ground and A2, but I am not sure what to do for the voltage divider circuit to hook up to A1...
mklinker is offline Find More Posts by mklinker
Reply With Quote
Sign up now
to remove ads between posts
Old Sep 17, 2012, 02:29 PM
Stick banger
Ace4's Avatar
USA, AZ, Chandler
Joined Oct 2004
1,031 Posts
Quote:
Originally Posted by mklinker View Post
Thank you!

can someone explain what the voltage divider is? I have the current sensor wired up to 5v, ground and A2, but I am not sure what to do for the voltage divider circuit to hook up to A1...
Voltage divider is how you drop the battery voltage to a level that is readable by the microcontroller. The analog inputs can sense 0-5V, and your battery voltage is likely higher than this. So a voltage divider is set up such that max battery voltage is dropped to just under 5V, and then you set the divider value in the code so that the code can convert back to real voltage. Check wikipedia or search for 'voltage divider calculator' for some pages that will help you to calculate what resistors to use.

It depends what current sensor you are using. Mine uses standard 3-wire servo wiring and has red as the battery voltage, white as the current signal (0-5V), and black for ground. So I have ground hooked up to the common ground, the current wire hooked up to A2, and then the voltage line goes through a divider which is hooked up to A1.
Ace4 is offline Find More Posts by Ace4
Reply With Quote
Old Sep 17, 2012, 03:43 PM
Registered User
mklinker's Avatar
Joined Jun 2011
471 Posts
Ace, thank you for your help, I appreciate it a ton. I have the ACS758 current sensor, and with the datasheet it was telling me that I had VCC, GND, and VIOUT. I was under the impression that I needed to have the VCC connected to the 5v on the arduino... GND to ground and VIout to the A2 pin. I assume that VCC is the voltage divider and should be hooked to A1.

EDIT --- I am figuring out that I am going to have to make my own voltage divider circuit, that it isnt just built into the sensor.
mklinker is offline Find More Posts by mklinker
Last edited by mklinker; Sep 17, 2012 at 04:27 PM.
Reply With Quote
Old Sep 17, 2012, 04:26 PM
Stick banger
Ace4's Avatar
USA, AZ, Chandler
Joined Oct 2004
1,031 Posts
Quote:
Originally Posted by mklinker View Post
Ace, thank you for your help, I appreciate it a ton. I have the ACS758 current sensor, and with the datasheet it was telling me that I had VCC, GND, and VIOUT. I was under the impression that I needed to have the VCC connected to the 5v on the arduino... GND to ground and VIout to the A2 pin. I assume that VCC is the voltage divider and should be hooked to A1.
If you have the plain ACS758 chip, you will need some circuitry around it (probably as simple as a resistor on VIOUT and a capacitor from VCC to GND. VCC is used to power the chip itself, so probably would want the 5V voltage that you are using for your arduino. VIOUT is relative to VCC, so if you use VCC of 5V it makes it simpler. GND is obviously ground. From a quick look at the datasheet, it looks like it is bidirectional. It reads VCC/2 for 0 current, v < VCC/2 for negative current and v > VCC/2 for positive. You would need to set the current sensor offset and scale factors appropriately in the config.h file, or put more circuitry around it to have an offset and rescale it.

Your battery voltage would have to be done separately from the ACS758, basically just tap off battery voltage from somewhere (input to the ACS758 maybe) and set up a voltage divider that gets hooked up to your A1 pin.

It all depends on how you want to set it up, the current sensor would probably need to be set up as a separate small board that goes inline with your battery and ESC, then run 3 wires to your OSD board. The drawback to this approach is that your current sensor needs to drop the battery voltage to 5V for VCC. This would likely need to be regulated (LM317 maybe) so that VIOUT has a stable reference center. Or you could have circuitry on the output of VIOUT to eliminate the shifting center. Or even just run 4 wires and send over the 5V VCC from the arduino. Or mount the current sensor on your OSD board and run your battery lines to your OSD. You have a lot of options, and how easy they are to implement depends on how you want to lay everything out.

For my initial setup I just ordered a pre-made current sensor meant for one of the 'namebrand' OSD's because I was feeling lazy at the time and wanted something quick.
Ace4 is offline Find More Posts by Ace4
Reply With Quote
Old Sep 17, 2012, 04:39 PM
Registered User
mklinker's Avatar
Joined Jun 2011
471 Posts
Thanks again Ace, youve cleared up most of my questions and hopefully I will have this guy mounted up on my quad soon.
mklinker is offline Find More Posts by mklinker
Last edited by mklinker; Sep 18, 2012 at 12:56 AM.
Reply With Quote
Old Sep 18, 2012, 12:56 AM
Registered User
mklinker's Avatar
Joined Jun 2011
471 Posts
Howdy again--

I have everything hooked up and now I am trying to configure the code for the bi-directional current sensor and the voltage divider. I havent really focused on the divider yet, but the current sensor is giving me some unexpected values.

The 100 amp sensor (ACS758) centers at 2.36 volts, so the signal should be approx 480 with no current load. What I am doing then is taking the 1.63*(ADCreal - 480).

1.63 comes from .98 * 1.66 -- .98 comes from the scaling and the 1.66 comes from me scaling the 480 - 1024 signal to 0 - 1024. (subtract the 480 then scale it back up)

So I know I obviously loose some accuracy in the current sensing doing this, but at this point that is fine. When I power everything up, it reads like .7 (thats fine, just need to adjust the zero point) but when I throttle up the motor, the current jumps up to a number that makes sense (~20 amps for the motor i am using) but then hops around to like 15, 8, .7, then back up and just jumps around.

I have multimeter'ed the signal coming from the sensor and it stays right on elevated voltage (~2.6 or something) and does not jump around. I thought it might be some noise, so i threw a cap on there, didnt help no matter what size cap I used.

Ideas?
mklinker is offline Find More Posts by mklinker
Reply With Quote
Old Sep 18, 2012, 12:36 PM
Stick banger
Ace4's Avatar
USA, AZ, Chandler
Joined Oct 2004
1,031 Posts
I thought there already were provisions for an offset in the existing code for the current sensor?

Most of the code uses a multiplier of 10 to save a decimal place, I suppose its more efficient code-wise than using doubles or floats, but I'm not familiar enough with Arduinos yet so that is conjecture. I assume if you are getting reasonable numbers initially, either that is coincidence or you have the offset/scaling correct and need some filtering. Are you hooking VIOUT directly to the Arduino input pin? Allegro's page recommends at least having a 0.1 uF cap between VCC and GND, and you probably want some filtering on VIOUT since you don't need high frequency response. A simple RC filter would probably be sufficient.
Ace4 is offline Find More Posts by Ace4
Reply With Quote
Old Sep 18, 2012, 12:46 PM
Just another user
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
1,081 Posts
Yes, the multiplier of 10 is just to avoid floating-points. Floating-points is nice to work with - but they are just too slow.

The Allegro current-sensors is a bit demanding on the output. ACS758 output load resistance should be minimum 4.7K, and the output load capacitance max 10 nF (VIOUT to GND).

To get proper filtering with standard RC lowpass-filter, you will need a high resistor-value and low capacitor value, as the current-sensor can't drive more than 10 nF.

Edit: See this post for further explanation of the measured noise from ACS758 without output-filter:
http://www.rcgroups.com/forums/showp...4&postcount=51
Dennis Frie is online now Find More Posts by Dennis Frie
Last edited by Dennis Frie; Sep 18, 2012 at 12:52 PM.
Reply With Quote
Old Sep 19, 2012, 03:39 PM
Registered User
mklinker's Avatar
Joined Jun 2011
471 Posts
Thanks Dennis and Ace,

I put a 4.7K and 10nF cap between the VIout and ground. I also put a .1 uF cap between Vin and Ground. Unfortunately it still jumps up and down. I would say it is less jumpy, but when I put like a 8amp current through it, it jumps between 4 and 8.

Maybe its time to try a new current sensor??

-Mike
mklinker is offline Find More Posts by mklinker
Reply With Quote
Old Sep 20, 2012, 12:58 PM
Registered User
Latvia, Riga
Joined Jan 2012
58 Posts
Maybe someone could put in some latest shematics with all needed parts for building one briliant OSD without any problems.. I have looked through all tread and now I have mess in my head..
I'm using multiwii for controling my copter and it uses GPS allready.. it would be great to combine these two systems as other users have posted before but i could use it in my plane while I'm not flying my copter so I want to make OSD with GPS and current sensor and so I can see voltage of my battery pack..

Please could you make up some drawing so I can just plug-n-play make this great OSD.. I'm kinda noob in electronics, just had use little bit code for multiwii pusposes.. Thanks in advance..
walkmanz is offline Find More Posts by walkmanz
Reply With Quote
Old Sep 20, 2012, 01:01 PM
Just another user
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
1,081 Posts
Quote:
Originally Posted by mklinker View Post
Thanks Dennis and Ace,

I put a 4.7K and 10nF cap between the VIout and ground. I also put a .1 uF cap between Vin and Ground. Unfortunately it still jumps up and down. I would say it is less jumpy, but when I put like a 8amp current through it, it jumps between 4 and 8.

Maybe its time to try a new current sensor??

-Mike
Sounds like you have coupled the resistor to ground? It should be coupled like this to work:
Dennis Frie is online now Find More Posts by Dennis Frie
Reply With Quote
Old Sep 20, 2012, 06:37 PM
Registered User
mklinker's Avatar
Joined Jun 2011
471 Posts
I go to MIT and I messed up a RC low pass filter.

*sigh*
mklinker is offline Find More Posts by mklinker
Reply With Quote
Old Sep 20, 2012, 06:58 PM
Registered User
bob4432's Avatar
United States, AZ
Joined May 2010
1,824 Posts
Sh*t happens, don't sweat it

Quote:
Originally Posted by mklinker View Post
I go to MIT and I messed up a RC low pass filter.

*sigh*
bob4432 is offline Find More Posts by bob4432
Reply With Quote
Old Sep 20, 2012, 08:09 PM
Chilled and served
Henry.'s Avatar
Sweden
Joined Mar 2005
289 Posts
http://www.muzique.com/schem/filter.htm

Could be used to calculate a simple low pass RC filter, althought the capacitor in this case for the sensor should not be higher then 10nF according to the datasheet.
Henry. is offline Find More Posts by Henry.
Reply With Quote
Old Sep 20, 2012, 11:25 PM
Stick banger
Ace4's Avatar
USA, AZ, Chandler
Joined Oct 2004
1,031 Posts
I had mine working well on a breadboard, so I transferred it to a perfboard. I made the mistake of trying to keep it small, and it isn't working. With the OSD hooked up, the video signal drops to black & white and has some distortion near the top of the screen. There is no text or text background showing up. Any suggestions on what could cause that? I'm guessing there's something on the bottom of the board touching that shouldn't be, but wiggling the wires and components doesn't affect the picture. None of the components themselves are touching each other. I built a voltage regulator into the board for the 5V and one for 3.3V for the GPS, they both appear to be working fine.

I realize it's almost impossible to diagnose a circuit by pictures, but I figured someone may have had a similar problem while building theirs and it could lead me to the correct pin/wire to check. Otherwise it's back to checking continuity from wire to wire on the bottom of the board.
Ace4 is offline Find More Posts by Ace4
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Diy osd karl k FPV Talk 2 May 03, 2011 01:31 AM
Idea New DIY OSD? atari7202 FPV Talk 1 Mar 25, 2011 01:08 AM
Discussion see my own diy OSD video Passion Aerial Photography 7 May 27, 2010 02:28 AM
Discussion REAL homebrew DIY OSD - Check it out! jafoca FPV Talk 8 Jun 29, 2009 07:52 PM
Discussion picoOSD DIY PIC12F683 based OSD in C kbosak FPV Talk 6 Jan 31, 2008 08:47 AM