2021-03-20

2021-03-20 OrangeBot Motor Controller MK2 - Current Sensing

 

OrangeBot Motor Controller MK2 - Current Sensing

1Introduction

One of the objectives for the OrangeBot MK2 Motor Controller is to add a third PID loop closed on the motor current.

The VNH7040 Half Bridge has a multi sense pin meant to monitor the H Bridge current, supply voltage and temperature. The current firmware driver should already ask the VNH7040 for the runtime current reading.

The objective for this entry is to check that the sense pin is working from an electrical standpoint, by checking no load and full load conditions and to implement electrical and firmware changes necessaries to make the current reading available to the microcontroller.

2VNH7040 Current Sensing


2.1Measure multi sense pin

A multimeter in series with the motor is used to measure the motor current.

An oscilloscope is used to measure the output of the multi sense pin.

Load is simulated by physically stopping the motor shaft by hand. No load/Stall.

Illustration 1: Setup

Illustration 2: Oscilloscope Measure


2.2Multi sense Circuit

Several circuits have been tested to bring the multi sense to the ADC pin.

On the microcontroller, PA0 ADC0 pin is used for the multi sense pin.

Illustration 3: Amplifier Circuit

Circuit:

  1. Works well enough

  2. Saturate due to high gain

  3. Somewhat less noisy as it takes the multi sense ground as reference.

The VNH7040 evaluation board uses a 33nF and 10KOhm resistor on the multi sense pin. This is not ideal because the ground is the noisy one from the power stage.

When building the proper VNH7040 motor controller board, the resistor can be grounded to the analog ground of the GD32VF103 and OP AMP for much improved noise rejection.


2.3GV32VF103 Pins

The output of the amplifier is connected to PA0 ADC0 pin of the microcontroller.

Illustration 4: Longan Nano GD32VF103 Pinout

 

Illustration 5: Schematics


2.4Firmware

With the electrical side of the circuit taken care of, support is added firmware side.

Right now the ADC reading is spot checked when the screen refreshes.

Illustration 6: Firmware Current

Github firmware repository (also click on photo)


3Conclusions

This entry described how the multi sense pin of the VNH7040 can be used to provide the GD32VFD103 with a direct measure of the motor current.






Video 1: No load/Stall microcontroller and oscilloscope readings








2021-03-07

2021-03-07 Motor Controller MK2

 Abstract

 The 8b 32MHz AT4809 microcontroller is not up to the task of running an high performance PID controller for the OrangeBot robot. A 32b 108MHz GD32VF103 Risc-V microcontroller has been choosen as replacement.

Significant effort went into writing the drivers to run the services, like screen and scheduler with minimal resource utilization. The scope of this entry is to glue the driver components together.

 

Architecture

  •  Longan Nano GD32VF103 32b 108MHz Risc-V microcontroller with screen
  •  IG32-05 Motor with low precision hall effect quadrature encoder
  • VNH7040 Driver

Illustration 1: Breadboard
 The encoder is wired directly to the hardware quadrature decoder integrated inside timer 2. The AT4809 had limitations in this regards, requiring expensive ISR based quadrature decoding that consumed CPU cycles.

An element missing is the current sensing. The driver of the ADC is up and running, and right now measures MCU temperature and reference voltage. Additional circuitry is needed to acquire the output current sense from the VNH7040 that will be needed to add a third PID loop on current.

Schematics

Illustration 2: Schematics

Firmware

 

Results

 The open loop test of the firmware, encoder and motor is a success.