Sep 17, 2012, 12:37 PM Registered User Joined Jun 2011 476 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...
Sep 17, 2012, 01:29 PM
Stick banger
USA, AZ, Chandler
Joined Oct 2004
1,031 Posts
Quote:
 Originally Posted by mklinker 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.
 Sep 17, 2012, 02:43 PM Registered User Joined Jun 2011 476 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. Last edited by mklinker; Sep 17, 2012 at 03:27 PM.
Sep 17, 2012, 03:26 PM
Stick banger
USA, AZ, Chandler
Joined Oct 2004
1,031 Posts
Quote:
 Originally Posted by mklinker 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.
 Sep 17, 2012, 03:39 PM Registered User Joined Jun 2011 476 Posts Thanks again Ace, youve cleared up most of my questions and hopefully I will have this guy mounted up on my quad soon. Last edited by mklinker; Sep 17, 2012 at 11:56 PM.
 Sep 17, 2012, 11:56 PM Registered User Joined Jun 2011 476 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?
 Sep 18, 2012, 11:36 AM Stick banger 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.
 Sep 18, 2012, 11:46 AM Just another user Denmark, Capital Region of Denmark, Naerum Joined Feb 2011 1,343 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 Last edited by Dennis Frie; Sep 18, 2012 at 11:52 AM.
 Sep 19, 2012, 02:39 PM Registered User Joined Jun 2011 476 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
 Sep 20, 2012, 11:58 AM 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..
Sep 20, 2012, 12:01 PM
Just another user
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
1,343 Posts
Quote:
 Originally Posted by mklinker 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:
 Sep 20, 2012, 05:37 PM Registered User Joined Jun 2011 476 Posts I go to MIT and I messed up a RC low pass filter. *sigh*
Sep 20, 2012, 05:58 PM
Registered User
United States, AZ
Joined May 2010
1,839 Posts
Sh*t happens, don't sweat it

Quote:
 Originally Posted by mklinker I go to MIT and I messed up a RC low pass filter. *sigh*
 Sep 20, 2012, 07:09 PM Chilled and served Sweden Joined Mar 2005 305 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.
Sep 20, 2012, 10:25 PM
Stick banger
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.