NEED HELP-- Basic Forward and Backward 2.4ghz RC Car

Hi everyone,
I am VERY new to using arduinos and have very little (Almost no) experience working with code. A while back, a friend asked me to work on a project for him. He wanted a basic rc car that could just move forward and backwards and be controlled by a small remote from about 100 yards away. I started by ordering the components to an rc car using an ESC from ebay and a 2.4ghz transmitter and receiver from Hobbyking. I removed all the electrical components from the transmitter and found that the board on it would be too big for my project. Wanting to have the smallest system possible, I ordered a microduino core + and nrf24 transceiver module. I want to continue using only the receiver from the hobbyking setup, but I would like to use the Microduino unit instead of the hobbyking transmitter. Does anyone know if this is possible? How would I start the code? Has anyone else used this microduino 2.4ghz module? I have not been able to upload the sample code to the unit because the IDE gives me several error messages. (I DO have the microduino configuration files for the IDE). I Am not sure how to program with the transceiver module.

here are the parts I want to use-
ESC- http://www.ebay.com/itm/320A-Brushed-Brush-Speed-Controller-ESC-w-Reverse-for-RC-Car-Truck-Boat-1-8-1-10-/310879535602?pt=Radio_Control_Parts_Accessories&hash=item4861dd41f2

Hobbyking Receiver-Radio Control Planes, Drones, Cars, FPV, Quadcopters and more - Hobbyking36509__HobbyKing_GT_2_2_4Ghz_Receiver_3Ch_US_Warehouse.html

Microduino Nrf24 (For transmitting to the hobbyking receiver)- http://www.microduino.cc/Modules/Microdoino%20Extension%20Modules/nRF24

Thanks for the help!

Hi,

That's a very interesting idea. I'd not thought of using one of these nRF24L01+ modules for a transmitter for RC before, but after a short read found it is a GFSK radio just like that HK GT-2 receiver, and even found this youtube video which pretty much shows a proof of concept for what you're suggesting.

It does seem feasible - have you seen someone else do this before? There is a lot of chatter over at the RCGroups.com forums about home-grown transmitters. I got a heap of hits searching for nRF24L01 so hopefully there's good information in there.

All the best with your project,
Geoff

Thanks! With that video, at least now I know that it can actually be done. A lot of the other arduino transmitters that I have seen before use an arduino on both the receiving end and the transmitting end. For the sake of cost, I would prefer not to have to go out and buy another arduino (or microduino). I will search that forum for more info. Thanks!

I've hacked the 6CH HobbyKing transmitter for a really cool project. All you need is the 1"x1" square 2.4Ghz radio module inside the transmitter. You don't need anything else. You'll need to supply 5V to this module and use a digital I/O pin connected to the PPM signal. You'll also put the "SW" pin to 5V high. Then you just need to output a PPM signal (not the same as PWM) on that digital pin. Fortunately others have already done the hard work for you. I'm using an interrupt timer that encodes the PPM for me. You set how many channels you are using (This can be 1 through 6) and then you just set output value for each of the channels. The interrupt code handles the rest. Here's a demo of this working in my custom transmitter:

I even have a PCB shield that I designed specifically for this which is open source and you can use if you want to. Here's the complete build thread:

Wow! that is a nice setup! I was considering trying to remove the transmitter from the hobbyking unit, but none of the pins are labled... I was able to figure out which pins were GND and +5v with a volt meter but I don't know which pins are for the SW or PPM. Where did you get the interrupt code? Do you think that using the hobbyking transmitter is going to be easier than using the Microduino transceiver Module?

Xpendable:
I'm using an interrupt timer that encodes the PPM for me.

Does that produce accurate timing? It sounds like the same approach used by the Servo library, and people who've examined the Servo output on a scope say it suffers from quite a lot of timing jitter.

I do know that there are a couple of variations on the transmitter. The PCB on mine was labelled, so I guess I was lucky?

Here's the source code I used to generate my PPM signal:

I modified it slightly for my purposes, but didn't change how it works. Basically I time the output of the data signal for my NeoPixel RGB LED's during the reset pulse of the PPM since the NeoPixels needs the interrupts to be disabled during that transmission, and the PPM reset pulse is the perfect pulse to send that data since it won't mess up the PPM signal if it's only a few pixels.

Here's another video that shows the radio module I have:

PeterH:
Does that produce accurate timing? It sounds like the same approach used by the Servo library, and people who've examined the Servo output on a scope say it suffers from quite a lot of timing jitter.

The original code I started with by some user on rcgroups named HASI actually gave a lot of jitter and generally didn't work very well. Then I found the code here:

And it is virtually jitter free as long as you don't do something that messes with it. For example, if you happen to use the i2c bus, you should time the data to bursts during the PPM reset pulse so as not to interfere with the PPM signal. I had to do this with my Adafruit NeoPixels. I actually had to change their library a little bit. I am using a NewHaven display that has serial, i2c, and SPI interfaces. I tired converting to i2c but you have to set the i2c bus to 100Khz max for it to work and it takes too long to clock out the data... it will screw up the PPM. But changing the NewHaven display to do serial worked for me and kept the PPM honest.

This is where I need to do research on how to write code... haha. I pretty much know nothing about code, so I should probably spend some time learning how to adjust everything to my needs... This is probably a really stupid question, but what do all of the "i" s mean in the program?

You’re going to have a really tough time getting it to work if you don’t know the first thing about programming.

The “i” is a variable.

int i = 0;

This creates a variable named “i” of type “int” which means “integer” and has been initialized to the value of 0. An int is a 16-bit integer that can hold any value between -32768 and 32767.

for(i=0;i<NB_WAY;i++)
{
...
}

This is a called a “for loop”. It’s purpose is to execute the code between the braces { } repeatedly until the condition specified is no longer true. There are 3 parameters to a for loop. The first parameter is the variable that will be used as the “iterator” (i.e., counter) each time through the loop. The second parameter is the condition you want to test for. The last parameter is what should happen to the iterator after each time through the loop. Let’s break it down:

i=0;
This sets the variable “i” to 0. We know this variable is an int because that was defined by another line of code higher up in the program.

i<NB_WAY;

This basically translates to: Keep executing this loop while the value of “i” is less than (<) the value of variable NB_WAY. At the top of the program NB_WAY is set to 6. So as long as i < 6, the loop will keep executing.

i++
This is a shortcut for saying “i = i + 1”; It takes whatever value that is current in the variable i and it increases it by 1.

So when the loop first executes, i = 0.
The second time it executes, i = 1.
The third time it executes, i = 2.
The fourth time it executes, i = 3.
The 5th time it executes, i = 4.
The 6th time it executes, i = 5.
Now just before it executes a 7th time, i= 6. Since 6 is NOT < 6, the for loop terminates and execution continues on to the code that appears after the closing brace “}” character.

I suggest you start going through some of the “getting started” projects to build up your knowledge.

Yeah, I have not had time to research how to write code, but now with summer here, I will have more free time to work on this and actually learn how to make an appropriate program for my project. I really appreciate all your help! In the future, I may need to make another one of these and if I can, I would prefer to not have to buy the hobbyking transmitter. Do you think that the microduino transmitter could work for this project as well?