Distance Measuring Device

Hello. I’m Serkan. This is my first message. I’m happy to join your community.

I’m making a distance measuring device. 10 meters of rope is wrapped around the device. The reel will be connected to a bldc motor with a diameter of 80 mm. My goal is to keep the rope tight using simplefoc.

I’m thinking of buying this card. https://tr.aliexpress.com/item/1005005511197423.html

I have Magntek MT6835 SPI encoders. I can connect them to my precision cnc machine at work and calibrate them to very high accuracy rates.

Now let’s come to my questions;

1- The motor will always pull the rope in the same direction. I will limit the motor torque to 200 gr pulling force. The user will be able to pull and extend the rope by overcoming this force. When the rope is released, it will rewind with the same force without any slack in the rope. Is this scenario possible with simplefoc?

2- In another scenario, the user will enter a target measurement. For example, 274cm. When it starts to pull the rope, it will be able to pull the rope by exceeding the standard 200gr force. When the measurement reaches 274cm, the motor will resist pulling the rope more. However, if there is a negative movement, it should always be ready to wind with 200gr force. Thus, it will act like a mechanism that can be pulled like a spring up to 274cm and cannot be pulled any further. Is this possible?

3- Can I use MT6835 with Simplefoc? When I say something like 0x1234 (like) from SPI, it returns its position as 3 bytes (24bit). Except for the last 3 bits, the remaining 21bits are the position. How do I tell this to Simplefoc?

4- The software will use the position coming from the spi encoder to make foc. However, I need to transfer the position information to my computer instantly. I do not want to use a serial port because it will slow down the loops. Even a 1000hz sampling rate would be enough for me. What should I do?

5- The card I am thinking of buying seems to have SPI support, but I could not see the pins in the pinout section. Am I missing something?

Thank you so much for your help.

Hi @serkan ,

What you describe is possible with SimpleFOC, or at least, using the SimpleFOC library to drive the motor and adding your own layer of control on top.

Yes, no problem but how will you know when the rope is finished rewinding? How to differentiate this case from the case where the rope is stuck but not finished rewinding?

Yes, but how will you measure the distance? The motor (SimpleFOC) works in radians, and you can get the absolute angle like 200 radians. If the reel is 8cm diameter is has 8 x PI cm circumference, but the rope on the spool is changing the diameter as you unwind it, so the conversion from radians to cm is not exactly precise.
As long as you don’t need perfect precision I think you can use the radians x circumference / 2PI calculation.

Yes. Please see the SPI driver we have for this sensor in our drivers (SimpleFOC drivers library). It handles all the communication for you.

You could use the other outputs of the sensor like ABZ output or PWM output to interface to the computer, and use the SPI on the motor control side.

Not clear from the product description so you’d better ask for clarification. It seems to me because it’s ESP32 and you can reassign pins very flexibly, you could run 2 SPI sensors on the same SPI bus using the combination of sensor pins available on the two ports. But the pull ups you would expect to have on the I2C lines might interfere with the SPI… better to either ask, or just order one and try it out.

There were two similar efforts IIRC:

https://community.simplefoc.com/t/help-needed-in-designing-system/1836/1

https://community.simplefoc.com/t/using-bldc-motor-for-string-based-haptic-force-feedback/1082

Check those out.

Cheers,
Valentine

My paragliding simulator works in a similar way, so yes you can do it with the accuracy restrictions pointed out by @runger .