Git Product home page Git Product logo

gravimetric's Introduction

Gravimetric

From https://github.com/epccs/Gravimetric/

Overview

This board has an application micro-controller (ATmega324pb) with hardware set up for measuring some event times using ICP1 (flow pulse), ICP3 (start), and ICP4 (stop). It has two serial (UART) channels for user application, and a third serial connected to the multi-drop line for hosts to interface with. There are some current source outputs and some inputs that can measure with ADC or do digital IO.

The board is a general-purpose controller in most ways, but there are a few areas aimed at the gravimetric calibration of flow measurement instruments. ICP1 is for measuring time events from flow meters (e.g., pulses). ICP3 is for a start event and ICP4 a stop event; ICP3 and ICP4 have one-shot pulse extenders. Diversion control is a specialized circuit on this board; it starts when the ICP3 capture event occurs and ends with the ICP4 capture event. The ICP3 capture input will need its ISR to enable CS_DIVERSION, and the ICP4 capture ISR should disable CS_DIVERSION for the diversion control to work correctly. Two serial inputs are available to connect a load cell amplifier (e.g., bit-bang an HX711 or serial with a calibrated scale) and a volume prover's inputs (e.g., bit-bang launch and ready or if a prover has serial). I2C is available to interface with a high-resolution ADC (but let's get the onboard stuff working first).

In previous boards, headers for a shield (e.g., RPUpi) were provided, but I removed those headers and added the multi-drop serial manager on this board. A 20x2 pinout for a Raspberry Pi SBC header is on the board but not populated. The R-Pi pins for I2C (SMBus) are connected to the manager, and SPI pins are connected to the application controller. The auxiliary power input is controlled by the manager and a state machine (battery manager) is in early development. The auxiliary power input is also used to operate a simple day-night state machine, which works if a solar panel is used. A host shutdown switch is used to operate a state machine that removes power from the SBC. The host shutdown state machine is also in the early stages and proven to be tricky. The hope is that the application can ignore some things that in the past needed to be considered (e.g., battery management and host shutdown).

Status

Status

Hardware files include a schematic, bill of materials, and various notes for testing and evaluation. Layout files are separate.

Licenses have mostly changed from LGPL to BSD, but some work remains.

Example

Do not think of this as a PLC. A PLC runs a well-tested interpreter that emulates things (e.g., a logic sequence that may be done with a hardwired circuit) that historically served to implement control processes. The firmware that runs on this board is written in C or assembly (I do not recommend C++). The program needs careful reviewing and compiled into the binary instructions that operate the processor. I recommend dividing the software into parts that are as minimally functional as possible for testing. Testing and ensuring correctness is the user's responsibility.

The first UART on the application controller is used for a multi-drop serial bus that is interfaced with the serial hardware on a Single Board Computer (SBC). That serial link allows firmware uploads and general-purpose communication but for security goals, it does not cross network (IP) boundaries. The 40 pin header for a Raspberry Pi uses pins 8 and 10 for RX and TX, other SBC's should also work (I do not test them). The RJ45 connectors are for the multi-drop serial bus daisy chain connection with terminations at the ends.

MultiDrop

Diverting a calibration fluid onto a scale during a precisely measured time while measuring the meter flow pulses is how I am going to calibrate my meters. The start and stop events will be synchronized to the diversion control, and their event time can be compared to the flow meter events. The START and STOP can be from a volume that is being calibrated.

AVR toolchain

This board uses the AVR toolchain. I use the one from Microchip that has been packaged for Debian (it is also on Ubuntu, Raspbian, and Windows with WSL). With the toolchain installed, the AVR application can compile localy.

The frequently used files for this board are in the /lib folder. Each example application has its files and a Makefile in a separate folder. The toolchain is also available as packages.

sudo apt-get install make git gcc-avr binutils-avr gdb-avr avr-libc avrdude
git clone https://github.com/epccs/Gravimetric

The software is a guide; it is in C.

gravimetric's People

Contributors

epccs avatar

Stargazers

 avatar

Watchers

 avatar  avatar

gravimetric's Issues

Verify that the m32[48]pb Clock Fail Disable bit works.

The default is 0. For a fuse, that means it is set, confusing? Yes! I have been setting it to 1 thinking... well enough about that.

My current hypothesis is that the chip will start in a failed mode (e.g., 8MHz internal) and then switch to the softly driven pendulum (low power crystal). However, once in that mode, if the crystal fails, it will be latched to the internal oscillator.

To test, I may be able to short the oscillator input pin to the ground at start-up and watch blink rate, then open the short, and see if it is faster, and short again to see if it slows and keeps going slow when open again.

I2C multi-boss bug

Three Little Daemons

Actually, they are three state machines running. The day-night daemon (again it's a state machine) tracks the status of the alternate power input which could go to a solar panel. The battery-manager (bm) charges during the DAY and disconnects at other day-night states. The bm has some charging modes and trips the host shutdown if the battery is low. The host shutdown daemon enables the manual switch 90 seconds after powerup or after bringing the host UP from shutdown. When a shutdown occurs by software or manual switch the current is monitored to be stable for 90 seconds and then a 40-second delay occurs before removing power. The 90-second wait can be skipped if the application will stop alternating current usage (blinking LEDs) to cause current usage to be stable.

The daemons are done so that they can report state changes over I2C to the manager. This is done by changing the roles of the I2C devices, normally the application plays the role of boss, and sends things to the peon. But today the peon gets to become the new boss and send daemon events to the old demoted boss. Unfortunately, if the old boss tries to access things again the promoted peon can at times defecate on his ostentation (a bug I have not tied to fix, it seems appropriate for the times).

Latch-Up Test

The last page of this app note describes how to evaluate CMOS for Latch-Up.

https://www.onsemi.com/pub/Collateral/AN-339.pdf.pdf

AVR 32[48]pb might be susceptible to destructive latch-up; it is not clear from anything I have seen.

https://en.wikipedia.org/wiki/Latch-up

My thinking has been that the "trench" industry-standard technique helps to limit the destructive current, but some discussion and things like that On/Fairchild Semiconductor application note changed my mind.

Microchip corporation is going to be releasing a new line of AVR128DA that will target safety-critical industrial applications. Those will hopefully address some of these problems that can occur when microcontrollers are trusted to operate the equipment reliably.

https://www.microchip.com/wwwproducts/en/AVR128DA64

With that said, it should be evident that a more industrial worthy path forward will be to replace the 328pb and 324pb (perhaps with AVR128DA32 and AVR128DA48). However, development with the current parts will continue for the near term.

When a datasheet says must not be used within "safety critical" System that may be a clue about latch-up being a known issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.