Project

General

Profile

Revision 762

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

View differences:

branches/autonomous_recharging/code/projects/autonomous_recharging/archs/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
			
branches/autonomous_recharging/code/projects/autonomous_recharging/archs/Robot Debug/main.c
58 58
    next = 0;
59 59
	i2c_init(0x01, NULL, recv, NULL);
60 60
	
61
	usb_puts("init'd everything.\r\n");
61
	//usb_puts("init'd everything.\r\n");
62 62
	
63 63
	while(1) {
64 64
		delay_ms(2000);
branches/autonomous_recharging/code/projects/autonomous_recharging/archs/Makefile
56 56

  
57 57

  
58 58
# Target file name (without extension).
59
TARGET = ConstantCharging
59
TARGET = Charging
60 60

  
61 61

  
62 62
# List C source files here. (C dependencies are automatically generated.)

Also available in: Unified diff