From 398ee3d81d45aa489802ebefc46ffde016b2a89d Mon Sep 17 00:00:00 2001 From: Malaphor <55569990+Malaphor@users.noreply.github.com> Date: Tue, 30 Aug 2022 17:12:49 -0700 Subject: [PATCH] Added docs info --- docs/analog-input.rst | 2 ++ docs/can-protocol.rst | 1 + docs/figures/can-protocol.csv | 1 + tools/create_can_dbc.py | 7 ++++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/analog-input.rst b/docs/analog-input.rst index 7df9b6df..21ad4bc8 100644 --- a/docs/analog-input.rst +++ b/docs/analog-input.rst @@ -10,3 +10,5 @@ To read the voltage on GPIO1 in odrivetool the following would be entered: :code Similar to RC PWM input, analog inputs can also be used to feed any of the numerical properties that are visible in :code:`odrivetool`. This is done by configuring :code:`odrv0.config.gpio3_analog_mapping` and :code:`odrv0.config.gpio4_analog_mapping`. Refer to :ref:`RC PWM ` for instructions on how to configure the mappings. + +You may also retrieve voltage measurements from analog inputs via the CAN protocol by sending the Get ADC Voltage message with the GPIO number of the analog input you wish to read. Refer to :ref: `CAN Protocol ` for guidance on how to use the CAN Protocol. \ No newline at end of file diff --git a/docs/can-protocol.rst b/docs/can-protocol.rst index 128228c9..ac892b6e 100644 --- a/docs/can-protocol.rst +++ b/docs/can-protocol.rst @@ -74,6 +74,7 @@ All multibyte values are little endian (aka Intel format, aka least significant * These messages are call & response. The Master node sends a message with the RTR bit set, and the axis responds with the same ID and specified payload. * These CANOpen messages are reserved to avoid bus collisions with CANOpen devices. They are not used by CAN Simple. * These messages can be sent to either address on a given ODrive board. + * You must send a valid GPIO pin number in the first byte to recieve coreect ADC voltage feedback. Since you're both sending and receiving data the RTR bit must be set to false. Cyclic Messages diff --git a/docs/figures/can-protocol.csv b/docs/figures/can-protocol.csv index f00da301..1bf194ca 100644 --- a/docs/figures/can-protocol.csv +++ b/docs/figures/can-protocol.csv @@ -104,4 +104,5 @@ IEEE 754 Float","32 32","1 1","0 0" +0x01C,Get ADC Voltage****,Master***,ADC Voltage,0,IEEE 754 Float,32,1,0 0x700,CANOpen Heartbeat Message**,Slave,-,-,-,-,-,- \ No newline at end of file diff --git a/tools/create_can_dbc.py b/tools/create_can_dbc.py index ccc0f5b5..933545c8 100644 --- a/tools/create_can_dbc.py +++ b/tools/create_can_dbc.py @@ -157,6 +157,10 @@ velGain = cantools.database.can.Signal("Vel_Gain", 0, 32, is_float=True) velIntGain = cantools.database.can.Signal("Vel_Integrator_Gain", 32, 32, is_float=True) setVelGainsMsg = cantools.database.can.Message(0x01B, "Set_Vel_gains", 8, [velGain, velIntGain]) +# 0x01C - Get ADC Voltage +adcVoltage = cantools.database.can.Signal("ADC_Voltage", 0, 32, is_float=True) +getADCVoltageMsg = cantools.database.can.Message(0x01C, "Get_ADC_Voltage", 8, [adcVoltage]) + db = cantools.database.can.Database( [ heartbeatMsg, @@ -184,7 +188,8 @@ db = cantools.database.can.Database( clearErrorsMsg, setLinearCountMsg, setPosGainMsg, - setVelGainsMsg + setVelGainsMsg, + getADCVoltageMsg ] )