Uncategorized

spv 0.1

ProjectsJun 305 / 5Jul 57h ago

Making a Rpi Pico Based Smart Vehicle

ProjectsJun 305 / 5Jul 57h ago

tlfong0110 4d

Pico Smart Vehicle, Part 1 – Controlling a DC motor.

(1) How do I describe my project?

Just now I browsed the projects category here and found not too many examples for me to learn how to properly present my project work in progress.

I jumped to the quick conclusion that there are no strict and fast rules on how to describe your work in progress projects. For one project I saw a brief introduction post, followed by short replies of comments and discussions. For another project I saw the project proposer posts some videos in his Instagram.

My feeling is that the general rule is to post short messages on my work in progress, so other interested readers might comment and make suggestions, so I can modify my project specification and requirements for along the way.

For my previous Micky Mouse toy Rpi projects, I used to post messages in forums, such as in rpi.org, and my favourite section is “Automation, sensing and robotics”.

An example post is this DC Motor Post

The rpi.org forum accepts imgur.com images, but does not entertain videos. So I usually upload YouTube videos about my work in progress. such as this:

tlfong01’s Step Motor Test Youtube Video 2021may1501step_motor_test_2021jul01011024×288 125 KB


(2) Now I am reading the following tutorial to learn how to use Pico to control a DC motor. tlfong01:

How to Use Your Raspberry Pi Pico With DC Motors (Using DRV8833, L298 or L9110S) – By Les Pounder, Tom’s Hardware 2021jan30

How to Use Your Raspberry Pi Pico With DC Motors (Using DRV8833, L298 or L9110S) – By Les Pounder, Tom’s Hardware 2021jan30

I usually summarize what I have learned by a sequence of pictures which also are useful for refreshing memory later, or for newbie readers to get a rough picture of what I am doing.

And I usually modify slightly or sometimes heavily the tutorial’s hardware setup and software configurations etc. By not just blindly following everything in the tutorial but trying new things make me learn things deeper and remember ideas harder.


pico_motor_2021jul07011024×314 75.3 KB


pico_motor_2021jul07021134×361 82 KB


I also study the tutorial’s software code twice, the first time separate code segments and explanations, and the second time, the complete code. I make sure I understand every statement of the complete code, before I modify it for my version of project. Now the complete code listing below.

import utime
from machine import Pin

motor1a = Pin(14, Pin.OUT)
motor1b = Pin(15, Pin.OUT)

def forward():
   motor1a.high()
   motor1b.low()

def backward():
   motor1a.low()
   motor1b.high()

def stop():
   motor1a.low()
   motor1b.low()

def test():
   forward()
   utime.sleep(2)
   backward()
   utime.sleep(2)
   stop()

for i in range(5):
	test()


(3) Now I following the above Tom’s Harware tutorial to use the Pico and a DC motor driver to move a motor.


pico_setup_2021jul01011024×778 171 KB


(3.1) I am using the Chinese Windows 10 Thonny python IDE. This way everything is simple: (a) No external power supply is needed for now. Of course an external power supply for the motor is required later.

(3.2) I am using a simple “toggle the system LED” program to make sure the Pico hardware is setup more or less OK. The test program listing and a run program sample output is shown below.

# Program Name
#   toggle_pico_system_led_v03.py - tlfong01 2021jul01hkt1531
# Configuration
#   Thonny 3.3.3, Windows 10 (64-bit), Python 3.7.9 (32-bit), Tk 8.6.9, USB COM Port #3
# Intepreter
#   Micropython (Rapsberry Pi Pico)
# Program Function
#   Toggle Pico system LED at GPIO pin 15
# User Guide
#   Run code to toggle LED from On to Off or Off to On

from machine import Pin

systemLed = Pin(25, Pin.OUT)
systemLed.toggle()

# END

# Sample Output - tlfong01 2021jul01hkt1537
# MicroPython v1.14 on 2021-02-02; Raspberry Pi Pico with RP2040

# Type "help()" for more information.
# >>> %Run -c $EDITOR_CONTENT
# >>> 


(4) Now I using a modified version of Tom’s Hardware tutorial demo program to move a DC motor. To make things as simple, as cheap, and as newbie safe/proof as possible, for this prototyping stage, I am not using the very popular L298N motor driver, but MX1509, which is more efficient. And for the motor, not that expensive N20 gear motor with encoder, but the cheapest TT130 yellow toy motor.

The basic test of driving only one motor is OK. The program listing is shown below. More documentation will come later.


# Program Name
#   move_dc_motor_v01.py - tlfong01 2021jul01hkt1629
# Configuration
#   Thonny 3.3.3, Windows 10 (64-bit), Python 3.7.9 (32-bit), Tk 8.6.9, USB COM Port #3
# Intepreter
#   Micropython (Rapsberry Pi Pico)
# DC Motor
#   TT130 DC3~6V DC Gear Motor - AliEXpress US$1
#   https://www.aliexpress.com/item/32855311589.html
# DC Motor Driver
#   MX1508 2~10V, 1.5A, Dual H-Bridge DC Motor Driver - AliExpress US$1
#   https://www.aliexpress.com/item/32688083107.html

# Program Function
#   Move DC motor forward, backward, and stop
# User Guide
#   Run code to move motor

import utime
from machine import Pin

motor1a = Pin(10, Pin.OUT)
motor1b = Pin(11, Pin.OUT)

def moveMotorForward():
    motor1a.high()
    motor1b.low()

def moveMotorBackward():
    motor1a.low()
    motor1b.high()

def stopMotor():
    motor1a.low()
    motor1b.low()

def test():
    print('  Begin move motor test()')
    moveMotorForward()
    utime.sleep(1)
    moveMotorBackward()
    utime.sleep(1)
    stopMotor()
    print('  End   test()')

for i in range(2):
    print('Test ', i)
    test()

# *** End of program ***

# *** Sample Output - tlfong01  2021jul01hkt1707
'''
>>> %Run -c $EDITOR_CONTENT
Test  0
  Begin move motor test()
  End   test()
Test  1
  Begin move motor test()
  End   test()
>>> 
'''



mx1508_dc_motor_driver_rr1024×650 205 KB

Pico, MX1508 motor driver, TT130 motor test video


References

(1) MX1508 2~10V, 1.5A, Dual H-Bridge DC Motor Driver – AliExpress US$1

/ to continue, …Reply

tlfong014d tlfong01:

Pico Smart Vehicle, Part 1 – Controlling a DC motor.

Pico Smart Vehicle, Part 2 – Controlling Two DC Motors.

  1. For Part 2 Controlling Two Motors, I will be using Piromoni Tiny2040 and N20 motors.

tiny_2040_2021jul0101677×703 193 KB


n20_motor_spec_2021jul01021116×586 177 KB

Testing Plan of Pico Smart Vehicle Part 2, Moving Two Motors

My testing/development plan is something like below.

(1) Modify the move one motor program to move two motors.

(2) Mount two TT130 motors on a TWD (TWo Wheel Driver) body, and write a small program to turn the robot car, first turn left, then turn right, then stop.

(3) Repeat Test (2) above, replacing TT130 motors by N2 motors.

/ to continue, …


References

(1) N20 DC3V/6V/12V RPM 7.5 to 6000 Micro Gear Motor – AmazonReply

tlfong0110 1d tlfong01:

Testing Plan of Pico Smart Vehicle Part 2, Moving Two Motors

It appears that I can no more edit/append my own post if it is two or three days old . So my workaround is “quote something and reply”. This makes my incremental short project progress report like a long blog, where other readers can comment and make suggestion in time. I am thinking of later using a blog site to report my progress, so the late readers can read a coherent article.

Update 2021jul04hkt1307

Errata: I just found out that this pi-top forum is using the Discourse software: Discourse (Software 2013 by Jeff Atwoodet al) – Wikipedia, which I never heard of, and therefore have misunderstood the working and restriction of newbie/low level users. Eg, I wrongly thought that I could not edit my own posts after a couple of days. Actually if I have gone up high levels, I can edit my own post within 30 days. Also Discourse seems to encourage “long form” input, and “infinite scrolling”, which I don’t have any idea about. I am used to StackExchange’s short form Q&A (Question and Answers), not discussion forums, so I need to change my mindset. Anyway, I need to know more about Discourse, before I can make up my mind how to present my project.


Anyway, now I am reading pi-top 4 DIY/Robotic Kit’s documents to get a rough idea of how their rovers look like, so my Smart Pico Vehicle (SPV v1.0) can follow their ideas somewhat. Here are the pi-top 4 references I am reading:

(1)pi_top_rover_2021jul03011134×589 129 KB

(2) pi-top 4 DIY

It appears that the pi-top 4 DIY edition is still a work in progress. So I think I can for now DIY my project Smart Pico Vehicle flexibly, perhaps also let other readers give brainstorming ideas.


So I am now reading more N20 motor documentation, and perhaps rapid prototyping a 4WD, ie Four Wheel Drive, with four N20 motors.n20_motor_spec_2021jul03011024×492 116 KB


This gloomy lock down Sunday morning I was browsing casually around the forum and I was glad to see other users also making 4WDs, using pi-top Robotic kits. I found them using “Mecanum Wheels” which I read long time ago, but never have a chance playing with the real thing. I think these strange looking wheels need advanced, scary maths. So for now, humble me will stick to simple, plain wheels.


SPV (Smart Pico Vehicle) v0.1 Assembly Notespico_4wd_2021jul04021024×503 167 KB


/ to continue, …


References

(1) How to use motor drivers with H-bridge and PWM input, to control direction and speed of DC motors? – EE SE Q&A, Asked 2020jul16, Viewed 1k times

(2) 10 Software Packages You Can Add to Your Pi-Top [4] – Elijah Phillips, 2020jun15

(3) Further – Easy to Use STEM Software for Schools – pi-top.com

(4) Raspberry Pi Pico by Raspberry Pi – ClassRoomEshop Hongkong/Taiwan HK$40
CLASSROOM eShop

Raspberry Pi Pico (board only)

Taiwan eShop: https://bit.ly/2MeEvNM  1 x Raspberry Pi Pico (board only) Raspberry Pi Pico, the new flexible microcontroller board from Raspberry Pi. Board Specifications Raspberry Pi Pico is a low-cost, high-performance microcontroller…Reply

tlfong017h tlfong01:

SPV (Smart Pico Vehicle) v0.1 Assembly Notes

pico_4wd_2021jul0402

/ to continue, …


I can no longer edit/append to my old post, so I continue by a reply.

I found Pi-top [4] Rover with ultrasonic sensor and camera too complicated. So I am thinking of using the simpler MMK (Motors and Motion Kit) as a reference.


pi_top_mmk_2021jul05011024×371 147 KB

In other words, I am starting off with a 2WD, and only later scale it up to a 4WD.


So I am assembling my Pico 2WD with 47mm diameter simple plain wheels. But I am jealous seeing other guys building 4WD’s with Mecannum wheels of 60mm diameter, I think. So I have decided to also use 60mm plain wheels, to make it easier to convert to Mecanum later.


spv_2wd_v01_2021jul05011024×313 103 KB


References

(1) Moebius 60mm Mecanum Wheel Omni Tire Compatible with TT Motor LEGOs for Arduino DIY Robot STEM Toy Parts – AliExpress US$25
aliexpress.com

25.77US $ 7% OFF|MOEBIUS 2020 HOT 60mm Mecanum Wheel Omni Tire Compatible…

Smarter Shopping, Better Living! Aliexpress.com

(2) Pi-top [4] 4WD Mecannum – forum.pi-top.com 2021may251

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.