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 [u]migrate these three parts of the code from MEGA to DUE[/u] where 99% of the code is already due compatible and USB java.
Thanks in advance, Albert
// 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;
// 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();
ISR(TIMER4_OVF_vect)
{
if(token == 1){
OCR4A=LocalFreqPWM;
OCR4B=LocalHbridge12;
OCR4C=LocalHbridge34;
token++;
}
}