Raspberry Pi + MSP430 controlling Tamiya TT-01 RC car


21 posts
by Robo » Mon Apr 01, 2013 10:16 am
Image

http://i.imgur.com/LVMqyHp.jpg

Here's the video of it working:

http://youtu.be/plBGQRBN6Qo

The Pi is powered by an USB battery pack, the MSP430 is mounted on the breadboard, powered by the 3v3 GPIO from the Pi, commands are sent to MSP430 using UART. This all means there's very little wiring.

The Pi is setup as a wireless access point so devices can very easily connect to it, it runs a server listening to commands. I originally was going to make it run in WiFi ad-hoc mode, but access point is easier to connect.

There's no Arduino because Ti MSP430 is way cheaper and takes up very little space. A huge advantage is it can be detached from the development board.

Currently it's controlled by laptop, but it wouldn't be difficult to make an Android app for it.

The Tamiya TT-01 is way too fast for what I need to do, it gets to 60km/h, and 80km/h with LiPo battery. However, since I bought second hand choices are limited. This car is way more robust than anything home made, it can take a beating, and spare parts will always be available.
Posts: 23
Joined: Fri Sep 21, 2012 6:39 am
by joan » Mon Apr 01, 2013 11:16 am
Good job.

How did you identify the pins to connect to on the car's controller chip?

Pity the Launchpad is now $9.99. It's a more powerful chip now though.
User avatar
Posts: 5981
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Robo » Mon Apr 01, 2013 11:29 am
I'm not sure I understand the question. The only thing I've connected from the car is the servo and the ESC, both use the red/black/white wires, the white one being the signal wire receiving PWM signal.

So, controlling the servo and ESC is identical, in fact in my code I call them servo1 and servo2.

Didn't realise the price gone up on the Launchpad, Element 14 and RS in my area still have stock left at the old price.
Posts: 23
Joined: Fri Sep 21, 2012 6:39 am
by joan » Mon Apr 01, 2013 11:49 am
Robo wrote:I'm not sure I understand the question.
...

You use a different approach. On my cheapo RC cars I try to tap into the controller module and simulate the L/R F/B pulse being received from the radio transmitter. I've not considered detaching the servo cables as I'd assumed I'd then have problems supplying the power. Time to open up the cheapo RC cars again and have another look.

Odd on the TI's. The UK Farnell Launchpads are currently priced at £4.06, which is only 50p or so more than they were some months ago. Perhaps TI has had a change of heart. The USD price went from $4.30 to $9.99, which was reflected in the UK price a couple of weeks ago.
User avatar
Posts: 5981
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by simplesi » Mon Apr 01, 2013 11:55 am
I can imagine a little Shrimp circuit http://shrimping.it/blog/shrimp/ would be even lower cost :)

(Mind you - I just googled for the TT-01 - the price of the controller is not significant!!! - its out of my pocket money range)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
Posts: 2107
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
by simplesi » Mon Apr 01, 2013 11:56 am
But if there are cheaper vehicles that just need 2 PWM signals then I'd be VERY interested in them :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
Posts: 2107
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
by Robo » Tue Apr 02, 2013 1:14 am
simplesi wrote:(Mind you - I just googled for the TT-01 - the price of the controller is not significant!!! - its out of my pocket money range)

Simon


Preciously why I bought second hand! I didn't need to put it together myself, it came with everything, plus the motor, ESC, and other parts were already upgraded.

Having said that, TT-01 is a kit, so it's way more hackable than a cheapo RC car, and a lot more fun.
Posts: 23
Joined: Fri Sep 21, 2012 6:39 am
by Robo » Tue Apr 02, 2013 1:22 am
joan wrote:You use a different approach. On my cheapo RC cars I try to tap into the controller module and simulate the L/R F/B pulse being received from the radio transmitter. I've not considered detaching the servo cables as I'd assumed I'd then have problems supplying the power. Time to open up the cheapo RC cars again and have another look.


I see what you mean now. Yes you will have problem supplying the power, the servo requires 4.8 to 6v.

In a regular TT-01 setup, the car battery is connected to the ESC, and the ESC's red/black cable supplies power to the RC receiver and servo. On my circuit the servo's red/black cable is directly connected to the ESC.
Posts: 23
Joined: Fri Sep 21, 2012 6:39 am
by searchplex » Wed Apr 03, 2013 4:24 am
Hi,

I am doing the same thing with Raspi and MSP430 launch pad, but have a lot of isues reading / writing to the UART over usb (I have connected MSP LP to the USB of the RASPI to power it up and read serial) it is recognized as ACM0 but nothing gets transferred over serial!! seems the driver on Raspi is broken or faulty or it is recognizing the MSP as something else, do you mind explaining if you are using usb to communicate between the two? and would be great to see some of your codes :-)

Cheers
Posts: 1
Joined: Wed Apr 03, 2013 4:20 am
by Robo » Wed Apr 03, 2013 4:59 am
searchplex wrote:Hi,

I am doing the same thing with Raspi and MSP430 launch pad, but have a lot of isues reading / writing to the UART over usb


I'm using UART to communicate, but not over USB. In fact, I don't even know how to do that, is there an advantage?

If you look at my image, the white wire from the Pi to the MSP430 is the one sending UART signal. It goes from Pi's UART pin to MSP430's UART pin (marked TXD on the MSP430 board which was misleading me initially).

On the Pi, I used wiringPi's wiringSerial library, on MSP430, I used this guy's harduart library (uart.c):

https://github.com/wendlers/msp430-harduart

Both libraries work out of the box, no modification needed, simple to use.

I bought the Saleae Logic Analyser for debugging. It's a bit pricey but it really did helped. If you already have an oscilloscope that probably works as well, but I didn't have one to start with.

Let me know if I can help with anything else.
Posts: 23
Joined: Fri Sep 21, 2012 6:39 am
by mikerr » Wed Apr 03, 2013 3:25 pm
joan wrote:
Robo wrote:I'm not sure I understand the question.
...

You use a different approach. On my cheapo RC cars I try to tap into the controller module and simulate the L/R F/B pulse being received from the radio transmitter. I've not considered detaching the servo cables as I'd assumed I'd then have problems supplying the power. Time to open up the cheapo RC cars again and have another look.


This type uses regular servo control as its a more expensive modular car kit - the "cheapie" cars (<£100) are their own non standard electrics.

This thread reminds me I still have old kyosho optima mid and yokomo super dogfighters sat the loft waiting to gut/refurbish,
looking on ebay they seem to have gone up in value :shock: so may have to be the latter
Got a Pi Camera? View it in my android app - Raspicam Remote ! No software required on the pi
User avatar
Posts: 1250
Joined: Thu Jan 12, 2012 12:46 pm
Location: NorthWest, UK
by nicknml » Tue Apr 16, 2013 4:08 pm
searchplex wrote:Hi,

I am doing the same thing with Raspi and MSP430 launch pad, but have a lot of isues reading / writing to the UART over usb (I have connected MSP LP to the USB of the RASPI to power it up and read serial) it is recognized as ACM0 but nothing gets transferred over serial!! seems the driver on Raspi is broken or faulty or it is recognizing the MSP as something else, do you mind explaining if you are using usb to communicate between the two? and would be great to see some of your codes :-)

Cheers

Yea it would be nice to get serial communications to work over USB for the MSP430. At least the Raspberry Pi plays nicely with my Arduino when it comes to serial over USB communications.
User avatar
Posts: 195
Joined: Thu Mar 15, 2012 8:44 pm
by Edmond » Fri Sep 26, 2014 1:17 pm
Hi Robo,
What does MSP430 do in your project?
Is it possible to use Raspberry Pi directly to control Tamiya TT-01?
Posts: 3
Joined: Fri Sep 26, 2014 1:12 pm
by Robo » Fri Sep 26, 2014 8:01 pm
Hi, we need to send PWM (pulse width modulation) signals to the throttle and servo of the Tamiya. The Pi is running Linux and not a real time operating system, so it can't send accurate pulse width signals. That's what the MSP430 is for.
Posts: 23
Joined: Fri Sep 21, 2012 6:39 am
by joan » Fri Sep 26, 2014 8:19 pm
Robo wrote:Hi, we need to send PWM (pulse width modulation) signals to the throttle and servo of the Tamiya. The Pi is running Linux and not a real time operating system, so it can't send accurate pulse width signals. That's what the MSP430 is for.

The Pi can send accurate PWM on multiple channels, e.g. my pigpio. It's likely to be a lot more flexible that the Launchpad as well.
User avatar
Posts: 5981
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Robo » Fri Sep 26, 2014 8:28 pm
OK, I tried using WiringPi library before, and it didn't work.

https://projects.drogon.net/raspberry-p ... m-library/

It was fine for blinking some LEDs, but wouldn't move a servo.

Can you give some description on how your library works?
Posts: 23
Joined: Fri Sep 21, 2012 6:39 am
by joan » Fri Sep 26, 2014 8:38 pm
Robo wrote:OK, I tried using WiringPi library before, and it didn't work.

https://projects.drogon.net/raspberry-p ... m-library/

It was fine for blinking some LEDs, but wouldn't move a servo.

Can you give some description on how your library works?

Servo and PWM pulses are generated by the DMA hardware independently of Linux. Once programmed there is no more software involvement unless a servo/ESC pulse width or a PWM dutycycle is changed.

Servos default to 50Hz updates at 5 microsecond resolution (can be increased to 400Hz and 1 microsecond). PWM defaults to 800Hz with dutycycles 0(off) to 255 (fully on). All (accessible) gpios can be independently controlled (in frequency, pulsewidth/dutycycle).
User avatar
Posts: 5981
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Edmond » Fri Sep 26, 2014 9:49 pm
joan wrote:
Robo wrote:OK, I tried using WiringPi library before, and it didn't work.

https://projects.drogon.net/raspberry-p ... m-library/

It was fine for blinking some LEDs, but wouldn't move a servo.

Can you give some description on how your library works?

Servo and PWM pulses are generated by the DMA hardware independently of Linux. Once programmed there is no more software involvement unless a servo/ESC pulse width or a PWM dutycycle is changed.

Servos default to 50Hz updates at 5 microsecond resolution (can be increased to 400Hz and 1 microsecond). PWM defaults to 800Hz with dutycycles 0(off) to 255 (fully on). All (accessible) gpios can be independently controlled (in frequency, pulsewidth/dutycycle).



So our conclusion is that we could use Raspberry Pi directly to control Tamiya TT-01?
Posts: 3
Joined: Fri Sep 26, 2014 1:12 pm
by joan » Fri Sep 26, 2014 10:21 pm
Edmond wrote:
joan wrote:
Robo wrote:OK, I tried using WiringPi library before, and it didn't work.

https://projects.drogon.net/raspberry-p ... m-library/

It was fine for blinking some LEDs, but wouldn't move a servo.

Can you give some description on how your library works?

Servo and PWM pulses are generated by the DMA hardware independently of Linux. Once programmed there is no more software involvement unless a servo/ESC pulse width or a PWM dutycycle is changed.

Servos default to 50Hz updates at 5 microsecond resolution (can be increased to 400Hz and 1 microsecond). PWM defaults to 800Hz with dutycycles 0(off) to 255 (fully on). All (accessible) gpios can be independently controlled (in frequency, pulsewidth/dutycycle).



So our conclusion is that we could use Raspberry Pi directly to control Tamiya TT-01?

Yes. The Pi should be just as capable as an Arduino/Launchpad in this respect.

One day I'll spend some time and see just how stable Arduino/Launchpad PWM pulses are compared to the Pi.
User avatar
Posts: 5981
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Edmond » Mon Oct 13, 2014 10:25 pm
Joan
How do you know the servo frequency is 50Hz?
I am trying to control the servo in my ECX Torment Truck, but it does not work very well (not working as what I suppose.
The servo is SPMS 401 and the code I am using is

import time
import RPi.GPIO as GPIO

GPIO.setwarning(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.OUT)

p.GPIO.PWM(18,50)
p.start(7.5)

while 1:
try:
p.ChangeDutyCycle(7.5)
time.sleep(1)
p.ChangeDutyCycle(12.5)
time.sleep(1)
p.ChangeDutyCycle(2.5)
time.sleep(1)
except(KeyboardInterrupt):
GPIO.output(18,False)
quit()


I don't know if I am using the wrong duty cycle?
Posts: 3
Joined: Fri Sep 26, 2014 1:12 pm
by joan » Tue Oct 14, 2014 7:55 am
The update rate isn't really crucial as long as it's between the limits the servo expects. It's the pulse width which is important. Usually a 1500us pulse centres the servo, a 1000us pulse goes to one extreme, and a 2000us pulse goes to the other extreme.

Servos vary in the extremes they accept. Telling a servo to go beyond its extremes can damage the servo.

With 50 updates per second each time slot is 20000us long.

A duty cycle of 7.5% is on for 7.5*20000/100 us or 1500us which means you get a 1500us long pulse 50 times per second.

Similarly 12.5% gives a 2500us pulse. 2.5% gives a 500us pulse. Both these are outside the range of normal servos. You need to confirm your servo can cope.

For safety its best to keep the duty cycle between 5 and 10% until you have tested your servos limits.

RPi.GPIO uses software PWM and your servo is likely to twitch.
User avatar
Posts: 5981
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK