PDA

View Full Version : PBP3 Timer and RS232



CLAUDY
- 15th February 2014, 18:04
Hello to all

I thought of making a small quite simple interface but that does not turn(shoot) as I want.
The program is realized in PBP3 and the PIC is programmed with one pickit3.
I use a PIC16F1825, chosen as its programmable internal clock to 32MHz and I make him(it) turn(shoot) in 16MHz with the internal oscillator.
A port RS232 TTL receiving "words" (in 100Kb/) representing the width of the impulse to take(bring) out on one other pine of the pic
The entrance(entry) RS232 is on Rx, I use the instruction Hserin, I put a temporary billposter LCD, information arrives well at the pic.
The problem is in the management of the timer.
I have impulses got out of it but the width does not really depend on the mass received(successful) word of command(order).
I know that I could use the "pulsout" without using the timer but it is not possible in my case because the information arrives too quickly in RS232 and I do not have time to receive information, to handle(treat) them, and to take out again them if I do not use the timer.
Have you a track(runway)??
Thank you in advance

CLAUDY

Acetronics2
- 16th February 2014, 20:33
Hi Claudy

a small drawing showing how input and output signals behave ( un chronogramme, in our beloved French language ! ) would save loooooots of time, hair and coffee ...

no need to add your English is somewhat terrible ... that obviously doesn't help either ...

BTW Have my best wishes for this new year ...

Alain

CLAUDY
- 16th February 2014, 20:53
Sorry.
I wanted to help a friend
Good evening

Acetronics2
- 17th February 2014, 09:30
OK ...

I dug out the original Query ...

the goal is to output a pulse whose length is given by the RS232 message received ...

Here is the trail code ( excerpt ! )...


DEFINE OSC 16 'Oscillator speed in MHz: 3(3.58) 4 8 10 12 16 20 24 25 32 33 40
tmr1GE var t1gcon.7
TMR1ON var T1CON.0
TMR1IF VAR PIR1.0 ' Alias RCIF (USART Receive Interrupt Flag)
LED1 VAR PORTC.1 ' Alias LED
LED2 VAR PORTC.2 ' Alias LED

IN_SBUS var PORTC.5 'p 5
S1 VAR PORTA.5 ' p 2
i VAR BYTE ' loop counter

' voir fichier "PIC16F1825.INFO"
'Config pour PIC16F1825
'************************************************* *****************************
'Configuration
'************************************************* *****************************
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CLKOUTEN_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG

on interrupt goto timer_int
disable
osccon=%01111011 'page 70
ansela=0 'page 126
anselc=0
option_reg=0 'page 185 bit7 à zéro pour pouvoir activer les résistances de pull up
apfcon0=0 'page 121
apfcon1=0 'page 122
wpuc=%00100000 'page 137 pull up sur C5
trisa=%11011111
trisc=%11111001

recom_test:
gosub essai_timer
gosub test_led
led1=0
debut:
led2=!led2
for i=1 to 100 'si je met "pause 100", la led régie par le timer clignote mais pas à la cadence du timer
pause 1
next i
goto debut


test_led: ' teste les leds au début juste pour voir si le programme démarre
for i=1 to 10
led1=0
pause 50
led2=0
pause 50
led1=1
pause 50
led2=1
pause 50
next i
return

disable
timer_int:
'TMR1ON=0
led1=!led1
tmr1h=200
tmr1l=200
'TMR1ON=1
T1con=%00000101 'page 195
'tmr1GE=1
tmr1if=0
resume
enable

essai_timer:
''pour timer1 :
T1con=%00000100 'page 195
tmr1h=128
tmr1l=128
intcon=%11000000 'page 90
pie1 =%00000001 'page 91
pie3 =0
tmr1if=0
T1con=%00000101 'page 195 lancer une première fois le timer
'tmr1GE=1
return

End


OKayyyyyyyyyyyyyyy

I finally understood !!!

It's a trail to tweak the FUTABA ( R/C systems ) SBus protocol ...

output pulse is a classical servo signal ( 1.5ms +/- 500µs @ 50 Hz ) ...

so, final goal is to convert a RS232 info into a corresponding R/C pulse .... or to be exact ... convert an RS232 stream ( 4 servo positions ? ) into ... multiple R/C pulses ( 4 ? )

I wonder this kind of matter has already been treated here or aboard RC Groups forum ...


Alain ( who has no interest in that except ... friendship ! )