Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Serial Interface 7135 to AVR microcontroller

Status
Not open for further replies.

Manpreet1604

Junior Member level 1
Junior Member level 1
Joined
Nov 20, 2015
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,422
hello everyone,

I am trying to interface ICL7135 with microcontroller, during my search I found that we can communicate this IC with only single wire and get our data which is also mention in the datasheet page 6 "A very simple means for transmitting the data down a single wire pair from a remote location would be to AND BUSY with clock and subtract 10,001 counts from the number of pulses received - as mentioned previously there is one “NO-count” pulse in each reference integrate cycle."


I have a hardware already created with AVR uC now i want to recreate code for same hardware but unable to understand how to implement this piece of code.

any help will be appreciated
 

Attachments

  • IC7135.PDF
    42.5 KB · Views: 222

Hi,

My personal opinion: This ADC is huge, expensive and complicated to interface to a microcontroller. Thus I'd never use it.

But you are free to use it.
To give you support we need to see your circuit (not the datasheet one).
Otherwise there are too much questions like: is your ICLxxx circuit cirrect, is the AND wiring correct, which AVR and which pins you used...
For further debugging we need to see your PCB layout, too.

You said "you tried" ... but we don't see this.
We will help you, but "helping" does not mean we provide the solution or the code. So we need to see your idea, your flow chart, your sketches, your code.
At least you need to tell us what you understand so far and where exactly is the problem.
Then we are able to support you and rectify some errors.

Klaus
 

hello klausST,

circuit diagram is already attached in pdf I have a hardware which is connected in this way with AVR ATMEGA 32 micro with only 4 pins CLK of 7135 is connected with PB1 & Polarity with PB3 where Busy pin is connected with PD2 and PD3 which are interrupt pins of AVR ATMEGA 32 the concept of reading data is generate 'CLK' from uc 'AND' with BUSY '-' 10,001 '=' READING

when we AND CLK with BUSY it give Burst of pulses and count them and substract from 10001 is our actual reading and busy pin also act like interrupt when it gone from high to low start counting

I dont know how to implement this in a software
 

Hi,

Your schematic is incomplete (REF, power supply capacitors, OUT ... and more)
and wrong: power supply values
missing: exact ATMEGA32 type.

ICL7135_CLK needs to be generated else where.
I guess you want to AVR to do this.
If so: use an OCxx output. Then the AVR perifieral can generate the desired clock without processing power ( = hardware solution)
Use AVR_OC0 (or AVR_OC2) and connect it with ICL7135_CLK.

AND_OUT is used as gated clock for a counter.
Indeed, if you make the AVR generate the ICL7135_CLK, you may omit the AND gate.
But at first let´s go with the AND gate:
AND_OUT sends oupt pulses as long as the ADC is BUSY. The AVR needs to count these pulses.
The AVR contains 3 counter perifierals. Two for 8 bit values, one for 16 bit values.
Since the number of counts is expected to go above 256 (= 8 bit limit) I recommend to use the 16 bit counter.
The input for this counter is "T1".
--> thus conect AND_OUT to AVR_T1

ICL7135 is used to sync the AVR with the ICL measurement.
--> connect ICL7135_BUSY with AVR_INT0 (or AVR_INT1)

Software: (pseudo code)
MAIN:
* declare ADC_value as int16, volatile
* init ports
* init timer0 (or timer2) to generate the desired ICL7135 clock frequrency
* init timer1, clock source = T1, no prescaler
* init INT0 (or INT1): to generate an interrupt at the falling edge.


INT0_ISR:
* ADC_Value = TCNT1 - 10001
* clear TCNT1
* RETI

*****
That´s it basically.
Just use ADC_value in MAIN as you like

Klaus
 
Last edited:
Hi,

Your schematic is incomplete (REF, power supply capacitors, OUT ... and more)
and wrong: power supply values
missing: exact ATMEGA32 type.

ICL7135_CLK needs to be generated else where.
I guess you want to AVR to do this.
If so: use an OCxx output. Then the AVR perifieral can generate the desired clock without processing power ( = hardware solution)
Use AVR_OC0 (or AVR_OC2) and connect it with ICL7135_CLK.

AND_OUT is used as gated clock for a counter.
Indeed, if you make the AVR generate the ICL7135_CLK, you may omit the AND gate.
But at first let´s go with the AND gate:
AND_OUT sends oupt pulses as long as the ADC is BUSY. The AVR needs to count these pulses.
The AVR contains 3 counter perifierals. Two for 8 bit values, one for 16 bit values.
Since the number of counts is expected to go above 256 (= 8 bit limit) I recommend to use the 16 bit counter.
The input for this counter is "T1".
--> thus conect AND_OUT to AVR_T1

ICL7135 is used to sync the AVR with the ICL measurement.
--> connect ICL7135_BUSY with AVR_INT0 (or AVR_INT1)

Software: (pseudo code)
MAIN:
* declare ADC_value as int16, volatile
* init ports
* init timer0 (or timer2) to generate the desired ICL7135 clock frequrency
* init timer1, clock source = T1, no prescaler
* init INT0 (or INT1): to generate an interrupt at the falling edge.


INT0_ISR:
* ADC_Value = TCNT1 - 10001
* clear TCNT1
* RETI

*****
That´s it basically.
Just use ADC_value in MAIN as you like

Klaus

Code:
//Timer2 is used to genrate  125khz pulse from pin 11 in uno and pin 5 is use to count pulse using Timer1

#include <avr/io.h>
#include <avr/interrupt.h>

const int pulseOut = 11;
const int LED_pin = 13;
const int BUSY_PIN = 2; //busy pin used as input counter @ pin5 and pin2
unsigned long ADC_count;

void setup() {
 
  Serial.begin(115200);//start Serial
 
  pinMode(11,OUTPUT);
  pinMode(LED_pin,OUTPUT);
  pinMode(BUSY_PIN,INPUT_PULLUP);

  attachInterrupt(digitalPinToInterrupt(BUSY_PIN),isr, CHANGE);//pin2 interrupt
 
//Timer2 used to generate 125kHz at pin 11

  TCCR2A |= (1<<COM2A0) | (1<<COM2B1) | (1<<WGM21) | (1<<WGM20);
  TCCR2B |= (1<<WGM22) | (1<<CS22);

// Timer1 used as counter @ pin5 and pin2 as input
  noInterrupts();
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1 = 0;
  //TCCR1B |= (1<<CS10);//clkI/O/1 (no prescaling)
  //TCCR1B |= (1<<CS10)|(1<<CS11) |(1<<CS12);//External clock source on T1 pin. Clock on rising edge.
  //TIMSK1 |= (1<<TOIE1);//enable time overflow
  interrupts();
}

void isr(){
  if (digitalRead(BUSY_PIN) == LOW) STARTtimer1();
  else STOPtimer1();
}

void STARTtimer1()
{
  //TCCR1B |= (1<<CS10)|(1<<CS11) |(1<<CS12);//External clock source on T1 pin. Clock on rising edge.
  TCCR1B |= (1<<CS10);//no prescaler
  ADC_count = TCNT1 - 10001;
}


void STOPtimer1()
{
  TCCR1A = 0;
  TCCR1B = 0;
  //Serial.println("STOP");
  TCNT1 = 0;
}

void loop() {
 
    Serial.println(ADC_count);   
 // Serial.println(TCNT1);
  delay (500) ;
 
}


hi all this is the code iam using to perform above task counter is working but the reading is not correct iam using ardiuno uno bard instant of AVR
 
Last edited by a moderator:

Hi,

Still we don't have a complete schematic.
"The reading is not correct" is no useful error message. Please write what you expect and what you get instead.
You ignored my recommendation "* declare ADC_value as int16, volatile". You did neither "signed" nor "volatile".

Klaus
 

Code:
#include <avr/io.h>
#include <avr/interrupt.h>

const int pulseOut = 11;
const int LED_pin = 13;
const int BUSY_PIN = 2; //busy pin used as input interrupt
const int BUSY_PIN_2 = 3; //busy pin used as input interrupt
volatile int ADC_count;

void setup() {
 
  Serial.begin(115200);//start Serial
 
  pinMode(11,OUTPUT);
  pinMode(LED_pin,OUTPUT);
  pinMode(BUSY_PIN,INPUT_PULLUP);
  pinMode(BUSY_PIN_2,INPUT_PULLUP);

  attachInterrupt(digitalPinToInterrupt(BUSY_PIN),STARTtimer1, FALLING);//pin2 interrupt
  attachInterrupt(digitalPinToInterrupt(BUSY_PIN_2),STOPtimer1, RISING);//pin3 interrupt
 
//Timer2 used to generate 125kHz at pin 11

  TCCR2A |= (1<<COM2A0) | (1<<COM2B1) | (1<<WGM21) | (1<<WGM20);
  TCCR2B |= (1<<WGM22) | (1<<CS22);

// Timer1 used as counter
  noInterrupts();
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1 = 0;
  interrupts();
}

void STARTtimer1()
{
  //TCCR1B |= (1<<CS10)|(1<<CS11) |(1<<CS12);//External clock source on T1 pin. Clock on rising edge.
  TCCR1B |= (1<<CS10);//no prescaler
   
}


void STOPtimer1()
{
  TCCR1A = 0;
  TCCR1B = 0;
  ADC_count = TCNT1 - 10001;
  TCNT1 = 0;
}

void loop() {
 
  Serial.println(ADC_count);  
  delay (1000) ;
   
}


I have made some changes in code and pin 5 is blank as i told iam using Ardiuno uno board in which pin 11 is used as clock output for ICL7135 and pin 2 and 3 used as interrupt Iam getting the value in ADC_count but unable to corelate with actual input like for 1volt TCNT1-10001 is varying from which i am unable to identifying actual reading

ADC_count

0
9578
1647
-26961
-6967
13040
10618
2668
-4499
-24082
31837
-21265
-5000
-2847
7789
9430
1254
10733
-28945
 

Hi,

no wonder ... with the incomplete schematic. (as already mentioned in post#4)

Klaus
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top