Skip to main content
34 events
when toggle format what by license comment
Mar 9 at 16:52 vote accept bardulia
Mar 19, 2023 at 8:03 answer added Antonio51 timeline score: 1
Mar 18, 2023 at 19:28 answer added Justme timeline score: 4
Mar 18, 2023 at 19:24 history edited bardulia CC BY-SA 4.0
added 5 characters in body
Mar 18, 2023 at 19:16 history edited bardulia CC BY-SA 4.0
edited body
Mar 18, 2023 at 18:46 history edited bardulia CC BY-SA 4.0
added 19 characters in body
Mar 18, 2023 at 18:38 comment added PStechPaul You are taking four samples in each 2 second interval, which are then averaged to give you a reading between the printout intervals. But they might not be synchronized, so sometimes you might read samples at time 0, 0.5, 1, 1.5, and sometimes 0.49, 0.99, 1.49, and 1.99.
Mar 18, 2023 at 18:35 comment added bardulia @PStechPaul that makes sense! I will update the code, try again the readings and post here the results (it will take some time as I need to prepare the battery).
Mar 18, 2023 at 18:22 comment added PStechPaul You shouldn't use a float variable for ADCValue, especially when used in an ISR. An unsigned integer will give you 16 bits of resolution. Averaging can be done with an unsigned long integer. All scaling should be done only in the main loop where values are being printed out. Also, it would be more efficient to trigger ADC conversions using a timer interrupt, and then an ADC interrupt (end of conversion) to read the integer value.
Mar 18, 2023 at 18:03 comment added bardulia @PStechPaul No, there isn't. I tried with all the different data rates possible (from 8 to 860) and results were similar. I have just updated the question with the relevant code for the ADC measurement.
Mar 18, 2023 at 18:03 history edited bardulia CC BY-SA 4.0
added 2541 characters in body
Mar 18, 2023 at 17:50 comment added PStechPaul Is there any reason for running the ADC at 860 sps when you only use one of the readings every 2 seconds? Also, it would be helpful if you could provide the relevant code and schematic details for ADC measurement.
Mar 18, 2023 at 17:50 comment added bardulia @Antonio51 I am checking ADS1115 datasheet and it only talks about one ground (GND) on pin 3, no info about any AGND. I am also checking Adafruit ADS1115 breakout board and it also has only one ground (GND) that recommends to wire to the AGND of the circuit. What do you mean by "Gnd is wired with the power supply of the sub_board"?
Mar 18, 2023 at 15:57 comment added Justme @bardulia It depends what your main code does. But you seem to be doing all the things you should never do in interrups, such as printing. Unless you know how the MCU handles interrupts, and how the mystery Arduino code modules function, and what you can do or not in interrupts, you should not do anything more that you have to in interrupts. And I have never written any Arduino code in my life and I would not use any Arduino code on AVR so I have no clue what you should do.
Mar 18, 2023 at 15:57 comment added Antonio51 Only the agnd should be wired to your system. Gnd is wired with the power supply of the sub_board.
Mar 18, 2023 at 15:49 comment added Antonio51 The ads1115 has two grounds (gnd and agnd). Only the gnd ground is used ... so that agnd is "floating" ... and measurements also... by a little voltage. So, your offset between your BTS values and ADC values. Note also that your reference is not "fixed".
Mar 18, 2023 at 15:47 history edited bardulia CC BY-SA 4.0
added 19 characters in body
Mar 18, 2023 at 15:13 comment added bardulia @Antonio51 can you elaborate a bit more on that?
Mar 18, 2023 at 15:12 comment added bardulia @Justme I will check it and come back to you with the results. What would you do instead of timer interrupts? just with millis() function?
Mar 18, 2023 at 12:55 comment added Justme I think the code is just not interrupt safe and copying around floats in a couple of timer interrups is just very awkward way of trying to achieve what you want. Fix the code so that you know the code is not causing the issues you are seeing. It may be a code problem and not a problem in hardware.
Mar 18, 2023 at 12:53 comment added Antonio51 Perhaps a mix of GND and AGND on the ADS1115 board?
Mar 18, 2023 at 12:28 comment added Andy aka Breaking the system down into parts is a tried and tested way of solving problems like this.
Mar 18, 2023 at 12:26 comment added bardulia @Andyaka No, I haven't, but it is a interesting idea. I will try it.
Mar 18, 2023 at 12:25 history edited bardulia CC BY-SA 4.0
added 81 characters in body
Mar 18, 2023 at 12:24 comment added Andy aka Have you tried replacing the battery with an accurate fixed value voltage source and see if you still have the problem? In other words; divide and conquer or, deal with the errors from each sub-system rather than trying to debug the whole system.
Mar 18, 2023 at 12:23 history edited bardulia CC BY-SA 4.0
added 81 characters in body
Mar 18, 2023 at 12:16 comment added bardulia @Justme yes it is! However, that averaging does not remove the oscillations.
Mar 18, 2023 at 12:15 comment added bardulia @Andyaka I have just updated the question. ADC samples at 860 sps, and then at the PLC I store the last value in a variable and print it to a file every 2 seconds (because the BTS also gives values every 2 seconds). The ADC voltage reference is the internal one, I have added the datasheet link. I don't understand what you mean by other ADC1115 inputs? and what do you mean by settling time in the multiplexer?
Mar 18, 2023 at 12:15 comment added Justme Was this project using the code where the averaging was done using copying floating point numbers around in two separate timer interrupts like it is safe but isn't?
Mar 18, 2023 at 12:09 history edited bardulia CC BY-SA 4.0
added 78 characters in body
Mar 18, 2023 at 12:07 comment added Andy aka What about the other inputs on the ADC1115? How much settling time do you provide for the multiplexer?
Mar 18, 2023 at 12:01 comment added Andy aka Are these single ADC measurements made once per two second? You use the words epochs and, I think you mean samples? Have you done an error budget calculation for the ADC? Please link the data sheet of the ADCs. What ADC voltage reference are you using?
Mar 18, 2023 at 11:56 history edited bardulia CC BY-SA 4.0
deleted 33 characters in body
Mar 18, 2023 at 11:51 history asked bardulia CC BY-SA 4.0