Hi,
I need to use two independent PWM units at the same time to control two DC motors of the car track and a hardware interrupt for counting car laps and a button to switch functions. I have everything plugged in and it almost works. It just happens to me that one or the other pwm device turns off after an interrupt is triggered. This happens when the hall sensor triggers an interrupt. I have to restart it again with the command:
hpwm pwmdiv16, 0, 0, %0001, 124, valSpeedM1 ; car 1
pwmout pwmdiv16, motor2, 124, valSpeedM2 ; car 2
Speed control voltage measurement:
symbol speedM1 = 0
symbol speedM2 = 1
readadc10 speedM2, valSpeedM2
readadc10 speedM1, valSpeedM1
Car 1:
;symbol motor1 = C.2
hpwm pwmdiv16, 0, 0, %0001, 124, 173
Car 2:
symbol motor2 = C.1
pwmout pwmdiv16, motor2, 124, 173
To count laps, I have two hall sensors connected to a hinterrupt configured as follows:
symbol bINTMask = b21 ;w10
bINTMask = %00000111
callINTSetup:
{
setbit bINTMask, 6
hintsetup bINTMask
clearbit bINTMask, 6
setintflags or %00000111, bINTMask
; fix reset PWM's after STOP, after interrupt call.
pwmout pwmdiv16, motor2, 124, valSpeedM2
hpwm pwmdiv16, 0, 0, %0001, 124, valSpeedM1
; ---
return
}
track 1 ( car 1 ) = hint0flag
track 2 ( car 2 ) = hint1flag
game button = hint2flag
Please don't you know how to set an alternative mode so that both PWM devices work together with the set hardware interrupt? Thank you for your response.
I need to use two independent PWM units at the same time to control two DC motors of the car track and a hardware interrupt for counting car laps and a button to switch functions. I have everything plugged in and it almost works. It just happens to me that one or the other pwm device turns off after an interrupt is triggered. This happens when the hall sensor triggers an interrupt. I have to restart it again with the command:
hpwm pwmdiv16, 0, 0, %0001, 124, valSpeedM1 ; car 1
pwmout pwmdiv16, motor2, 124, valSpeedM2 ; car 2
Speed control voltage measurement:
symbol speedM1 = 0
symbol speedM2 = 1
readadc10 speedM2, valSpeedM2
readadc10 speedM1, valSpeedM1
Car 1:
;symbol motor1 = C.2
hpwm pwmdiv16, 0, 0, %0001, 124, 173
Car 2:
symbol motor2 = C.1
pwmout pwmdiv16, motor2, 124, 173
To count laps, I have two hall sensors connected to a hinterrupt configured as follows:
symbol bINTMask = b21 ;w10
bINTMask = %00000111
callINTSetup:
{
setbit bINTMask, 6
hintsetup bINTMask
clearbit bINTMask, 6
setintflags or %00000111, bINTMask
; fix reset PWM's after STOP, after interrupt call.
pwmout pwmdiv16, motor2, 124, valSpeedM2
hpwm pwmdiv16, 0, 0, %0001, 124, valSpeedM1
; ---
return
}
track 1 ( car 1 ) = hint0flag
track 2 ( car 2 ) = hint1flag
game button = hint2flag
Please don't you know how to set an alternative mode so that both PWM devices work together with the set hardware interrupt? Thank you for your response.