-
Notifications
You must be signed in to change notification settings - Fork 953
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
VARIANT_USART issues :-/ #65
Comments
Give me some time to process the answer for you. |
Take your time :-) |
in case you don't belive me: https://youtu.be/cpnbJV8CpyU |
Okay i added a nice VARIANT_UARTCAR and ported my closed loop into your main.c.
Only variable i need is:
For the MAX_RECUPERATION i need:
Took me some time to notice that a negative curL_DC stands for power consumption and a positive value for charging the battery. I think such a VARIANT_UARTCAR makes sense:
I will embark on a new 500 km journey tomorrow - with your nice FOC control, thanks again :-) |
Maybe I am too late but the UART should be improved significantly now. |
Great that you improved your serial communication. Will give it at try when i am on the road. My SerialFeedback becomes unusable when the motors are running. Don't know why i have so much noise in my cables. But i remember that your SerialFeedback worked better than mine. I am not really going anywhere. I simply drive the same circle forever. Hof -> Regensburg -> Nurenberg -> Bamberg -> Hof. This is my 500km loop number 46. "All that you own end up owning you." (Tyler Durden) |
By waiting for the full lenght package is also not optimal, because one you lose one byte you are out-of-sync and is hard to get back on track. The best is to use "UART Idle line detection interrupt" to process the UART data, as I did in the main firmware. However, I am not sure if Arduino support Idle line detection at all.
Also, CLAM replaced by IN_RANGE => so, fixed. Thanks!
|
|
|
First, i am very happy that your hoverserial.ino worked right out of the box :-)
But i had some issues that forced me to fork your nice firmeware and implement the serial protocol of my previous fork. If you want you can search for SERIAL_ROBO in the following files:
https://github.com/RoboDurden/hoverboard-firmware-hack-FOC/blob/master/Src/main.c
https://github.com/RoboDurden/hoverboard-firmware-hack-FOC/blob/master/Inc/util.h
https://github.com/RoboDurden/hoverboard-firmware-hack-FOC/blob/master/Src/util.c
1. HoverReceive() only works fine when the loop() is empty. That is because you set the send-feedback interval to 10 ms in main.c and in HoverReceive() only reads a single byte from the serial buffer.
my HoverReceive() waits until SerialFeedback data is complete and then processes it in one call:
2. Sending a Serialcommand with steer=0 at 9600 baud sometimes yields -1000 for steer :-(
I can upload a video where my two wheels start spinning in opposite directions :-((
And your SerialFeedback logs
steer = -1000
back !!I think that is because the stm32 loop is way faster than 9600 baud and it happens more often that readCommand() gets processed while that tiny circular command buffer gets overwritten.
Your 0xABCD does not really solve that issue !
Best would be to simply switch from a circular buffer to one that skips incomming data when full. With only 8 bytes and even 10 ms a 1 second buffer would only need 800 bytes.
I tried for such a non-circular buffer already with my old fork but i am an absolute stm32 beginner and failed.
My way simply is to make a double copy of the command buffer and than try all 8 offsets until my more secure crc32 is correct.
3. After you succeed with your 0xABCD and the simple crc you CLAMP steer and speed to -1000 +1000. I would call this as a bug. As your 0xABCD and crc is not 100% safe, the chance that a corrupted steer value with a range of 65536 is clamped to +-1000 is very high.
I would at least suggest you validate the speed and steer like
if ( (pCmd->steer >= INPUT_MIN) && (pCmd->steer <= INPUT_MAX) && (pCmd->speed >= INPUT_MIN) && (pCmd->speed <= INPUT_MAX) )
4. A faulty steer or speed should not cause damage because of the low-pass in main.c
However the mixer is after the low-pass. And a steer change can affect the speed change more then a steer change by itself. But i think that is okay :-)
I have put an arduino example for both protocols to my fork:
https://github.com/RoboDurden/hoverboard-firmware-hack-FOC/tree/master/hoverserial
5. In my protocal i send back the current of the two motors. I guess that would be
where i made these two variables available with
But i only receive 0 values on the arduino side :-/
Maybe you instantly see what i miss :-)
I am happy that you are still active with your firmware and therefore do not really want to continue my own fork.
If you agree that your crc is not 100% safe, you might be happy to include some of my code.
I do not really know how github works. So i do not know how to become a contributor.
And i would understand if want to keep such a nasty guy like me out of your nice project :-)
roland, the little physicist :-)
"you either lose.. or fail - nothing else - nothing in between !" (Robo Durden)
The text was updated successfully, but these errors were encountered: