December 26th, 2010 § § permalink
TX2C ATS302T which is available on Taobao) , so I thought I would try to figure out the circuit by looking at it. Kind of inconvenient because the components are on one side while the circuit trace is in the other.
Flipping over the board constantly is annoying and it’s rather hard to follow. Best would be to see both sides at the same time, no?
So this is what I did:
- took a picture of both sides in macro mode
- cropped both pictures
- created layers using GIMP (a cross-platform OpenSource software similar to Photoshop)
- Put each image on their layers
- Change opacity of top layer
- “Image > Transform > Flip Horizontally” one of the image
- Move one of the image until screw holes on both align
[gallery link="file"]
Much easier then to figure out what is connected to what, but still difficult…
Anyway, I decided to try instead to buy a TX2C and follow its datasheet to re-create the circuit. In the meantime, I’ve removed the board entirely from the remote control body and I’ll connect to that directly with the Arduino.]]>
December 20th, 2010 § § permalink
A.R.T.: Autonomous Robot Toy ^_^
Some theory gleaned related to PWM and RF
Disclaimer: this is my first contact with PWM and RF… Feel free to correct me.
General PWM introduction
Using the Arduino to do drive the transmitter circuit would be a temporary hack. Best would be to be a simple circuit using a few dedicated IC to achieve the same (specifically the
TX2C).
Generating correct Pulse Modulation
I’m trying to have Arduino output a PWM that will in turn drive the transmitter (using a crystal oscillator at a specific frequency) on/off to achieve the needed pulses.
According to “
How Stuff Works“, RC control is four pulses that are 2.1 milliseconds long, with 700-microsecond intervals.
The pulse segment, which tells the antenna what the new information is, uses 700-microsecond pulses with 700-microsecond intervals. The number of pulses will tell what order to execute:
- Forward: 16 pulses
- Reverse: 40 pulses
- Forward/Left: 28 pulses
- Forward/Right: 34 pulses
- Reverse/Left: 52 pulses
- Reverse/Right: 46 pulses
also:
- RC control is 2.1 ms HIGH + 0.7ms LOW for a total of 2.8ms.
- This represents a duty of 2.1/2.8 = 75% duty cycle and a frequency of 1/0.00028 = ~3571 Hz.
- Pulse segment duty cycle is 50% (since pulse = interval) with a frequency of 1s/1.4ms (0.7ms+0.7ms) 714Hz.
According to the Secrets of
Arduino PWM and the
Servo PWM FAQ the Arduino (or rather, the ATMega168 that it uses) has a 16Mhz clock with prescalers (1, 8, 64, 256, or 1024) that can divide this to a “timer”. Final precise control is done by using an integer in the ICR. The microcontroller will count up to ICR and then count down back to 0, turning to HIGH everytime it gets to zero.
Can probably dig this out of the ATMega168 doc: http://www.atmel.com/dyn/resources/prod_documents/doc2545.pdf
The equation is: desired_frequency = system_clock / (2*prescaler_value*ICR)
(1/0.00028) = 16e6/ (2*prescaler*x) or x = (16e6*2.8e-4)/(2*prescaler)
where prescaler…
- 1: 2240
- 8: 280
- 64: 35
- 256: 8.75
- 1024: 2.1875
…we can thus use prescaler value 1,8,64 + corresponding ICR value. We cannot use 256 and 1024 because their results are fractional.
Same exercise with the pulse segment:
(1/0.0014) = 16e6 / (2*prescaler*x) or x = (16e6*1.4e-3)/(2*prescaler)
where prescaler…
- 1: 11200
- 8: 1400
- 64: 175
- 256: 43.75
- 1024: 10.9375
…we can use either 1, 8 or 64 prescaler (the other two are fractional values).
Higher prescale is better generally as lower timer also reduces power consumption.
The
ATmega timers script should be useful at some point, but I don’t understand the output right now…
How do I turn this knowledge into an Arduino embedded program?
I have no idea yet! I did try to manually create a PWM here by using sleeps:
…and feed that into an hacked together RF circuit based on what I could figure out from the circuit but it… obviously doesn’t do much
I’ve come to the conclusion that buying the IC chip that does the same work and use the provided schematics… would be a lot easier…
]]>
December 20th, 2010 § § permalink
Saw Ricky came in with a RC car today and kicked his Robot RC car project. Very cool! Read more…
Also, spoke NPI today about hosting robot RC car race in their place in the future. A robot F-1! That would be fun.]]>
December 19th, 2010 § § permalink
I bought an RC car from Taobao at the extremely cheap price of 67RMB (shipping included! 10$USD!)!
For that price, you get an RC remote, a rechargeable Ni-Cd 400mAh/6V battery pack, the radio transmitter (27.145Mhz). Wheels have rubber, autonomy and range is decent although the chassis is very very cheap plastic obviously.
The downsides: on wood floor, it tends to spin so any autonomous program would need to constantly adjust based on sensor (distance ranging) input. It also has propulsion motors on a simple shock so the base isn’t totally flat with the ground.
The transmitter needed two AA batteries (not included!) so on Friday I ran out late at night to buy a pair of them (6RMB) and went on an excursion in the cold night to acquire a bunch of precision screwdrivers (25RMB, although really they’re worth 15). Pretty difficult achievement since this is after 9pm on a Friday night!
While charging the battery, I used my new screwdrivers and removed the plastic cover. I also took a look at the electronics for the transmitter. The transmitter is very simple, with 4 contact switches, what I assume is a Pulse Modulation IC, a couple of capacitors and resistances. The way an RC transmitter works is described informatively on “
How Stuff Works“.
As an hack, I hook up the four switches to each emitter pin of a ULN2803APG (a simple IC that is basically 8 NPN transistors) with the base controlled by the Arduino itself. This lets me control the car with a very simple program to test Forward, Backward, Left and Right.
The challenges ahead:
1) finding a distance ranging solutions
The robot needs to know how far walls and various objects are…
The GP2Y0A700 looks like one with the longest range, but it’s also very expensive (around 50$USD). The next one, GP2Y0A02, is about 15$USD with a range of 20cm-150cm. I probably want a bunch (3?) so I this is probably more cost effective.
c) probably a combination of them
2) need to mount the Arduino, a breadboard and the sensors on the car. This will probably require a custom aluminium plate that I can mount using the screwholes that were used for the plastic cover.
3) Figuring out how to control the motors.
Two ways;
a) remove the current control board and substitute my own. This means an H-bridge that would let me control the motors both ways (Texas Instruments L293NE or Texas Instruments SN754410)
b) create my own RC transmitter.
I’m favoring (b) right now and I went out to buy a bunch of 27.145Mhz crystals at electronics town (10RMB for 8!)
]]>