-
Notifications
You must be signed in to change notification settings - Fork 2
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
116 RC Threshold Calibration #131
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#include<EEPROM.h> | ||
int rc_channel2 = 3; | ||
int rc_channel3 = 4; | ||
int switchA = 6; //Channel 5 | ||
int switchB = 7; //Channel 6 | ||
|
||
//Address in EEPROM | ||
const int rc2_addr_max = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider moving this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make this file pinout agnostic There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e.g. #@file pinout.h
#define RC_CHANNEL2 3
#define RC_CHANNEL3 4 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Further, the EEPROM addresses need to be in a header file (e.g. |
||
const int rc2_addr_min = 1; | ||
const int rc2_addr_central = 2; | ||
|
||
const int rc3_addr_max = 3; | ||
const int rc3_addr_min = 4; | ||
const int rc3_addr_central = 5; | ||
|
||
const int rc5_addr_zero = 6; | ||
const int rc5_addr_one = 7; | ||
|
||
const int rc6_addr_zero = 8; | ||
const int rc6_addr_one = 9; | ||
|
||
void setup() { | ||
// put your setup code here, to run once: | ||
pinMode(rc_channel2, INPUT); | ||
pinMode(rc_channel3, INPUT); | ||
pinMode(switchA, INPUT); | ||
pinMode(switchB, INPUT); | ||
Serial.begin(9600); | ||
} | ||
|
||
void loop() { | ||
int rc2; //Right Joystick | ||
int rc3; //Left Joystick | ||
int swa; //Channel 5 (Remote E-stop) | ||
int swb; //Channel 6 (Mode Switch) | ||
|
||
//**********Right Joystick**********// | ||
//MAX Position | ||
Serial.println("Please move the right joystick to the maximum position\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you specificy that the maximum position is up (like forwards) |
||
delay(2000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use delays. I suggest doing something like the following:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest creating a seperate function for this with a few arguments: int get_threshold(const char * user_question, bool min = false, bool max = false, bool mean = false, uint8_t rc_pin, uint8_t eeprom_addr)
{
/*
1.print the string
2.wait for a start char
3.sample and store into a temp array
4.wait for time end or end char. Or, cancel char which exits the measurement and re-runs the question routine.
5.get min/max/mean
6.write value to eeprom
7.return true is successful data collection and eeprom write, else false
*/
} |
||
rc2 = pulseIn(rc_channel2, HIGH); | ||
EEPROM.put(rc2_addr_max, rc2); | ||
//MIN Position | ||
Serial.println("Please move the right joystick to the minimum position\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. specify what the minimum position is |
||
delay(2000); | ||
rc2 = pulseIn(rc_channel2, HIGH); | ||
EEPROM.put(rc2_addr_min, rc2); | ||
|
||
//Central Position | ||
Serial.println("Please move the right joystick to the central position\n"); | ||
delay(2000); | ||
rc2 = pulseIn(rc_channel2, HIGH); | ||
EEPROM.put(rc2_addr_central, rc2); | ||
|
||
//**********Left Joystick**********// | ||
//MAX Position | ||
Serial.println("Please move the left joystick to the maximum position\n"); | ||
delay(2000); | ||
rc3 = pulseIn(rc_channel3, HIGH); | ||
EEPROM.put(rc3_addr_max, rc3); | ||
|
||
//MIN Position | ||
Serial.println("Please move the left joystick to the minimum position\n"); | ||
delay(2000); | ||
rc3 = pulseIn(rc_channel3, HIGH); | ||
EEPROM.put(rc3_addr_min, rc3); | ||
|
||
//Central Position | ||
Serial.println("Please move the left joystick to the central position\n"); | ||
delay(2000); | ||
rc3 = pulseIn(rc_channel3, HIGH); | ||
EEPROM.put(rc3_addr_central, rc3); | ||
|
||
//**********Switch A(Remote E-stop)**********// | ||
//Position 0 | ||
Serial.println("Please move Switch A to 0\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to label these on the RC itself somehow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed |
||
delay(2000); | ||
swa = pulseIn(switchA, HIGH); | ||
EEPROM.put(rc5_addr_zero, swa); | ||
//Position 1 | ||
Serial.println("Please move Switch A to 1\n"); | ||
delay(2000); | ||
swa = pulseIn(switchA, HIGH); | ||
EEPROM.put(rc5_addr_one, swa); | ||
|
||
//**********Switch B(Mode Switch)**********// | ||
//Position 0 | ||
Serial.println("Please move Switch B to 0\n"); | ||
delay(2000); | ||
swb = pulseIn(switchB, HIGH); | ||
EEPROM.put(rc6_addr_zero, swb); | ||
|
||
//Position 1 | ||
Serial.println("Please move Switch B to 1\n"); | ||
delay(2000); | ||
swb = pulseIn(switchB, HIGH); | ||
EEPROM.put(rc6_addr_one, swb); | ||
|
||
for(;;){} //stop the loop function | ||
} |
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.
pls format using
Ctrl + Shift + I
on vscodeThere 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.
yes yes