User avatar
winkleink
Forum Moderator
Forum Moderator
Posts: 288
Joined: Mon Nov 07, 2011 9:12 am
Location: UK

Help: Using GPIO to control a remote control car

Mon Jan 14, 2013 11:25 pm

I'm looking to use the GPIO pins to control a remote control car by activating the switches in the controller using a transistor as a switch.
The controller is powered by 2 AA batteries (3V) and the pins for the different controls are tied high normally. When the switch is activated the pin is tied to Zero (-)

I was considering the following attached circuit and before I wire it all up I thought it might be a good idea to make sure I have it right. I have basic-ish knowledge of electronics and don't want to damage my Raspberry Pi
g3075.png
g3075.png (38.69 KiB) Viewed 3377 times
In my head this ties the pin to 3V until a Base current is applied.
When the current is applied the circuit effectively become 3V - R1 - Pin - Q1 (0Ohm) - OV, so Pin is tied to 0V.

Also, any suggestions for R1 and R2

My Guess
R1 - 1KOhm
R2 - 10KOhm (Base)

I checked the current across the switches (so inline) and it was reading 0.1mA. With a 10KOhm resistor and 3.3V from the GPIO I would be providing 0.33mA (I think), so way more than enough to saturate the Base.

Any and all tips appreciated. You could save a Raspberrp Pi from being being fried...

Thanks,
Albert.
Twitter:Winkleink
Google+: Winkleink

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am

Re: Help: Using GPIO to control a remote control car

Mon Jan 14, 2013 11:39 pm

Yep, looks all good.
I have basic-ish knowledge of electronics and don't want to damage my Raspberry Pi
You have done all the right things, measured the correct currents and calculated all the values fine.
I have seen posted data much, much worse then this.
In fact if everybody put as much work in us 'experts' wouls have only a fraction of corrections to do.

One final point: you might want to add a 10K resistor between base and ground.
That way the circuit is in a defined state during booting when some GPIOs are set to input mode.

User avatar
winkleink
Forum Moderator
Forum Moderator
Posts: 288
Joined: Mon Nov 07, 2011 9:12 am
Location: UK

Re: Help: Using GPIO to control a remote control car

Mon Jan 14, 2013 11:46 pm

Gert van Loo wrote:Yep, looks all good.
I have basic-ish knowledge of electronics and don't want to damage my Raspberry Pi
You have done all the right things, measured the correct currents and calculated all the values fine.
I have seen posted data much, much worse then this.
In fact if everybody put as much work in us 'experts' wouls have only a fraction of corrections to do.

One final point: you might want to add a 10K resistor between base and ground.
That way the circuit is in a defined state during booting when some GPIOs are set to input mode.
Gert, thank you. My head is swelling getting a comment like that from the Gertboard man.
Also, thanks for the pointer on the additional resistor.

The plan is to have this working for the Egham/Staines Raspberry Jam on Sunday so your extremely prompt reply id hugely appreciated.

Albert.
Twitter:Winkleink
Google+: Winkleink

User avatar
winkleink
Forum Moderator
Forum Moderator
Posts: 288
Joined: Mon Nov 07, 2011 9:12 am
Location: UK

Re: Help: Using GPIO to control a remote control car

Wed Jan 16, 2013 10:50 pm

Yeah.

I built the circuit and it worked. Not yet with a Raspberry Pi. As the Raspberry Pi is the newest piece for me I wanted to make sure all the other bits were sorted so that when I mess up on the Raspberry Pi piece I know it is only that bit I have to troubleshoot rather than thinking maybe the circuit was wrong.

I tested using an Arduino and successfully has the car going forward, backwards and turning left and right.

Tomorrow night is the Raspberry Pi bit...
Twitter:Winkleink
Google+: Winkleink

User avatar
Burngate
Posts: 6546
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore

Re: Help: Using GPIO to control a remote control car

Thu Jan 17, 2013 11:26 am

Looking forward to seeing it working, Sunday!

User avatar
winkleink
Forum Moderator
Forum Moderator
Posts: 288
Joined: Mon Nov 07, 2011 9:12 am
Location: UK

Re: Help: Using GPIO to control a remote control car

Thu Jan 17, 2013 1:13 pm

Burngate wrote:Looking forward to seeing it working, Sunday!
So, am I. :D
Twitter:Winkleink
Google+: Winkleink

Return to “Interfacing (DSI, CSI, I2C, etc.)”