Sunday, 29 November 2020

Model Rocket Launcher Bluetooth Android Part 2

Summary
This blog details hardware and code changes to the Bluetooth PSoC Model Rocket Launcher for monitoring battery voltage and current. The current monitoring output provided by the high side switching device was measured and calibrated using multi-point characterisation in the launcher’s PSoC controller.

Purpose of Monitoring
Under-voltage battery monitoring was included to minimise the chance of battery over-discharge. The battery voltage for a
25% State of Charge (SoC) was used as a reference in the rocket launcher firmware.

Measurement and monitoring of the current drawn by the igniter were included to check the recommended all-fire current of 2 A (Estes forum) was reached during a launch.

Battery Voltage
A hardware connection for monitoring the battery voltage, using a Cypress PSoC ADC input, was not part of the initial circuit board design (PCB).

Rocket Launcher PCB with Strapped Battery ADC Input
Rocket Launcher PCB with Strapped Battery ADC Input

As the PCB included hardware for a voltage divider across the batter, a connection was required to a spare PSoC pin with ADC capability. In the image above a wire was strapped from the voltage divider to the ADC input.

Launcher Battery Voltage Divider
Launcher Battery Voltage Divider

The resistor values selected for the voltage divider were changed to use values already available in the design. Assuming a battery charged to 13.8 V, the voltage at the ADC input, taking into account the loss in the reverse protection Schottky diode D6, was approximately 2.4 V.

For the PSoC SAR ADC reference voltage, the VDDA supply pin on the PSoC was used.

It should be noted that the battery voltage measurement was for indicative purposes only. To improve ADC measurement accuracy, the ADC reference voltage could be changed to utilise the PSoC internal 1.024 V reference. Adjustment to the battery voltage divider would be required.

Launcher SAR ADC Configuration
Launcher SAR ADC Configuration

Igniter Current
The high side switching device (VN7040) features an output which provided a voltage representation of the current measured by the VN7040. A
PSoC ADC input was used to measure the voltage.

Launcher Battery Current Sense Output
Launcher Battery Current Sense Output (MSense)

The value of the resistor connected to the output of the high side switch (MSense) was reevaluated to suit an Estes igniter. Assuming losses in the circuit such as cabling (resistive), reverse protection diode forward voltage (477 mV @ 15A), the high (40 mR) and low side (30 mR) switching devices MOSFET resistances. A full charged lead-acid battery driving an igniter (Estes 800 mR) with the resistive losses should result in a current of slightly over 10 A.

VN7040 K-Factor vs Isense Response (Courtesy ST)
VN7040 K-Factor vs Isense Response (Courtesy ST)

As the operating current was expected to be above 4.5 A, the K factor of 1340 was selected from the VN7040 datasheet.

VN7040 Current Sense K Factor > 4.5 A
VN7040 Current Sense K Factor > 4.5 A

There were two caveats for calculating the current sense resistor value. Firstly, under normal operating conditions the voltage generated across the current sense resistor should be less than the ADC maximum voltage. For the existing design, the SAR ADC reference voltage was 5 V so this was not a primary concern. The maximum voltage should be reviewed if the ADC reference voltage was changed to 1.024 V. Secondly, the maximum current output by the sense output (MSense) of the high side switches was listed as 10 mA.

VN7040 Current Sense Output Max Operating Characteristics
VN7040 Current Sense Output Max Operating Characteristics

Selecting a current of 10 A and a nominal k factor of 1340, the formula shown in Table 11 of the VN7040 data sheet was applied.

VN7040 Truth Table with Current Sense Formula
VN7040 Truth Table with Current Sense Formula

Applying the formula shown in the truth table pictured above, an Isense value of 7.46 mA was yielded.

VN7040 Isense Calculation
VN7040 Isense Calculation

With a maximum ADC reference voltage of 5 V, a 590 R resistor was selected. The maximum voltage at the PSoC ADC pin, being the product of the Isense value and the resistor value, gave approximately 4.4 V.

ADC Configuration
The SAR ADC was configured for two channels, 12-bit with a conversion time of approximately 2 ms.

PSoC SAR ADC Setup
PSoC SAR ADC Setup

The results from the SAR ADC, battery voltage and current sense (voltage), were converted into millivolts.

static uint16_t    adc_result_multiplier     = 23u;
static uint16_t    adc_result2_multiplier    = 554u;
static uint16_t    adc_result_divider       = 10u;
static uint16_t    adc_result2_divider   = 100u;
static uint16_t    adc_result_trim      = 154u;

adc_result1 = ADC_SAR_CountsTo_mVolts(0,ADC_SAR_GetResult16(0));
adc_result2 = ADC_SAR_CountsTo_mVolts(1,ADC_SAR_GetResult16(1));
adc_voltage_result = (adc_result2 * adc_result2_multiplier)/adc_result2_divider;
adc_current_result= ((adc_result1 * adc_result_multiplier)- adc_result_trim)/adc_result_divider;

To calibrate the PSoC ADC current measurement, a multi-point characterisation was performed. Various resistive loads were used in place of the igniter and the ADC result recorded.

PSoC ADC Raw Data from Resistive Loads with Power Supply
PSoC ADC Raw Data from Resistive Loads with Power Supply

The ADC result was output on the serial port. ADC results were plotted against the measured current to produced the graph displayed below.

Measured Current vs PSoC ADC Voltage for Various Resistive Loads
Measured Current vs PSoC ADC Voltage for Various Resistive Loads

ADC Data Serial Output
The ADC results were output on the Rocket Launcher serial port. The data was transmitted at a rate of 921,600 baud to an Android phone which was running the application Serial USB Terminal. Written by Kai Morich, the application was one of the few which supported higher baud rates and was stable at that data rate.

Serial USB Terminal Android Application Landing Screen
Serial USB Terminal Android Application Landing Screen

Shown in the capture above is the Android phone application. Connection of a USB to TTL adaptor from the launcher to the Android phone was achieved using an On The Go (OTG) adaptor cable.

Serial USB Terminal Android Application Settings Screen
Serial USB Terminal Android Application Settings Screen

Configuration for the 921,600 baud rate was achieved through the settings tab in the application.

Serial data was captured for two supply types, the first a benchtop Rigol linear power supply and the second a lead-acid battery (1.2 AH).  The graph shown below provides the ADC measurement plotted against various resistive loads.

PSoC ADC Voltage vs Resistive Load
PSoC ADC Voltage vs Resistive Load

Bench testing with resistive loads showed that ADC measurements were stable. The graph below shows the ADC current measurement when testing with a 5 R load.

PSoC ADC Voltage Samples for Resistive Load of 5R
PSoC ADC Voltage Samples for Resistive Load of 5R

Low Battery and Current Error States
The ADC result from the battery voltage measurement was compared to a threshold of 12 V for the under-voltage detection. Similarly, for the under-current detection, the current measurement was compared a value of 0.558 V which represented approximately a current of 2 A.

    
if (SYSTEM_FLAGS_ADC.adc_has_result == true)
{   
/* Order of execution sets priority */
    if (adc_voltage_result < under_voltage_compare)
    {
        Error_State = under_voltage;
    }
    else if (adc_current_result < under_current_compare)
    {
        Error_State = under_current;
    }
}

OLED Screen Update
Additional error states relating to the low battery voltage and low igniter current were added to the rocket launcher firmware.

The OLED screen below was shown after the rocket launch cycle if the battery voltage fell below 12 V during the launch.

Rocket Launcher OLED Low Battery Screen
Rocket Launcher OLED Low Battery Screen

For the low current, the screen below was displayed after the rocket launch cycle, if the measured current fell below approximately 2 A during the launch.

Rocket Launcher OLED Low Current Screen
Rocket Launcher OLED Low Current Screen

Field Testing
Field rocket launches were performed to capture ADC results with Estes igniters. There were multiple events which caused the ADC results to vary of which some events were intrinsic to the igniter behaviour during a launch.

The graph below represents one of the instances where the launch of the rocket was successful however, the igniter wires shorted moments after liftoff. The constant current draw of the shorted wires is represented by the constant high from time 53 s.

Rocket launcher igniter current toggling at start
Rocket Launcher Igniter Current Toggling

Field Launches
Below are snippets from recent launches.

Estes Curvilinear model rocket with standard size A engine.

Estes Fat Boy model rocket with standard size A engine.

Unbranded model rocket.


Final Thoughts
The hardware and firmware updates performed to the rocket launcher provided additional features and monitoring. Specifically, monitoring the igniter current provided insight into the different events and responses which can occur to the igniter on the launchpad. In a future release, a scheme for current monitoring would involve the development of the firmware to handle the various igniter responses.

Downloads
The
updated firmware for the PSoC launcher project.

Rocket Launcher PSoC Project rev 1.03
Rocket Launcher PSoC Project rev 1.03