Hi i made a connection computer-->rs232-->pic16f876. it works fine. then i connected an h-bridge and a dc motor to my pic. it works fine. with 1 it moves counterclockwise with 2 clockwise and with 0 it rests.my program
INCLUDE "MODEDEFS.BAS"
B0 VAR WORD
B1 VAR WORD
Pause 500
SerOut2 PORTC.6,84,["Hi!",13,10]
start:
SerIn2 PORTC.7,84,[DEC B0]
IF(B0==1) Then
Low PORTC.1
High PORTC.2
EndIF
IF(B0==0) Then
Low PORTC.1
Low PORTC.2
EndIF
IF(B0==2) Then
Low PORTC.2
High PORTC.1
EndIF
GoTo start
End
I have to problems:
first i want to put some different levels of speed.
so i wrote the following program but it works as the first program!with numbers 3 and 4 i can't see reduce in speed.
INCLUDE "MODEDEFS.BAS"
B0 VAR WORD
B1 VAR WORD
Pause 500
SerOut2 PORTC.6,84,["Hi!",13,10]
start:
SerIn2 PORTC.7,84,[DEC B0]
IF(B0==1) Then
Low PORTC.1
High PORTC.2
EndIF
IF(B0==0) Then
Low PORTC.1
Low PORTC.2
EndIF
IF(B0==2) Then
Low PORTC.2
High PORTC.1
EndIF
IF (B0==3) Then
Low PORTC.2
PWM PORTC.1,128,10
EndIF
IF (B0==4) Then
Low PORTC.2
PWM PORTC.1,64,10
EndIF
GoTo start
End
SECONDLY i want the motor dc to run in the speed i say until a new press from my keyboard.do i need harware pwms? i need 4 (=2 motors). is there a pic with 4 pwms?
Thanx in advance
Bookmarks