DRV8313 and solenoids

I read the datasheet of our beloved driver and saw it can also drive three electric magnets.
I was wondering, if a PWM signal would make it pull like a muscle or a linear actuator?

I have some JF-0530B with 24V/300mA spec. which I’d like to control.
Closed loop would be nice.

I don’t know if it would work. I think usually the actuation is caused by magnetic saturation of the core/shaft, which takes considerable amount of time. I have not seen solenoids used as anything other than two-state devices.

There is a basic test-program in the simpleFOC examples, which sets each output to a certain voltage.
I’ll write a routine that increases the voltage in the loop and see what happens.
In my imagination it’s not much different from a BLDC : bring magnetic fields in balance.
The e-magnets come with a spring, so there is some linear growing resistance against the magnetic attraction. The mag-attraction is not linear, which makes it hard to find the balance.

I modified the PWM test routine, but it didn’t show any signs the driver voltage would ramp up/down .
The magnet just moves to the endstop and stays there.
Did I misinterpret the purpose of driver.setPWM ?

// BLDC driver standalone example
#include <SimpleFOC.h>


// BLDC driver instance
BLDCDriver3PWM driver = BLDCDriver3PWM(13, 12, 14, 27);

void setup() {
  
  // pwm frequency to be used [Hz]
  // for atmega328 fixed to 32kHz
  // esp32/stm32/teensy configurable
  driver.pwm_frequency = 50000;
  // power supply voltage [V]
  driver.voltage_power_supply = 12;
  // Max DC voltage allowed - default voltage_power_supply
  driver.voltage_limit = 12;

  // driver init
  driver.init();

  // enable driver
  driver.enable();
  driver.setPwm(0.0,0.0,0.0);
  _delay(1000);
}

void loop() {
    // setting pwm
    for (int v = 0; v= 12000; v++){
      driver.setPwm(0.0+v/1000,0,0);
      _delay(100);
    }

    for (int v = 12000; v= 0; v--){
      driver.setPwm(0.0+v/1000,0.0,0);
      _delay(100);
    }
}

I think the v/1000 won’t get you exactly what you’re expecting… maybe v/1000.0f would be better…

Other than this the code should vary the PWM duty cycle from 0 to 100%

1 Like

I’ve already changed the loop to 0-12 and tried all_integer. But no changed behaviour.
I assumed the PWM would be in float, I’ll give your suggestion a try.
Else, I have to read the datasheet again. Maybe I’ve connected the e-magnet wrong.

Success!!
Embaracing to tell that the for loops were wrong.

for (int v=0; v< 1200; v++)...

Also I had way too much delay ( or not enough patience).

Anyway, the muscle starts to contract at around 6-7V until it finally snaps to endposition.
The relaxing is quite different. Once the magnet is in endposition, it holds there until the voltage drops to around 2-3V.
Those numbers highly depend on the (spring) load, so it will be necessary to add an angle-sensor loop.
I made a short video, but it’s too big to upload. Will post a YT-link

1 Like

Now that my extruder project is working (more or less), I can pick up this crazy idea.

I’m not sure, how to init a single coil motion system with a mag-sensor. The least I’ve seen here is a DC motor, but a solenoid accepts negative voltage but would still contract in the same way. (no direction change from reversed polarity).
I guess, I can try to init FOC by providing calibration angle and direction?
If not, I’d have to add a second e-magnet acting as a trizeps?

how is the encoder connected? it’s not trivial to change from linear motion (solenoid) to angular motion (encoder)?

also: do you have any designs for implementing bistable solenoids? I have a project where I want to have the solenoid to snap to one or the other direction. is the pulling force about the same as the pushing force in your experience?

Hi,
I’m still waiting for a bunch of cheap mag-sensors before I go to the drawing board.
The solenoid will pivot around the upper end while the actuator moves the knee with a balljoint. (where the sensor is placed)
I haven’t seen bistable solenoids before. It might be a much better solution, because they would move the other way when the polarity changes.
The release force of my e-magnets depend fully on gravity and the spring that sits on the shaft.

I also think of filling the coil with ferrofluid which has a much better permeability vs. air.
But that’s just a wet dream in the true sense of the meaning. The fluid would leak out everywhere…