Skip to content
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

UART Control Scheme and acceleration #75

Open
amarotica opened this issue Jan 29, 2019 · 7 comments
Open

UART Control Scheme and acceleration #75

amarotica opened this issue Jan 29, 2019 · 7 comments

Comments

@amarotica
Copy link

Hi there,
First off, your firmware is awesome! I have tried controlling using ADC inputs but I am wanting to just use UART control because ADC is only single directional. My question is what range of values do I send to the controller to control? I understand I have to use:
Serial.write((uint8_t *) &turn, sizeof(turn));
Serial.write((uint8_t *) &velocity, sizeof(velocity));
delay(10);
When controlling with arduino 3.3v but I do not understand what the "turn" and "velocity" values should be. Are they int's or bytes or char's or what? Also, what is the range of these values? Is it like -20 to 20 or -10000 to 10000? I cannot find in the config.h or in the other files I've read through what sort of values to send to the control board. Also, other than the bobbycar version, are there any acceleration settings built in or do I need to send increasing velocity values over a certain time frame, calculated by my arduino?

I really appreciate any input or info about the UART control input setup that anyone can give because currently I feel lost. Thank you

@wholepair
Copy link

I too am working on getting control of the driver via UART for a differential bot. A write-up, a ino, or samples of python script would be much appreciated!

I bought the hoverboard-breakout board here:
https://github.com/Jan--Henrik/hoverboard-breakout/tree/master/bobbycar_breakout
I don't fully understand the master/slave interconnects but was thinking that would become clear when I populated the pcb w/ components.

Thanks!

@Jana-Marie
Copy link
Collaborator

Hey @wholepair ,

The interconnect matrix can be used for UART board to board communication. You can just connect RX to TX and TX to RX between to mainboards. But we've never used that feature, therefore we didn't write code for that. (Also I don't really know if somebody else did it)

@AntumArk
Copy link

https://github.com/AntumArk/hoverboard-firmware-dual/tree/newprotocol/HoverSerial Here is Arduino code for communications. I used BluePill(STM32f103). And as @Jan--Henrik said, you just need to connect TX, RX and GND to your sender. You can also try using Bluetooth module for this communication, but just be careful to use 3.3v.
As for what the actual meaning those -1000 /1000 is - I have no idea. Although it would make more sense to use real speed values or position.
@amarotica https://github.com/NiklasFauth/hoverboard-firmware-hack/blob/9beae76952119e3bb3e367d43a307f4ac420c6e4/Inc/config.h#L84 . Please read more carefully.

@p-h-a-i-l
Copy link
Contributor

Please be careful with the default UART implementation. There is no feature to validate the input, you can get really bad speed values when there are disturbances on the RX line (which are to be expected, in noisy motor control).
I am using a uart protocol which is under development right now. (have look at #72 for further information).

As for the values -1000 to 1000: This is the duty cycle for the motors. -1000 represents 100.0% duty cycle (full speed) backwards.

@amarotica
Copy link
Author

Please be careful with the default UART implementation. There is no feature to validate the input, you can get really bad speed values when there are disturbances on the RX line (which are to be expected, in noisy motor control).
I am using a uart protocol which is under development right now. (have look at #72 for further information).

As for the values -1000 to 1000: This is the duty cycle for the motors. -1000 represents 100.0% duty cycle (full speed) backwards.

Thanks for the info @p-h-a-i-l
I am going to give the fork you mentioned a look and maybe try it out. I am glad you mentioned the safety/reliability problem with the current setup because that is a really important part of the system that I have completely overlooked until now.

@Combinacijus
Copy link

So I took some time and modified serial communication code. As far from all of my tests it's smooth even for poorly connected data lines. Motors stops if data lines are disconnected You can find the code in my fork here:
https://github.com/Combinacijus/hoverboard-firmware-hack
There is also example code for Arduino which sends command via TX pin

@Combinacijus
Copy link

So I took some time and modified serial communication code on original NiklasFauth respository. As far from all of my tests it's smooth even for poorly connected data lines. Motors stops if data lines are disconnected. Reconnection also works well. You can find the code in my fork here:
https://github.com/Combinacijus/hoverboard-firmware-hack
There is also example code for Arduino which sends command via TX pin
But original code only have pwm control so you can't just set speed you want well at least it's really smooth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants