Just a few comments from my basic understanding of RC
Code:
Pulselen var word ' Pulselen can be 0 - 255, 100 = 1 ms, 200 = 2 ms
Init var word ' Init used to flash LED
Clear ' set all variables = 0
Input GPIO.4 ' set pin 3 to RX signal - changed as GPIO3 is not ideal
ReadPWM:
PulsIn GPIO.4, 1,Pulselen ' pin 3 - read high pulse length, times out after .65535 seconds
pause 15
If Pulselen < 50 Then GoTo Blink ' no signal -> blink led
If Pulselen > 75 Then GoTo solid ' signal -> Solid led
GoTo ReadPWM
If you read the comments for pulselen it states that 100 = 1ms and 200 = 2ms, but your if / then statement states that if its less than 50 go blink. If you are monitoring a "normal" PPM signal from a receiver, the pulse length will be around 1ms for low stick and 2ms for full stick, with 1.5ms at centre. So even at low stick the signal will be 1ms or a pulse length of 100, it will never be lower than 50, and this the code will never jump to flash.
I too had to change the config line to MCLRE_OFF for it to program without error
EDIT:
Oh and one other thing that may be causing the problem is that the RX will be sending the PPM pulse every 20ms, so you will need to get the timing right so that the pin is checked for a pulse at the right time. According to code it times out after .65535 seconds, maybe you need to make this time out after 20ms so it loops back round. Most of my experiments with other languages used the pre-scaler to get the timer to roll over at the desired timing if a pulse wasn't present. Maybe some of the more experienced guys can jump in here as I don't know if PBP features this option ?
Bookmarks