Need help arduino control


#1

Hi…i m playing odrive a week…i like odrive…i need a sketch for arduinio…that will control odrive…
1 incremental encoder connected to arduino …and 1 encoder attached to hoverboard hub motor…i want that when i turn the encoder that connect to arduino ,the hub motor acts like the position of arduino encoder.
i tried but writing a sketch is chinese for me…do i need to pay for the sketch? Thnx


#2

Hello

You can use the ODrive Arduino library (https://github.com/madcowswe/ODrive/tree/master/Arduino/ODriveArduino). There is an example sketch you can work with and learn from.

The encoder from the hoverboard hub motor needs to be set up in the ODrive firmware via odrivetool. The process of setting up the encoder is well-described here (https://docs.odriverobotics.com)

Why would you want to control a hoverboard with an encoder? Isn’t it better to just have a potentiometer to do speed control? But if you want to read encoders using Arduino, I can recommend you to start with the encoder lib for Arduino (https://github.com/PaulStoffregen/Encoder)

If you are stuck somewhere, I am willing to find some time to help you.


#3

Thank you…i want to make position control…speed not important…i want to make something like that…


#4

Do you think odrive can handle that job on the first video?


#5

Yes, the odrive with the help of an arduino can accomplish what is in the first video.

Use the position (setPosition) part of the arduino example in the example link above. You would then be easily to take in position information of encoder not connected to the motor, and ouput that number to the odrive using setposition. This should accomplish what is in the first video.

Note, you will have to make sure that your pulses per revolution for each of the encoders are either the same or convert them to match each other.

Rough non programming flow:

  1. Get encoder position of separate encoder (example: 250)
  2. Set position of odrive motor using setPosition (example: 250)
  3. Output position data to serial to confirm positions match

Again, both encoders’ PPR will need to match for this to work.

Also, as lowiek said above, the hoverboard motors will need to be set up using the odrive firmware before being able to control with arduino if my understanding is right.


#6

Thanks a lot…i will try…