RoboDurden / oo-hoverboard-firmware

object oriented hoverboard firmware
GNU General Public License v3.0
4 stars 4 forks source link

Compile errors when including CONTROL_SERIAL_USART2 #2

Open RobotronicSmith opened 4 years ago

RobotronicSmith commented 4 years ago

@RoboDurden I really appreciate your online compiler. Without it, I would be completely stuck.

I would really like to be able to use UART control and was hoping you could help. When I include the CONTROL_SERIAL_USART2 option it does not compile and I get the following:

Src/main.c: In function 'int main()': Src/main.c:165:5: error: 'UART_Control_Init' was not declared in this scope UART_Control_Init(); ^~~~~ Src/main.c:165:5: note: suggested alternative: 'UART_Init' UART_Control_Init(); ^~~~~ UART_Init make: *** [build/main.o] Error 1

I was able to fix that by replacing UART_Control_Init(); with UART_Init();

However after that, then when I try to compile I get this error: build/main.o: In function main': /var/www/html/hoverhack/source/robodurden_oo-hoverboard-firmware/Src/main.c:249: undefined reference tohuart2' collect2: error: ld returned 1 exit status make: *** [build/hover.elf] Error 1

I have not been able to see how to fix this problem. I cannot find where huart2 is defined or where something like it is defined such as just huart.

I would be grateful for any suggestions or help that you could provide.

RoboDurden commented 4 years ago

For UART you should select my RoboDurden firmware.Then when i choose a CONTROL_SERIAL_NAIVE_USART2/3 preset at the bottom of the pageand finally click 'compile at your own..'everthing works fine. only edit the main.c when you want to implement custom behaviour. the Rolandplease send me $1+ : Help me get infected, fly to Wuhan + help 6 months organized by Roland Bollmann

|

Help me get infected, fly to Wuhan + help 6 months organized by Roland B...

Story:By the end of the eighteenth century, 'variolation' had gaine… Roland Bollmann needs your support for Help... |

|

|

Am Mittwoch, 19. Februar 2020, 19:09:25 MEZ hat RobotronicSmith <notifications@github.com> Folgendes geschrieben:  

@RoboDurden I really appreciate your online compiler. Without it, I would be completely stuck.

I would really like to be able to use UART control and was hoping you could help. When I include the CONTROL_SERIAL_USART2 option it does not compile and I get the following:

Src/main.c: In function 'int main()': Src/main.c:165:5: error: 'UART_Control_Init' was not declared in this scope UART_Control_Init(); ^~~~~ Src/main.c:165:5: note: suggested alternative: 'UART_Init' UART_Control_Init(); ^~~~~ UART_Init make: *** [build/main.o] Error 1

I was able to fix that by replacing UART_Control_Init(); with UART_Init();

However after that, then when I try to compile I get this error: build/main.o: In function main': /var/www/html/hoverhack/source/robodurden_oo-hoverboard-firmware/Src/main.c:249: undefined reference to huart2' collect2: error: ld returned 1 exit status make: *** [build/hover.elf] Error 1

I have not been able to see how to fix this problem. I cannot find where huart2 is defined or where something like it is defined such as just huart.

I would be grateful for any suggestions or help that you could provide.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

RobotronicSmith commented 4 years ago

@RoboDurden Thank you for your quick reply. I saw your video on Youtube about going to Wuhan. It seems like an interesting idea. How would I send you any money to help with your idea?

I did already successfully compile the RoboDurben firmware and then I used the Arduino sample code to try to control it. I was not able to make any changes to the Arduino sample code that would change the speed. And once the motors started running the only way I could stop them was to turn off the power to the hoverboard. So the reason I was looking at the oo-hoverboard-firmware was it showed a simple example of a couple of lines of Arduino code that looked like they would be easier for me to work with: // for Arduino, use void loop(void){ Serial.write((uint8_t ) &steer, sizeof(steer)); Serial.write((uint8_t ) &speed, sizeof(speed));delay(20); }

RoboDurden commented 4 years ago

the oo-firmware is not working at all.It is just the beginning to port the firmware object-oriented. All it does is to compile without errors.

The arduino code is for my robodurden-firmware. Simple usevoid Send(int16_t iSpeed){...}to set the speed.

If that does not work you need a usb-uart module to read the controlers debut output. Like shown in my video tutorial. What mcu are you using ? I had problems with the esp8266 softwareserial and had to move to the Arduino Mini to establish serial connection. I do not like to answer technical questions by email as no others can profit. I would prefer if you ask new question in the comments of the tutorial video.

Kickstarter rejected my campaignhttps://www.kickstarter.com/projects/robodurden/help-me-get-infected-fly-to-wuhan-and-help-for-6-months?ref=1d7qaw&token=359de488 I am new to GoFundMe, but when you click on the donate button you get a page where you can donate. I only ask you for 1€ :-) I need a few donations to get momentum. And as i do not have any friends, i can not ask anyone to do me a favor. I do not like it that there is no hard funding goal like with Kickstarter where i would only get the money when the goal is reached. I definitely would not like to do the job if there were not so enough people want me to do it. But maybe the GoFundMe community is generous enough to donate anyway.

Am Mittwoch, 19. Februar 2020, 21:43:12 MEZ hat RobotronicSmith <notifications@github.com> Folgendes geschrieben:  

@RoboDurden Thank you for your quick reply. I saw your video on Youtube about going to Wuhan. It seems like an interesting idea. How would I send you any money to help with your idea?

I did already successfully compile the RoboDurben firmware and then I used the Arduino sample code to try to control it. I was not able to make any changes to the Arduino sample code that would change the speed. And once the motors started running the only way I could stop them was to turn off the power to the hoverboard. So the reason I was looking at the oo-hoverboard-firmware was it showed a simple example of a couple of lines of Arduino code that looked like they would be easier for me to work with: // for Arduino, use void loop(void){ Serial.write((uint8_t ) &steer, sizeof(steer)); Serial.write((uint8_t ) &speed, sizeof(speed));delay(20); }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

RobotronicSmith commented 4 years ago

@RoboDurden Thank you, for the information. I will see what I can do with the robodurden-firmware. I am using an Arduino Mini. You may be getting my messages through your email, but I am posting them on Github so they are available to the public. But if you prefer me asking questions on Youtube I am happy to do so. I will also look into your GoFundMe project. Good luck with that.

RobotronicSmith commented 4 years ago

@RoboDurden I posted the following questions on your Youtube video but, did not hear back from you, so I thought I would try here on Github. There are two things I would like to ask about:

First, I am still having problems controlling the speed of the motors.

I am using the RoboDurden/hoverboard-firmware-hack code and example code for Arduino https://github.com/RoboDurden/hoverboard-firmware-hack/blob/master/hoverserial.ino

When I send different values to the Send(int16_t iSpeed) function any value over 2 runs the motors at max speed one direction and any value under -2 runs the motors at max speed the other direction. Do you have any suggestions of what I might be doing wrong? Or what I need to do to be able to adjust the speed of the motors?

Second, I have recently discovered there are these small boards called blue pills with a STM32F103C8T6 on them that people are programming with the Arduino IDE. What do you think would be the possibility of programming the hoverboard motor control board using the Arduino IDE? If it is possible, how difficult would it be to do so?

RoboDurden commented 4 years ago

Sorry where is your youtube comment ? if you have not changed anything in my fork, this define in config.h is active:

define SPEED_IS_KMH        //ROBO spped is 10*km/h so 60 would be 6.0 km/h

So when you send 2 that would be 0.2 km/h I guess my control loop in main.c is buggy and once the speed is not zero, the power is increased instead of decreased. So my loop thinks it should increase the kmh whereas it should decrease it. Have you changed these defines ?:

define INVERT_R_DIRECTION

define INVERT_L_DIRECTION

My first guess is that your Send() targets a speed like 4 km/h but the hall sensors respond wiht -4 kmh. So my loop increases the speed to 5 kmh but feedback is -5 kmh. And so on until it has full power = +-1000. Try uncommenting SPEED_IS_KMH to activate the original control loop where +1000 is full power forward and -1000 is full power backwards.

Or invert this line in main.c :

ifdef SPEED_IS_KMH

    long iSpeed =   abs(HallData[0].HallSpeed_mm_per_s) > abs(HallData[1].HallSpeed_mm_per_s) ? -HallData[0].HallSpeed_mm_per_s : -HallData[1].HallSpeed_mm_per_s;

As i said, i guess that iSpeed is in the wrong direction.Please post your changes to config.h so i can learn why my control is buggy.

I am not sure the arduino-stm32 support is mature enough.Programming a stm32 needs a very lot of configuration.

Am Mittwoch, 4. März 2020, 15:41:23 MEZ hat RobotronicSmith <notifications@github.com> Folgendes geschrieben:  

@RoboDurden I posted the following questions on your Youtube video but, did not hear back from you, so I thought I would try here on Github. There are two things I would like to ask about:

First, I am still having problems controlling the speed of the motors.

I am using the RoboDurden/hoverboard-firmware-hack code and example code for Arduino https://github.com/RoboDurden/hoverboard-firmware-hack/blob/master/hoverserial.ino

When I send different values to the Send(int16_t iSpeed) function any value over 2 runs the motors at max speed one direction and any value under -2 runs the motors at max speed the other direction. Do you have any suggestions of what I might be doing wrong? Or what I need to do to be able to adjust the speed of the motors?

Second, I have recently discovered there are these small boards called blue pills with a STM32F103C8T6 on them that people are programming with the Arduino IDE. What do you think would be the possibility of programming the hoverboard motor control board using the Arduino IDE? If it is possible, how difficult would it be to do so?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

RobotronicSmith commented 4 years ago

@RoboDurden

Sorry where is your youtube comment ?

I attached it to your video: https://www.youtube.com/watch?v=15UBBcZvMh8

Thank you for the suggestions I will try them and let you know how it works out.

RobotronicSmith commented 4 years ago

@RoboDurden Thank you so much, it is working now. The only change I made was in main.c after: long iSpeed = abs(HallData[0].HallSpeed_mm_per_s) > abs(HallData[1].HallSpeed_mm_per_s) ? -HallData[0].HallSpeed_mm_per_s : -HallData[1].HallSpeed_mm_per_s; I added: iSpeed = -iSpeed;

I have modified the Arduino code to work on a Mega board so that I would have more serial ports. That way I am able to change the motor speed by typing a value into the Arduino terminal.

RobotronicSmith commented 4 years ago

@RoboDurden I have tried your other suggestion as well and thought it works better. I commented out the following lines

define INVERT_R_DIRECTION

define INVERT_L_DIRECTION

define SPEED_IS_KMH

This made the feedback motor speed values positive when sending a positive value and also made the usable range of values for speed from -1000 to 1000 as you said.

RoboDurden commented 4 years ago

Without my SPEED_IS_KMH ,the speed is only the power of the motors = the pwm duty cycle that drives the mosfets. As my solar car is only allowed to drive at max 6 km/h on the streets I need that control loop to adjust the duty cycle to match the actual speed. So when my control loop was not working you already had these lines commented out?

define INVERT_R_DIRECTION

define INVERT_L_DIRECTION

So putting your iSpeed = -iSpeed inside a   #ifdef could solve the bug ? Please make my code better. I am currently on a 600 km journey with my solar car and don't want to recompile my code now.

Gesendet von Yahoo Mail auf Android

Am Fr., März 6, 2020 at 0:56 schrieb RobotronicSmithnotifications@github.com:
@RoboDurden I have tried your other suggestion as well and thought it works better. I commented out the following lines

define INVERT_R_DIRECTION

define INVERT_L_DIRECTION

define SPEED_IS_KMH

This made the feedback motor speed values positive when sending a positive value and also made the usable range of values for speed from -1000 to 1000 as you said.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

RobotronicSmith commented 4 years ago

@RoboDurden

So when my control loop was not working you already had these lines commented out?

define INVERT_R_DIRECTION

define INVERT_L_DIRECTION

No those lines were not commented out. So today I tried just commenting out:

define INVERT_R_DIRECTION

define INVERT_L_DIRECTION

and keeping:

define SPEED_IS_KMH

This also worked with your Arduino sample code that just varied the speed from full reverse to full forward. However, the useful range of values for the Send() function is limited to between -60 and 60.

So putting your iSpeed = -iSpeed inside a #ifdef could solve the bug ?

Yes, I put it in the following:

`#ifdef SPEED_IS_KMH long iSpeed = abs(HallData[0].HallSpeed_mm_per_s) > abs(HallData[1].HallSpeed_mm_per_s) ? -HallData[0].HallSpeed_mm_per_s : -HallData[1].HallSpeed_mm_per_s; iSpeed = -iSpeed; // Added line //long iSpeed = (HallData[0].HallSpeed_mm_per_s + HallData[1].HallSpeed_mm_per_s)/-2; // mm/s long iSpeed_Goal = (cmd2 * 1000) / 36; // mm_per_s

if (    (abs(iSpeed_Goal) < 56) && (abs(cmd2Goal) < 50) )   // iSpeed_Goal = 56 = 0.2 km/h
{
    speed = cmd2Goal = 0;
}   

ifdef MAX_RECUPERATION

else if ((currentL+currentR)/2 < -MAX_RECUPERATION)
{
    cmd2Goal += 5;
    if (cmd2Goal > 1000)    cmd2Goal = 1000;
}

endif`

Please make my code better. I am currently on a 600 km journey with my solar car and don't want to recompile my code now.

I appreciate your help and would like to help you if I can. I apologize I am very new to Github. Still, I think that I could fork your project and make changes to the code. However, I would guess your online compiler would not see the changes.
If your solar car is limited to 6 KMH I can see your journey is going to take a long time. I wish you safe travels.

RoboDurden commented 4 years ago

However, the useful range of values for the Send() function is limited to between -60 and 60.

I don't see why you could not send 1253 to set a speed of 125.3 km/h

Of course you might need to uncomment //#define WHEEL_SIZE_INCHES 8.5 // - set to your wheelsize to override the default 6.5

RobotronicSmith commented 4 years ago

As you said before, the code is set up to limit the max speed to 6 km/h. So far I have not looked into where the limitation occurs because, for the robots I am hoping to use the motors in, 6 km/h is fast enough.

On Sat, Mar 7, 2020, 6:14 AM Robo Durden notifications@github.com wrote:

However, the useful range of values for the Send() function is limited to between -60 and 60.

I don't see why you could not send 1253 to set a speed of 125.3 km/h

Of course you might need to uncomment //#define WHEEL_SIZE_INCHES 8.5 // - set to your wheelsize to override the default 6.5

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RoboDurden/oo-hoverboard-firmware/issues/2?email_source=notifications&email_token=AAXOQMTEUG6GAWFJ4OQ6NULRGJCERA5CNFSM4KX6RSP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEODZDTI#issuecomment-596087245, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXOQMQ75ODA45PGDXWHIDDRGJCERANCNFSM4KX6RSPQ .

RoboDurden commented 4 years ago

There is no limitation in my firmware. Only my solar car here in Germany is legally limited to 6 kmh. Therefore my personal aruduino code will not send speeds faster than +-60. But of course the Send() function allows to send speeds as you like.

RobotronicSmith commented 4 years ago

In my testing, with SPEED_IS_KMH the max speed of the motors was around 6kmh. With SPEED_IS_KMH commented out the max speed was 7 kmh even when Send(1000). The only exception is that if I set the steering to 1,000 and the speed to 1,000 then one of the motors would get up to 12 kilometers per hour.

On Sat, Mar 7, 2020, 6:52 AM Robo Durden notifications@github.com wrote:

There is no limitation in my firmware. Only my solar car here in Germany is legally limited to 6 kmh. Therefore my personal aruduino code will not send speeds faster than +-60. But of course the Send() function allows to send speeds as you like.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RoboDurden/oo-hoverboard-firmware/issues/2?email_source=notifications&email_token=AAXOQMTIMQ3FAA5EHSPLWSTRGJGSXA5CNFSM4KX6RSP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEODZ7GI#issuecomment-596090777, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXOQMXYJPZVTWPFQ4HXXGDRGJGSXANCNFSM4KX6RSPQ .

RobotronicSmith commented 4 years ago

If there is no limit in the motor control firmware the it is probably in the Arduino code. I don't have the code in front of me right now. But like I said it wasn't something that concern me so I didn't look into it.

On Sat, Mar 7, 2020, 6:52 AM Robo Durden notifications@github.com wrote:

There is no limitation in my firmware. Only my solar car here in Germany is legally limited to 6 kmh. Therefore my personal aruduino code will not send speeds faster than +-60. But of course the Send() function allows to send speeds as you like.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RoboDurden/oo-hoverboard-firmware/issues/2?email_source=notifications&email_token=AAXOQMTIMQ3FAA5EHSPLWSTRGJGSXA5CNFSM4KX6RSP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEODZ7GI#issuecomment-596090777, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXOQMXYJPZVTWPFQ4HXXGDRGJGSXANCNFSM4KX6RSPQ .

RoboDurden commented 4 years ago

In my testing, with SPEED_IS_KMH the max speed of the motors was around 6kmh. With SPEED_IS_KMH commented out the max speed was 7 kmh even when Send(1000). The only exception is that if I set the steering to 1,000 and the speed to 1,000 then one of the motors would get up to 12 kilometers per hour.

I guess that is because you still have the default config values:

#define SPEED_COEFFICIENT   0.5  // higher value == stronger. 0.0 to ~2.0?
#define STEER_COEFFICIENT   0.5  // higher value == stronger. if you do not want any steering, set it to 0.0; 0.0 to 1.0

Which will reduce the speed by 50% to able to add 50% due to steering:

    // ####### MIXER #######
    #ifdef SWITCH_WHEELS
      speedL = CLAMP(speed * SPEED_COEFFICIENT -  steer * STEER_COEFFICIENT, -1000, 1000);
      speedR = CLAMP(speed * SPEED_COEFFICIENT +  steer * STEER_COEFFICIENT, -1000, 1000);
    #else
      speedR = CLAMP(speed * SPEED_COEFFICIENT -  steer * STEER_COEFFICIENT, -1000, 1000);
      speedL = CLAMP(speed * SPEED_COEFFICIENT +  steer * STEER_COEFFICIENT, -1000, 1000);
    #endif

That my SPEED_IS_KMH control loop will only achieve 6 km/h when max speed (pwm = 100%) is 7 km/h is acceptable :-)