PDA

View Full Version : R/C receiver to PIC16F84



tech
- 11th September 2008, 22:31
Im trying to hook up 2 channel R/C control system to pic16f84.

How do i came out the programm to input the signal from the receiver to PIC?
Do i use the Pulsin for this, need help, thanks?

Squibcakes
- 12th September 2008, 02:13
I've successfully used Pulsin to count the servo pulses out of a receiver and then displayed on an LCD to show the servo movement. So I can say that this will work.

This thread has good example of the bar graph http://www.picbasic.co.uk/forum/showthread.php?t=2359

Squib

tech
- 12th September 2008, 03:20
I've successfully used Pulsin to count the servo pulses out of a receiver and then displayed on an LCD to show the servo movement. So I can say that this will work.

This thread has good example of the bar graph http://www.picbasic.co.uk/forum/showthread.php?t=2359

Squib


Is it possible if u could send me the sample code of using Pulsin with the input from the receiver.
I dont have an LCD to determine the value of the pulses coming through the receiver.

[email protected]

really appriciate it.

Rohaimi

skimask
- 12th September 2008, 03:44
Is it possible if u could send me the sample code of using Pulsin with the input from the receiver.
I dont have an LCD to determine the value of the pulses coming through the receiver.

[email protected]

really appriciate it.

Rohaimi

Or...Or...Or...and I'm just going out on a limb here...You could read that other thread, forget the fact that you don't have an LCD and just ignore it, maybe even do something crazy like comment out anything to do with the LCD, write some code and do what you're going to do with the code, which you haven't said what your end result will be...But that's just me going out on a limb, ya know, trying something out for the first time...'cause that's just too funny...

Acetronics2
- 12th September 2008, 08:48
Hi, Tech ( I do adore the joke ! )

The good thing would be to know WHAT you want to do with the Rx decoded outputs ...

cause channels capture code will depend upon that ...

Alain

I think a search in these columns with "PULSIN" K.W. could give you lots of relevant hits ...subject is not "brand new" ... Lol !

tech
- 12th September 2008, 15:02
----------------------------------
result1 var word
result2 var word

radio:

pulsin PORTB.0,1,result1
pulsin PORTB.1,1,result2

if result1 < 600 then forward1
if result1 > 900 then reverse1
if result2 < 600 then ccw
if result2 > 900 then cc

goto radio

-------------------------------

Very sorry bout the previous post, just out it a side then.
I've been trying the pulsin . Two channel go directly to the input.

if result1 < 600 then forward1

i.ve used this based on my previous school project using basic stamp. It was not programm by me. Did the order of programm goes in this way?

comment appreciated.

Acetronics2
- 12th September 2008, 15:28
Ok ...

This is code obviously coming straight from a BS2 !!!

1) you must tell PbP you work @ 20 Mhz ...

DEFINE OSC 20 ... and use HS Oscillator

2) as your channels follow each other, you must know you'll measure CH1, miss CH2, miss CH1, measure CH2, measure CH1, miss CH2, miss CH1 , measure CH2, etc, etc ...

not very critical but you must know it for your timings ...


3) Think CH1 and CH2 are refreshed every 20 - 25 ms ... and you'll have to update your captures ... so what do forward1,reverse1,ccw and cc subs must not take too long a time, to allow updating your channels at a "decent" rate ...

4) may be you will have to add wrong pulses detection ... but it is another story !!!

Alain

tech
- 12th September 2008, 16:34
i get what u mean and had Define OSC 20 and the HC oscillator

i dont get what u mean by the point below.
How i measure CH1 and CH2? what u mean by "miss CH2"

2) as your channels follow each other, you must know you'll measure CH1, miss CH2, miss CH1, measure CH2, measure CH1, miss CH2, miss CH1 , measure CH2, etc, etc ...

skimask
- 12th September 2008, 16:36
i dont get what u mean by the point below.
How i measure CH1 and CH2? what u mean by "miss CH2"
2) as your channels follow each other, you must know you'll measure CH1, miss CH2, miss CH1, measure CH2, measure CH1, miss CH2, miss CH1 , measure CH2, etc, etc ...

Takes to time to do what a PIC has to do according to your program.
Therefore, if doing all of this thru software (i.e. not using any internal hardware modules), you'll spend time measuring the pulse width of CH1, then while acting upon that (driving another servo or something?), the PIC is too busy doing one thing to measure another pulsing (CH2).

Acetronics2
- 12th September 2008, 16:45
Re,

That's simple :

The channel signals follow each others within ~ 10-15 ns ( nano seconds ! ) delay ...

PULSIN need a little time ( some µs ) to be ready to catch the signal. (see PbP libs ! )

those µs being more than the ns channel separation time, the second PULSIN doesn't see the second pulse rising edge ... and must wait for the following frame.

That's all

Alain