Go Down

Topic: Full H-bridge (mega = > due) controlled by ElectroShaman Java GUI (Read 732 times) previous topic - next topic

Sep 05, 2013, 12:35 pm Last Edit: Aug 26, 2014, 08:29 pm by selfonlypath Reason: 1
Please find detailed video instructions on how to modify the arduino sketch to Java control a full H-bridge driver

http://www.youtube.com/watch?v=V0U2sLcUwno


Runs on Arduino MEGA, requires ElectroShaman v2.0.5 on Win/MAC to manage operational parameters

Almost fully compatible on Arduino DUE requiring only to change timer4 initialization and ISR4 (Interrupt routine).

If somebody would be willing to migrate these three parts of the code from MEGA to DUE where 99% of the code is already due compatible and USB java.

Thanks in advance, Albert

Code: [Select]
// select output pins & initialize timer4
 pinMode(outputPinH1H2, OUTPUT);
 pinMode(outputPinH3H4, OUTPUT);
 TCCR4A = B00111001; // Phase and Frequency correct at OCR5A
 TCCR4B = B10001;    // prescaling by 1 the system clock
 TIMSK4 = B1; // ISR management to detect OverFlow
 TIFR4 = B1;


Code: [Select]
// always use TCNT different than ZERO because of multiple TCNT's AVR bug not updating correctly if TCNT=0
 cli();
 TCNT4=1;
 OCR4A=LocalFreqPWM;
 OCR4B=LocalHbridge12;
 OCR4C=LocalHbridge34;
 sei();


Code: [Select]
ISR(TIMER4_OVF_vect)
{
 if(token == 1){
   OCR4A=LocalFreqPWM;
   OCR4B=LocalHbridge12;
   OCR4C=LocalHbridge34;
   token++;
 }
}

Go Up