Jump to content


Voltage and current Monitor

Voltage Current Monitor

  • Please log in to reply
33 replies to this topic

#1 pixaero

pixaero

    Member

  • Members
  • PipPip
  • 13 posts
  • Country: flag of Belgium Belgium

Posted 11 October 2011 - 11:39 PM

Hello,

I would like to use this :

http://www.coolcompo...products_id=795

in order to provide CC with voltage / Current monitoring.

As cc has limited external world connectivity i see a quick way is to use an arduino to interface the sensor
and connect CC to it over i2c .

Is there a better way ?

Regards
c

#2 ligi

ligi

    Core Developer

  • Members
  • PipPipPip
  • 200 posts
  • Country: flag of Germany Germany


Posted 12 October 2011 - 12:02 AM

or free up some of the rc-inputs by using e.g. spectrum and use them.
Would also love to see that - please keep us updated

#3 Scott

Scott

    Developer

  • Members
  • PipPipPip
  • 92 posts
  • LocationBay Area
  • Country: flag of Australia Australia


Posted 12 October 2011 - 12:10 AM

I wrote a flight module that reads this ADC chip (MCP3424) via I2C. http://ww1.microchip...eDoc/22088c.pdf

This is the eval board I'm using (comes populated for $15): http://ww1.microchip...eDoc/51737a.pdf

I'm using two of the four channels for K-type thermocouples and was planning to add voltage / current sensing to the 3rd and 4th channels for a gas engine monitoring system. V and I would be for the electronic ignition battery. I'm no electronics expert so this is by no means a well researched solution.... Does work though and hats off to the guys who wrote the low-level I2C code for OP!

I'll be uploading it shortly to Git in case it is of use to others.

Could be a much lower power option than the arduino.

Edited by Scott, 12 October 2011 - 12:13 AM.


#4 pixaero

pixaero

    Member

  • Members
  • PipPip
  • 13 posts
  • Country: flag of Belgium Belgium

Posted 12 October 2011 - 12:01 PM

Hi,

yes your i2c ADC is elegant i'll order one here :

http://jeelabs.com/p...cts/analog-plug its 10EUros and its small package compared to your dev board.

But untill i have it i'll use Arduino nano  in slave mode emulating the MCP3424, i have it here then the code should work with adc without too many modifications.

If you can post your code it will be a  good start for me.

I realy hate flying without voltage information.

Regards

Ps: Arduino can be usefull onboard anyway for example to make an intervalometter for camera etc.
Ps: It could be nice to have an arduino lib to decode uavtalk . so arduino can sniff infos on telemetry port .

I know all this will be included in the pro board but intill its available this is a good start to start playing with openpilot

regards

#5 Amundsen

Amundsen

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts
  • Country: flag of Norway Norway


Posted 12 October 2011 - 12:35 PM

http://forums.openpi...__fromsearch__1

What arduino module do you use?
Best regards
Oyvind Amundsen
Norway

#6 pixaero

pixaero

    Member

  • Members
  • PipPip
  • 13 posts
  • Country: flag of Belgium Belgium

Posted 12 October 2011 - 01:27 PM

Hi,

i was planning to use Arduino Pro Mini 328 5V/16Mhz witch from what i understood does not have enough RAM.

i'll check out the other thread .

Regards

#7 Brian

Brian

    Core Developer

  • Members
  • PipPipPip
  • 567 posts
  • LocationTucson, AZ
  • Country: flag of United States United States


Posted 12 October 2011 - 01:34 PM

View Postpixaero, on 12 October 2011 - 01:27 PM, said:

i was planning to use Arduino Pro Mini 328 5V/16Mhz witch from what i understood does not have enough RAM.

With a little effort you might be able to get it to work.

1) If you only send/receive small messages, you can likely shrink down the tx/rx/ buffers, which default to 256 bytes each.
2) You should be able to remove the tx buffer with a bit of rearranging of the code.  You should be able to stream messages out the serial port rather than building the message in a buffer and then streaming it out.

#8 Scott

Scott

    Developer

  • Members
  • PipPipPip
  • 92 posts
  • LocationBay Area
  • Country: flag of Australia Australia


Posted 13 October 2011 - 05:19 AM

@pixaero
Nice find with the miniature breakout board for the mcp3424. That will be a much better final solution.

I'll upload the code just as soon as I put all the specific files for this module into a separate branch. Will let you know here when it is in the git repository. Give me a day or so...

#9 Amundsen

Amundsen

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts
  • Country: flag of Norway Norway


Posted 13 October 2011 - 03:59 PM

Have ordered one analog-plug :-)
Best regards
Oyvind Amundsen
Norway

#10 Scott

Scott

    Developer

  • Members
  • PipPipPip
  • 92 posts
  • LocationBay Area
  • Country: flag of Australia Australia


Posted 14 October 2011 - 02:06 AM

Just pushed the code to git in this branch: "origin/scott/mcp3424". Should be up to date with the latest "Next" branch.

This is working beta code that talks to two devices via I2C. The first is the mcp3424 chip with 4 analog inputs. My plan is for the following:

Channel 1: Cylinder head temperature
Channel 2: Exhaust gas temperature
Channel 3: Ignition battery voltage
Channel 4: Ignition battery current

[Thermocouple scaling factor could be wrong in this code.... likely to be updated very soon.]

The second device is the mcp9804 chip which is an accurate temperature sensor chip that is used to read the cold junction temperature that the thermocouples are relative to.

Care should be taken to tie the appropriate pins to Vcc or ground to set the correct I2C address for each device.

Attached is the circuit I'm using (sorry... no Eagle layout skills yet).

Both chips should run off 3.3 - 5V supply.

- Scott

Attached File  MCP3424Thermocouplecircuit.png   63.25K   111 downloads

#11 Scott

Scott

    Developer

  • Members
  • PipPipPip
  • 92 posts
  • LocationBay Area
  • Country: flag of Australia Australia


Posted 14 October 2011 - 07:01 PM

Git branch updated. Should build now. Sorry about that.... (Total git rookie here)

#12 pixaero

pixaero

    Member

  • Members
  • PipPip
  • 13 posts
  • Country: flag of Belgium Belgium

Posted 19 October 2011 - 09:41 PM

I wrote the arduino based i2c proxy today ,it read perfectly the voltage and the current (event if the curent mesure is not perfect but it give the "average" good numbers).

I got also MCP3424 today as you can see its not much smaller than arduino , and i think its good to have an arduino around to implement all kind of goodies for example on my MK i use arduino to tirgger camera on panoramic rotation , its good to do intervalometter too .

But anyway the i2c code is the same.

I'll setup the dev environement tomorrow and try to compile the module in the CC, i'll need to understand the Task prioritys and other pios stuff , but it look very clear and easy from your module !


regards

Attached Files



#13 Scott

Scott

    Developer

  • Members
  • PipPipPip
  • 92 posts
  • LocationBay Area
  • Country: flag of Australia Australia


Posted 28 October 2011 - 11:55 PM

Just received my AttoPilot current and voltage sensor. Did you manage to get yours integrated yet?

#14 Scott

Scott

    Developer

  • Members
  • PipPipPip
  • 92 posts
  • LocationBay Area
  • Country: flag of Australia Australia


Posted 31 October 2011 - 06:47 AM

Just pushed my latest code for the MCP3424 that now reads the Attopilot voltage and current sensor values through channels 3 and 4. I'll probably rename this module to something like "GasEngine" since it has all the pieces now.

Also going to add another module just for reporting the main flight battery voltage/current and mAh consumed.

#15 Malx

Malx

    Key Member

  • Members
  • PipPipPip
  • 313 posts
  • Country: flag of Sweden Sweden


Posted 31 October 2011 - 11:00 AM

View PostScott, on 31 October 2011 - 06:47 AM, said:

Just pushed my latest code for the MCP3424 that now reads the Attopilot voltage and current sensor values through channels 3 and 4. I'll probably rename this module to something like "GasEngine" since it has all the pieces now.
Have you actually tried the module on the CC? I recall the core devs having some problems with the i2c bus... (don't remember why, what and when)

#16 Scott

Scott

    Developer

  • Members
  • PipPipPip
  • 92 posts
  • LocationBay Area
  • Country: flag of Australia Australia


Posted 31 October 2011 - 06:17 PM

Only tested on OP Pro Beta so far. I'll try it on the CC tonight.

#17 Scott

Scott

    Developer

  • Members
  • PipPipPip
  • 92 posts
  • LocationBay Area
  • Country: flag of Australia Australia


Posted 01 November 2011 - 05:57 AM

Had to update the makefile to turn on I2C and to have it compile the new UAVObjects but can now say it works on CopterControl too. :-)

Latest code in Git.

Need to figure out how to run both GPS, telemetry and I2C from CC at the same time..... Probably a branch somewhere that will do it....

#18 Malx

Malx

    Key Member

  • Members
  • PipPipPip
  • 313 posts
  • Country: flag of Sweden Sweden


Posted 01 November 2011 - 02:59 PM

Thanks for testing it. I have ordered the boards and will take a look at the code when I receives them. (I'm only interested in voltage and current from the main battery). I'm also going to use it to get a analog signal from a distance sensor for low altitude hold.

#19 Kenn Sebesta

Kenn Sebesta

    Controls Master!

  • Members
  • PipPipPip
  • 896 posts
  • Country: flag of Luxembourg Luxembourg


Posted 01 November 2011 - 09:39 PM

View PostScott, on 01 November 2011 - 05:57 AM, said:

Had to update the makefile to turn on I2C and to have it compile the new UAVObjects but can now say it works on CopterControl too. :-) Latest code in Git. Need to figure out how to run both GPS, telemetry and I2C from CC at the same time..... Probably a branch somewhere that will do it....

Don't know how I missed this, but it looks fantastic. Congrats! Support for an external analog sensor board is really neat.

#20 pixaero

pixaero

    Member

  • Members
  • PipPip
  • 13 posts
  • Country: flag of Belgium Belgium

Posted 02 November 2011 - 11:26 AM

Hi,

yes its working with both Arduino (pretending to be MCP), i still have problems to compile the firmware on my laptop so i need to reinstall a proper dev environement.

Dont you think you should keep all in the same generic module called ExternalSensors with configurable mapping of MCP .
So anybody can use it to push yet another sensor data ?

I use arduino as bridge witch allow to output MikroCopter compatible data using http://www.mikrokopt.../NaviDataStruct , so it works directly with AltaStation code (or jeti telemetry) so you have the current / Voltage directly on your radio.

Regards


View PostScott, on 31 October 2011 - 06:47 AM, said:

Just pushed my latest code for the MCP3424 that now reads the Attopilot voltage and current sensor values through channels 3 and 4. I'll probably rename this module to something like "GasEngine" since it has all the pieces now.

Also going to add another module just for reporting the main flight battery voltage/current and mAh consumed.