Yes , i tried like Robin said. It seems looks OK. but most of the times the previous values not getting changes. That mean it replies the same adc value. but my adc input keeps changing.
i cleared the inChar and inputstring everything.
Is that anything we can do like clearing the serial buffer?
So really this is nothing to do with serial interrupts? You have a problem with the ADS1115 converter. You may find that the I2C communication speed between your code and the ADS1115 is the problem (plus it would take a little while to do the conversion). You could try increasing the I2C speed.
Basically, the 1115 is a pretty slow ADC, and its default configuration is 128samp/s: about 8ms per conversion.
It CAN go as fast as 860samp/s, or you can set it to do continuous conversions and get the "most recent" result pretty much instantaneously, but you'll have to modify the library to get either of those behaviors.
I2C isn't a very fast interface either, but it shouldn't result in "several milliseconds" of delay.
The initial question wandered off into questions about serial interrupts, when it would have been more helpful to disclose that you were having problems reading from the ADS1115 ADC converter in a timely way.
Yes, there was 8ms delay for conversion_delay in adafruit_ads1015.h .
ads1115 operate in oneshot and continuous mode.
in one shot after every sample read at 1.2 ms it goes sleep or idle for 123.8 ms. so next value updated might after 125ms.
now i configured to ads1115 to continuous mode, Now Can i change conversion_delay deafault value to 2ms? because now i think there wont be any idle time for 123.8ms. . so max time taken will be around 1.3 to 1.4 ms as data sheet stated.
I am asking because there is default value for conversion delay was 8ms. for other pointer(config) register i configured to achieve both Continuous mode and 475SPS
Yes, there was 8ms delay for conversion_delay in adafruit_ads1015.h .
ads1115 operate in oneshot and continuous mode.
in one shot after every sample read at 1.2 ms it goes sleep or idle for 123.8 ms. so next value updated might after 125ms.
now i configured to ads1115 to continuous mode, Now Can i change conversion_delay deafault value to 2ms? because now i think there wont be any idle time for 123.8ms. . so max time taken will be around 1.3 to 1.4 ms as data sheet stated.
I am asking because there is default value for conversion delay was 8ms. for other pointer(config) register i configured to achieve both Continuous mode and 475SPS
Post your configuration code. And more of your other code.
Obviously, if you have the chip configured for more than 125 Samp/s, you shouldn't have to wait 8ms for a conversion complete.
The way I read the datasheet, if you have the chip set to "continuous" mode, you should be able to read the value with zero delay, and you'll get the LAST value that was converted (up to 1/8 s ago, if you're in 125 Samp/s mode.) This sounds like it should be useful for most arduino-like applications; you have at worst a delay of one sample time from the actual value, vs a delay of at least one sample time from the time you ask for a sample in one-shot mode. At the expense of higher power consumption in the realm of "dwarfed by other arduino components anyway."
The one thing that isn't clear is how changing the MUX (channel) value affects things (and I didn't see any info in the datasheet, either.) Does the converter run while you're changing the mux (causing the first reading to be bogus)? Does changing the mux restart a conversion even in continuous mode ? Can you even change the mux while the chip is running in continuous mode? What if the new channel is the same as the old channel? The Adafruit library ALWAYS writes the mux, which seems problematic if you're only reading one channel. At this point, you might want to discard most of the adafruit library and write your own code, using it as "reference material."
alagappan:
Yes, there was 8ms delay for conversion_delay in adafruit_ads1015.h .
If your main code wants a value every 50 millisecs how can this be a problem. You can get 6 readings at 8ms each within 50 ms.
Why not just write your Arduino code to get values from the ad1115 as often as it can and save the value to a variable. Then when a request for a value arrives just send the value that is in the variable.
If the call to the ad115 is a blocking call I would be very tempted to just get one reading immediately AFTER I sent a value - as that way the blocking call would be least likely to interfere with anything else.
I think you want to change the readADC_SingleEnded1() function to NOT re-write the configuration register each time. Instead, you should do all that in the/an initialization function (xxxx.begin()?) ...
I did now the conversion is faster. less than 1 ms. I configured in continuous mode and 3300SPS
inside begin, i am writing config register, not on every readsingleended function, in readsingleended i simply read and return the values.
I have another doubt. How to use serial interrupt instead of polling
because i tried with attachinterrupt(0,ISR,CHANGE);
detachinterrupt(0);
but not worked,
Can anyone tell me 1)how can i handle interrupt instead of polling in arduino? 2) i need to ensure whether my prev value at serial buffer is cleared or not ? how can i clear Serial tx,rx buffer
will use of function Serial.clear() clears the buffer
alagappan:
I have another doubt. How to use serial interrupt instead of polling
because i tried with attachinterrupt(0,ISR,CHANGE);
detachinterrupt(0);
Have you not read any of the earlier advice you were given ?
Yes , Thanks to Robin andall, I hope my problem solved
hi Robin,
just i wanted to know how to check whether my previous transmitted value in Serial.print function has been cleared. i am not facing any issue.
May i know where i can find these Serial function in installed libraries?. So that i can get to know about how data has been written into Serial transmit register.
alagappan:
Can anyone tell me 1)how can i handle interrupt instead of polling in arduino? [/quote]
**What do you want to do with the interrupt? Pull a character and put it into a buffer? That is already being done for you. It is one of those things you have to do on other boards but the code is already there happening in the Arduino core. You aren't going to make it happen any faster than it already does. **
When I am receiving data via Tx,Rx pin from GUI, is this communicating via Softwareserial or HardwareSerial. Which library i have to look at, either Hardware serial or software serial.
How can i know in which speed my I2c communicating. because in datasheet for standard(100khz) and fast mode(400khz) in configuration and signaling it not mentioned any changes. But for setting into high speed mode it needs master to send 00001xxx followed by repeated start slave address + r/w .
Anyway i am not going for High speed mode. Now i want to know whether my ads1115 slave I2C communicate with my master arduino in standard or fast mode. How can i check??
When I am receiving data via Tx,Rx pin from GUI, is this communicating via Softwareserial or HardwareSerial.
That depends on how you are connecting the PC to the Arduino. If you are using an FTDI cable, you have not provided enough information to answer your question. If you are using a USB cable, the HardwareSerial class instance Serial will be reading the data.