Author Topic: ADC not being read  (Read 8125 times)

gillecaluim

  • Newbie
  • Posts: 13
  • I'm a llama!
    • View Profile
ADC not being read
« on: February 28, 2020, 02:24:31 PM »
I must be doing something stupid.  I'm trying to read the ADC values but the online monitoring of the FX1616BA shows all of the ADC channels grayed out and showing 0
How do I enable the reading of the ADC channels?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3170
    • View Profile
    • Internet Programmable PLCs
Re: ADC not being read
« Reply #1 on: February 28, 2020, 11:58:41 PM »
You need a program inside the PLC that run the ADC(n) function to read the value of ADC channel n.

The PLC does not want to waste CPU cycle to read ADC if it is not required in the program.

You can use a clock pulse such as 0.1s to drive a custom function. Inside the custom function you can write the following:

FOR I = 1 to 8
    DM = ADC(I)
NEXT

The ADC channel data will be read into DM[1] to DM[8] and their value will also be available on the online monitoring screen.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

gillecaluim

  • Newbie
  • Posts: 13
  • I'm a llama!
    • View Profile
Re: ADC not being read
« Reply #2 on: February 29, 2020, 06:50:48 AM »
I have that circuit in my program with a 1 sec trigger and I verified that it's being executed by monitoring DM[4]

Code: [Select]
DM[2] = ADC(1)*10000/4096
DM[3] = ADC(2)*10000/4096
DM[4] = (DM[4] +1) MOD 4095
SETLCD 4,1,"Water I/O Temps="+STR$(DM[2]/10) +"."+ STR$(DM[2] MOD 10)+CHR$(223)+"C"

I've even tried running the sample ADC program and get the same result
I've even tried it on a Nano board with the same result
« Last Edit: February 29, 2020, 07:59:15 AM by gillecaluim »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3170
    • View Profile
    • Internet Programmable PLCs
Re: ADC not being read
« Reply #3 on: February 29, 2020, 08:33:44 PM »
So does DM[2] and DM[3] return value you expected or do they all return only zero?

Did you connect the voltage to ADC(1) and ADC(2). Note that ADC(1) is on the PIN 8 of the DB15 connector and ADC(2) is on the PIN 7 of the DB15 connector. Please make sure that you have applied analog voltage to the correct PIN on the DB15 connector.

Email: support@triplc.com
Tel: 1-877-TRI-PLCS

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re: ADC not being read
« Reply #4 on: February 29, 2020, 09:54:36 PM »
This is a screen shot showing the on-line debugger running in i-TRiLOGI Version 6.6 build 04.  The PLC is a Nano-10.

ADC(1) and ADC(2) are being accessed, periodically, as part of the PLC program. The ADC inputs are about 3.71 and 4.07 VDC relative to the analog ground reference. 

Note the non-zero values for ADC 1 and 2 on the screen shot. 

I suggest that you disconnect anything that you may have connected connected to your PLC (ADC) inputs. Now jumper the +5V analog reference voltage to one of the ADC inputs. This is the reference voltage used by the PLC ADCs and this voltage should result in the ADC measuring the full scale value of 4095 counts.

As noted by TRI support the PLC must be executing a PLC program that periodically "reads" the ADC values.  Otherwise, the registers accessed by the on-line debugger will return a value of zero.

Another reason that you may get a zero reading is that voltage measurement is relative to the AGND input.  If you try to measure the voltage of a D cell battery, connecting only the + end of the battery to ADC 1 will get you a zero reading.  You must connect the - end of the D cell to the AGND, also.


Gary D
« Last Edit: March 01, 2020, 10:02:47 AM by garysdickinson »