-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ads1x1x: added support for ADC chip #6584
base: master
Are you sure you want to change the base?
Changes from 4 commits
ce7e14e
030df02
15f2a93
3105a5d
8f59447
43a15f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4824,6 +4824,51 @@ vssa_pin: | |
# noise. The default is 2 seconds. | ||
``` | ||
|
||
### [ads1x1x] | ||
|
||
ADS1013, ADS1014, ADS1015, ADS1113, ADS1114 and ADS1115 are I2C based Analog to | ||
Digital Converters that can be used for temperature sensors. They provide 4 | ||
analog input pins either as single line or as differential input. | ||
|
||
``` | ||
[ads1x1x my_ads1x1x] | ||
chip: ADS1115 | ||
#pga: 6.144V | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the default is 4.096V then please use the comment |
||
# Default value is 4.096V. The maximum voltage range used for the input. This | ||
# scales all values read from the ADC. Options are: 6.144V, 4.096V, 2.048V, | ||
# 1.024V, 0.512V, 0.256V | ||
#mode: single | ||
# Default value is single. Turn off the chip after a single reading or keep | ||
# it running. Turning off saves power but turning it back on will be slower. | ||
# Options are single and continuous. | ||
#samples_per_second: 128 | ||
# Default value is 128. The amount of samples that the ADC can provide per | ||
# second. A lower value makes the samples more accurate, but it takes longer | ||
# until a new value is available. | ||
# ADS101X's support 128, 250, 490, 920, 1600, 2400, 3300. | ||
# ADS111X's support 8, 16, 32, 64, 128, 250, 475, 860. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just out of curiosity, why would a user ever configure these two settings? Since the code knows the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Someone might want to change it for higher accuracy, how many samples_per_second you can get away with also depends on how many inputs of the chip are used as one sampling would have to be done after the other. It would make more sense to try to calculate that automatically, someone would need to know too much about how klipper and the ADS chip works to choose a good value. A report_time in setup_adc_callback of for example 0.010s, would be 100 samples per second. On a single input I would choose 128. If 4 inputs are used, I would need to choose 920 (128 X 4 = 512, next best is 920) for ADS101X and 860 for ADS111X, reducing the accuracy but fitting in the time frame. I would then output a warning if the sample_rate needs to be higher than the chip can support. It's a bit of extra logic finding the next best value and counting the used inputs, but then I could kick out the samples_per_second. Concerning the single or continous mode, there is a theoretical power saving on single mode. I just wanted to include it for completeness. If I compute the sample_rate anyway, this could be hard coded to continous. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. Just to be clear, my comments here are not "blockers" to merging. As for "power savings" - I can't see anyone caring, so it sounds like continuous is a better default and one can use a code constant to make it possible to enable sleep mode. As for auto-calculating wakeup times - I'll defer to you if that's something worthwhile to implement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have now added a calcuation for the sample rate. I made single mode the default though, it turns out that the idle state that we check on to see if the sampling is done, only gets set on single mode, not on continuous mode. |
||
i2c_mcu: host | ||
i2c_bus: i2c.1 | ||
#address_pin: GND | ||
# Default value is GND. There can be up to four addressed devices depending | ||
# upon wiring of the device. Check the datasheet for details. The i2_address | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "i2c_address"? |
||
# can be specified directly instead of using the address_pin. | ||
``` | ||
|
||
The chip provides pins that can be used on other sensors. | ||
|
||
``` | ||
sensor_type: ... | ||
# Can be any thermistor or adc_temperature. | ||
sensor_pin: my_ads1x1x:AIN0 | ||
# A combination of the name of the ads1x1x chip that and the pin. Possible | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra "that"? |
||
# pin values are AIN0, AIN1, AIN2 and AIN3 for single ended lines and | ||
# DIFF01, DIFF03, DIFF13 and DIFF23 for differential between their | ||
# correspoding lines. For example | ||
# DIFF03 measures the differential between line 0 and 3. Only specific | ||
# combinations for the differentials are allowed. | ||
``` | ||
|
||
### [replicape] | ||
|
||
Replicape support - see the [beaglebone guide](Beaglebone.md) and the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be useful to add a warning about using the sensor for heaters - maybe something like:
Note: Use caution if using this sensor to control heaters. The heater
min_temp
andmax_temp
are only verified in the host and only if the host is running and operating normally. (ADC inputs directly connected to the micro-controller verifymin_temp
andmax_temp
within the micro-controller and do not require a working connection to the host.)