Quantcast
Channel: AVR ATmega Projects Archives - Projects Tutorials Code Library for Atmels Atmega32 AVR
Viewing all 1082 articles
Browse latest View live

PHONE CONTROLLED MOBILE ROBOT CIRCUIT MT8870 ATMEGA16

$
0
0

Wireless, remotely controlled applications quite popular in this project through the mobile phone robot control is done the robot on the Nokia 1100 mobile phone used phone signals from the MT8870 receiver DTMF decoder… Electronics Projects, Phone Controlled Mobile Robot Circuit MT8870 ATMega16 “avr project, microcontroller projects, “

 atmega16-mt8870-cep-telefonu-kontrollu-mobil-robot

Wireless, remotely controlled applications quite popular in this project through the mobile phone robot control is done the robot on the Nokia 1100 mobile phone used phone signals from the MT8870 receiver DTMF decoder out ATMega16 microcontrollers are sent to the command given by l293d drive through the motor control is done the robot outside for many applications kullanılail water tanks, etc., using more powerful motor drives. controls can be performed ..

mt8870-dtmf-wireless-controlled-robots-use-rf-circuits-atmega16-mobile-robot

GSM-RO~1

Source: avadhutelectronics.blogspot.com alternative phone-controlled-mobile-robot-circuit-mt8870-atmega16.rar alternative link3


Connecting Piezo Speaker to ATmega32

$
0
0

An ATMega32 sound generator code is extremely simple to implement. Almost any GPIO pin can drive a piezo buzzer, and the output quality is fine for producing some beeps. The code shown here is the simplest one I remember using basic physics, and since it does not use PWM it could be implemented on almost any microcontroller.

sound-piezo-buzzer

The program simply toggles the output of a pin, between 5 V and 0 V, very fast. The square wave generated drives a piezoelectric speaker directly. Here is a sample of the output I recorded; I Hope your computer has sound switched ON.

Example Sound

scale

Here is a recording proof that this code actually works. We test all the code thoroughly before publishing.

Programming Terminology

SPEAKER_PORT |= (1 << SPEAKER_PIN)

The programming terminology is very simple as you can see. This will simply send a 1 to pin 7 on my development system where the speaker is connected.

SPEAKER_PORT &= ~(1 << SPEAKER_PIN)

This will send a 0 to the speaker pin. As you can see, by sending ones and zeros very quickly in a loop, the speaker makes a sound!

Delay Function

_delay_ms(x)

Luckily, some built-in functions such as delay are useful to use. In this function the parameter x is in milliseconds.

Prototype Sound Function

PLAYNOTE(float duration, float frequency)

Here is my own prototype function that works really well. I decided to call it PlayNote because essentially that is what it does, it plays a note. The note frequency in Hertz, and the duration in milliseconds, passes to the function.

Sound Generator Physics

Sound Generator Physics

 

The sound principle is very simple and anyone with basic knowledge should understand it. Wavelength (w) and frequency (f) are related, by the equations below.

f =1/w, and w=1/f

A complete period is one wavelength (w); therefore, a half period is w/2. The number of cycles is simply the duration of the note divided by w. This value is used in a “for” loop to count to the number of cycles required.

In this case, w is the wavelength calculated from frequency using the formula w = 1 / f. We output 5 V for a length of time determined by w/2, and then output 0 V, for the same length of time.

Do not expect a symphony; at most, this will sound like R2D2. This circuit uses a cheap 50-cent piezo, and square waves to generate sound. At most, it will output beeps of different frequencies and durations. This is very useful, in error debugging to produce beeps similar to BIOS beep codes used on PC motherboards.

Portability

This program does not use Pulse Width Modulation (PWM), or internal timers to generate the sound. As a result, almost any microcontroller and any pin could work. It should even work with PIC microcontrollers!

Generating Sound Program Code

1: /********************************************

2: Author: Peter J. Vis

3: Title: R2D2

4:

5: Microcontroller: ATmega32

6: Crystal: 16 MHz

7: Platform: Development System

8:

9: LIMITATIONS:

10: No psrt of this work may be used in commercial

11: applications without prior written permission.

12:

13: This work cannot be reproduced for blogging

14: Copyright Protected. All Rights Reserved.

15:

16: PURPOSE:

17: This program is used to test the Piezo

18: speaker by generating musical notes.

19:

20: CIRCUIT:

21: Piezo Speaker connected to PortC pin PC7.

22: An 8 Ω voice coil speaker could also be

23: used with a 2 Ω resistor in series.

24:

65: *********************************************/

66:

67: #define F_CPU 16000000UL

68:

69: #include <avr/io.h>

70: #include <util/delay.h>

71:

72: #define SPEAKER_PORT PORTC

73: #define SPEAKER_DDR DDRC

74: #define SPEAKER_PIN 7

75:

76: // My Prototype is simply called PLAYNOTE.

77: void PLAYNOTE(float duration, float frequency);

78:

79: int main(void)

80: {

81:

82:  PLAYNOTE(400,880);  // Musical note 880 Hz

83:  PLAYNOTE(400,932);

84:  PLAYNOTE(400,988);

85:  PLAYNOTE(400,1047);

86:  PLAYNOTE(400,1109);

87:  PLAYNOTE(400,1175);

88:  PLAYNOTE(400,1244);

89:  PLAYNOTE(400,1319);

90:  PLAYNOTE(400,1397);

91:  PLAYNOTE(400,1480);

92:  PLAYNOTE(400,1568);

93:  PLAYNOTE(400,1660);  // Musical note 1660 Hz

94:

95: }

96:

97:  // —————————————

98:  // The PLAYNOTE function must be given the

99:  // duration, and frequency values.

100: // The duration is how long the note

101: // is played for. The frequency value

102: // determines the musical note.

103: // —————————————

104:

105:

106: void PLAYNOTE(float duration, float frequency)

107: {

108:  // Physics variables

109:  long int i,cycles;

110:  float half_period;

111:  float wavelength;

112:

113:  wavelength=(1/frequency)*1000;

114:  // Standard physics formula.

115:  cycles=duration/wavelength;

116:  // The number of cycles.

117:  half_period = wavelength/2;

118:  // The time between each toggle.

119:

120:  // Data direction register Pin 7

121:  // is set for output.

122:  SPEAKER_DDR |= (1 << SPEAKER_PIN);

123:

124:  for (i=0;i<cycles;i++)

125:  // The output pin 7 is toggled

126:  // for the ‘cycles’number of times.

127:  // ——————————–

128:

129:  {

130:         _delay_ms(half_period);

131:    // Wait 1 half wavelength.

132:    SPEAKER_PORT |= (1 << SPEAKER_PIN);

133:    // Output 5 V to port Pin 7.

134:    _delay_ms(half_period);

135:    // Wait 1 half wavelength.

136:    SPEAKER_PORT &= ~(1 << SPEAKER_PIN);

137:    // 0 V at port pin 7.

138:  }

139:

140:  return;

141:  // Return to main()

142:

143: }

 


Limitations: Notice that in this code, half_period is a float variable that feeds the standard built-in _delay_ms function, which beginners usually use with an integer constant. Before you lurch up on your desks to press the “hit” button or send me an email, let me assure you that it is not an error. You simply need to understand the operation of the delay function. In reality, the avr-gcc toolchain usually links functions from the library so that you can pass a variable to it. There are limitations to this method such as memory usage and accuracy of sound; however, this code is just an example to make a beep sound. You can always work around the limitations by making your own delay function if you wish.

The official Atmel site also suggests that the new implementation of _delay_ms(double __ms) with __builtin_avr_delay_cycles(unsigned long) support is not backward compatible. Therefore, please make sure you are using the correct version of the function and library.

 

Read More Detail:Connecting Piezo Speaker to ATmega32

RTTTL Player for the ATmega32

$
0
0

Ring Tone Text Transfer Language (RTTTL) is a simple text-based code for recording monophonic musical tones. The script is usually loaded into a mobile phone, which is able to convert the code to equivalent musical notes. Many early phones had an integrated RTTTL player, which played these codes, serving as a ring tone.

Here is a neat little program I wrote for playing simple monophonic tunes on an ATMega32. This was the first program I wrote, to parse a string and it works really well. I figured it was better to make a RTTTL Player, as there are already many tunes available from the mobile phone industry. Originally, I wrote this for a PIC microcontroller and decided to port the code to the ATmega32. I was hoping to play “Rule Britannia”, but there are no RTTTL scripts for this currently. If you find one, please feel free to email it.

An advantage of this program is that it does not use timers or pulse width modulation (PWM), specific to any microcontroller IC architecture. This means that the code will work on almost any microcontroller. The program simply toggles the output of a pin, between 5 V and zero, very fast. The square wave generated drives the piezo speaker directly.

I have kept the program code as simple as I can by using “if-else-if”, and “do-while” loops, for parsing. There are other ways, but I want to keep it simple for students who are just starting out.

Postman Pat – Playback

postmanpat

Here is proof that the code actually works.

RTTTL Standard

The text based data string has not been standardised, and consequently many manufacturers have made slight changes to it. Sometimes a ring tone for one brand of mobile phone will not work for another brand. Sometimes the string may contain a duration value of 64, or 128. There are also variations in the octave scale as well. The program that I have created expects the following format.

“song title:d=duration, o=octave, b=beatpermin:[length][note][#][octave][period.],”

  • Valid duration values are 1, 2, 4, 8, 16, and 32.
  • Valid octaves are 4, 5, 6, and 7.
  • Beats per minute can be a value between 1 and 3 digits long.

RTTTL Parameter Sequence

When the code parses the string, the following parameter values are expected.

  1. The standard values 1, 2, 4, 8, 16, and 32 are the duration lengths of a note.
  2. The notes are a, b, c, d, e, f, g, h, p, c#, d#. f#, and g#, where p is a silent pause or rest.
  3. The hash symbol # signifies a sharp note.
  4. The octave value provides the following scales 4, 5, 6, and 7.
  5. A period symbol denotes a pause length multiplier of 1.5.

Octave calculation

There is no need to store the frequencies of all the notes of all the octaves. Given a base frequency, it is possible to calculate the next octave simply by multiplying by a factor of 2. This is how RTTTL programs calculate the frequency. For example, given the frequency scale of octave 4, multiply the frequencies by 2 for octave 5, multiply the frequencies by 4 for octave 6, and multiply by 8 for octave 7.

Duration Calculation

The following formula provides seconds per beat (spb), given beats per minute (bpm). It sets the tempo of the music.

spb = 60 / bpm;

We multiply by 1000 to convert to milliseconds. In this formula, m is a multiplier of 1.5 when there is a period within the music script, otherwise m is 1.

duration = (spb / length) × 1000 × m;

String Manipulation

x = atoi (temp);

This is how I do mine, and I am the only one who does it this way, however now that I am publishing this, chances are everyone else will as well. This converts a string value into an integer where x is an integer.

temp[c] = tune[pointer];

This copies the contents of a string called tune to a temporary string temp. Obviously, “c” and “pointer” are counters, which have to incremented in step.

RTTTL Player Code

This code is very involved, and it took two days to write it, but I was determined to write it. Here is the program listing and the source code file.

rtttl-player-code.c

1: /*********************************************

2: Author: Peter J. Vis

3: First written: 8 Dec 1999

4: Last updated: 12 Dec 2006

5:

6: Microcontroller: ATmega32

7: Crystal: 16 MHz

8: Platform: Development System

9:

10: URL:https://www.petervis.com

11:

12: LIMITATIONS:

13: No part of this work may be used in commercial

14: applications without prior written permission.

15:

16:

17:

18: PURPOSE:

19: RTTTL Player made for the ATmega32

20: Microcontroller. It will parse a string

21: containing notes based on the RTTTL standard.

22:

23: CIRCUIT:

24: Piezo Speaker connected to PortC pin PC7

25:

26: ADVANTAGES:

27: Pulse Width Modulation is not used in

28: this program.

29:

30: **********************************************/

31:

32: #define F_CPU 16000000UL

33:

34: #include <avr/io.h>

35: #include <util/delay.h>

36: #include <ctype.h>

37: #include <stdlib.h>

38: #include <stdio.h>

39:

40: #define SPEAKER_PORT PORTC

41: #define SPEAKER_DDR DDRC

42: #define SPEAKER_PIN 7

43:

44: // ——————————————-

45: // The classic British Postman Pat Tune:

46: // These are the program notes stored in a

47: // string. The string will be parsed.

48: // ——————————————-

49:

50: char tune[] = {“Postman Pat:d=4,o=5,b=100:16f#,

51: 16p,16a,16p,8b,8p,16f#,16p,16a,16p,8b,8p,16f#,

52: 16p,16a,16p,16b,16p,16d6,16d6,16c#6,16c#6,16a,

53: 16p,b.,8p,32f#,16g,16p,16a,16p,16b,16p,16g,16p,

54: 8f#.,8e,8p,32f#,16g,16p,16a,16p,32b.,32b.,16g,

55: 16p,8f#.,8e,8p,32f#,16g,16p,16a,16p,16b,16p,

56: 16g,16p,16f#,16p,16e,16p,16d,16p,16c#,

57: 16p,2d”};

58: // ——————————————-

59:

60:

61: // Arrays

62: char temp[4];

63:

64: // Prototypes

65: void

66: PLAYNOTE(float duration, float frequency);

67: // Defaults Parameters

68: int defaultlength;

69: int defaultoctave;

70: int beatspermin;

71:

72: // Variables

73: int length;

74: int octave;

75: float basenote;

76: float note;

77:

78: // Duration calculation.

79: float spb=0;

80: // seconds per beat.

81: float duration;

82: // Duration of the note.

83: float m=0;

84: // ‘.’ Multiplier.

85: float bpm=0;

86: // Beats per min.

87:

88: // Counters.

89: int c=0;

90: int pointer=0;

91:

92: int main(void)

93: {

94:

95:  // Skip the music title

96:  do{

97:  pointer++;

98:  }while(tune[pointer] != ‘:’);

99:  // until ‘:’ reached.

100:  pointer++;

101: // Skip ‘:’

102:

103:

104: // Extract the default duration

105:  pointer++;

106: // Skip ‘d’

107:  pointer++;

108: // Skip ‘=’

109:  c = 0;

110: // Reset the array index.

111:  do{

112:  temp[c] = tune[pointer];

113: // Copy to a temporary array.

114:  pointer++;

115:  c++;

116:  }while(tune[pointer] != ‘,’);

117:  temp[c]=’\0′;

118: // Insert a null terminator.

119:  defaultlength = atoi(temp);

120: // Convert the string to integer and

121:

122: // set “note duration”.

123:  pointer++;

124: // Skip the comma.

125:

126:

127: // Extract the default octave.

128:  pointer++;

129: // Skip 0

130:  pointer++;

131: // Skip =

132:  c = 0;

133: // Reset the array index.

134:  do{

135:  temp[c] = tune[pointer];

136: // Copy to a temporary array

137:  pointer++;

138:  c++;

139:  }while(tune[pointer] != ‘,’);

140:  temp[c]=’\0′;

141: // Insert a null terminator

142:  defaultoctave = atoi(temp);

143: // Convert string to integer and

144:

145: // set “default octave”.

146:  pointer++;

147: // Skip ‘,’

148:

149:

150: // Extract the beats per minute information.

151:  pointer++;

152: // Skip ‘b’

153:  pointer++;

154: // Skip ‘=’

155:  c=0;

156: // Reset the index.

157:  do{

158:  temp[c] = tune[pointer];

159: // Copy to a temporary array

160:  pointer++;

161:  c++;

162:  }while(tune[pointer] != ‘:’);

163:  temp[c]=’\0′;

164: // Insert a null terminator.

165:  beatspermin = atoi(temp);

166: // Convert the string to integer and

167:

168: // set beats-per-minute.

169:  pointer++;

170: // Skip ‘:’

171:

172:

173:

174: do {

175:

176:

177: // Get the duration of the note.

178:  if ((tune[pointer] == ‘3’) &&

179: (tune[pointer+1] == ‘2’)) {

180:  length = 32;

181:  pointer = pointer+2;

182:  }

183:  else if ((tune[pointer] == ‘1’) &&

184: (tune[pointer+1] == ‘6’)) {

185:  length = 16;

186:  pointer = pointer+2;

187:  }

188:  else if (tune[pointer] == ‘8’) {

189:  length = 8;

190:  pointer++;

191:  }

192:  else if (tune[pointer] == ‘4’) {

193:  length = 4;

194:  pointer++;

195:  }

196:  else if (tune[pointer] == ‘2’) {

197:  length = 2;

198:  pointer++;

199:  }

200:  else if (tune[pointer] == ‘1’) {

201:  length = 1;

202:  pointer++;

203:  } else length = defaultlength;

204:

205:

206:

207: // ——————————————-

208: // Set the basenote to the correct frequency.

209: // Octave 4 is used here.

210: // Look for the # sharps first.

211: // ——————————————-

212:

213:

214:  if ((tune[pointer] == ‘a’) &&

215: (tune[pointer+1] == ‘#’)) {

216:  basenote = 466.164;

217:  pointer = pointer+2;

218:  }

219:  else if ((tune[pointer] == ‘c’) &&

220: (tune[pointer+1] == ‘#’)) {

221:  basenote = 554.365;

222:  pointer = pointer+2;

223:  }

224:  else if ((tune[pointer] == ‘d’) &&

225: (tune[pointer+1] == ‘#’)) {

226:  basenote = 622.254;

227:  pointer = pointer+2;

228:  }

229:  else if ((tune[pointer] == ‘f’) &&

230: (tune[pointer+1] == ‘#’)) {

231:  basenote = 739.989;

232:  pointer = pointer+2;

233:  }

234:  else if ((tune[pointer] == ‘g’) &&

235: (tune[pointer+1] == ‘#’)) {

236:  basenote = 830.609;

237:  pointer = pointer+2;

238:  }

239:  else if (tune[pointer] == ‘a’) {

240:  basenote = 440.000;

241:  pointer++;

242:  }

243:  else if (tune[pointer] == ‘b’) {

244:  basenote = 493.883;

245:  pointer++;

246:  }

247:  else if (tune[pointer] == ‘c’) {

248:  basenote = 523.251;

249:  pointer++;

250:  }

251:  else if (tune[pointer] == ‘d’) {

252:  basenote = 587.330;

253:  pointer++;

254:  }

255:  else if (tune[pointer] == ‘e’) {

256:  basenote = 659.255;

257:  pointer++;

258:  }

259:  else if (tune[pointer] == ‘f’) {

260:  basenote = 698.456;

261:  pointer++;

262:  }

263:  else if (tune[pointer] == ‘g’) {

264:  basenote = 783.991;

265:  pointer++;

266:  }

267:  else if (tune[pointer] == ‘p’) {

268:  basenote = 0;

269:  pointer++;

270:

271:  } else basenote = basenote;

272:

273:

274:

275:

276:

277: // If there is a number in the string then

278: // at this point it is always the octave

279: // scale numbers. Either, 4,5,6,or 7.

280:  if (tune[pointer]==’4′){

281:  octave=4;

282:  pointer++;

283:  }

284:  else if (tune[pointer]==’5′){

285:  octave=5;

286:  pointer++;

287:  }

288:  else if (tune[pointer]==’6′){

289:  octave=6;

290:  pointer++;

291:  }

292:  else if (tune[pointer]==’7′){

293:  octave=7;

294:  pointer++;

295:  } else octave=defaultoctave;

296:

297:

298: // Calculate the note based on the

299: // octave value

300:

301:  if (octave == 4) {

302:  note = basenote; //*1

303:  }

304:  else if (octave == 5) {

305:  note = basenote*2;

306:  }

307:  else if (octave == 6) {

308:  note = basenote*4;

309:  }

310:  else if (octave == 7) {

311:  note = basenote*8;

312:  }

313:

314:

315:

316: // When a period ‘.’ is found

317: // duration is x1.5

318:

319:  if (tune[pointer] == ‘.’) {

320:  m = 1.5;

321:  pointer++;

322:  } else m=1;

323:

324:

325:

326: // Calculate the duration.

327:  bpm=beatspermin;

328:  spb = 60/bpm;

329:  duration=(spb/length)*1000*m;

330:

331:

332:

333: // Either play a note or pause for

334: // the time specified by duration.

335:

336:  if (note == 0){

337:  _delay_ms(duration);

338:  } else

339:  {

340:  PLAYNOTE(duration, note);

341:  }

342:

343:

344: // This is the pause between each note.

345:  _delay_ms(spb*150);

346:

347:

348:

349:  } while (tune[pointer++] == ‘,’);

350:

351:

352: }

353:

354:

355: // Function to play a note given

356: // the duration and frequency.

357:

358: void PLAYNOTE(float duration, float frequency)

359: {

360:  // Physics variables

361:  long int i,cycles;

362:  float half_period;

363:  float wavelength;

364:

365:  wavelength=(1/frequency)*1000;

366:  cycles=duration/wavelength;

367:  half_period = wavelength/2;

368:

369:

370: // Data direction register: Pin 7 is

371: // set for output.

372:  SPEAKER_DDR |= (1 << SPEAKER_PIN);

373:

374:  for (i=0;i<cycles;i++)

375:  {

376:  _delay_ms(half_period);

377:  SPEAKER_PORT |= (1 << SPEAKER_PIN);

378:  _delay_ms(half_period);

379:  SPEAKER_PORT &= ~(1 << SPEAKER_PIN);

380:  }

381:

382:  return;

383: // Return to main()

384: }

 

Read More Detail:RTTTL Player for the ATmega32

ATmega32 ADC for Light and Temperature Sensors

$
0
0

This tutorial shows how to implement the Analogue to Digital Converter (ADC) function on ATMega32 using C code. It consists of code examples, and the meaning of some nomenclature such as sampling rate, and resolution. However before we get to the code, let us start from the beginning. The ATMega32 has a built-in 10-bit ADC. The input to this ADC has a multiplexer to provide eight single-ended channels, where each channel can have a dedicated sensor such as an LDR or a Thermistor to provide an input voltage. These channels share the GPIO pins 33 to 40 on Port A. The output from the multiplexer feeds the non-inverting input of an operational amplifier with programmable gain. The gain is available in the following steps, 0 dB (1×), 20 dB (10×), and 46 dB (200×).

block-diagram

There is also an option to have three differential inputs by way of ADC5, ADC6, and ADC7, which feeds a second multiplexer connecting to the inverting input side of the op-amp.

From a hardware consideration, the AVCC pin provides voltage to the ADC circuitry and Port A also. This pin requires connection to the Vcc voltage supply, even when the ADC is not used. However when using the ADC, you should also include a filter capacitor as the ADC requires an extremely clean power supply.

The ADC also has a dedicated clock circuit, which allows the programmer to shut-off all the other clocks to reduce noise and therefore increase the precision of the ADC.

ADMUX Register

7 6 5 4 3 2 1 0
REFS1 REFS0 ADLAR MUX4 MUX3 MUX2 MUX1 MUX0
REFS1 REFS0 Methods for selecting Voltage Reference
0 0 AREF, Internal Vref turned OFF
0 1 AVCC with external capacitor at AREF pin
1 0 Reserved
1 1 Internal 2.56 V Voltage Reference with external capacitor at AREF pin

The ADC requires a reference voltage to determine the conversion range. The analogue signal for sampling must be between ground and Vref for capture.

For most applications, Vcc is sufficient by setting bit REFS0 to binary 1. Vcc is prone to noise so as a result an external decoupling capacitor helps filter this noise.

ADMUX |= _BV (REFS0);

Analog Channel and Gain Selection Bits

In the ADMUX register, the first four “MUX bits” organise as follows. The first seven numbers select single-ended input configuration. From eight onwards you can select a combination of differential inputs with different gain factors. The gain factor is available only for differential inputs.

MUX
4,3,2,1,0
Single Ended +Differential
Input
-Differential
Input
Gain factor
00000 ADC0 NOT
AVAILABLE
00001 ADC1
00010 ADC2
00011 ADC3
00100 ADC4
00101 ADC5
00110 ADC6
00111 ADC7
01000 N/A ADC0 ADC0 10×
01001 ADC1 ADC0
01010 ADC0 ADC0 200×
01011 ADC1 ADC0
01100 ADC2 ADC2 10×
01101 ADC3 ADC2
01110 ADC2 ADC2 200×
01111 ADC3 ADC2
10000 ADC0 ADC1
10001 ADC1 ADC1
10010 ADC2 ADC1
10011 ADC3 ADC1
10100 ADC4 ADC1
10101 ADC5 ADC1
10110 ADC6 ADC1
10111 ADC7 ADC1
11000 ADC0 ADC2
11001 ADC1 ADC2
11010 ADC2 ADC2
11011 ADC3 ADC2
11100 ADC4 ADC2
11101 ADC5 ADC2
11110 1.22V (VBG) N/A
11111 0V (GND)

In a simple case, we can use a single-ended input. Any port from ADC0 to ADC7 will work. The ADC port can be any number from 0 to 7 and passed through the following functions.

  1. ReadADC(uint8_t ADCport);
  2. ADCport=ADCport & 0b00000111;
  3. ADMUX|=ADCport;

ADCSRA – Control and Status Register

7 6 5 4 3 2 1 0
ADEN ADSC ADATE ADIF ADIE ADPS2 ADPS1 ADPS0

ADCSRA |= _BV (ADEN);

Bit 7 – ADEN: Set this to binary 1 to enable the microcontroller ADC circuits, whilst binary 0 will switch it OFF.

ADCSRA |= _BV (ADSC);

Bit 6 – ADSC: Setting ADSC bit to binary 1 starts the conversion process. This bit clears automatically when the conversion process completes. Therefore, this bit provides an indication that the conversion has completed.

While (ADCSRA & _BV (ADSC));

This while loop waits for the ADSC bit to become binary 0 again.

ADPS2, ADPS1, ADPS0

These bits determine the division factor between the XTAL frequency and the ADC input clock.

Converting an analogue signal to digital requires a clock frequency for the approximation circuitry. This principle is similar to the strips under a curve in maths class. The more strips the better the approximation of the analogue signal. A frequency between 50 kHz and 200 kHz is typical for maximum resolution.

The prescaler frequency is a fraction of the crystal frequency, usually achieved by using a division factor. The bits ADPS2, ADPS1, ADPS0, determine the division factor.

ADPS2 ADPS1 ADPS0 Division Factor
0 0 0 2
0 0 1 2
0 1 0 4
0 1 1 8
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128

16000000 / 128 = 125 kHz

This ATMega32 development board has a 16 MHz crystal; therefore, a division of 128 provides 125 kHz for the prescaler frequency.

ADCSRA |= _BV (ADPS2) | _BV (ADPS1) | _BV (ADPS0);

This value is within the maximum resolution range so we choose a prescaler division factor of 128 by setting bits ADPS2, ADPS1, ADPS0 to binary 1.

ADC Example C Code

This program displays the sampled ADC value on HyperTerminal, so you will need a working UART circuit. Make sure you have a working MAX232 interfacing circuit connected to the UART. Make sure you have tested the UART communications with HyperTerminal using uart.h and uart.c include files as shown in the following section. ATMega32 UART PC Interface – Testing

1: /*******************************************
2: Author: Peter J. Vis
3: Last Updated: 8 Dec 2009
4:
5: Microcontroller: ATmega32
6: Crystal: 16 MHz
7: Platform: Development System
8:
9: URL: https://www.petervis.com
10:
11: LIMITATIONS:
12: No part of this work may be used for
13: commercial use without prior written
14: permission. This program can not be used by
15: bloggers for blogging purposes.
16:
17:
18: PURPOSE:
19: To test LDR Sensor. To calibrate for maximum
20: and minimum values.
21:
22: CIRCUIT:
23: LDR connected to ADC2 port of the ATmega32
24: ********************************************/
25:
26: #define F_CPU 16000000UL
27:
28: #include <avr/io.h>
29: #include <util/delay.h>
30: #include “uart.h”
31: #include “uart.c”
32:
33:
34: // prototypes
35: void initADC();
36: void uart_init();
37: uint16_t ReadADC(uint8_t ADCport);
38:
39: int main()
40: {
41: uint8_t i;
42: uint16_t analog_value;
43:
44: // init ADC
45: initADC();
46:
47: // init UART – this function is
48: // in an external file
49: uart.c
50:
51: // This is needed to make printf
52: // work to send characters to HyperTerminal.
53:
54:
55: uart_init();
56:
57: // init HyperTerminal by sending VT100
58: // escape sequences.
59: printf(“\x1B[2J\x1B\x63”);
60:
61: // Print a welcome message.
62: printf(“Are you ready to calibrate? \r\n”);
63:
64:
65: while(1)
66: {
67:
68: //Read LDR Sensor on port ADC02
69: ReadADC(2);
70:
71: // Read the result from the ADC register
72: analog_value = ADC;
73:
74: // Move the HyperTerminal cursor to
75: // the next line.
76: // [2;1H moves the cursor to Row 2,Column 1.
77: // 2K erases the line.
78:
79: printf(“\x1B[2;1H\x1B[2K”);
80:
81: // Print a 10-bit analog value to
82: // HyperTerminal,
83: printf(“ADC value: %u\r\n”, analog_value);
84:
85: // Wait 100 ms
86: for(i=0; i<10; i++)
87: _delay_ms(10);
88: }
89:
90: return 0;
91: }
92:
93:
94:
95:
96: // This function will initialize the ADC for
97: // the correct Vref and Prescaler and then
98: // enable it.
99:
100:
101:
102: void initADC()
103: {
104: // Initialise the ADC.
105: // Select Vref -> AVcc with external
106: // capacitor at the AREF pin.
107: ADMUX |= _BV(REFS0);
108:
109: // Select the prescaler of 128
110: ADCSRA |= _BV(ADPS2) | _BV(ADPS1) |
111: _BV(ADPS0);
112: // Enable the ADC.
113: ADCSRA |= _BV(ADEN);
114:
115: }
116:
117:
118: /******************************************
119: This function will read the ADC value from
120: the ADC port specified.
121:
122: Port values: My system has 3 different
123: sensors on respective ports.
124: Therefore, you must pass the port number to
125: the function for the sensor you require.
126:
127: ADCPort Circuit
128: 0 Analog Input
129: 1 Thermistor
130: 2 LDR
131:
132: *******************************************/
133: uint16_t ReadADC(uint8_t ADCport)
134: {
135:
136: ADCport=ADCport&0b00000111;
137: ADMUX|=ADCport;
138:
139: // Start the single conversion mode process.
140: ADCSRA |= _BV(ADSC);
141:
142: // Wait for the conversion to finish.
143:
144: // The ADC signals that it has completed by
145: // automatically clearing the ADSC bit.
146:
147: // Wait in a while loop until the bit
148: // clears.
149: while( ADCSRA & _BV(ADSC) );
150:
151: return(ADC);
152: }

Switch debounce library

$
0
0

Contact bounce (ref. https://en.wikipedia.org/wiki/Switch#Contact_bounce) is a common problem with mechanical switches and relays. Switch and relay contacts are usually made of springy metals. When the contacts strike together, their momentum and elasticity act together to cause them to bounce apart one or more times before making steady contact.

You can find below a sample of a bouncy button press. You can see the typical ripples of the bounce button press.

Switch debounce library (1)

If you use a microcontroller to read the button status, depending on the speed you read the button it may seem that it is pressed many times, even if it is pressed once, and that’s should become a problem.

To solve this issue there is two way:

  • Hardware
  • Software
The usual hardware way is to build a low pass filter. Sometimes you will find a Schmitt-trigger after the RC filter, to avoid hysteresis.
The limitation of the hardware way is that you have to implement it on your board, to select the correct component values, and to use more hardware.
A software solution may help us, providing a malleable way to solve this issue.

An interesting reading about this topic is Jack Ganssle‘s article “A Guide to Debouncing” http://www.ganssle.com/debouncing.htm

Also, I suggest you take a read at the two articles series by Elliott Williams, he explains this issue very well and also proposes a few hardware and software solutions:

The library I propose here is, of course, a software solution developed on ATmega microcontroller but portable to many other micros.

It is based on the Trent Cleghorn code you can find it here: https://github.com/tcleg that is an implementation of the Jack Ganssle article posted above.

What it practically does is to read the button status a bounch of time, and set the final status button only if all the times the reading was done is the same.
Ganssle by experiments analyzes that a value from 10ms to 20ms is enough to consider stable a button output. In my example, I read 8 times the button each 10ms, but one can also use less time without a problem.

The library works by byte status, it means it can debounce multiples of 8 buttons at the time, one for each bit. Therefore a 2-byte implementation can debounce 16 buttons.

There is a function to get the press and release button, and the current status. Press and release functions also are implemented in such a way that one can read that function and arm back that function status only after it is read.

Code

Read More Detail:   Switch debounce library

MCP4725 DAC AVR ATmega library

$
0
0

The MCP4725 DAC is a pretty common and cheap single channel 12 bit buffered voltage DAC, it also has an onboard EEPROM.

To drive this chip we can use I2C interface.

MCP4725 DAC AVR (1)

The ATmega8 used for my implementation has an embedded I2C interface, so we just can use that interface.
The selected I2C library is the one proposed by Peter Fleury, you can find it here: http://homepage.hispeed.ch/peterfleury/avr-software.html

To library provides simple functions to set the output channel of the IC by using raw value or a voltage value.
MCP4725 DAC AVR (2)

The voltage output of this chip is limited by his voltage input, that is 2.7v to 5.5v, and the current allowed at the output pin is 25mA.
If you need more current, or more voltage, you can use a combination of opamp and power transistors.

Up to 8 MCP4725 can be driven using this library, the IC address has to be selected using the hardware pulldown selector.

This project has been developed and tested on an ATmega8 running at 8Mhz.

An example program is provided in order to help the library usage.

MCP4725 DAC AVR (3)

Code

Read More Detail:MCP4725 DAC AVR ATmega library

BLUETOOTH JOYSTICK CONTROLLED DISCOVERY ROBOT PROJECT

$
0
0

Very detailed advanced robot project for many of us not be implemented, but the code, schematics, methods different robot project can be used in reconnaissance robot via mobile phone blutut can be manipulated by…Electronics Projects, Bluetooth Joystick Controlled Discovery Robot Project “avr project, microcontroller projects, “

BLUETOOTH JOYSTICK CONTROLLED

Very detailed advanced robot project for many of us not be implemented, but the code, schematics, methods different robot project can be used in reconnaissance robot via mobile phone blutut can be manipulated by further joystick control have a computer connection is made control programs have the hardware all sources, including files shared. Atmel is used in the manufacture of floor control module.

BLUETOOTH JOYSTICK CONTROLLED (2) BLUETOOTH JOYSTICK CONTROLLED (3) BLUETOOTH JOYSTICK CONTROLLED (4)

Source: http://www.fourwalledcubicle.com/ExplorerBot.phpfourwalledcubicle.com/ExplorerBot.php alternative bluetooth-joystick-controlled-discovery-robot-project.RAR alternative link3

 

64 LED PROPELLER EFFECT CIRCUIT ATMEGA8

$
0
0

Led effect circuit 64 leds LEDs on the printed circuit board disposed in the impeller has a very different effect. A plurality of circuit components used SMD type. Effects displacement, velocity pcb solder buttons…Electronics Projects, 64 Led Propeller Effect Circuit ATmega8 “atmega8 projects, avr project, led projects, microcontroller projects, “

64 LED PROPELLER EFFECT

Led effect circuit 64 leds LEDs on the printed circuit board disposed in the impeller has a very different effect. A plurality of circuit components used SMD type. Effects displacement, velocity pcb solder buttons mounted face. Source code for the project and provided drawings eagle pcb diagram.

64 LED PROPELLER EFFECT (1)

Source: paja-trb.unas.cz/elektronika/konstrukce/snowflake.html  alternative 64-led-propeller-effect-circuit-atmega8.rar


ROBOTIC DOG PROJECT, 16 CHANNEL SERVO CONTROL PROGRAM

$
0
0

Prepared with great effort as a hobby project “robot dog” very detailed, especially the mechanical portion control, etc. rc5 remote control computer. has features such as control solid Atmel ATmega32 and ATMEGA8515 based on… Electronics Projects, Robotic Dog Project, 16 Channel Servo Control Program”avr project, microcontroller projects, “

ROBOTIC DOG PROJECT

Prepared with great effort as a hobby project “robot dog” very detailed, especially the mechanical portion control, etc. rc5 remote control computer. has features such as control solid Atmel ATmega32 and ATMEGA8515 based on the resource. bass extension software and hex codes given of a computer used to control 16 channels servo control program source Visual Basic code there last robot’s mechanical parts, the dimensions of the cut in the Schemes given.

ROBOTIC DOG PROJECT (2)

servo-motor-control-program

Source: b.urbani.free.fr/pagecabot/cabot.htm alternative robotic-dog-project-16-channel-servo-control-program.rar alternative link2

NI-MH BATTERY CHARGER CIRCUIT ATMEL ATTINY26

$
0
0

 

Ni-MH Battery Charger circuit 4 AA batteries can be charged in the circuit is more complex, but in general attiny26 microcontroller circuits BD140 transistors and a few passive components consist of batteries connected to… Electronics Projects, Ni-MH Battery Charger Circuit Atmel ATtiny26 “avr project, battery charger circuit, microcontroller projects, “

NI-MH BATTERY CHARGER

Ni-MH Battery Charger circuit 4 AA batteries can be charged in the circuit is more complex, but in general attiny26 microcontroller circuits BD140 transistors and a few passive components consist of batteries connected to the channels via LEDs showing status. Attiny26 operated 8MHz internal oscillator used for additional crystal oscillator fuse settings do not need to be connected, are the source c hex code.

NI-MH BATTERY CHARGER (1)

NI-MH BATTERY CHARGER (2)

Tiny NiMH charger (1)

The charger is designed to charge secondary 1 to 4 cells. Each cell / accumulator is charged separately (not associated), and each has its own termination algorithm after full charge. The full charge detection is performed by evaluating the charging characteristic, especially its downward part, where the cell shows a negative difference -dV.

Characteristics of general NiMH:

Tiny NiMH charger graph

The method of evaluating the charging cycle -dV is based on the measurement and evaluation of the voltage drop on the cell after reaching the full charge – the peak of the Vmax characteristic. If we want the battery to be charged at this voltage value (disable charging after reaching this peak), it should first be determined and we would also get the charger for just one particular battery. In addition, the maximum may change for example with time, temperature, age … For universal use, it is better to discontinue charging after the -dV (or other full charge detection method based on charging characteristics). This way, you can charge any current capacity – will be relatively the same as the charging current will radically vary.

The -dV method is to turn off charging “tightly” after its full charge. This way, the cell can be charged from any state (for example, 50% discharge) and it is not necessary to discharge it completely in advance. Here is the point to refute the dogma of a “memory effect”! Such a phenomenon exists, however, it does not have such disastrous consequences as it is attributed to it, and in ordinary practice it can be neglected, as its influence is very small. In addition, one complete discharge and charging cycle can be removed. Therefore, it can not be said that the memory effect has shortened our lifetime or reduced capacity. Capacity or lifetime limitations can be achieved by poor charging, which eliminates this charger (incorrect charging occurs on chargers with an end-of-life time when the battery with a current capacity is not used or not fully discharged – typically a timer charger) or misuse, mainly excessive discharge or deep discharge.

Very similar charging characteristics also have NiCd secondary cells , the difference is in their steeper drop after reaching the maximum voltage (-dV / dt), so they can also be charged with this charger. It can even be said to charge better than NiMH with this charger. However, the design I designed / developed and tuned only for NiMH.

Diagram:

NI-MH BATTERY CHARGER CIRCUIT schamatic

I created the particular circuit solution with MCU Atmel ATLiny26L-8PI, which contains enough I / O lines for memory, memory capacity and especially 10 bit AD converter with 11x multiplex and internal reference 2.56V. All measurement accuracy is dependent on this internal voltage, but we only require accuracy at -dV.The MCU works with an 8MHz internal RC clock.

Source: solarskit.wz.cz/tinych.html alternative link: ni-mh-battery-charger-circuit-atmel-attiny26.rar

LINE FOLLOWING ROBOT PROJECT ULTRASONIC SENSOR CIRCUIT ATMEGA16 CNY70 SFR05

$
0
0

Quite a different line following robot project was already in school competition designed for the author as he could a nice job exposes the robot’s appearance sumo robots similar to healthy controls ATMega16 microcontroller… Electronics Projects, Line Following Robot Project Ultrasonic Sensor Circuit Atmega16 CNY70 SFR05 “avr project, microcontroller projects, “

LINE FOLLOWING ROBOT

Quite a different line following robot project was already in school competition designed for the author as he could a nice job exposes the robot’s appearance sumo robots similar to healthy controls ATMega16microcontroller (16MHz is used) provided by software GCC WinAVR and AVR Studio 4 was written.

If the robot’s power supply line provided with 4 1100 mAh NiMH batteries in the follow-up standards have Senri CNY70 tamer, but I’m not sure if SFR05 Ultrasonic Sensor can be used to detect obstacles. The robot’s mechanical and PCB design was very stylish resources and resource c eagle, given hex ​​code through.

LINE FOLLOWING ROBOT (1)

LINE FOLLOWING ROBOT (2)

Source: solarskit.wz.cz/century.html alternative line-following-robot-project-ultrasonic-sensor-circuit-atmega16-cny70-sfr05.rar

REMOTE CONTROLLED ROBOT CIRCUIT RC5 AT90S2313

$
0
0

The robot’s control AT90S2313 microcontroller provided with the processor 4MHz is operated for control rc5 protocol that uses a control used robot çalışmala for 4 pcs 2200mAh NiMH batteries used for the experiment alkaline… Electronics Projects, Remote Controlled Robot Circuit RC5 AT90S2313 “avr project, microcontroller projects, “

REMOTE CONTROLLED ROBOT

The robot’s control AT90S2313 microcontroller provided with the processor 4MHz is operated for control rc5 protocol that uses a control used robot çalışmala for 4 pcs 2200mAh NiMH batteries used for the experiment alkaline batteries can be used (engines more powerful, if) Project of the schema and source c software is available.

Mechanical part of the overall practice skeletons plaque components and the PCB by soldering copper pipes made progress in front of the house if the balance used ping-pong ball.

ROBOTIC DOG PROJECT (3)

The robot is actually a radical upgrade to the Krakatit version. It does not already have autonomous behavioral algorithms, but is completely under the control of the remote controller from a TV using RC5. This is mainly about the relatively practical use of the RC5 dictated protocol .

The computing power is provided by the AT90S2313 clocked at 4MHz, which as the main part of the program reads pin PB.7 on which is the IR receiver of SFH506-36, whose output is already useful signal without 36kHz carrier wave. If the slope PB.7 detects a downward edge, the RC5 protocol acquisition algorithm starts and the LED is blinking. Wait for the delay procedure to complete the frame reception, and if the correct startbits are run, the correct combination for switching the relevant transistors will be sent to the H-Bridge (for details on the RC5 frame detection algorithm here ). This value is kept alone for 200ms (this provides the C / T1 interrupt procedure), after which time the robot itself stops. So if the RC5 signal is constantly received (transmission period at RC5 is 114ms), the robot executes the movement after dropping itself after 200ms stops.

Firmware is here .

The movement of the robot is controlled by the numerical part of the remote control in a way that is omnidirectional. For example, 2 – Forward, 8 – Reverse, 1 – Half turn forwards and right (Left engine stands and right moves forward, movement is slow as only one engine is running), similarly 3, 7 and 9, 6 rotates to the left / right. Only additional 5 – red LED and 0 – green LED.

Scheme here:

REMOTE CONTROLLED ROBOT Schamatic

To improve movement, the pinpong ball is used instead of the front wheels, making it much better to turn, even on roughened motion. Using a pinpong ball took up the space where the electronics were before, so it was necessary to create some kind of extension that exceeded the height of the ball so that it was possible to put the PCB with the electronics.

Source: solarskit.wz.cz/rc5robot.html alternative link: remote-controlled-robot-circuit-rc5-at90s2313.rar

ZENER DIODE TEST CIRCUIT VOLTAGE INDICATOR ATMEGA8

$
0
0

Interestingly circuited actually zener diode test measuring instruments should have a property zener measurement of when you are secure, a voltage see better, but so far no measuring instruments equipped with this feature I… Electronics Projects, Zener Diode Test Circuit Voltage Indicator ATmega8 “atmega8 projects, avr project, microcontroller projects, “

ZENER DIODE TEST CIRCUIT

Interestingly circuited actually zener diode test measuring instruments should have a property zener measurement of when you are secure, a voltage see better, but so far no measuring instruments equipped with this feature I have not seen though the circuit design a separate beauty measurement probe to be in shape to use is easy. Zener test circuit for ATmega8 microcontroller based on the indicators used 2 × 16 LCD also very practical and clever Inbox big thick felt-tipped pen used.

Circuit visionav source code of the code sprint pcb layout (zener_tester.lay) file spline scheme (zener_tester.spl7) and there are pictures about insurance options.

zener-tester-test-circuit

ZENER DIODE TEST CIRCUIT schamatic

Source: http://radiokot.ru/circuit/digital/measure/52/ alternative link: zener-diode-test-circuit-voltage-indicator-atmega8.rar alternative link2

LIPO LI-ION BATTERY CHARGER CIRCUIT BALANCING ATTINY26

$
0
0

Attiny26 microcontroller based on the charging circuit has a lot of features in a single package 3l 12.6V LiPo batteries and Li-ion batteries and battery charging voltage edebiliry balanslıy regulate temperature, timing, voltage and… Electronics Projects, Lipo Li-ion Battery Charger Circuit Balancing ATtiny26 “avr project, battery charger circuit, microcontroller projects, “

LIPO LI-ION BATTERY CHARGER CIRCUIT

Attiny26 microcontroller based on the charging circuit has a lot of features in a single package 3l 12.6V LiPo batteries and Li-ion batteries and battery charging voltage edebiliry balanslıy regulate temperature, timing, voltage and current controls there. Software source code prepared by the assembly of printed circuit boards insurance options, there are schema files.

LIPO LI-ION BATTERY CHARGER CIRCUIT (1)

 

LIPO LI-ION BATTERY CHARGER CIRCUIT (2)

Source: aviamodelka.ru alternative lipo-li-ion-battery-charger-circuit-balancing-attiny26.rar

REMOTE CONTROLLED PROPELLER CLOCK CIRCUIT AT90S2313

$
0
0

Before air time, “Propeller Clock” projects I shared in this project control and mode selection can be achieved in both analog clock and digital clock view modes control for the Sony control protocol used… Electronics Projects, Remote Controlled Propeller Clock Circuit AT90S2313 “avr project, microcontroller projects, “

REMOTE CONTROLLED PROPELLER CLOCK

Before air time, “Propeller Clock” projects I shared in this project control and mode selection can be achieved in both analog clock and digital clock view modes control for the Sony control protocol used control floor Atmel AT90S2313 microcontroller available (16MHz) logout the LEDs (18 LEDs) to drive ULN2803 RES pin AT90S2313 has also been used in the MC34064 is used in the integrated low-voltage detection for use with battery guess how necessary a kind of protection do not know …

REMOTE CONTROLLED PROPELLER CLOCK (1)

 

REMOTE CONTROLLED PROPELLER CLOCK (2)

 

REMOTE CONTROLLED PROPELLER CLOCK (3)

Source: REMOTE CONTROLLED PROPELLER CLOCK CIRCUIT AT90S2313 alternative link: remote-controlled-propeller-clock-circuit-at90s2313.rar


TOY CAR MODIFICATION MADE SIMPLE ROBOT PROJECT ATTINY2313

$
0
0

Simple robot project ATtiny2313 microcontroller used robot body for a cheap remote controlled toy car is made up of the robot’s four sides LED sensors placed somewhere when it hit the back çekliy direction…Electronics Projects, Toy Car Modification Made Simple Robot Project ATtiny2313 “avr project, microcontroller projects, “

TOY CAR MODIFICATION MADE SIMPLE ROBOT

Simple robot project ATtiny2313 microcontroller used robot body for a cheap remote controlled toy car is made up of the robot’s four sides LED sensors placed somewhere when it hit the back çekliy direction change somewhere else until you hit continues 🙂 motor drives the car as on the original circuit drive partition (sm6135w) used There is a simple transistor circuit .. schema, in addition to a distinct beauty of this pressure sensor circuit diagram drawings, source code through ATtiny2313 find. Also check ATtiny2313 floor designed as a simple set of experiments can use it in different projects, each floor of the circuit works ..

TOY CAR MODIFICATION MADE SIMPLE ROBOT (1)

I admit honestly, initially I, like many, had seen enough of the websites / forums on robotics and wanted to make myself a useful robot – a vacuum cleaner (well, what else is simple and useful you can think of, if I do not participate in any competitions and I don’t even know Is there any kind of robot-building activity in my city?). But life taught us not to rush into the pool with my head right away, so for the beginning it was decided to assemble a simple, super-cheap robot – for testing. Since I somehow figured out the electronics, the problem began with the mechanics (chassis, body, suspension) and the choice fell on a toy car, as the most affordable version of the chassis, which does not require much effort to upgrade to fit my needs. At the local bazaar, in the ranks with children’s toys, a seller was found who agreed to sell me a cheap car on a radio control for a cheap price (without a remote control,
Then the creative process began … 

Obstacle sensor on 3 LEDs
I admit honestly, I am a beginner in electronics and have just been repeating other people’s finished designs before. I came across an article (http://habrahabr.ru/blogs/arduino/55470/or forum68 / topic6768.html) that a conventional LED can be adapted as a light sensor. Krutenko principle is this: power is supplied not to the anode (as usual), but to the cathode, charging the parasitic capacitance between the LED and the legs of the microcontroller; After a few milliseconds, the parasitic capacitance is charged and the power from the cathode is removed, and the corresponding microcontroller output is transferred to the input and the time required for the microcontroller’s signal to fall into a logical 0, which depends on the LED illumination (the stronger the LED is illuminated, the faster the parasitic capacity on his leg). Collected. Checked It worked. People in the network also makes sensor modules based on such LEDs. They work on that
As they say, I thought for a long time …:-)Joke. A thought occurred to me, but why only a light sensor? Why not an obstacle sensor? It seems to be a simple idea – to light one LED to the second (both LEDs look in the same direction) and if the light is reflected from an obstacle, then the discharge time of the LED sensor will decrease significantly. There is only one problem. Such a sensor is completely unprotected from external “flare” (i.e., the illumination of the “terrain” is not taken into account, for example, during the day and at night it will be radically different). Therefore, it was decided to add a second LED sensor, which would not be illuminated by the LED headlight, but would “measure” the total illumination, knowing that the readings of the obstacle sensor can be correctly interpreted. For,
The board was drawn, the construction was assembled The control program is super simple: if the discharge time of the LED sensor forward is less than that directed upwards, then there is an obstacle (otherwise, there is no obstacle). 

Engine management module (engine driver)
In the machine itself, there was a handkerchief responsible for receiving, transcoding, and then controlling the movement of the machine. It was assembled on the Chinese chip SM6135W (this is a specialized receiver chip for radio-controlled machines, analogue of the RX-2B, which itself decodes commands received over the radio channel into 4 commands: FORWARD, BACKWARD, LEFT and RIGHT). Each of the commands corresponds to the chip output (LEFT and RIGHT turn the front wheels left / right). At first, the idea to pretend to wire commands for this chip was set on fire, as if they were received over the radio channel, but the test attempts did not succeed (firstly, the command system is not described on the chip itself (I will not say anything as I read the data in Chinese in translation google), an analog was found – the date is shit on the RX-2B (analog)
Due to the failure to use the SM6135W native chip (the advantage was the ability to control the motors over one wire, with some complication of the control program), I dropped this mikruhu and redid the control to direct control of the microcontroller of the FORWARD, BACKWARD, LEFT and RIGHT commands directly from the microcontroller ports ( at the same time, 4 microcontroller legs were involved, but in general I had enough legs). 
Because of this, the control of the engines is also simple – we set 1 on the corresponding leg of the microcontroller (to move forward on the FORWARD leg, to back on the BACKWARD leg, to the left on the LEFT leg and to the right on the RIGHT leg). 

Microcontroller board ATtiny2313
Either I do not like excesses, and the task was to make the test robot as cheap as possible, the choice fell on the ATtiny2313 microcontroller (calculations showed that there were enough legs, although literally all legs were involved, except for RESET and one pin of the PORTD port). The microcontroller board was completely taken from the site RoboZone.su (http://robozone.su/2009/06/30/prostaya- … y2313.html). (PS: In general, many thanks to the authors of the site, I started to look at them with their designs and still often look there). The only difference is that the outer quartz was not set (again, both as superfluous and to make the structure cheaper). The built-in one is quite enough (frequency stabilization is of no use to the robot, and the debugging was also successfully passed from the built-in generator through the COM port). 

Assembly design
It was decided to use 4 obstacle sensors (one above each wheel). 4 sensors with two outputs per each (cathode of the LED pointing up and LED pointing forward) took 8 legs (all PORTB), 4 legs of the PORTD port took commands to control the driver of the engines from a radio-controlled machine, 2 ports are used to debug the program via COM-port .0 and PORTD.1), and even involved PORTA (START and STOP buttons). So almost all the legs of the microcontroller were in business.
In the process, it turned out that for some reason (I don’t know exactly why so far) on the PORTB.5 stem (responsible for the SCK signal when programming), the signal level never drops to logical 0 (although if you touch the voltmeter probe, then everything starts to work), so PORTB.5 was moved to PORTD.6 (the only free leg of the port PORTD). But this is for those who decide to see the outcome of the nickname of the firmware, so as not to be surprised.
The issue of power was resolved using 4 batteries of 1.2 volts each (total 4.8 volts). Initially, the machine was designed for 6 volts (4 AA batteries), but somehow I didn’t want to supply 6 volts to the microcontroller (although I read what I had to withstand), and the idea of being able to charge batteries repeatedly attracts much more than disposable batteries buying two extra batteries cost as much as the rest of the machine with mechanics and electronics combined, but perhaps it says more about the cheapness of the robot itself).
The whole structure is assembled on a piece of transparent plexiglass lying in a flat, which was later supplemented with a bumper made of a plastic lid from a can of mayonnaise (because it was tired to unbend the “crumpled” LEDs while debugging the program). The plastic bumper cover was surprisingly excellent. Tough enough and at the same time quite elastic. In a word, although from what it was, perhaps it would have been better not to do it.
When the motors were turned on and off, noticeable drawdowns were observed on the power supply, up to the reset of the microcontroller, so that a 2200µF / 16 Volt capacitor was added to the power supply (I didn’t know how to correctly calculate the required capacity, so I just picked up the “random” capacious, not sickly and not expensive) . Enough for the eyes (although it seems that the battery power is more stable and less prone to voltage subsiding than the test power through the KR142EN5A, which I fed to the robot while debugging on the table in stationary conditions (wheels in the air).
In addition to the “native” battery compartment, located under the bottom of the machine, another one was added on top, connected in parallel, to be able to install 8 batteries (giving a total more current), because practice has shown that this voracious baby eats enough many (40 minutes of active driving sits a set of batteries). 

Programming
In principle, the tasks of the robot did not stand any. So far, just goes without bumping into obstacles. So the program turned out to be simple. The sensors are polled sequentially (at first I tried polling in parallel, but apparently the “ground” is common for all microcontroller legs, because for all the LEDs the discharge time was always exactly the same). But a consistent survey of sensors is also quite enough. Typically, the discharge time of the LED sensor in cloudy weather is about 7-10 milliseconds. Those. All 8 LED sensors can be polled for 80 milliseconds, which is about 12.5 polls per second. Robot large FPS and not needed. In addition, measures have been taken to prevent “freezing” on the survey of sensors. (the fact is that in complete darkness, the LED sensors can be discharged to 2-3 seconds, which of course is unacceptably slow for a robot, but if the sensor looking forward is not discharged in 7-10 milliseconds, as in cloudy weather, then it probably already doesn’t light up due to the obstacle of the neighboring LED, and therefore there is no sense to wait any longer and the general “illumination” doesn’t worry us in this case, t. to. Obviously there are no obstacles).
The movement of the robot can be described by the words “where it is free to go there.” Those. if both front sensors do not show any obstacles, go ahead. If the obstacle is in front of the left, then the food is still ahead, but we turn to the right (what if it is the leg of a chair and we have time to go around it?), Etc. Similarly, we act when we go back, and we go back, if both front sensors show obstacles. If the obstacles show all 4 sensors (well, we drove into a corner between furniture), then turn off the engines and wait until the “developer” carefully rearranges to free space. 

Tests
I admit honestly, the sensors on LEDs are certainly not as protected from illumination as the sensors on TSOPs, but the presence of a second LED that measures the total illumination all the same clearly improves the situation. The only case when the sensor incorrectly interprets the situation is when, for example, the Sun from the window in the morning / evening at a small angle lights up the LED pointing forward more than upward, but this usually happens with one sensor out of 4 (the Sun cannot light up the sensors directed forward and directed back at the same time?). It is solved by directing all 4 sensors in different directions (for example, front sensors at an angle of 120 degrees between themselves and rear sensors at an angle of 120 degrees between themselves). Thus, the Sun, even being low above the horizon, “mistakenly” lights up no more than one sensor, and when the machine goes “to” the Sun,
With indoor lighting (a lamp on the ceiling), without light or in daylight, the device behaves adequately (there is no such that the LED pointing forward is more illuminated than the one that is directed upwards when there is no obstacle). Although with a bright sun, of course, the “range” of detecting an obstacle falls sharply (the LED light gives a weak “additive” to the already strong background illumination). At night or in the dark – generally behaves well. If you give the robot a name, then I would probably call it “The Bat!” (Bat) for the most adequate work in the twilight and darkness and the desire to “slip away” from direct Sunlight into the shade.:-)
Power supply of 5 volts for 6 volt engines is enough. Although the soft carpet goes with difficulty. The pitfall to which I ran into the engine driver was the following: it’s understandable that you cannot simultaneously send opposite FORWARD and BACKWARD or LEFT and RIGHT signals, since This causes a fault in the engine driver. And this possibility was programmatically excluded. But it turned out that if the signals change quickly (and the microcontroller operates at 8 MHz), then there is still a short-circuit (apparently, the transistors in the driver do not switch so quickly), and the current flowing in the motor windings must be “extinguished”. So before each change in the direction of the engine, the controller first pauses 0.7 seconds, and only then changes the direction of rotation of the engine. 0.7 seconds was chosen experimentally (I do not know how to count them either).

TOY CAR MODIFICATION MADE SIMPLE ROBOT

Source: http://roboforum.ru/forum10/topic9762.html alternative toy-car-modification-made-simple-robot-project.rar

0-30V REGULATED DIGITAL SWITCHING POWER SUPPLY ATMEGA8 LM2576ADJ

$
0
0

Very high quality design of the digital power supply circuit. Voltage current of 2 × 16 lcd display of the beauty and power of the switching mode operation switching DCDC Madden LM2576 ADJ (adj… Electronics Projects, 0-30V Regulated Digital Switching Power Supply ATmega8 LM2576ADJ “atmega8 projects, avr project, dc dc converter circuit, microcontroller projects, “

REGULATED DIGITAL SWITCHING

Very high quality design of the digital power supply circuit. Voltage current of 2 × 16 lcd display of the beauty and power of the switching mode operation switching DCDC Madden LM2576 ADJ (adj = adjustable) used the output voltage 0 …30 volt current is 0.3 amps between the hex file of the source code and pcb drawings. Meanwhile, pcb files .MDI format this format, it’s called “Microsoft Document Imaging” I just found out about it:) You may download the files as the program bmp export mdiconverter you can open programme I have option to download the file to a bmp file into the computer as not able to remi …

The circuit input voltage DC 12v … lm324 op amp supply from negative 30v lmc7660 9v-if you do not find this integrated market had obtained additional 9v transformer with symmetric +-9v regulated circuit do

REGULATED DIGITAL SWITCHING (1) REGULATED DIGITAL SWITCHING (2) REGULATED DIGITAL SWITCHING (3)

Source: https://320volt.com/en/lm2576adj-atmega8-0-30v-0-3a-ayarli-anahtarlamali-guc-kaynagi/ Alternatif link: 0-30v-regulated-digital-switching-power-supply-atmega8-lm2576adj.rar

FT232R USB I-O CIRCUIT ATMEGA88

$
0
0

USB I / O circuit ATMEGA88 based on the usb connection FT232 is done via detailed ir project ( German explanation ) the C source code, circuit diagrams and PCB drawing of the picture… Electronics Projects,FT232R USB I-O Circuit ATMEGA88 “avr project, microcontroller projects, “

USB I-O CIRCUIT (1)

USB I / O circuit ATMEGA88 based on the usb connection FT232 is done via detailed ir project ( German explanation ) the C source code, circuit diagrams and PCB drawing of the picture ‘s project uygulanmasa similar circuit for the enlightened can give . TARGET 3001 program prepared by the circuit diagram tarv15viewer_e.ex in the file and run the program open the file schaltplan_layout.t3001

Function overview :
6x digital input
2x analog output
3 PWM output
1x I2C bus connection
Programming SPI transfer port for renovation
PC connectivity
RS232 = 38400 baud, 8 data
Simple ASCII commands USB -I / O
RS232 ring buffer of 550 bytes in size
With 200 bytes of user ( user0 ) memory (virtual )
54 bytes for the user ( user9 ) memory (EEPROM)
8- bit PWM with 122Hz ( ideal for LED control )
Hardware and software watchdog
Displays all commands sent
I2C -bus search tool, error messages and more

USB I-O CIRCUIT (2)

Source: https://320volt.com/en/atmega88-ft232r-usb-io-karti/ alternative link: ft232r-usb-i-o-circuit-atmega88.rar alternative link2

MULTIFUNCTION DIGITAL AMPLIFIER PROJECT TDA7294 ATMEGA32 TDA7313

$
0
0

A lot of work in the ATmega32 occur when project featuring a beautiful rose amp amp volume control on the floor in the TDA7313 TDA7294 is used in the upgrade process. Digital FM radio… Electronics Projects,Multifunction Digital Amplifier Project TDA7294 ATmega32 TDA7313 “avr project, microcontroller projects, tda7294 amplifier circuit, “

MULTIFUNCTION DIGITAL AMPLIFIER

A lot of work in the ATmega32 occur when project featuring a beautiful rose amp amp volume control on the floor in the TDA7313 TDA7294 is used in the upgrade process. Digital FM radio (tuner control) remote control (RC5 Protocol) heat hours) DS1307) indicators Londness (bass sound strengthens) featured tone control, weekly programming, encoder control, audio output operates according to the external control (lighting shutdown, etc..) Section etc. .. There is a long list.

Go to the source code for ATmega32 has not given hex code sections, but on separate floors crafted amp, converters SMD PCB printed circuit diagrams and other cards (sprint layout) drawings can be useful.

MULTIFUNCTION DIGITAL AMPLIFIER (1)

Source: https://320volt.com/en/atmega32-tda7294-tda7313-cok-fonksiyonlu-anfi-projesi/ alternative multifunction-digital-amplifier-project-tda7294-atmega32-tda7313.raralternative link3 alternative link4

ATEMGA168 TLC5940 PWM RGB LED CYLINDER

$
0
0

95 pieces made using RGB LEDs Led cylinder project quite professional printed circuit board, software quality circuit that is used quite ATEMGA168 microcontroller with integrated LEDs TLC5940 LED driver plowed. Installation was very difficult… Electronics Projects, ATEMGA168 TLC5940 PWM RGB Led Cylinder “avr project, led projects, microcontroller projects, pwm circuits, “

TLC5940 PWM RGB LED CYLINDER

95 pieces made using RGB LEDs Led cylinder project quite professional printed circuit board, software quality circuit that is used quite ATEMGA168 microcontroller with integrated LEDs TLC5940 LED driverplowed. Installation was very difficult olmasy RGB LEDs makes the circuit very nice effect, but I made certain to be very puzzling. Also prepared with eagle pcb source, schema tlc5940.lb source C library and ATmega168, given java code.

TLC5940 PWM RGB LED CYLINDER (2)

Source: https://320volt.com/en/rgb-led-silindir-atemga168-20pu-tlc5940nt-pwm/ alternative link: atemga168-tlc5940-pwm-rgb-led-cylinder.rar

Viewing all 1082 articles
Browse latest View live