-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
…ndling freq and direction control; added `settings.json` for VS tab spacing.
…ode structure for algorithm of controlling pulse time and frequency.
There was a problem hiding this 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
.vscode/settings.json
Outdated
"files.associations": { | ||
"stdint.h": "c" | ||
}, |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Put this list in the |
There was a problem hiding this 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
* @brief : Header for main.c file. | ||
* This file contains the common defines of the application. |
There was a problem hiding this comment.
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.
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; |
There was a problem hiding this comment.
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.
#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 |
There was a problem hiding this comment.
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?
#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 ) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address the TODO.
#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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
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:
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:
[38, 45, 52, 76, 90, 104, 200]
usMiscellaneous Checklist
Ensure the package version changed appropriately according to semantic versioning.CHANGELOG.md
has been updatedREADME.md
has been updated if applicableAll compiler, linker, and static analysis warnings have been resolved / suppressed-if-justifiedThe MISRA C 2023 coding directives have been followed (static analysis can enforce rules but not directives)