One man in other forum told me to try this one, but still nothing :/ maybe here someone will have a clue.
But as i read this code and i dont get it why it dont work ;/ it looks everything logically. I meassured pins wile working, and it works good i think, RB0 - 5V after some time it drops to 2.5V and when to zero and RB1 opposite. But RB2 got only 0.12V all time.Code:MSpause var byte ' Milliseconds between charging caps, suggest 10 to 50, even numbers Ctr var byte ' Used in loop for 50% pwm RunCt var byte ' Used in loop Left var PORTB.0 ' Don't know which is which, so declare one as left. Right var PORTB.1 ' By default, the other is right. SD var PORTB.2 ' Shutdown; low=run, high=off. ANSEL = %00000000 ' All pins changed from analogue to digital OSCCON = $60 ' Internal clock setted to 4Mhz TRISB = %00000000 ' All PORTB pins are outputs. High SD ' Shut down MOSFET drivers MSpause = 50 ' initialize MSPause; 50mS, this will result in about 5 seconds forwards, ' 5 seconds stopped, 5 seconds reverse, 2 seconds stopped. Loop: ' Start the motor turning left. Full speed ahead! High Left ' Start running left... Low Right ' Set them opposite For RunCt = 1 to 100 ' We're going to loop 100 times, so run time will be MSpause * RunCt Low SD ' Turn on MOSFET drivers Pause (MSpause-1) ' wait a bit... High SD ' Turn off MOSFET drivers Pause 1 ' Charge MOSFET caps Next RunCt ' Stop the motor by giving it 50% PWM on both sides. For RunCt = 1 to 100 ' We're going to loop 100 times, so run time will be MSpause * RunCt For Ctr = 1 to (MSpause >> 1)-2 ' Low Right High Left ' Swap direction Low SD ' Turn on MOSFET drivers Pause 1 High SD ' Turn off MOSFET drivers High Right ' Swap direction Low Left Low SD ' Turn on MOSFET drivers Pause 1 High SD ' Turn off MOSFET drivers next Ctr Next RunCt ' Run the motor in reverse High Right Low Left For RunCt = 1 to 100 ' We're going to loop 100 times, so run time will be MSpause * RunCt For Ctr = 1 to (MSpause >> 1)-2 ' Low SD ' Turn on MOSFET drivers Pause MSpause ' delay for a bit High SD ' Turn off MOSFET drivers Pause 1 next Ctr next RunCt ' Driver is shut down, let's just pause for 2 seconds Pause 1000 Pause 1000 goto Loop ' do forever END




Bookmarks