interesting point. But let's assume 1KHZ a frequency. a cycle should be 1mS right?
rought and nasty example. Now you have to implement your tests during those cycles.. mmmCode:HPWM 1,127,1000 pause 1 ' one cycle pause 1 ' two cylce pause 1 ' three cycle CCP1CON=0 stop PWM
But there's some other way to use only High/LOW on specific Motor pins then using Pause/Pauseus (or loop of) to do the same thing and do your test within a loop.Code:HPWM 1,127,1000 ' Start Motor1 Hpwm 2,127,1000 ' Start Motor2 For Msec=0 to 300 PauseUS 10 ' 10uSec * 300 = 3mSec = 3 Cycles If SensorX=Something then Doplahplah If sensorY=Somethingelse then DoAnotherPlahPlah next
This will create a 50% duty cycle 'PWM' of a XCycleCode:For Msec=0 to ((Cycle*100)*2) Toggle Motor1 Toggle Motor2 PauseUS 5 If sensor... If sensor... next
Should be something to play 'round.
Now, if it was me, i would use HPWM to generate both signal to the motor, then use 2 sensor to monitor the revolution of the wheel using interrupts or internal counter. It add flexibility and also if a motor is burn or else, you'll be able to know it.




Bookmarks