Project

General

Profile

Revision 762

Added by Brad Neuman over 12 years ago

made some fixes to robot debug. Also added the current regulation to Charging.c, which seems to work!

View differences:

Charging.c
11 11
#ifndef TRICKLE
12 12
	#define FAST_I 450//660 //660 fries the 5A fuse!!
13 13
#else
14
	#define FAST_I 20 //Works => 1.3A
14
	#define FAST_I 250//20//Works => 1.3A
15 15
#endif
16 16

  
17 17
#define TEST_CURR 550
......
265 265
	TCCR1B |= _BV(CS12)|_BV(CS10); //leave timer on and set compare to 0 to make output off	
266 266
	OCR1B = 0;
267 267
	OCR1A = 0;
268
    
269
    error = 0;
268 270
	
269 271
	sei();
270 272
}
......
282 284
	int curr=0;
283 285
	int count=0;
284 286
	int diff=0;
287
    int newcurr=OCR1B;
285 288
	uint32_t sum=0;
286 289
		
287 290
		//OCR1B =120;
......
302 305
	else if(OCR1B >0 && curr > i)
303 306
			OCR1B--;
304 307
	
305
	return curr;
306
	*/
308
	return curr;*/
307 309
	
308 310
	
311
	
309 312
	//cool control law stuff
310
	diff=curr-i;
313
	diff=i-curr;
311 314
	
312
	OCR1B = diff/4 + curr/4; //K*Ierr + Kguess
315
	//OCR1B = diff/4 + curr/4; //K*Ierr + Kguess
316
    newcurr += diff/4;
317
    
318
    if(newcurr>255){
319
        OCR1B = 255;
320
    }else if(newcurr>0){
321
        OCR1B = newcurr;
322
    }else { //negative
323
        OCR1B = 1;
324
    }
313 325
	
314 326
	
315 327
	
......
327 339
		steady_current=0;
328 340
	
329 341
	OCR1B += diff/4;*/
342
    
343
    return curr;
330 344
	
331 345
}
332 346

  
......
431 445
		i2c_putpacket(0x01, tempData, 3);
432 446
		
433 447
		mod=abs_time%4;
434
		while(abs_time%4==mod)
435
		{
448
		while(abs_time%4==mod);
449
		//{
436 450
			if(supply_voltage())
437 451
			{
438
				//curr = regulate_current(500);
439
				curr = get_avg_current();
440
				OCR1B = 100;
452
				curr = regulate_current(FAST_I);
453
				//curr = get_avg_current();
454
				//OCR1B = 100;
441 455
			}
442 456
			else
443 457
			{
444 458
				curr = 0;
445 459
				OCR1B = 0;
446 460
			}
447
		}
461
		//}
448 462
		
449 463

  
450 464
		tempData[0] = 'P';
......
458 472
		curr=6666;
459 473
		
460 474
		mod=abs_time%4;
461
		while(abs_time%4==mod)
475
		//while(abs_time%4==mod)
462 476
		{
463 477
			volt = get_avg_voltage();
464 478
		}
......
471 485
		volt=6666;
472 486
		
473 487
		mod=abs_time%4;
474
		while(abs_time%4==mod)
488
		//while(abs_time%4==mod)
475 489
		{
476 490
			temp = get_avg_temperature();
477 491
			

Also available in: Unified diff