Skip to content
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

Initial Prototype (Unrefined) Release for Nucleo-144 STM32H743Z2 #1

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

memphis242
Copy link
Owner

@memphis242 memphis242 commented Nov 11, 2024

Description

This set of changes is where I successfully got exactly what I needed software-wise out of the Nucleo-144 STM32H743Z2 board to produce the emulated frequency-based sensor signal. I have not bothered much with refining the software, using good software practice, or moving away from the STM32CubeIDE and the dev board to a more professional grade build system setup. I just got whatever I needed to work, and I had to do it rapidly, and I succeeded in that regard!

Project Planning Tool User Story / Defect Number | Issue

No project planning tooling yet. Hoping to get that for myself soon.

Verification

Unit Tests

None written 😶‍🌫️ . Like I said, unrefined.

HIL Tests (if applicable)

None written 😶‍🌫️ . Like I said, unrefined.

System Tests

Nothing more than the Device Verification section below...

Device Verification

I was able to verify desired functionality with the Nucleo-144 STM32H743Z2 board + a breadboard that contained a potentiometer and transistor circuitry to change the 3.3V square wave signal into a 5V one. Below a screenshot of an example output signal from my board:

37us 328Hz 5V Screenshot 1

Validation

Although this worked great for what I needed, there was definitely some left to be desired with respect to the potentiometer used, coarse vs fine tuning, a display of some sort to show the presently set frequency and pulse width, and of course, a professionally assembled product instead of the dev board + breadboard combo 😅. Next iteration!

End-User Testing

Both myself and a work colleague tested and used this dev board setup just fine!

Statistics

Microcontroller Stats

None collected, and I do not plan on it for this initial release because I will be switching MCU types, and I have little desire to characterize this particular setup. Of course, I'd love to know, but I also must prioritize my time spent here, sadly 😞.

Communication Bus Network Stats

No communication buses used here during the actual operation of this prototype.

Upstream / Downstream Repositories

None. Either the next iteration of the one after will contain a separation of the hardware-specific configuration and the logic to carry out the signal setpoint.

Requirements

None officially written down. This was simply about creating a prototype that could:

  1. Produce a square wave signal
  2. Adjustable frequencies between ≈3.5Hz to ≈2.66kHz
  3. Selectable pulse width between the discrete set [38, 45, 52, 76, 90, 104, 200] us
  4. ≈0V min, ≈5V max
  5. Powered through USB from a laptop

Miscellaneous Checklist

  • Ensure the package version changed appropriately according to semantic versioning.
    • No package management system set up intended for this prototype release.
  • The CHANGELOG.md has been updated
  • The README.md has been updated if applicable
  • All compiler, linker, and static analysis warnings have been resolved / suppressed-if-justified
    • This level of strictness will not be enforced for this initial prototype release.
  • The MISRA C 2023 coding directives have been followed (static analysis can enforce rules but not directives)
    • This level of strictness will not be enforced for this initial prototype release.

@memphis242 memphis242 added the enhancement New feature or request label Nov 11, 2024
@memphis242 memphis242 self-assigned this Nov 11, 2024
@memphis242 memphis242 marked this pull request as ready for review November 11, 2024 23:37
Copy link
Owner Author

@memphis242 memphis242 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low-hanging fruit out-of-the-way. 113/219 files viewed

Comment on lines 2 to 4
"files.associations": {
"stdint.h": "c"
},
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

@@ -1,9 +1,47 @@
# Frequency Sensor Emulator
Embedded software - intended to be generic /w HAL abstraction - meant to output a square wave of variable frequency and duty cycle to emulate a frequency input sensor - such as a magnetic rotational speed sensor.
At work, I had the need for a device that could produce particular subset of square wave signals. No function generator around could do exactly what I needed, so I decided this was enough to do with almost any microcontroller around. I selected the STMicroelectronics Nucleo-144 STM32H743ZI2 board along with some additional circuitry on a breadboard for the prototype. That worked quite well and just for fun and learning, I plan to bring this up to a professional-grade product.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
At work, I had the need for a device that could produce particular subset of square wave signals. No function generator around could do exactly what I needed, so I decided this was enough to do with almost any microcontroller around. I selected the STMicroelectronics Nucleo-144 STM32H743ZI2 board along with some additional circuitry on a breadboard for the prototype. That worked quite well and just for fun and learning, I plan to bring this up to a professional-grade product.
At work, I had the need for a device that could produce particular subset of square wave signals. No function generator around could do exactly what I needed, so I decided that this desired behavior was easy enough to get almost any microcontroller to do. I selected the STMicroelectronics Nucleo-144 STM32H743ZI2 board along with some additional circuitry on a breadboard for the prototype. That worked quite well and just for fun and learning, I plan to bring this up to a professional-grade product.

@memphis242
Copy link
Owner Author

image

Put this list in the SystemArchitecture/Requirements/ directory.

Copy link
Owner Author

@memphis242 memphis242 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Software/Code/Code/Core/Inc/main.h header file reviewed

Comment on lines +5 to +6
* @brief : Header for main.c file.
* This file contains the common defines of the application.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a better description for this file.

Comment on lines +41 to +54
enum Direction_E
{
DIRECTION_FORWARD_MIN,
DIRECTION_FORWARD_NOMINAL,
DIRECTION_FORWARD_MAX,
DIRECTION_REVERSE_MIN,
DIRECTION_REVERSE_NOMINAL,
DIRECTION_REVERSE_MAX,
DIRECTION_ERROR,
DIRECTION_NOT_AVAILABLE
};

typedef float Hz_T;
typedef uint32_t us_T;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to an application header file instead. This does not need to be shared. Likewise with the exported constants user section below and anywhere else applicable in this file.

Comment on lines +61 to +65
#define DIRECTION_FORWARD_HIGH_PULSE_TIME_NOMINAL 45000.0f // ns
#define DIRECTION_FORWARD_HIGH_PULSE_TIME_TOLERANCE 7000.0f
#define DIRECTION_REVERSE_HIGH_PULSE_TIME_NOMINAL 90000.0f
#define DIRECTION_REVERSE_HIGH_PULSE_TIME_TOLERANCE 14000.0f
#define DIRECTION_ERROR_HIGH_PULSE_TIME 200000.0f
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to be floating-point?

Comment on lines +70 to +75
#define MAX_ADC_COUNT(adc_handle) __HAL_ADC_DIGITAL_SCALE((adc_handle)->Init.Resolution)
#define MIN_ADC_COUNT 0u

#define TIMER_CLOCK_RATE_HZ 64000000 // TODO: Use an actual generated config for this; just need to find it. Candidate macro: HSI_VALUE of Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_rcc.h
#define NANOSECONDS_PER_TIMER_COUNT ( (float)( 1.0e9f / (float)TIMER_CLOCK_RATE_HZ ) )
#define TIMER_COUNTS_PER_NANOSECOND ( 1.0f / NANOSECONDS_PER_TIMER_COUNT )
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to a separate HAL timer / ADC peripheral utility header file.

#define MAX_ADC_COUNT(adc_handle) __HAL_ADC_DIGITAL_SCALE((adc_handle)->Init.Resolution)
#define MIN_ADC_COUNT 0u

#define TIMER_CLOCK_RATE_HZ 64000000 // TODO: Use an actual generated config for this; just need to find it. Candidate macro: HSI_VALUE of Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_rcc.h
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address the TODO.

Comment on lines +123 to +126
#define BLUE_BUTTON_PIN B1_Pin
#define BLUE_BUTTON_PORT B1_GPIO_Port
#define FRQ_OUT_PIN Frq_Out_Pin
#define FRQ_OUT_PORT Frq_Out_GPIO_Port
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best if this is in an input/output driver config file.

### Prototype
Here is a screenshot of an example signal I was able to produce:

![37us 328Hz 5V Screenshot 1](https://github.com/user-attachments/assets/18f7d477-d7f0-4fc0-a244-829e36fbbb07)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upload a video to YouTube and link it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant