bipropellant / bipropellant-protocol

defines and implements a low level protocol shared between a few different hoverboard repositories
MIT License
20 stars 17 forks source link

Questions about using protocol and speed control #20

Closed AntumArk closed 5 years ago

AntumArk commented 5 years ago

Hello, Is there a feature for protocol to set speed setpoint and not increment them?

Also I have found how to send with machine protocol, but I am missing information about how to read it from another device.

Also there could be a feature to disable all safety features when you are only debugging communications.

btsimonh commented 5 years ago

ref safety features, i assume you mean power off... I just created https://github.com/bipropellant/hbprotocol/wiki/Hints-on-getting-started - feel free to add your expereinces.

Ref Setting speed rather than incrementing; you can't do this via the ASCII protocol, you must use the machine protocol.

So, there are two options:

1/ to set PID controlled speed demand in mm/s, use subcmd 03 to set 'speedData'. send a message containing the first two longs only (unless you want to change the max power settings). This will enable PID controlled speed on write.

2/ to set PWM directly (no PID control), use subcmd 0x0D or 0x0E to set 'PWMData'. send a message containing the first two longs only (unless you want to change the max power settings in 0x0D; 0x0E is ONLY the two long PWM values). This will enable PWM on write.

ref reading the machine protocol, the code is symmetrical, so you can take 'machine_protocol.c' from here, and use it in your controlling device. Personally, I use NodeRed and have a (incomplete) javascript implementation for testing. Indeed, I believe phail uses this repo as-is in an ESP32 based controller... but we could do with cleaning it up so that it has fewer external dependencies on the main repo.

AntumArk commented 5 years ago

Thank you! And about safety, I meant temperature and voltage measurements.

btsimonh commented 5 years ago

ahh.. no, not played with them. I think they are all defines - so depending on how you are building, either change in platformio.ini (if using platformio env builds), or in config.h (if using platformio normal build? - not sure here when config.h is used), or if using makefile? We probably need to do some cleanup of unused defines and make some of the values flash values.... There is one value in flash - MaxCurrLim.

AntumArk commented 5 years ago

Yes they are defines. At the end of the main, near timeouts. I am currently disabled them using new SAFETY definition. I am currently using platformio, but i am planning to migrate this project to Keil as I did with original hoverboard-hack. I think it would be easier for new people to use it in config.h instead of platformio. In addition it could be used on other platforms.

Is it a good idea to also include option to disable button controls? My current application is required for button to be always on as the power circuitry is disabled by external safety electronics.

AntumArk commented 5 years ago

I was able to implement ASCII protocol with C# application. After some tweaks I will try to implement machine protocol. By the way, I really like what you did with platformio enviroment variables. It is far easier to make changes now. Good work!

p-h-a-i-l commented 5 years ago

Thanks! You can also have a look at https://github.com/p-h-a-i-l/HoverboardAPI It's a work-in-progress C++ Wrapper for the protocol. I want to make an easy to use class to communicate with the board. Will be moved to this team soon.

p-h-a-i-l commented 5 years ago

Can we find your C# code somewhere?

AntumArk commented 5 years ago

Currently, no. I am planning to post it when I get protocol part separated from robot class I am using. This may happen within a week or two. Also it is not tested with motors.