December 27th, 2010 § § permalink
First time I made holes in a piece of wood with a Dremel
First time I bought tie-wraps in China
First time I blew up the fuse for Xindanwei putting everyone in the dark when I tried to solder
First time I’ve connected the Vin for an Arduino Dueminalove (instead of the external power header or USB)
First time I’ve read values from an infrared sensor (E18-D80NK with a Chinese only datasheet)
First time I got an autonomous robot to be, well, autonomous – by myself! (video)
[gallery link="file"]
It’s neither very nice looking or very impressive when it runs, but I’m still very happy with the results. I planned something electro-mechanical with a tiny bit of embedded software all by myself (with some help from Niko with the Dremel and Héqíchén / 何琪辰 to buy the tie-wraps!). I planned, executed and… got the results I wanted!
The simplistic code that I used:
const int FORWARD = 2;
const int REVERSE = 3;
const int LEFT = 4;
const int RIGHT = 5;
const int INFRARED_FORWARD = A0;
const int INFRARED_REVERSE = A1;
const int MINIMUM_INFRARED_READING = 500;
int current_reverse = LEFT;
int alt_forward = RIGHT;
char current_state;
void setup() {
pinMode(FORWARD, OUTPUT);
pinMode(REVERSE, OUTPUT);
pinMode(LEFT, OUTPUT);
pinMode(RIGHT, OUTPUT);
pinMode(INFRARED_FORWARD, INPUT);
pinMode(INFRARED_REVERSE, INPUT);
Serial.begin(9600);
}
char update_state(char state, int reason) {
char previous_state = current_state;
if(state != current_state) {
current_state = state;
Serial.print(current_state);
Serial.println(reason);
}
return previous_state;
}
void loop(){
// always check if we can go forward
int value = analogRead(INFRARED_FORWARD);
if(value >= MINIMUM_INFRARED_READING) {
// maybe we were correcting, so check that
char last_state = update_state('F', value);
digitalWrite(current_reverse, LOW);
digitalWrite(REVERSE, LOW);
if(last_state == 'R') {
// we just successfully exited a bad loop, turn for a bit for half a second
digitalWrite(alt_forward, HIGH);
digitalWrite(FORWARD, HIGH);
delay(1000);
digitalWrite(alt_forward, LOW);
}
digitalWrite(FORWARD, HIGH);
} else {
// otherwise, still correcting, keep off
digitalWrite(FORWARD, LOW);
// we want to try to find an alt path
int value = analogRead(INFRARED_REVERSE);
if(value >= MINIMUM_INFRARED_READING) {
//still have some ability to go backward
update_state('R', value);
digitalWrite(current_reverse, HIGH);
digitalWrite(REVERSE, HIGH);
} else {
// whooaah, even backward is not possible, we're stuck
digitalWrite(current_reverse, LOW);
digitalWrite(REVERSE, LOW);
update_state('S', value);
}
}
}
Wins:
- Wooden board and tie-wraps work exceptionally well to prototype the physical arrangement
- Using the breadboard to prototype the electronics also works well
- The Arduino “Vin” to provide current in the board header works very well (and can seamlessy switch between USB and that without resetting!)
- Sticking the RF transmitter board directly on the robot and controlling the motors with that from the Arduino works well
- The LED that comes on when an obstacle is detected by the infrared sensors is very useful for debugging (need to keep that in mind when using other sensors)
- It works!
Losses:
- Uses Alkaline AA batteries (I want to switch to the exact same Rechargeable NiCad as the car uses)
- I spent too much time working with Sketchup instead of manually testing the mechanical design first (and then Sketchup)
- There’s not much around Xindanwei in terms of computer, electronic or small mechanical stores, so I should plan ahead to shop on Beijing road
- The infrared sensors that I found in the pile of stuff in Xinchejian work, but more like “on/off” sensors (don’t seem to have any linearity in the distance)
- No bumper (the infrared sensor was crashing into the walls…)
- Making an obstacle course big enough is annoying
- I had forgotten to make the holes to attach the sensors (more holes == better)
- No on/off switch so have to manually remove the connections to turn off power
- You can never have enough tie-wraps… We only had four at Xinchejian before I bought a pack of 500 for 15RMB (but really, worth about 5RMB)
- I need to learn how to solder… without blowing fuses…
]]>
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
Time: 3pm Dec 26, 2010
Location: Xin Che Jian, 2nd floor, Yongjia Rd 50 (close to Shaanxi Road South)
Cost: 30RMB for non-Xinchejian members, free of charge for Xinchejian members.
Seeed Studio is an open hardware facilitation company based in Shenzhen, China. Benefiting from local manufacture power and convenient global logistic system, we integrate resources to serve new era of innovation. Seeed also works with global distributors and partners to push open hardware movement.
We design modular electronics for quick prototyping and small scale projects, which could be found at Bazaar. It also carries inventories from community innovators, we help people make, distribute their designs and collect the revenue. It’s a win-win situation and taking a shape towards an ecosystem. By working with us, innovators could focus on the designs, provide better support to the user and promote the product. Seeed Studio or similar service provider could get more traffic and bring up other product sales.
The manufacture part of hardware involves a lot details. We provide Propagate service to facilitate the process. Innovator send finished prototype with manufacturing files including Gerber file, BOM, test plan and other requirements. Our engineering team will validate and integrate the design into small batch production line. All products will be tested and packed under instruction. Innovators could also view current manufacture and distribution status from propagate. After deducting the manufacture costs, profit will be returned to innovators when inventory sold out.
To estimate the popularity before investing manufacture, innovators could post the idea or prototype to Wish. The community would vote, comment and collaborate on projects. You could also join interested groups to see what’s hot being worked on. By participating Wish, ideas with many votes could convert the popularity into coupons to purchase product or service. The idea poster could also share some coupon to the valuable commenter as appreciation.
Products and service info are hosted at a wiki called Garden. Feel free to add your guide, project or yourself as a freelancer.
About the speaker
Eric Pan, founder and director of Seeed Studio, grew up with DIY culture in China. He graduated as an EE bachelor from Chongqing University, with experiences and prizes from national wide contests of MCU, Embe dded Design, Robotics, and English skills. He first joined Intel in Chengdu as a FCBGA product Engineer whose main job includes quality control and new product integration. Then he worked at Beamstream LLC as international sourcing manager on system solutions. He established Seeed Studio since 2008 from bare ground and now turning it into an open source hardware facilitator with 30+ employee.
新山寨第一期: 开源硬件与开放式创新
时间:2010年12月26日下午3点
地点:徐汇区永嘉路50号2楼新车间 (靠近陕西南路)
费用:新车间会员免费, 非新车间会员每人30元
Seeed Studio 是一个位于深圳的开源硬件生产公司. 得益于本土制造业的巨大力量以及便利的全球物流系统. 我们整合不同资源从而服务于新纪元创新时代. Seeed也与全球分销商和合作伙伴合作共同推动开源硬件的前进.
Eric Pan 是Seeed studio 的创始人, 他从小受DIY文化影响. 他毕业于重庆大学,获得了电子工程学士学位. 他在微型计算机, 嵌入式设计, 机器人, 英文技能领域都有丰富经验集获奖. 他的第一份工作是在成都intel 担当FCBGA 产品工程师. 其主要工作是腹侧质量控制和新产品整合开发. 随后他在Beamstream LLC 工作担任国际采购经理. 在2008年他创立了Seeed studio —从零起点开始到现在拥有30名员工的开源硬件生产中心.
更多信息可以参考 http://seeedstudio.com/]]>
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…
]]>