arduino-libraries / Arduino_MachineControl

GNU Lesser General Public License v2.1
38 stars 29 forks source link

Analog input individual mode selection #101

Closed SJThomas29 closed 1 year ago

SJThomas29 commented 1 year ago

Changed the analog_in.set... functions so they take a channel input. Allowing channel modes to be set individually. I.e. measure current on AI0 and voltage on AI1. Also updated analog in examples with this functionality with a link to warning in full-pinout documentation.

CLAassistant commented 1 year ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

github-actions[bot] commented 1 year ago

Memory usage change @ 61ae6f3d5020dcb1d1ddc165071190272eff1283

Board flash % RAM for global variables %
arduino:mbed_portenta:envie_m7 :green_heart: -64 - 0 -0.01 - 0.0 0 - 0 0.0 - 0.0
Click for full report table Board|examples/Analog_Out
flash|%|examples/Analog_Out
RAM for global variables|%|examples/Analog_input/Analog_input_0_10V
flash|%|examples/Analog_input/Analog_input_0_10V
RAM for global variables|%|examples/Analog_input/Analog_input_4_20mA
flash|%|examples/Analog_input/Analog_input_4_20mA
RAM for global variables|%|examples/Analog_input/Analog_input_NTC
flash|%|examples/Analog_input/Analog_input_NTC
RAM for global variables|%|examples/CAN/ReadCan
flash|%|examples/CAN/ReadCan
RAM for global variables|%|examples/CAN/WriteCan
flash|%|examples/CAN/WriteCan
RAM for global variables|%|examples/Digital_output
flash|%|examples/Digital_output
RAM for global variables|%|examples/Digital_programmable/CombinedIOExpander
flash|%|examples/Digital_programmable/CombinedIOExpander
RAM for global variables|%|examples/Digital_programmable/Digital_input
flash|%|examples/Digital_programmable/Digital_input
RAM for global variables|%|examples/Digital_programmable/GPIO_programmable
flash|%|examples/Digital_programmable/GPIO_programmable
RAM for global variables|%|examples/Encoders
flash|%|examples/Encoders
RAM for global variables|%|examples/Ethernet
flash|%|examples/Ethernet
RAM for global variables|%|examples/RS232
flash|%|examples/RS232
RAM for global variables|%|examples/RS485_fullduplex
flash|%|examples/RS485_fullduplex
RAM for global variables|%|examples/RS485_halfduplex
flash|%|examples/RS485_halfduplex
RAM for global variables|%|examples/RTC
flash|%|examples/RTC
RAM for global variables|%|examples/RTC_Alarm
flash|%|examples/RTC_Alarm
RAM for global variables|%|examples/Temp_probes_RTD
flash|%|examples/Temp_probes_RTD
RAM for global variables|%|examples/Temp_probes_Thermocouples
flash|%|examples/Temp_probes_Thermocouples
RAM for global variables|%|examples/USB_host
flash|%|examples/USB_host
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- arduino:mbed_portenta:envie_m7|0|0.0|0|0.0|-64|-0.01|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0
Click for full report CSV ``` Board,examples/Analog_Out
flash,%,examples/Analog_Out
RAM for global variables,%,examples/Analog_input/Analog_input_0_10V
flash,%,examples/Analog_input/Analog_input_0_10V
RAM for global variables,%,examples/Analog_input/Analog_input_4_20mA
flash,%,examples/Analog_input/Analog_input_4_20mA
RAM for global variables,%,examples/Analog_input/Analog_input_NTC
flash,%,examples/Analog_input/Analog_input_NTC
RAM for global variables,%,examples/CAN/ReadCan
flash,%,examples/CAN/ReadCan
RAM for global variables,%,examples/CAN/WriteCan
flash,%,examples/CAN/WriteCan
RAM for global variables,%,examples/Digital_output
flash,%,examples/Digital_output
RAM for global variables,%,examples/Digital_programmable/CombinedIOExpander
flash,%,examples/Digital_programmable/CombinedIOExpander
RAM for global variables,%,examples/Digital_programmable/Digital_input
flash,%,examples/Digital_programmable/Digital_input
RAM for global variables,%,examples/Digital_programmable/GPIO_programmable
flash,%,examples/Digital_programmable/GPIO_programmable
RAM for global variables,%,examples/Encoders
flash,%,examples/Encoders
RAM for global variables,%,examples/Ethernet
flash,%,examples/Ethernet
RAM for global variables,%,examples/RS232
flash,%,examples/RS232
RAM for global variables,%,examples/RS485_fullduplex
flash,%,examples/RS485_fullduplex
RAM for global variables,%,examples/RS485_halfduplex
flash,%,examples/RS485_halfduplex
RAM for global variables,%,examples/RTC
flash,%,examples/RTC
RAM for global variables,%,examples/RTC_Alarm
flash,%,examples/RTC_Alarm
RAM for global variables,%,examples/Temp_probes_RTD
flash,%,examples/Temp_probes_RTD
RAM for global variables,%,examples/Temp_probes_Thermocouples
flash,%,examples/Temp_probes_Thermocouples
RAM for global variables,%,examples/USB_host
flash,%,examples/USB_host
RAM for global variables,% arduino:mbed_portenta:envie_m7,0,0.0,0,0.0,-64,-0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 ```
facchinm commented 1 year ago

@SJThomas29 thanks for the PR! I'd only add an overload for the function call without parameters so older sketches will not break (and examples will not need to be changed). @Rocketct can you test the functionality in the meantime?

SJThomas29 commented 1 year ago

@SJThomas29 thanks for the PR! I'd only add an overload for the function call without parameters so older sketches will not break (and examples will not need to be changed). @Rocketct can you test the functionality in the meantime?

No problem! Good idea, that will work better. Have reverted the example changes and added the overload when no input is given.

github-actions[bot] commented 1 year ago

Memory usage change @ 287fd644a746d70fc65f4d87ef98d0fdc76dcfa0

Board flash % RAM for global variables %
arduino:mbed_portenta:envie_m7 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table Board|examples/Analog_Out
flash|%|examples/Analog_Out
RAM for global variables|%|examples/Analog_input/Analog_input_0_10V
flash|%|examples/Analog_input/Analog_input_0_10V
RAM for global variables|%|examples/Analog_input/Analog_input_4_20mA
flash|%|examples/Analog_input/Analog_input_4_20mA
RAM for global variables|%|examples/Analog_input/Analog_input_NTC
flash|%|examples/Analog_input/Analog_input_NTC
RAM for global variables|%|examples/CAN/ReadCan
flash|%|examples/CAN/ReadCan
RAM for global variables|%|examples/CAN/WriteCan
flash|%|examples/CAN/WriteCan
RAM for global variables|%|examples/Digital_output
flash|%|examples/Digital_output
RAM for global variables|%|examples/Digital_programmable/CombinedIOExpander
flash|%|examples/Digital_programmable/CombinedIOExpander
RAM for global variables|%|examples/Digital_programmable/Digital_input
flash|%|examples/Digital_programmable/Digital_input
RAM for global variables|%|examples/Digital_programmable/GPIO_programmable
flash|%|examples/Digital_programmable/GPIO_programmable
RAM for global variables|%|examples/Encoders
flash|%|examples/Encoders
RAM for global variables|%|examples/Ethernet
flash|%|examples/Ethernet
RAM for global variables|%|examples/RS232
flash|%|examples/RS232
RAM for global variables|%|examples/RS485_fullduplex
flash|%|examples/RS485_fullduplex
RAM for global variables|%|examples/RS485_halfduplex
flash|%|examples/RS485_halfduplex
RAM for global variables|%|examples/RTC
flash|%|examples/RTC
RAM for global variables|%|examples/RTC_Alarm
flash|%|examples/RTC_Alarm
RAM for global variables|%|examples/Temp_probes_RTD
flash|%|examples/Temp_probes_RTD
RAM for global variables|%|examples/Temp_probes_Thermocouples
flash|%|examples/Temp_probes_Thermocouples
RAM for global variables|%|examples/USB_host
flash|%|examples/USB_host
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- arduino:mbed_portenta:envie_m7|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0
Click for full report CSV ``` Board,examples/Analog_Out
flash,%,examples/Analog_Out
RAM for global variables,%,examples/Analog_input/Analog_input_0_10V
flash,%,examples/Analog_input/Analog_input_0_10V
RAM for global variables,%,examples/Analog_input/Analog_input_4_20mA
flash,%,examples/Analog_input/Analog_input_4_20mA
RAM for global variables,%,examples/Analog_input/Analog_input_NTC
flash,%,examples/Analog_input/Analog_input_NTC
RAM for global variables,%,examples/CAN/ReadCan
flash,%,examples/CAN/ReadCan
RAM for global variables,%,examples/CAN/WriteCan
flash,%,examples/CAN/WriteCan
RAM for global variables,%,examples/Digital_output
flash,%,examples/Digital_output
RAM for global variables,%,examples/Digital_programmable/CombinedIOExpander
flash,%,examples/Digital_programmable/CombinedIOExpander
RAM for global variables,%,examples/Digital_programmable/Digital_input
flash,%,examples/Digital_programmable/Digital_input
RAM for global variables,%,examples/Digital_programmable/GPIO_programmable
flash,%,examples/Digital_programmable/GPIO_programmable
RAM for global variables,%,examples/Encoders
flash,%,examples/Encoders
RAM for global variables,%,examples/Ethernet
flash,%,examples/Ethernet
RAM for global variables,%,examples/RS232
flash,%,examples/RS232
RAM for global variables,%,examples/RS485_fullduplex
flash,%,examples/RS485_fullduplex
RAM for global variables,%,examples/RS485_halfduplex
flash,%,examples/RS485_halfduplex
RAM for global variables,%,examples/RTC
flash,%,examples/RTC
RAM for global variables,%,examples/RTC_Alarm
flash,%,examples/RTC_Alarm
RAM for global variables,%,examples/Temp_probes_RTD
flash,%,examples/Temp_probes_RTD
RAM for global variables,%,examples/Temp_probes_Thermocouples
flash,%,examples/Temp_probes_Thermocouples
RAM for global variables,%,examples/USB_host
flash,%,examples/USB_host
RAM for global variables,% arduino:mbed_portenta:envie_m7,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 ```
MDBInd commented 1 year ago

Please can this PR be progressed. I really need this feature and the documentation (Updated 08/05//2023) clearly states:

"Each channel is SW configurable to be: 0-10V input 4-20mA input NTC input..."

I am happy to help in any way I can. Many thanks

AndrewDugenske commented 1 year ago

Friends, A big vote for this PR to become finalized and added to the docs. Needing it for a project. Thanks for all you are doing!

akash73 commented 1 year ago

@manchoz would you mind to give this a spin ?

MDBInd commented 1 year ago

As the CLA has not been signed would anyone object to me re-factoring @SJThomas29 code and creating a new PR?

leonardocavagnis commented 1 year ago

Hi @SJThomas29, Thank you for proposing this change. We've decided not to implement it. The reason for this decision is our concern for hardware safety. Incorrect management could potentially damage the board.

MDBInd commented 1 year ago

@leonardocavagnis, This functionality is still cited in the data sheet dated 21/09/23 on Page 12:

"There are three independent analog input channels available. Each of them has an analog switch TS12A44514PWR which is switching between three modes: 0-10V: The input is connected to a 100 kΩ and 39 kΩ resistor divider. A 0-10V input is scaled down to 0-2.8V. The input impedance is approximately 28 kΩ. 4-20mA: The input is connected to a 120Ω resistor. Having 4-20mA current input for a 0.48V-2.4V voltage. NTC: The input is connected to a 3V voltage reference (REF3330AIRSER) with a 100 kΩ resistor in series, becoming part of a resistor divider powered by the voltage reference."

Are you going to update the documentation to align with your decision?

Please can you detail the potential damage you are sighting. I am using this code in my project to monitor 0-10V and 4..20mA sources and have not experienced any problems for 4 months.

leonardocavagnis commented 1 year ago

Hi @MDBInd, For example, potential damage arises in your case if you accidentally reverse the voltage reading sensor with the current reading sensor, breaking the analog input port. We prefer not to offer the user the option to select different types of readings to prevent potential issues. Feel free to use this PR at your own risk.