Planning a DIY Data Acquisition/Engine Controller

Started by dubbleUJay, October 21, 2009, 09:09:03 AM

Previous topic - Next topic

rl71459

Everyone has probably already looked but.... I just tried searching Arduino on ebay....
There are many items! even a "getting started" book!

anyway... just thought it might be of interest for someone.

Rob

BruceM

I ran into something that might be useful for your project, WJ:  It's a chip that does precision RMS calculation.  It's the AD737.  About $6 US at Digikey.com.

I think the AVR chips and Arduino are good choices, just more challenging for the novice than the Picaxe.  I'm not going to be able to help with your code except in generalities- I haven't used either.  

Another thought for your project as I was looking for low quiescent current 7805 substitutes for my battery bank charge controller (BBCC):

If you use a PWM regulator from your 24VDC down to 5.5V, then clean off the ripple with a LF50AB or MIC5237, or best, Microchip's MCP1825 regulator.  They are all low dropout regulators, with low quiescent current.

My BBCC is designed for extremely low power, so the 5-7 ma quiescent current  (constant ground pin loss) of a standard 7805 is greater than the projected nightime power used!

You can reorganize your material anytime you want, just let me know if you need me to help with the cleanup.  



dubbleUJay

Thanks Bruce, I'll definitely look at the power supply/regulator parts and also the rms chip.

I found this site 2day which have a huge selection of ready made sensors and stuff for the Arduino, one can probably buy most of the kit there and the prices seems good.
Particularly of interest to me was this CT power meter probe or you can just get the CT by itself. They have a 30&100Amp version.
http://www.seeedstudio.com/depot/electronic-brick-electricity-meteranalog-p-471.html
Have a look at their "Electronic Brick Kits" & also "Sensors" to the left of the page.
For someone who wants this logger/controller and not make the sensors (or most of them anyway) this could be a supply.

They develop extension boards for Arduino, all one can want by the looks of it and they are busy with a data-logger as well, which might be a bit pricey and not available yet. It has a GPS module on board, but it seems they will take that off to bring the cost down.
http://www.seeedstudio.com/blog/?p=687

I'm going to sh!t myself though if I'm busy re-inventing the wheel and this thing of them are dirt cheap!
Mind you, the nice thing about the Arduino is that most of my code should run on it regardless.  :)

It just blows me away what one can do with these things!

About the coding Bruce, I'm battling to read the correct channels from the 4067 as I'm reading 2 values at the same time with just 1 sensor connected to 1 input???
I've asked on the Arduino forum and got some joy, but I'm still having problems. I've been through it a couple of times and will have to go over everything again. :'(
Its a stupid mistake somewhere and I'm going to kick myself when I find it!
dubbleUJay
Lister  - AK - CS6/1 - D - G1 - LR1 -
http://tinyurl.com/My-Listers

BruceM

Post or email me the code and I'll take a quick look. 

Jedon

Sometimes units always report battery voltage even with no inputs connected, at least that's how the board I'm using works.
I just hooked up mine today but I think I need a different potentiometer, the one I had laying around is a 1K ohm I think and it's really hot. I clamped a pipe wrench on it as a heat sink :-D
I'm using a pot since the board needs analog input to be under 20V and I have a 48V battery bank.
I put a 500A shunt on one of the positive inputs to inverter then to the pot, then to the board.
I fiddled with the pot until 50V reads as 11V or so.
I hooked the board to a serial to ethernet device and plugged that into an old wireless router so I can read the values up at the house.
From there I run my data service ( windows .net c#) that interprets the data from the board and saves it into a SQL server, then I have a website where I can graph the data, interrogate the board, and once I get some relays hooked up I should be able to trigger the generator based on time of day, battery charge and other inputs like ( in the future ) how much water is in my 2600g storage tank so it could turn on the generator and fill it up if it got too low.
I know I'm cheating by not making the board myself but it's from my job :-)

BruceM

#95
WJ, Nice price on the current transformer, but that's all it is, no conversion to analog 5V scale.

Glad to hear you're making good progress on your data acquisition setup, Jedon!




BruceM

Got your code and found a bug in setting the multiplexer address.

This brings up an important point-  for a novice coder, the Picaxe basic is the easiest to learn and understand.  C is not as clear, by a long shot.


dubbleUJay

AAARRRGGGG!!!!!
Bruce, I can pull my hair out! It's working now, but this is what happened:

1) I originally (before I understood any of the code) copied code from a 4x 16ch 4067 project and it didn't count correctly.

2) Obviously that portion of the program was incorrect so I changed it, but still it didn't work!

3) I made the changes you suggested, but still no go!

4) Then I saw it was only the 3rd bit that didn't change, found a soldering problem pulling that output to ground, problem SOLVED!!!

I had the correct code all along, but just presumed it was the same fault, incidentally yours work and 2 other "ways" I was using also works.
So I was going in circles all the time!

I must say that I only understood the way it was done once I looked at your code from the 2nd email, thank you very much.  :)
I'm going to be so forward as to email you a short Arduino Programming Handbook if you don't mind,
if you do, I'm sorry, its already on its way!  ::)  ;D

It sounds like there's a better way of addressing the outputs, but I cant find any reference on the net as how to do it, maybe you can point me as it does have a BYTE "command" that you asked me about elsewhere?
I can now take all the extra code out that I used for testing it and make it as small as possible, just one question, would one save the values read by this routine into an ARRAY to be accessed by the rest of the program or is there a better way to store them?

Thanks again, I feel much better now on this Sunday afternoon, I thought I'm going to start my Monday with a blueish color ;)

Wilhelm
dubbleUJay
Lister  - AK - CS6/1 - D - G1 - LR1 -
http://tinyurl.com/My-Listers

BruceM

I looked at the manual; the Arduino language does not have a byte output!!! Perhaps you can find the code in in someone's library.  You can code around the problem, but good grief, what an oversight.  You could always just use the AVR C compiler, which is reportedly very good.  Perhaps Arduino allows calls to AVR C routines- but I don't know. 

Since you couldn't just count and output the mux address as an upper bits masked byte, it made the code a lot more involved and confusing, having shuffle bits for write to pin commands.   

Yes, I'd store the values in an array for easy access.

The two problems at once situation is always a hair puller and time eater, glad you got it sorted.




dubbleUJay

Thanks again Bruce!

There must be a good reason for not having a byte output or its not mentioned in the "3rd party" manual.
I presume with the enormous following of the Arduino, someone would've complained in the beginning about it.
I'll see if I can find reference to it somewhere. When I asked about the 4067 problem on the Arduino forum, the one guy also mentioned that it was a crappy way of  addressing the multiplexer, but when I asked him how he would do it then, he never came back to me!  ::)
3x projects I looked at using multiplexers on the Arduino used this way to do it.

OK, now I have a micro with the following I/O still free or to use:
10x Digital I/O pins (4x PWM capable)
5x Analog I/O pins (Original)
16x Analog I/O pins (Extended)
1x Voltage reference pin for Analog inputs (AREF)
and I still have access to I2C bus if I need it in the future.

Once I've cleaned up the code for the multiplexer, I can continue with the important stuff like the various probes! ;)
dubbleUJay
Lister  - AK - CS6/1 - D - G1 - LR1 -
http://tinyurl.com/My-Listers

BruceM

I did a little looking for you, WJ.  Arduino "language" (bastardized AVR C) does support AVR C routine calls, since the Arduino language is so limited.

Here's a link to the info you need to do byte outputs to the AVR chip ports:
http://arduino.cc/en/Reference/PortManipulation.




dubbleUJay

Quote from: BruceM on November 30, 2009, 04:18:25 AM
I did a little looking for you, WJ.  Arduino "language" (bastardized AVR C) does support AVR C routine calls, since the Arduino language is so limited.

Here's a link to the info you need to do byte outputs to the AVR chip ports:
http://arduino.cc/en/Reference/PortManipulation.

Thank again Bruce, sometimes I don't know "for what or how to" search for the info that I need.
By that I mean, I know what I want to do, but with English, acronyms and being a novice at code, I think you can imagine how I feel!  :'(
I'll see if I can use the info on that page after I've read it a couple of times.
Ultimately I want the code that reads the 4067 inputs as short as possible because it should run fast and continuously all the time.
dubbleUJay
Lister  - AK - CS6/1 - D - G1 - LR1 -
http://tinyurl.com/My-Listers

BruceM

#102
You don't need to worry about speed, the  code is compiled and is plenty fast enough, just primitive. You can use your bit version that works without concern.

If you want to learn the write a byte to a port code later, I'll help.

Crumpite

Folks,

I started making up a list of useful I/O signals that we could use for DA/Control.

I've come to the conclusion that we should make the I/O as general as possible.
Since each user will have different needs and wants, I think both the hardware and software will need to be modular so each application can pick and choose what's applicable to their situation.
I'm likely telling you what you already know, but I always find that a project goes together better when the framework gets nailed down first.

I think we can separate the code into two sections, the first for control and the second for acquisition.

The controller code can be in two sections, engine control and auxiliary control.
The engine control code can be split into three sections, startup, emergency shutdown and controlled shutdown.
The auxiliary part can cover fuel, temperature, pumps, charging, etc.
There is less chance of code failure if you keep each section simple and easy to understand and analyze.

The acquisition part is quite a bit simpler in complexity, but a lot worse in how to handle the I/O and what to do with it.
Are we going to use a PC to store the data, or some memory device or both.
There is some advantage to storing some of the data at the microprocessor level, such as memorizing the "states" of some of the variables,
For example: is the engine running right now or not (say after a power glitch - don't want to try to start a running engine, or which pumps were running when the glitch happened, etc.)
And what do we use to move the data ? Ethernet, RS232, Wireless, etc...

Which of course implies some sort of PC front end (HMI, Human Machine Interface)...
Can be as simple as a display of current values to a full-blown "click here to to turn on the main circulation pump" or "click here to automatically start the correct pumps and valves to heat the house to 72 Deg. F."

After all that, here's a list of potential I/O for the system, not sorted by digital or analog input or output:

Inputs:
RPM, Oil Lvl, Oil PSI, Coolent Temp's, Exhaust Temp's, Vibration sensor, AC voltage X 2, AC current X 2, DC current, DC volts, Frequency of AC power (HZ), Fuel flow, Fuel lvl, Shutdown switch, Crash Shutdown switch (emergency stop), Generator Temp, Start lockout, Fuel flow in/out, low fuel switch, Fuel temp, Engine temp.

Outputs:
Shutdown, Starter, All OK, Fuel changeover valve, glowplug, generator overload, Alarm condition, Horn, Alternator field on/off, fuel cutoff, throttle, Alternator to main power contactor

Idiot lights:
Oil lvl/pressure, temps OK

Things that it might be good to store in micro:
Hours runtime, watthours total, fuel valve changover state

More can be/should be/might be added to the list.

I used to do this for a living, so you can see I've got a certain "approach" to the system that's industrial in nature, and likely way, way overboard for what we want.

I hope this adds a little to the discussion, I'm not really sure where you all are on the design of this thing.

It might be a good idea to list what hardware is going to be used, and a list of what is available in the form of digital and analog inputs, as well as what exact type of microcomputer is being used.

I've got a nice relay rack that's looking for a new purpose in life.  :)

Daryl



BruceM

Good to have your contributions, Daryl.  WJ hasn't started on engine control, his priority was data collection. His ass is covered, hardware wise, as he has I2C expansion available which can add any DI/DOs and analog he might need.

I can provide my Picaxe Basic source code for the operational code base. It's been in service for a couple years.  It's fairly decent and documented, bug free.  It has no data logging, except status logging via a serial opto-isolated current loop (cat5 cable) to the remote control panel.

I'm inherently skeptical about software and controller hardware when words like "group", "we", "open", "universal", an "generic" are used. Watched Motorola blow over 5 million on such software fantasies, 3 years later a total loss.

For an engine controller, no one's suite of sensors, actuators is going to be the same, but obviously there can be some sharing of hardware and software.