Hi everyone
Here I use the following webpage to implement a h-bridge motor circuit with Arduino.
http://www.mcmanis.com/chuck/robotics/tutorial/h-bridge/bjt-circuit.html
The differences with mine are optocouplers&resistors and 24V DC and Arduino Mega.
Flickr ? good_wise ? bjt-schematic (1)
I use TLP512-2 optocoupler and 300ohm resistor to drive the optocouplers.
datasheet: TLP521-2 pdf, TLP521-2 Description, TLP521-2 Datasheet, TLP521-2 view ::: ALLDATASHEET :::
Writing some code to drive it as the motor run between forward and stop with 1 sec interval,
which the control pins are *EN=1 FORWARD=1 REVERSE=0(stop)
*EN=0 FORWARD=1 REVERSE=0(forward)
void setup(){
pinMode(2,OUTPUT);//FORWARD pin
pinMode(3,OUTPUT);//BACKWARD pin
pinMode(4,OUTPUT);//*EN pin
digitalWrite(2,HIGH);//FOWARD initially
digitalWrite(3,LOW);
}
void loop(){
digitalWrite(4,HIGH);//stop
delay(1000); //1 sec interval
digitalWrite(4,LOW);//running forward
delay(1000); //1 sec interval
}
Here comes problem
Every time the motor was running, the serial port became corrupted.
For example, here is the situation when i push the upload button in IDE.
IDE keep in uploading status, then output some error message.
Flickr ? good_wise ? uploading
Then I push the upload button again , IDE tells the COM port is already in use.
Flickr ? good_wise ? uploadingcomport
Now the Serial monitor button also become unavailable, no pop up window appears.
All upon error situation become normal until I turn off the 24 power supply and replug the arduino's usb line, or I writing the code that the motor is in stop status.
The error status occurs only when motor running.
As a conclusion, I think this is a electric problem , but seems unreasonable sence I had use the optocouper to isolate the Arduino 5V-system and external 24V-system,especially there's only 3 control pins(FWD,REV,*EN) are connected with arduino,no common gnd with 24v's V-.
Anyone can help and knowing the reason???
Here is the implement picture:
Flickr ? good_wise ? IMG_20120809_113800