I have a Raspberry Pi 2 model B. I would like to be able to control a motor with a regulator and PI4J.

I put the black cable to a ground pin and the PWM pin to pin 26. I've worked with servos before, so I tried to start the motors like a servo. It didn't work.

The ESCs: Kontronik CYBEC 40-6-12

The motors are Brushless: I'm sorry but I don't know what make.

public static void move(int power) throws InterruptedException
    SoftPwm.softPwmCreate(26, 0, 50); 
    SoftPwm.softPwmWrite(26, power); 
  • A picture of your setup, and your code would be very helpful in answering your question. – Jacobm001 May 10 '16 at 15:48
  • Here is the code that i use on the Rasp: codepublic static void move(int power) throws InterruptedException{ System.out.println("MOVE_ENG"); Gpio.wiringPiSetup(); SoftPwm.softPwmCreate(26, 0, 50); SoftPwm.softPwmWrite(26, power); }code – cy8berpunk May 10 '16 at 16:00
  • Thank you for the code. For future reference though, please add information via an edit. It's much easier to read! ;) – Jacobm001 May 10 '16 at 16:39
  • Ok sry....Can you help me anyway? – cy8berpunk May 10 '16 at 16:53
  • Not really. I've never worked with programming motors or pi4j. I was just trying to make sure your question was setup for the inevitable questions of those who can. – Jacobm001 May 10 '16 at 16:54

If I understand correctly you want to control a brushless motor which is being driven by an ESC (Kontronik CYBEC 40-6-12).

ESCs are controlled in a very similar way to servos. However they often require a particular start sequence for safety reasons (you don't want your model plane to fly off when the ESC is energised).

I suggest you try something like

one second at 1000 µs pulse width

followed by

one second at 2000 µs pulse width

That may initialise the ESC. You can then send pulse widths in the range 1000 (stop) to 2000 (full throttle) to control the speed.

If you are planning to do this seriously you'll need to use something like my pigpio or servoblaster to send the pulses, or buy external PWM hardware,

  • Thank you :D Can please edit my Code so that it would work..... – cy8berpunk May 11 '16 at 8:22
  • I have used wiringPi but am not that familiar with the detailed workings. You will need to look at the wiringPi software PWM functions and work out which dutycycle means 1000, which 2000 etc. – joan May 11 '16 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.