Home
Articles
Futaba servo signal interface
A How the PULSIN command works
Previous
1
2
3
4
A
B
C
D
Next
This circuit revolves around the PULSIN command. Without it, its operation would not be possible. The following is how the command works and some sample code that would utilize the command.
Here is a breakdown of the string.
PULSIN portd.0, This tells the PIC that it will be monitoring a pulse one Pin0 of portd.
1, This section tells the PIC that it will be measuring the length of the time the pulse
remains at logic High. If replaced with '0' the time the pulse remains at Logic Low
will be measured.
W0 This section tells the PIC what variable to store the length of the pulse to. It can be
any variable of your choice, as long as it is properly defined. In this case W0 stands for Width 0.
Now that the pulse width has been recorded to a variable it can be compared to a constant to execute a command.
If the pulse width is greater than 200, then Pin0 on PortC will be pulled to logic High. Any width lower than 200, and Pin0 of PortC will be pulled to logic Low.
As a result we would get a piece of code as follows.
Previous
1
2
3
4
A
B
C
D
Next
Articles
Futaba servo signal interface
A How the PULSIN command worksFutaba servo signal interface
Appendix
A How the PULSIN command works
This circuit revolves around the PULSIN command. Without it, its operation would not be possible. The following is how the command works and some sample code that would utilize the command.
| PULSIN portd.0, 1, W0 |
Here is a breakdown of the string.
PULSIN portd.0, This tells the PIC that it will be monitoring a pulse one Pin0 of portd.
1, This section tells the PIC that it will be measuring the length of the time the pulse
remains at logic High. If replaced with '0' the time the pulse remains at Logic Low
will be measured.
W0 This section tells the PIC what variable to store the length of the pulse to. It can be
any variable of your choice, as long as it is properly defined. In this case W0 stands for Width 0.
Now that the pulse width has been recorded to a variable it can be compared to a constant to execute a command.
| IF W0 > 200 THEN
Portc.0 = 1 Else Portc.0 = 0 ENDIF |
If the pulse width is greater than 200, then Pin0 on PortC will be pulled to logic High. Any width lower than 200, and Pin0 of PortC will be pulled to logic Low.
As a result we would get a piece of code as follows.
| W0 VAR BYTE
Start: PULSIN portb.0, 1, W0 IF W0 > 200 THEN Portc.0 = 1 Else Portc.0 = 0 ENDIF GOTO Start |


