Skip to content

Commit 41a0f4b

Browse files
author
Niklas Fauth
committed
ADD: define to change gametrak ADC wirering in software
1 parent 95dc493 commit 41a0f4b

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

Inc/config.h

+3-24
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,22 @@
3939

4040
#define INACTIVITY_TIMEOUT 8 // minutes of not driving until poweroff. it is not very precise.
4141

42-
// ############################### LCD DEBUG ###############################
43-
44-
//#define DEBUG_I2C_LCD // standard 16x2 or larger text-lcd via i2c-converter on right sensor board cable
45-
4642
// ############################### SERIAL DEBUG ###############################
4743

4844
//#define DEBUG_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used!
4945
//#define DEBUG_BAUD 115200 // UART baud rate
5046
//#define DEBUG_SERIAL_SERVOTERM
5147
//#define DEBUG_SERIAL_ASCII // "1:345 2:1337 3:0 4:0 5:0 6:0 7:0 8:0\r\n"
5248

53-
// ############################### INPUT ###############################
54-
55-
// ###### CONTROL VIA UART (serial) ######
56-
//#define CONTROL_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used!
57-
// #define CONTROL_BAUD 19200 // control via usart from eg an Arduino or raspberry
58-
// for Arduino, use void loop(void){ Serial.write((uint8_t *) &steer, sizeof(steer)); Serial.write((uint8_t *) &speed, sizeof(speed));delay(20); }
59-
60-
// ###### CONTROL VIA RC REMOTE ######
61-
// left sensor board cable. Channel 1: steering, Channel 2: speed.
62-
//#define CONTROL_PPM // use PPM-Sum as input. disable DEBUG_SERIAL_USART2!
63-
//#define PPM_NUM_CHANNELS 6 // total number of PPM channels to receive, even if they are not used.
64-
65-
// ###### CONTROL VIA TWO POTENTIOMETERS ######
66-
// ADC-calibration to cover the full poti-range: connect potis to left sensor board cable (0 to 3.3V) (do NOT use the red 15V wire in the cable!). see <How to calibrate>. turn the potis to minimum position, write value 1 to ADC1_MIN and value 2 to ADC2_MIN. turn to maximum position and repeat it for ADC?_MAX. make, flash and test it.
67-
//#define CONTROL_ADC // use ADC as input. disable DEBUG_SERIAL_USART2!
68-
//#define ADC1_MIN 0 // min ADC1-value while poti at minimum-position (0 - 4095)
69-
//#define ADC1_MAX 4095 // max ADC1-value while poti at maximum-position (0 - 4095)
70-
//#define ADC2_MIN 0 // min ADC2-value while poti at minimum-position (0 - 4095)
71-
//#define ADC2_MAX 4095 // max ADC2-value while poti at maximum-position (0 - 4095)
72-
7349
// ###### TRANSPOTTER FIRMWARE #######
7450
#define CONTROL_GAMETRAK
7551
#define SUPPORT_LCD
7652
#define SUPPORT_NUNCHUCK
7753
//#define SUPPORT_REMOTE
7854

55+
#define GAMETRAK_CONNECTION_NORMAL // for normal wireing accoring to the wiki Instructions
56+
//#define GAMETRAK_CONNECTION_ALTERNATE // use this define instead if you messed up the gametrak ADC wirering (steering is speed, and length of teh wire is steering)
57+
7958
#define ROT_P -1.2 // P coefficient for the direction controller. Positive / Negative values to invert gametrak steering direction.
8059
#define FILTER 0.1 // lower value == softer filter. do not use values <0.01, you will get float precision issues.
8160

Src/main.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,15 @@ int main(void) {
335335

336336

337337

338-
338+
#ifdef GAMETRAK_CONNECTION_NORMAL
339339
uint16_t distance = CLAMP((adc_buffer.l_rx2) - 180, 0, 4095);
340340
steering = (adc_buffer.l_tx2 - 2048) / 2048.0;
341+
#endif
342+
#ifdef GAMETRAK_CONNECTION_ALTERNATE
343+
uint16_t distance = CLAMP((adc_buffer.l_tx2) - 180, 0, 4095);
344+
steering = (adc_buffer.l_rx2 - 2048) / 2048.0;
345+
#endif
346+
341347
feedforward = ((distance - (int)(setDistance * 1345)));
342348
if (nunchuck_connected == 0) {
343349
speedL = speedL * 0.8f + (CLAMP(feedforward + ((steering)*((float)MAX(ABS(feedforward), 50)) * ROT_P), -850, 850) * -0.2f);

0 commit comments

Comments
 (0)