ADC Driver Source Code

We have a custom board that uses the G120 SOM.
We call the board in an enclosure with cell modem, battery back-up…a PAC

We are working on the next gen that will use one of the following:
SCM20260D
SCM20260E
SCM20260N

BTW: the page: System on Modules - GHI Electronics is (initially) confusing.
It shows pics at the top going from left to right as:
SCM20260D
SCM20260E
SCM20260N
SCM20100E

Comparison grid shows SOMs going from left to right:
SCM20100E
SCM20260N
SCM20260E
SCM20260D

Visually, takes more than a glance to figure out which SOM pic goes with which Comparison grid spec column.

Anyway, we have many PACs deployed in the field.
The PAC is remotely commanded and controlled…IOT
IO let’s us know the status of the PAC and any attached equipment.

IO consists of digital and analog.
A primary status indicator of attached equipment is brought in via A4 / P1_30
We use A0 - A7 for status indication, along with several digitals.

We have seen and known for quite some time that analog values can freeze (not change value when pin voltage changes) and also show value = 0 event though there may be 3.3v applied to the pin(s).

Our workaround is to use a known value.
We use the incoming power to the PAC (24VDC to 480VAC) to signal if analogs are frozen.

If analogs were frozen the PAC would power-cycle and usually the analogs would be back on-line and good to go. However, we are seeing a population of PACs where the power-cycling methodology
does not work well, i.e. analogs remain frozen for many power-cycles. This has become a high priority to fix!

I have looked thru the forum, LPC1788 User Manual, Eratta, etc. The links below:

https://www.nxp.com/docs/en/user-guide/UM10470.pdf

The link:

Was around the earliest of being aware that we were not the only ones to discover the analog freeze problem.

A question that was posted:
Are the G120 ADC reads coming from the ADC Global Data Register (GDR), or the individual ADC Channel Registers?

DAT replied:
ADC Channel Registers in Burst Mode
ADC Global Data Register is for trigger mode.

Seems ADC Channel Registers can handle both mode, but ADC Global Data Register is only valid in trigger mode.

Following the link chain I got to:

John_Brochue reply at end of link seems to be a good starting place for fixing the frozen analog problem?

With more reading…The errata say’s:
When using either burst mode or hardware triggering, the individual A/D Channel Data
registers should be used instead of the A/D Global Data register to read the A/D
conversion results.

So, we would want to use Burst mode and read individual A/D Channel Data
registers.

Questions:

Is using Burst mode and reading individual A/D Channel Data registers…The way to go?

Is the G120 ADC driver source code available?
If not open source or such, is there someway (sign a doc, pay money) which allow me access to this source code?

Could we contract GHI to help in this endeavor?

Thanks…enjoy ‘Labor Day’.!

Oh wow. Gus post but needs time to digest. We will get to it shortly and your are nice than welcome to contact us directly

Great Gus -

Talk sometime in coming week…

Curious to find out why this happens as I have a G120 using the internal ADC to read an oven temperature and have not had any freezing in over 3+ years of operation.

Are you changing ADC channels? On my design I am only using a single channel and not changing this. Could it be related to the ADC mux?

Dave -

It sounds like I am doing the same as you are.
Below is the code, albeit each line is in different sections of code.
Shown in-line for convenience.

private static AnalogInput _AI8_HV_IN = null; //The HV Input is an analog
_AI8_HV_IN = new AnalogInput(Cpu.AnalogChannel.ANALOG_4, 12); //User HV-Input, //A4 = P1_30
readVal = _AI8_HV_IN.ReadRaw();

The ADC driver code behind the class AnalogInput(…) is currently a black box to me.
Assume your term ‘internal ADC’ means the same as AnalogInput(…) ?

Thanks for input…every bit helps.!

Dave -

Ooops, missed answering your questions.

As the AnalogInput class is behind the sheets, I am not sure what this underlying code (ADC driver)
is doing.

So, AFAIK
The ADC driver code may or may not be changing ADC channels.
If the ADC driver code is changing ADC channels, perhaps the ADC mux is the problem?

Again, no idea what the ADC driver code actually does?

Thanks again…

I went to find the code from a few years and I remember that the built in ADC was really noisy so I had to do loads of samples to filter it. I was using 2 channels, as I forgot about the room temp sensor (theromcouple cold junction temperature) so I am reading more than 1.

NETMF 4.3 and no freezing but then this is not running 24/7 but in the 3+ years of use, never had any freezing. This is the code parts I am using.

static AnalogInput adcThmc = new AnalogInput(Cpu.AnalogChannel.ANALOG_1, 12);
static AnalogInput adcRoom = new AnalogInput(Cpu.AnalogChannel.ANALOG_0, 12);

static int analogRead(int chan)
{
    int adcRaw = 0;

    if (chan == 0)
        adcRaw = adcThmc.ReadRaw();
    else
        adcRaw = adcRoom.ReadRaw();

    return adcRaw;
}

Can you clarify please because there are images right above comparison with images and each image has a name under it.

Do it mean order the columns to match the image?

Yes, the order of columns should match the order of images.

1 Like

Dave -

Both your code and ours are doing the same thing.
So, not sure why we are seeing frozen (AI counts = 0, when voltage applied to input pins) and you do not.?

Thanks for your post.