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

FWT-11 #2 hallelujah effect sensor #1

Merged
merged 53 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
942e48c
Updated to fix CMAKE errors
ol2764RIT Feb 20, 2024
fb49d10
pseudocode
ol2764RIT Feb 20, 2024
04a34dd
pseudocode pt 2
ol2764RIT Feb 20, 2024
c3ff6e3
pseudocode pt 3
ol2764RIT Feb 20, 2024
bac0b6f
some real code from pseudocode
ol2764RIT Feb 21, 2024
841ee33
added some redamentary logic for rotation
ol2764RIT Feb 21, 2024
5d8a8a7
some small logic for hallSensor
ol2764RIT Feb 24, 2024
408c2e4
setup main target
ol2764RIT Feb 24, 2024
ca7b885
updated for gpio pin
ol2764RIT Feb 24, 2024
cc0d489
fixed include for CMAKE
ol2764RIT Feb 27, 2024
260189e
refactoring code for rising edge handler
ol2764RIT Mar 5, 2024
6251827
reverterd
ol2764RIT Mar 8, 2024
7f53631
added fix for GPIO
ol2764RIT Mar 20, 2024
a9b3a00
added workaround for ms using halSysTick
ol2764RIT Mar 29, 2024
f5394e6
added workaround for ms using halSysTick
ol2764RIT Mar 29, 2024
378e774
fixed so that it boilds correctly
ol2764RIT Mar 29, 2024
39ba763
namespace bug wtih DEV
ol2764RIT Mar 29, 2024
f02f1e3
should fix it
ol2764RIT Mar 29, 2024
45ebc97
halo 3 elite approves
ol2764RIT Mar 29, 2024
f4b8adb
halo 3 elite approves pt 2
ol2764RIT Mar 29, 2024
e81b452
Applied Formatting Changes During GitHub Build
Mar 29, 2024
6b50ab6
added can support
ol2764RIT Apr 5, 2024
b47e189
added can fixes
ol2764RIT Apr 5, 2024
8e6ea5b
changed namespace
ol2764RIT Apr 5, 2024
0b88756
changed namespace
ol2764RIT Apr 5, 2024
fbaff6e
Merge pull request #2 from RIT-EVT/feature/ol2764RIT/WSSMain
ol2764RIT Apr 11, 2024
a273a75
Applied Formatting Changes During GitHub Build
Apr 11, 2024
7d57d39
sleep
ol2764RIT Apr 16, 2024
02ec177
Merge remote-tracking branch 'origin/feature/ol2764RIT/hallEffectSens…
ol2764RIT Apr 16, 2024
bd53c13
Sensor Driver Rework
mjmagee991 Apr 18, 2024
b3fdc6c
Applied Formatting Changes During GitHub Build
Apr 18, 2024
04e6e22
small fix to WSS to correct sensor not zeroing on stop.
mjh9585 Apr 19, 2024
b565fa0
cleaned up comments and did some requested code changes
chl1043 Sep 28, 2024
c804f9d
cleaned up comments and did some requested code changes
chl1043 Sep 28, 2024
ae98eff
Applied Formatting Changes During GitHub Build
Sep 30, 2024
b292c32
updated the main program descriptor comment
chl1043 Oct 1, 2024
6f93a65
added requested comments and made the test use one class instance to …
chl1043 Oct 1, 2024
1412c1b
fixed comments and implemented speed calculation and updated README
chl1043 Oct 5, 2024
a909677
added chip to readme and fixed variable comments
chl1043 Oct 7, 2024
ddeeba8
fixed the wheel speed algorithm
chl1043 Nov 15, 2024
d5f5f5f
updated comments and implemented multiple magnets per wheel option
chl1043 Nov 15, 2024
94bfb11
Formatting fixes
savillea1375 Nov 15, 2024
c2690c8
fixed the hallsensor test program
chl1043 Nov 16, 2024
2fc19fd
Merge remote-tracking branch 'origin/feature/ol2764RIT/hallEffectSens…
chl1043 Nov 16, 2024
df79aea
deleted the build folder and fixed formatting and comments
chl1043 Nov 16, 2024
65564b7
comment fixes and deleted logging raw recieved CAN data
chl1043 Nov 16, 2024
4426d99
Applied Formatting Changes During GitHub Build
Nov 16, 2024
9fd519e
cleaned up comments
chl1043 Nov 16, 2024
0321093
Merge remote-tracking branch 'origin/feature/ol2764RIT/hallEffectSens…
chl1043 Nov 16, 2024
4d9bf99
fixed comments and the magnet detection method and cleaned other thin…
chl1043 Nov 23, 2024
e778605
Applied Formatting Changes During GitHub Build
Nov 23, 2024
b8f780d
fixed the comments
chl1043 Jan 17, 2025
3312d6e
Git dumb
mjh9585 Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Top level CMakeList for building the *EVT_BOARD_NAME* source code
# Top level CMakeList for building the WSS source code
###############################################################################
cmake_minimum_required(VERSION 3.15)

Expand Down Expand Up @@ -44,7 +44,7 @@ include(${EVT_CORE_DIR}/cmake/evt-core_install.cmake)
###############################################################################
# Project Setup
###############################################################################
set(BOARD_LIB_NAME BOARD_NAME)
set(BOARD_LIB_NAME WSS)
if("${BOARD_LIB_NAME}" STREQUAL BOARD_NAME)
message(FATAL_ERROR
"You must set the template project name in the top-level CMakeLists.txt")
Expand All @@ -55,22 +55,22 @@ file(STRINGS version.txt BOARD_VERSION)
project(${BOARD_LIB_NAME}
VERSION ${BOARD_VERSION}
LANGUAGES CXX C
)
)

add_library(${PROJECT_NAME} STATIC)

# Add sources
target_sources(${PROJECT_NAME} PRIVATE
src/dev/LED.cpp
src/BOARD_NAME.cpp
)
src/WSS.cpp
src/dev/HallSensor.cpp
)

###############################################################################
# Handle dependencies
###############################################################################
target_link_libraries(${PROJECT_NAME}
PUBLIC EVT
)
)

###############################################################################
# Install and expose library
Expand All @@ -80,4 +80,4 @@ install_and_expose(${PROJECT_NAME})
###############################################################################
# Build Target Code
###############################################################################
add_subdirectory(targets)
add_subdirectory(targets)
83 changes: 7 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,9 @@
# Project Template

## Overview

### EVT-core
For an overview of EVT please see the following links:

[EVT-core Documentation](https://evt-core.readthedocs.io/)

[EVT-core GitHub](https://github.com/RIT-EVT/EVT-core/)

### Template Project

This project-template serves as the skeleton template that is used for
all EVT board repositories. It contains the following capabilities:

- Includes EVT-core as a submodule and compiled as a library for the board
- Set up to contain code pertinent to the board to be built
- Supports an arbitrary number of executable targets to be built and deployed onto a microcontroller
- These contain targets to be run on a specific EVT custom PCB
- Also contain utilities for validation and debugging
- Provides a framework for auto-generated and built documentation using Sphinx and hosted on
`readthedocs.io`

## Steps to Set Up a New Project

1) Create a new repo based on the project-template
1) From [project-template](https://github.com/RIT-EVT/project-template) click `Use this template`
2) Set the owner of the repository to RIT-EVT
3) Name the repo with the new board's acronym
4) Set the privacy to Public
5) Don't include all branches
2) Clone the new repo and create a setup branch
1) `git clone <URL>`
2) `git checkout -b feature/<github-username>/inital-setup`
3) Set the project template up as an upstream repository
1) `git remote add upstream https://github.com/RIT-EVT/project-template`
2) `git remote set-url --push upstream no-push`
1) Confirm that this worked by running `git remote -v`
2) This should produce output similar to this:
```
origin https://github.com/RIT-EVT/ABC.git (fetch)
origin https://github.com/RIT-EVT/ABC.git (push)
upstream https://github.com/RIT-EVT/project-template (fetch)
upstream no-push (push)
```
3) `git fetch upstream`
4) `git merge upstream/main --allow-unrelated-histories`

4) Update the EVT submodule
1) `git submodule update --init --recursive && git pull`
2) `cd ./libs/EVT-core`
3) `git merge origin/main`
4) `cd ../..`
5) Import the project into Read the Docs, following the steps on
[the wiki](https://wiki.rit.edu/display/EVT/Documentation+and+Organization+Standards)
6) Update all instances of BOARD_NAME to match your project name
1) `CMakeLists.txt:28`
2) Directory `./targets/BIKE_NAME-BOARD_NAME`
3) `targets/BIKE_NAME-BOARD_NAME/CMakeLists.txt:3`
4) `src/BOARD_NAME.cpp`
5) `include/BOARD_NAME.hpp`
6) `docs/Doxyfile:35`
7) `docs/source/index.rst:6`
8) `docs/source/api/index.rst:4,12,15`
9) `README.md:56`
7) Sample files are included in `./src` and `./include`. Once proper functionality has been
confirmed, these files should be deleted. There are placeholders to demonstrate the board library
building functionality.
8) Everything in this README from this final step up should be deleted, leaving only the content
below. When finished, all the changes should be committed and pushed to the setup branch, and a PR
should be created to merge into main.

# BIKE_NAME-BOARD_NAME
# REV3-WSS

## Introduction

*One-paragraph summary of the board and its purpose on the bike*
The Wheel Speed Sensor (WSS) is a PCB that senses the RPM of wheels on the bike and calculates the speed of
the bike. It uses sensors in both the front and back wheels. It calculates the RPM of each wheel by using
a hall effect sensor and a magnet in each wheel to get a time interval of how long it takes for a wheel to
make a full rotation. This is then used to calculate RPM, and then RPM is used with the radius of the wheel
to calculate the speed of the bike in miles per hour. The WSS then broadcasts the data on the CAN network.
This is on chip STM32F334.
13 changes: 0 additions & 13 deletions include/BOARD_NAME.hpp

This file was deleted.

73 changes: 73 additions & 0 deletions include/WSS.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#pragma once

#include <EVT/io/CANDevice.hpp>
#include <EVT/io/CANOpenMacros.hpp>
#include <EVT/io/SPI.hpp>
#include <co_core.h>
#include <dev/HallSensor.hpp>

#define NUM_HALLSENSORS 2

using namespace EVT::core::IO;

namespace WSS {

/**
* This is an example of a class for a board
*/
class WSS : public CANDevice {
public:
WSS(DEV::HallSensor& hallSensor1, DEV::HallSensor& hallSensor2);

static constexpr uint16_t NODE_ID = 8;

/**
* Updates the temperature values in an array and updates the error array from the TMU object.
*/
void process();

CO_OBJ_T* getObjectDictionary() override;

uint8_t getNodeID() override;

uint8_t getNumElements() override;

private:
/** This is an array of the hall sensors for the front and back sensor */
DEV::HallSensor* hallSensors[NUM_HALLSENSORS]{};

/** This is an array of wheel speeds for the front and back wheel */
uint32_t wheelSpeeds[NUM_HALLSENSORS] = {0, 0};

/**
* Object Dictionary Size
*/
static constexpr uint16_t OBJECT_DICTIONARY_SIZE = 24;

/**
* CANopen object dictionary
*/
CO_OBJ_T objectDictionary[OBJECT_DICTIONARY_SIZE + 1] = {
MANDATORY_IDENTIFICATION_ENTRIES_1000_1014,
HEARTBEAT_PRODUCER_1017(2000),
IDENTITY_OBJECT_1018,
SDO_CONFIGURATION_1200,

// TPDO 0 CONFIGURATION
TRANSMIT_PDO_SETTINGS_OBJECT_18XX(0x00, TRANSMIT_PDO_TRIGGER_TIMER, TRANSMIT_PDO_INHIBIT_TIME_DISABLE, 2000),

// TPDO 0 MAPPING
TRANSMIT_PDO_MAPPING_START_KEY_1AXX(0, 2),
TRANSMIT_PDO_MAPPING_ENTRY_1AXX(0x00, 1, PDO_MAPPING_UNSIGNED16),
TRANSMIT_PDO_MAPPING_ENTRY_1AXX(0x00, 2, PDO_MAPPING_UNSIGNED16),

// TPDO 0 DATA LINKS
DATA_LINK_START_KEY_21XX(0, 2),
DATA_LINK_21XX(0x00, 1, CO_TUNSIGNED16, (uintptr_t) wheelSpeeds[0]),
DATA_LINK_21XX(0x00, 2, CO_TUNSIGNED16, (uintptr_t) wheelSpeeds[1]),

CO_OBJ_DICT_ENDMARK,
};
};

}// namespace WSS
46 changes: 46 additions & 0 deletions include/dev/HallSensor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include <EVT/io/GPIO.hpp>

namespace IO = EVT::core::IO;

namespace WSS::DEV {

class HallSensor {

public:
enum WheelSpeedState {
STOP = 0, // First pulse or wheel is dead
INITIALIZING = 1,// Setting speed based on first reading
MAINTAIN = 2, // Wheel is spinning at a constant speed or speeding up
};

// Constructor (take a GPIO instance and the radius of the wheel)
HallSensor(IO::GPIO& gpio, uint32_t wheelRadius);

void update();// Update the wheel speed

// Get the current speed of the wheel
uint32_t getSpeed();

// Get the last interval of one full rotation of the wheel
uint32_t getRawInterval();

private:
/** GPIO instance for the sensor */
IO::GPIO& gpio;
uint32_t wheelRadius;
/** Radius of the wheel */
uint32_t prevTime;
/** Previous time for calculating delta time */
uint32_t lastInterval;
/** Last fully measured interval */
WheelSpeedState state;
/** Current state of the wheel */
bool magnetInLastRead;
/** Flag to check if the sensor is high */

IO::GPIO::State MAGNET_DETECTED_STATE = IO::GPIO::State::LOW;
};

}// namespace WSS::DEV
47 changes: 0 additions & 47 deletions include/dev/LED.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion libs/EVT-core
Submodule EVT-core updated 239 files
3 changes: 0 additions & 3 deletions src/BOARD_NAME.cpp

This file was deleted.

29 changes: 29 additions & 0 deletions src/WSS.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <WSS.hpp>

namespace WSS {

WSS::WSS(DEV::HallSensor& hallSensor1, DEV::HallSensor& hallSensor2) {
this->hallSensors[0] = &hallSensor1;
this->hallSensors[1] = &hallSensor2;
}

CO_OBJ_T* WSS::getObjectDictionary() {
return objectDictionary;
}

void WSS::process() {
for (uint8_t i = 0; i < NUM_HALLSENSORS; i++) {
hallSensors[i]->update();
wheelSpeeds[i] = hallSensors[i]->getSpeed();
}
}

uint8_t WSS::getNodeID() {
return NODE_ID;
}

uint8_t WSS::getNumElements() {
return OBJECT_DICTIONARY_SIZE;
}

}// namespace WSS
Loading
Loading