-
Notifications
You must be signed in to change notification settings - Fork 0
Initial test technique for CAN messages -- Random messages #7
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
Open
YVishere
wants to merge
10
commits into
main
Choose a base branch
from
testCAN
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
886eb6b
Initial test technique for CAN messages -- Random messages
YVishere a8ec855
Improved displaying values logic
YVishere 3478e4d
Counter expiry updated
YVishere d504329
Made requested changes
YVishere ffa9d51
some changes
YVishere 1ec7e19
WORKING CODE: PDC sending correctly
bquan0 867ef3e
working can bounce test
YVishere 939aecb
Added one print
YVishere 13234d9
fix pin def
YVishere 5fc6896
fixed pins
YVishere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,86 @@ | ||
| #include <Arduino.h> | ||
| #include "IOManagement.h" | ||
| #include "const.h" | ||
|
|
||
| #include "canPDC.h" | ||
| #include "const.h" | ||
| #include "IOManagement.h" | ||
| #include "motor_control.h" | ||
| #include "adc.h" | ||
|
|
||
| //For random | ||
| #include <stdlib.h> | ||
| #include <time.h> | ||
|
|
||
| int counter; | ||
|
|
||
| //Counter for debug prints 20 ticks equates to a second | ||
| int counterExpiry = 20; | ||
|
YVishere marked this conversation as resolved.
Outdated
|
||
| CANPDC canBus(CAN1, DEF); | ||
|
|
||
|
|
||
| #if DEBUG_TECHNIQUE == 1 | ||
| void initData() { | ||
|
YVishere marked this conversation as resolved.
Outdated
|
||
| // Generate a random float between 0 and 100 | ||
| acc_out = ((float)rand() / RAND_MAX) * 100; | ||
| regen_brake = ((float)rand() / RAND_MAX) * 100; | ||
| lv_12V_telem = ((float)rand() / RAND_MAX) * 100; | ||
| lv_5V_telem = ((float)rand() / RAND_MAX) * 100; | ||
| lv_5V_current = ((float)rand() / RAND_MAX) * 100; | ||
| current_in_telem = ((float)rand() / RAND_MAX) * 100; | ||
| brake_pressure_telem = ((float)rand() / RAND_MAX) * 100; | ||
|
|
||
| //Random boolean | ||
| brakeLED = rand() % 2; | ||
|
|
||
| //Random digital data | ||
| digital_data.direction = rand() % 2; | ||
| digital_data.mc_speed_sig = rand() % 2; | ||
| digital_data.eco_mode = rand() % 2; | ||
| digital_data.mcu_mc_on = rand() % 2; | ||
| digital_data.park_brake = rand() % 2; | ||
| } | ||
| void debugPrint() { | ||
| Serial.printf("acc_out: %f\n", acc_out); | ||
| Serial.printf("regen_brake: %f\n", regen_brake); | ||
| Serial.printf("lv_12V_telem: %f\n", lv_12V_telem); | ||
| Serial.printf("lv_5V_telem: %f\n", lv_5V_telem); | ||
| Serial.printf("lv_5V_current: %f\n", lv_5V_current); | ||
| Serial.printf("current_in_telem: %f\n", current_in_telem); | ||
| Serial.printf("brake_pressure_telem: %f\n", brake_pressure_telem); | ||
| Serial.printf("brakeLED: %i\n", brakeLED); | ||
| Serial.printf("digital_data.direction: %i\n", digital_data.direction); | ||
| Serial.printf("digital_data.mc_speed_sig: %i\n", digital_data.mc_speed_sig); | ||
| Serial.printf("digital_data.eco_mode: %i\n", digital_data.eco_mode); | ||
| Serial.printf("digital_data.mcu_mc_on: %i\n", digital_data.mcu_mc_on); | ||
| Serial.printf("digital_data.park_brake: %i\n", digital_data.park_brake); | ||
| } | ||
| #endif | ||
|
|
||
|
|
||
| void setup() { | ||
| #if DEBUG_TECNIQUE | ||
|
YVishere marked this conversation as resolved.
Outdated
|
||
| int counter = 0; | ||
|
YVishere marked this conversation as resolved.
Outdated
|
||
| #endif | ||
|
|
||
| Serial.begin(115200); | ||
| initADC(ADC1); | ||
| initIO(); | ||
| initPDCState(); | ||
|
|
||
| //initialize random | ||
| srand(time(NULL)); | ||
| } | ||
|
|
||
| void loop() { | ||
| // Display digital and analog values every second (for testing) | ||
| if (DEBUG_TECHNIQUE == 1){ | ||
| if (counter >= counterExpiry) { | ||
| debugPrint(); | ||
| counter = 0; | ||
| } | ||
| counter++; | ||
| } | ||
|
|
||
| initData(); | ||
|
YVishere marked this conversation as resolved.
Outdated
|
||
| canBus.sendPDCData(); | ||
| canBus.runQueue(DATA_SEND_PERIOD); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.