Model Boat Mayhem

Please login or register.

Login with username, password and session length.
Pages: [1]   Go Down

Author Topic: Cheap Mixer for 3 brushed motor control using Raspberry Pi Pico  (Read 5916 times)

JohnG

  • Full Mayhemer
  • *****
  • Offline Offline
  • Posts: 132
  • enjoying the learning
  • Location: Dorset


I’ve programmed a raspberry Pi Pico to run 3 brushed motors taking input from the RC receiver.   


How it works  can be summarised as :   


 - Read the PWM signals for motor and steering from the RC receiver and scale them to be between -1 and +1
 - Take the motor input:
          -Use this for the centre motor
          - For the Right Motor add on the Steering Input
          - For the Left Motor Deduct the Steering Input.


That means that in a tight turn the outer motor will run faster, and the inner motor slower, or even in reverse.  With a little juggling, the model will turn in its own length.


Responsiveness can be scaled  to as to how 'harsh' is the steering input, and also i throttle back the motors so they're not overpowered for the model. The program cycles (reads the input) approx every half second, which in practice seems fine as a response time.


The Hardware: The pico drives the 3  motors via ‘h bridge’ chips – I used VNH5019 boards. They’ve become expensive and rare with the chip shortage (£20 for a double board is the best I found recently, some other prices are plain ridiculous) .
Equally I’m pretty sure that for example a L298N board would work (I tried them on a different Pi model).   That would give a cost of £8 for 2 driver boards (each can control 2 motors) plus £4-£6 for a pico plus postage.   Pretty economical


The RC receiver, pico and h- bridges all run off a step down board set at 5v. The motors run at 12v from lipo batteries. The model is a 1/96 scale ww1 flotilla leader/destroyer  [size=78%]https://www.modelboatmayhem.co.uk/forum/index.php/topic,64903.0.html[/size][size=78%] [/size]


Caveats: I’m new to this – it works for me – finding out by trial and error.  One error for your amusement is that I found I had to fit a ‘shut down the program’ button, otherwise it’s impossible to interrupt the pico in order to modify the programming…. Just too foolproof!   Also these are not waterproof electronics – something I’m still thinking how to handle in my model.   


Anyone who’d like to know more – do either post here or PM me.


Links:
Pi Pico:


https://shop.pimoroni.com/products/raspberry-pi-pico?variant=32402092294227


H Bridge controllers:
I used vnh5019 chips/boards – unbranded version of the one sold by Pololu  (who kindly post the datasheet):

https://www.pololu.com/product/1451

They were far far cheaper when bought some months ago. With the chip shortage they’re barely available/much pricier at the moment. This is the most realistic price I found in a quick search at £20 for a double board:


https://www.amazon.co.uk/Tyenaza-VNH5019-Electronic-Controller-Protection/dp/B0B2DLXSTC/ref=sr_1_1_sspa?crid=146PIG2RDO0IH&keywords=vnh5019&qid=1654460019&sprefix=vnh5019%2Caps%2C173&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyOEdFWUQ4MU9IN0taJmVuY3J5cHRlZElkPUEwODIwMjM3MVdMTDYxREMzMU1NNSZlbmNyeXB0ZWRBZElkPUEwNTIwMzkwMTFHQlBEME8wSlVHVSZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=


L298n boards (controls 2 motors for £4) - cheaper but slightly heavier and less efficient.


https://www.ebay.co.uk/itm/154316484041?hash=item23edfaadc9:g:EKwAAOSwdg1gGarH&amdata=enc%3AAQAHAAAA4JIGkShBD12iDVM3yoelNzLgz4p2WTYI9pXMvxp%2BXeFthxdQmlIJN20aw5hMfVyTccQRihBuhRvQITN6d%2FKMjQS3gnz7um07tamcgRZVQ3Ygzl65V9qKWsAOi7N3ZRpbmDKpo5dSHbEcbnO1SopgqOEY1rZ2DAj9pONwFC42wLEd6FSg9fjd%2B9G6GiNzZAb3pTrdEkPNeGNRmA6NwFIaTbMvbVwxKtgXqOSK9DUsISbD5uh2DvFD8AJq%2F8qKb5wzaj4AW6x%2B3ES%2FE9cy7%2FLyxJkHvcb8abiFNtVQprzoOoIB%7Ctkp%3ABFBMsLKK2KZg


Step down board to supply power:


https://www.ebay.co.uk/itm/193924880627?hash=item2d26d2d8f3:g:oYgAAOSwQNxgt4zR&amdata=enc%3AAQAHAAAA8MyLcMn1nW8F3TNn6BwyQg17S2SEVDO%2Bxa05he5b37povS1UzSNxYEstttWKXbnJVIDA8FTM1uufVU8r9xkTWUUUC5SzHZRCB4mRRhRezkX13XNsfq1bxXBAHjyxnW%2FJ0Wjm07OHoFMIZufF4fmcnzWdBIKQIkSmGScHRx3LbRv1qiIM7BcMrU2sOuS2rYyjm%2B2kPdjmeWHhvCQl7B6s8euziBQCUfmU6HsxuVa%2FsbZdLOzwSEQG%2B9ALTRTeugV206lbkx4ONPDMYwnR%2FD4lBsZKva%2F%2BFC5PgtVFp%2B0wkTKN5wFgpkuMPiP88mBk3yVf6g%3D%3D%7Ctkp%3ABFBMqOLr2aZg




Motors (not at all critical to the setup - i may switch to smaller/lighter ones. these are overpowered and a little heavy. ).


https://www.ebay.co.uk/itm/254012848432

Logged

xanthar

  • Shipmate
  • *
  • Offline Offline
  • Posts: 9
  • Model Boat Mayhem is Great!
  • Location: US
Re: Cheap Mixer for 3 brushed motor control using Raspberry Pi Pico
« Reply #1 on: January 09, 2023, 07:26:50 am »

I'd like to know more about how you implemented this. Did you use C or Python? I'd like to do something similar : )
Logged

tsenecal

  • Full Mayhemer
  • *****
  • Offline Offline
  • Posts: 501
  • Location: Arvada, Colorado, USA
Re: Cheap Mixer for 3 brushed motor control using Raspberry Pi Pico
« Reply #2 on: January 10, 2023, 12:38:04 am »

the only recommendation i would make is to simply have the pico output 3 servo pwm signals.  allow the user to buy and use his or her own ESC (brushed or brushless) to actually drive the motors, and reduce the initial cost of the hardware...
Logged

xanthar

  • Shipmate
  • *
  • Offline Offline
  • Posts: 9
  • Model Boat Mayhem is Great!
  • Location: US
Re: Cheap Mixer for 3 brushed motor control using Raspberry Pi Pico
« Reply #3 on: January 10, 2023, 03:14:12 pm »

@tsenecal , Might you have any example code for reading PPM on a pico ?
Logged

tsenecal

  • Full Mayhemer
  • *****
  • Offline Offline
  • Posts: 501
  • Location: Arvada, Colorado, USA
Re: Cheap Mixer for 3 brushed motor control using Raspberry Pi Pico
« Reply #4 on: January 11, 2023, 12:53:07 am »

@tsenecal , Might you have any example code for reading PPM on a pico ?

do you want to read ppm (one signal with all servo positions in a stream), or pwm (each connection is a single servo)?
Logged

JohnG

  • Full Mayhemer
  • *****
  • Offline Offline
  • Posts: 132
  • enjoying the learning
  • Location: Dorset
Re: Cheap Mixer for 3 brushed motor control using Raspberry Pi Pico
« Reply #5 on: January 12, 2023, 10:46:04 am »


Hi @tsenecal, just spotted your post.

the implementation is in python on the pi pico.

I'm very much a hobby programmer, so the code is functional rather than elegant.

it's here:

https://drive.google.com/file/d/1yghsZvpDdCMyusUHh8I2QfBF6UTTwZw2/view?usp=sharing

as you'll see i added sections (that could be stripped out) for:
- led control
- shut down of pico
- limp home if battery voltage drops

the biggest question i had was whether the approx 0.5 second cycle time was too slow, but in practice it seems to work fine.

The link isn't a permanent one, so take a copy.  I  hope this is helpful. 
Logged

xanthar

  • Shipmate
  • *
  • Offline Offline
  • Posts: 9
  • Model Boat Mayhem is Great!
  • Location: US
Re: Cheap Mixer for 3 brushed motor control using Raspberry Pi Pico
« Reply #6 on: January 12, 2023, 02:17:02 pm »

@JohnG.  Thank you for sharing that python code.  That's very helpful : )
Logged

JohnG

  • Full Mayhemer
  • *****
  • Offline Offline
  • Posts: 132
  • enjoying the learning
  • Location: Dorset
Re: Cheap Mixer for 3 brushed motor control using Raspberry Pi Pico
« Reply #7 on: January 12, 2023, 04:47:15 pm »

@xanthar, Happy to assist. If you use it, do post an update.
Logged

xanthar

  • Shipmate
  • *
  • Offline Offline
  • Posts: 9
  • Model Boat Mayhem is Great!
  • Location: US
Re: Cheap Mixer for 3 brushed motor control using Raspberry Pi Pico
« Reply #8 on: November 11, 2023, 12:16:35 am »

do you want to read ppm (one signal with all servo positions in a stream), or pwm (each connection is a single servo)?
PPM please : )
Logged
Pages: [1]   Go Up
 

Page created in 0.094 seconds with 22 queries.