Coder Social home page Coder Social logo

p-h-a-i-l / hoverboard-firmware-hack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lucysrausch/hoverboard-firmware-hack

55.0 55.0 31.0 32.66 MB

Obsolete repository, moved to bipropellant project

Home Page: https://github.com/bipropellant

License: GNU General Public License v3.0

C 97.05% Assembly 2.17% C++ 0.77% Makefile 0.02%

hoverboard-firmware-hack's People

Contributors

blubbi321 avatar bruegeln avatar btsimonh avatar crinq avatar jana-marie avatar larsmm avatar leodj avatar p-h-a-i-l avatar rene-dev avatar tobleminer avatar trilader avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hoverboard-firmware-hack's Issues

Actual speed reading

Is there a simple example to read the current speed with SERIAL_USART2_IT?
the example for the Serial Command works great, but
I need to always read the real speed with my teensy.
I believe it is possible but I am a beginner and I have many difficulties
Thanks in advance.

buffer out of sync ? CONTROL_SERIAL_NAIVE_USART3 && CONTROL_SERIAL_NAIVE_CRC

below a CONTROL_SERIAL_NAIVE_USART3 && CONTROL_SERIAL_NAIVE_CRC Arduino example (esp8266) that works but when the 8 byte serial command gets out of sync, the crc failes on the hoverboard. When i reset the esp8266 there seems to be a 1/8 chance that the the buffer is filled correctly :-(

What HAL_UART_ command would reset the buffer ?

ideas welcome !

`#define CONTROL_SERIAL_NAIVE_CRC // Add CRC32 check to control serial

typedef struct{
int16_t steer;
int16_t speed;
#ifdef CONTROL_SERIAL_NAIVE_CRC
uint32_t crc;
#endif
} Serialcommand;

volatile Serialcommand oCmd;

void setup()
{
Serial.begin(115200);
}

#ifdef CONTROL_SERIAL_NAIVE_CRC

uint32_t crc32_for_byte(uint32_t r)
{
for(int j = 0; j < 8; ++j)
r = (r & 1? 0: (uint32_t)0xEDB88320L) ^ r >> 1;
return r ^ (uint32_t)0xFF000000L;
}

void crc32(const void data, size_t n_bytes, uint32_t crc) {
static uint32_t table[0x100];
if(!*table)
for(size_t i = 0; i < 0x100; ++i)
table[i] = crc32_for_byte(i);
for(size_t i = 0; i < n_bytes; ++i)
*crc = table[(uint8_t)crc ^ ((uint8_t)data)[i]] ^ *crc >> 8;
}
#endif

void Send(int16_t iSpeed)
{
oCmd.steer = 0;
oCmd.speed = iSpeed;

#ifdef CONTROL_SERIAL_NAIVE_CRC
uint32_t crc = 0;
crc32((const void *)&oCmd, 4, &crc); // 4 2x uint16_t = 4 bytes
oCmd.crc = crc;
#endif

Serial.write((uint8_t *) &oCmd, sizeof(oCmd));
}

void loop(void)
{
//Send(100);delay(500); return;

for (int i=0; i<= 1000; i +=20)
{
Send(i);
delay(200);
}
for (int i=1000; i>= 0; i -=20)
{
Send(i);
delay(200);
}

for (int i=0; i<= 1000; i +=20)
{
Send(-i);
delay(200);
}
for (int i=1000; i>= 0; i -=20)
{
Send(-i);
delay(200);
}
}`

Compiling issue using Linux

Compiling ending with no rule to make Target error as below.

Make: *** No rule to make Target 'build/hallinterrupts.o', needed by 'build/hover.elf' . Stop

Reading back speeds kills the set point

Fyi, I found that reading back speeds, in my case using the 0x07 command, interferes with the FILTER mechanism of main.c. This effectively prevents main.c from reaching the required final set point in case one reads back the speed before it has settled.

The problem is in the function PreRead_getspeeds: it overwrites the desired setpoints with the current speed/steer, which might still be developing.

void PreRead_getspeeds(void){
    speedsx.speedl = SpeedData.wanted_speed_mm_per_sec[0];
    speedsx.speedr = SpeedData.wanted_speed_mm_per_sec[1];
    PwmSteerCmd.base_pwm = speed; # <--- this is also the set point!
    PwmSteerCmd.steer = steer;    # <--- this is also the set point!
}

Introduced here 27ef84b

P.S: My workaround is:

#define FILTER 1.0

Compiling in platformio

Hello, thanks for your effort and help with my issue in Niklas's repo.
So, i finally got some time to work on my project again, and i used your repo because it seems easier to compile.
QUESTION:
you said that i would need some editing within platformio... you ment to change the file for the output, so i would get a .hex file in the end?
i got this, so i changed the input for my PPM decoder, so i would like to confirm that this is the file that i need to flash my hoverboard!
Untitled

Lots of noise on serial line

The firmware works well, but often I' have problems with serial transmission:
when the motor is active (even at zero speed) I see many distortions with the oscilloscope and the motor stops.
I have tried with short cables, shielded cables, ferrite, etc. but the noise don't stop.
My Teensy 3.2 (3.3v) is powered with an external battery with the common ground.
Some advice?
Of course with the analog command works well and i've tried with different boudrate.

Thanks in advance.

20190516_222911
20190516_222921

ADC and PPM possible?

Is it possible to move PPM to the right connector and use ADC and PPM at the same time?
Would like to use the gametrax and RC-Remote.

Thanks

reliable bidirectional communication :-)

I added a better checkCRC() to your main.c

bool checkCRC2(volatile Serialcommand* command) 
{
	uint8_t a[15];
	memcpy((void*)a,(void*)command,8);
	memcpy((void*)(a+8),(void*)command,7);
	
	for (uint8_t iOffset=0; iOffset< 8; iOffset++)
	{
		Serialcommand* pCmd = (Serialcommand*) (a+iOffset);
		uint32_t crc = 0;
		crc32((const void *)pCmd, 4, &crc); // 4 2x uint16_t = 4 bytes
		if(pCmd->crc == crc) 
		{
			memcpy((void*)command,(void*)pCmd,8);
			setScopeChannel(0, 1);
			if (	(abs(pCmd->steer)>1000) || (abs(pCmd->steer)>1000)	)
			{
				setScopeChannel(1,255);
				return false;
			}
			setScopeChannel(1,(int) iOffset);
			return true;
		}
	}
	setScopeChannel(0, 0);
	setScopeChannel(1, (int)command->crc);
	return false;
}

and i implemented a small feedback communication:

typedef struct{
   int16_t iSpeedL;		// 100* km/h
   int16_t iSpeedR;		// 100* km/h
   uint16_t iHallSkippedL;
   uint16_t iHallSkippedR;
   uint16_t iTemp;		// °C
   uint16_t iVolt;		// 100* V
   int16_t iAmpL;		// 100* A
   int16_t iAmpR;		// 100* A
   uint32_t crc;
} SerialFeedback;
volatile SerialFeedback oFeedback;

#ifdef DEBUG_SERIAL_USART3
#define UART_DMA_CHANNEL DMA1_Channel2
#endif
#ifdef DEBUG_SERIAL_USART2
#define UART_DMA_CHANNEL DMA1_Channel7
#endif

and

#if defined DEBUG_SERIAL_FEEDBACK && (defined DEBUG_SERIAL_USART2 || defined DEBUG_SERIAL_USART3)
	    if(UART_DMA_CHANNEL->CNDTR == 0) 
	    {
			oFeedback.iSpeedL	= (int) (float)HallData[0].HallSpeed_mm_per_s * 0.36f;
			oFeedback.iSpeedR	= (int) (float)HallData[1].HallSpeed_mm_per_s * 0.36f;
			oFeedback.iHallSkippedL	= HallData[0].HallSkipped;
			oFeedback.iHallSkippedR	= HallData[1].HallSkipped;
			oFeedback.iTemp	= (int)	board_temp_deg_c;
			oFeedback.iVolt	= (int)	(batteryVoltage * 100.0f);
			oFeedback.iAmpL = (int) (currentL * 100.0f);
			oFeedback.iAmpR = (int)	(currentR * 100.0f);
			oFeedback.crc = 0;
			crc32((const void *)&oFeedback, sizeof(oFeedback)-4, &oFeedback.crc);

			UART_DMA_CHANNEL->CCR &= ~DMA_CCR_EN;
			UART_DMA_CHANNEL->CNDTR = sizeof(oFeedback);
			UART_DMA_CHANNEL->CMAR  = (uint32_t)&oFeedback;
			UART_DMA_CHANNEL->CCR |= DMA_CCR_EN;
	    }
#else
//ROBO end

      // ####### DEBUG SERIAL OUT #######
      #ifdef CONTROL_ADC
        setScopeChannel(0, (int)adc_buffer.l_tx2);  // 1: ADC1
        setScopeChannel(1, (int)adc_buffer.l_rx2);  // 2: ADC2
      #endif
      setScopeChannel(2, (int)speedR);  // 3: output speed: 0-1000
      setScopeChannel(3, (int)speedL);  // 4: output speed: 0-1000
      setScopeChannel(4, (int)adc_buffer.batt1);  // 5: for battery voltage calibration
      setScopeChannel(5, (int)(batteryVoltage * 100.0f));  // 6: for verifying battery voltage calibration
      setScopeChannel(6, (int)board_temp_adc_filtered);  // 7: for board temperature calibration
      setScopeChannel(7, (int)board_temp_deg_c);  // 8: for verifying board temperature calibration
      consoleScope();
#endif	//ROBO

changes in bldc.c

float batteryVoltage = BAT_NUMBER_OF_CELLS * 4.0;
float currentL = 0;	//ROBO
float currentR = 0;	//ROBO

and

  currentL = MOTOR_AMP_CONV_DC_AMP * (float) (adc_buffer.dcl - offsetdcl);	//ROBO
  currentR = MOTOR_AMP_CONV_DC_AMP * (float) (adc_buffer.dcr - offsetdcr);	//ROBO
  
  if(ABS((adc_buffer.dcl - offsetdcl) * MOTOR_AMP_CONV_DC_AMP) > DC_CUR_LIMIT || timeout > TIMEOUT || enable == 0) {

would be nice if you add this to your repo. Your old checkCRC isn't really of any use ?

Don't really know how to contribute myself.

And i rather wish to continue with the c++ port

here the modified firmware in action: https://youtu.be/5Wq42cbGRSU

the Roland :-)

Bidirectional USART control

HI @p-h-a-i-l ,

I know this branch is not supported any more, but I didn't know how to contact you.

I try to implement bi-directional USART control on my FOC branch and I got stuck in something.
Whenever I try to send or receive on huart3, I can only do it once and then the STM32 get's stuck.
So if I do:

HAL_UART_Transmit_DMA(&huart3, (uint8_t *)message, strlen(message));

where message = "Hello";

Then on serial Monitor I see
Hello
after which the STM32 gets stuck in an infinite loop. I followed your settings from this branch for the bidirectional USAR control. Did I miss something? How did you manage to work?

If I compile this brach I get on Serial Monitor "power off in 4s" and then infinite beeping.

10'' motors loosing sync

Hello,
I have the same firmware on two different cars, one 6'' and the second with 10'' wheels.
The 10'' setup seems to loose sync on start to move if any height is put on it.
Is there anything I should tune for the bigger motors?

Thanks
edit: it had nothing to do with sync, just serial communication errors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.