Xbox controller and accelerometer

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
aqua
Posts: 8
Joined: Wed Jan 12, 2011 4:53 pm
Contact:

Xbox controller and accelerometer

Post by aqua »

Hello everbody,
i'm building a RC car, a differential drive more precisley. Well, I don't really have a problem by programming but I don't know how to make my car go forward.
I have two motors and I must adjust their speed, how can i do this?

I want my Xbox controller control my robot. I got already an zigbee interface but here is my question: how do I programm the joystick? Because the flowcode example isn't clear enough. And can I use my Xbox controller as an input or must I configure something? (I've got a E-block usb).

Last question, if my Xbox controller works, how can i control my motors to accelerate with the left and right trigger?

Thanks for your help,
aqua.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Xbox controller and accelerometer

Post by Benj »

Hello,

In the articles section we have an article on driving DC motors. PWM is the name of the game for DC motor control. If you need direction control eg forwards and backwards then look up a H Bridge circuit. This uses a PWM control pin for speed and a second control pin for direction. 2 PWM pins plus 2 control pins would give you full direction and speed control for two motors.

XBOX controllers will be tricky as they are actually USB devices. I know because I use my old XBOX controllers with my PC. USB capable PIC devices can only act as a slave to a PC and therefore cannot host the USB to drive the controller. So unless you are going to open up the controller and start hacking into the analogue signals directly from the controller PCB you are out of luck using this controller.

Maybe a simple analogue joystick using a couple of linear potentiometers mounted at right angles would allow for an easier controlller input.

aqua
Posts: 8
Joined: Wed Jan 12, 2011 4:53 pm
Contact:

Re: Xbox controller and accelerometer

Post by aqua »

Hi,
thanks for your quick message. So I can't use a Xbox controler directly on a PIC, which controler could I use directly? A PS1 or PS2?

Since I'm mounting a camera on my robot, I will be able to see it on my computer, but how can I transmit what I'm doing to my Zigbee module and which app will be necessary to interface my Xbox controler and the zigbee module?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Xbox controller and accelerometer

Post by Benj »

Your best bet would be an analogue joystick eg the old 15-way d-type joysticks you used to be able to plug directly into the back of your PC motherboard. This can interface directly to a PIC chip.

Not sure of the PS1 or PS2 standards but im guessing that PS2 at least is also USB could be that PS1 is also USB too.

Im guessing the camera will be plugged directly into the PC and you will control the motors of the R/C car using a Zigbee module connected to the PC and another zigbee module connected to the car.

If this is the case then you can simply send commands through the zigbee RF channel and have your car interpret the commands as needed.

If your controlling the car from the PC anyway then you can still use your XBOX controller and then use a programming language eg VB or Pacal etc to read the XBOX controller and then send commands over the Zigbee.

aqua
Posts: 8
Joined: Wed Jan 12, 2011 4:53 pm
Contact:

Re: Xbox controller and accelerometer

Post by aqua »

Ok, but I'm not a pro on programm language. Do you think it would work on Visual programming language? Because I'm not sure that Zigbee will be compatible.

If that work the zigbee module must be connected with another PIC or directly on PC?

Regards,aqua.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Xbox controller and accelerometer

Post by Benj »

Hello Aqua,

This is not a straightforward project.

If you are not already an experienced coder then I would suggest you take one of the items eg communicating over zigbee and stick to that until you get it working. Otherwise your just going to end up frustrated and unable to proceed.

One step at a time is always better then trying to jump multiple hurdles and falling flat on your face :mrgreen:

aqua
Posts: 8
Joined: Wed Jan 12, 2011 4:53 pm
Contact:

Re: Xbox controller and accelerometer

Post by aqua »

yeah you're right,

I already made an example for Zigbee and it works. For the controler, I'm going to build one of my own the time I'm trying to learn new languages.

I finished my programm and it works.

So thank you for your help.

regards aqua

Post Reply