DC MOTORS with Cobrapin

104 views
Skip to first unread message

Chuda BOY

unread,
Jul 4, 2025, 9:47:29 AMJul 4
to mpf-...@googlegroups.com

Hi there,


What do you think is the best way to connect a DC motor to the Cobrapin board so that it can rotate in both directions?

Let's say, for example, that I'm using a 12V (or 6V) motor. The Cobrapin board is powered by 48V (coils) and 5V (light).

Do I need an to think about an additional driver board (H-Bridge ?) / but then how to drive it with cobrapin ?

I think I understand the MPF settings logic, but the hardware part is still a bit difficult for me.

 

Many thanks - chudaboy

cobra18t

unread,
Jul 4, 2025, 6:57:33 PMJul 4
to MPF Users
If you want to go both directions, you are going to need an H-bridge driver. There are many available advertised for use with Arduino.

You could also consider a continuous rotation servo. It takes a little effort to ensure that the servo stays still when you want it to since they can drift slowly if not tuned.

What mechanism are you trying to make/control?

David

unread,
Jul 4, 2025, 10:03:09 PMJul 4
to mpf-...@googlegroups.com
There's quite a few ways you could achieve this - it may depend on the speed of direction change you require, number of operations etc, etc?

You can use a double pole changeover relay to flip the polarity supplied to your motor and another relay to control the on / off for the motor.

Cobra has capacity for two relay outputs, I think it uses the 5V supply to drive the relay coils, then the motor voltage is independent of Cobra.

Good luck, lets us know what you ended up doing.
--
You received this message because you are subscribed to the Google Groups "MPF Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpf-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mpf-users/CAKeeqv3N3%3D8WSnF2Rc0no8ouxECTiMxgPQNE6sXYG3QvMTNBSA%40mail.gmail.com.



Virus-free.www.avg.com
Message has been deleted

Chuda BOY

unread,
Jul 5, 2025, 9:25:37 AMJul 5
to mpf-...@googlegroups.com
Thanks
What I'm trying to do is quite simple. The requirements aren't very demanding in terms of direction change speed.
A simple translation along the vertical axis locks the ball at a height of 15cm using a magnet. Then, lower it to put it back into play. There would be three position sensors (up, down, and rest). The ball should move slowly to create a nice animation for the player.
Using relay outputs actually seems like a simpler solution to implement. I haven't looked into MPF yet. Do you think I could adjust the motor speed with PWM on the relay outputs? I doubt the relays are fast enough to handle this.
What do you think might be the advantage of using the coil outputs to drive an H-bridge? I'm afraid it might be difficult to find a bridge that accepts 48V.

Thanks once again, that really helps


David

unread,
Jul 5, 2025, 6:41:39 PMJul 5
to mpf-...@googlegroups.com
I think I would try to choose the motor and associate gearing to set the speed of movement, then just use the simple two relays as I described.  But I reckon whatever way you go you will need a fair bit of testing and a mock up.

You would not normally pwm a relay, (to slow and mechanical limitations)  but you could use a mosfet driven by a pwm output in place of the on / off relay for speed control.   I don't know if the relay outputs on Cobra's board can be pwm'd - maybe Thomas will comment?   If the relay outputs cannot be pwm driven then you need a mosfet with gate voltage that suits whatever you're driving it with - presumably this would be a coil output.

Also don't discount the previous idea of a servo - you can get some little one for rc cars that claim torques of 35 kg.cm 

Good luck.

cobra18t

unread,
Jul 6, 2025, 7:55:57 PMJul 6
to MPF Users
For something like that, you may consider a crank slider or scotch yoke mechanism where you don't need to change directions. These were done for games like Pinbot, Tommy, Demolition Man, etc. You can still get all the positions with the switches you mentioned.

If you still want bidirectional, you can use one output for a DPDT relay as suggested. You can then use another coil output to PWM the motor.

The relay/coil outputs are "open-drain" outputs. They are not necessarily 48V outputs. They just selectively connect that output to GND. If you want to control an H-bridge or other lower voltage device, you have to provide a pull up resistor to an appropriate voltage. 

Message has been deleted

Chuda BOY

unread,
Jul 8, 2025, 10:15:48 PMJul 8
to MPF Users
THANKS

What I'm trying to do is quite simple.

The requirements aren't very demanding in terms of direction change speed.

A simple translation along the vertical axis locks the ball at a height of 15cm using a magnet. Then, lower it to put it back into play.
There would be three position sensors (up, down, and rest). The ball should move slowly to create a nice animation for the player.

Using relay outputs actually seems like a simpler solution to implement.
I haven't looked into MPF yet. Do you think I could adjust the motor speed with PWM on the relay outputs? I doubt the relays are fast enough to handle this.


What do you think might be the advantage of using the coil outputs to drive an H-bridge? I'm afraid it might be difficult to find a bridge that accepts 48V.


Thanks once again.  That really helps

Chuda BOY

unread,
Jul 8, 2025, 10:15:52 PMJul 8
to MPF Users
very interresting.  thanks everyone

Chuda BOY

unread,
Aug 6, 2025, 4:36:36 PMAug 6
to MPF Users
This quick message is to thank you again for your help.
My first choice turned to using two coil outputs to drive an L298N module (H-bridge). The first tests are quite conclusive. I now need to refine and build a more serious model.
This video shows the result with a simulation using mpf (the position switches are simulated on the keyboard).

cobra18t

unread,
Aug 6, 2025, 6:26:50 PMAug 6
to MPF Users
That is great! Thanks for sharing.
Reply all
Reply to author
Forward
0 new messages