Pages: [1]   Go Down
Author Topic: Full H-bridge (mega = > due) controlled by ElectroShaman Java GUI  (Read 588 times)
0 Members and 1 Guest are viewing this topic.
France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 266
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please find detailed video instructions on how to modify the arduino sketch to Java control a full H-bridge driver



http://github.com/selfonlypath
http://github.com/selfonlypath/Full-H-bridge-arduino-mega
http://www.tantratron.tk

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 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:
// 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:
ISR(TIMER4_OVF_vect)
{
  if(token == 1){
    OCR4A=LocalFreqPWM;
    OCR4B=LocalHbridge12;
    OCR4C=LocalHbridge34;
    token++;
  }
}
Logged

Pages: [1]   Go Up
Jump to: