Powering PIC 12F629 interface from RTS [SOLVED]

Powering PIC 12F629 interface from RTS [SOLVED]

Postby jean-marc.beaune » Tue Feb 21, 2006 9:14 pm

Hello,

I'm testing serial interface for FMS, I try to work with the following schema (the one provided with FMS) :
Image
The problem is that I have -5V from RTS, so I have -.5V above D1. So voltage is inverted and I can't power up the pic properly, though.

Could someone help me ?

Many thanks
Last edited by jean-marc.beaune on Thu Feb 23, 2006 9:50 pm, edited 2 times in total.
Who's searching will find, who's asking will be replyed
jean-marc.beaune
 
Posts: 9
Joined: Sun Feb 19, 2006 6:43 pm
Location: Bussy St Georges (77)

Postby phildc » Wed Feb 22, 2006 11:12 am

I told you powering from the PC could give problems.... ;)

A quick explanation: RTS means the PC is sending, so the xmtr is not allowed to send. Hence a RTS at logic O when the PC waits for an incoming signal.
With the RS-232 protocol, tne signal voltage is inverted, so we get a positive voltage on RTS in our case (when FMS is started). The diode (and resistor in series) prevents from bringing a negative voltage to the components. and, as it is a Zener, limits to its nominal voltage. I 'd put a 4.7 rather than a 5.6V.

You may try http://www.google.com with 'rts logic value powering' for more explanations.

Other remark: this topic had its place in "PIC interface" and not "Serialport -PPM- interface".
phildc
 
Posts: 352
Joined: Fri May 14, 2004 8:57 am
Location: Brussels Belgium - Club: JDM-Nivelles

Postby jean-marc.beaune » Wed Feb 22, 2006 9:43 pm

Sorry for placing this topic in the wrong place, maybe an admin could move it?
phildc wrote:I told you powering from the PC could give problems.... ;)

Anyway, I won't give up! :twisted:

Now the system is correctly powered (5.41V) but still doesn't work.

I have 4.80V signal coming out from the transmitter (pin 3 on SV2), but 0V on pin 5 and 6 on the PIC.

For information, I use a PIC 12F629, but I think it's not a problem.

Any idea? (I'll investigate further with an oscilloscope)
Who's searching will find, who's asking will be replyed
jean-marc.beaune
 
Posts: 9
Joined: Sun Feb 19, 2006 6:43 pm
Location: Bussy St Georges (77)

Postby phildc » Wed Feb 22, 2006 9:52 pm

How did you burn your PIC?
From an 'hex' file you got already made?
Or from a source that you assembled with the right definition file for your pic?
The hex file must be assembled for the pic model you use, because register and other addresses vary from one pic model to another.
If you used an existing hex file, you must get the corresponding PIC type.

Phil.
phildc
 
Posts: 352
Joined: Fri May 14, 2004 8:57 am
Location: Brussels Belgium - Club: JDM-Nivelles

Postby jean-marc.beaune » Thu Feb 23, 2006 7:09 pm

I though it could be ok without modifying the source... :lol:

I modified the code for a 12F629 and it works just fine now. By the way, the use of "option" and "tris" commands is not recommended, do you know by which command we could replace them?

Many thanks for your efficient help!
Who's searching will find, who's asking will be replyed
jean-marc.beaune
 
Posts: 9
Joined: Sun Feb 19, 2006 6:43 pm
Location: Bussy St Georges (77)

Postby phildc » Thu Feb 23, 2006 7:16 pm

I would say 'banksel' instruction and simple moves to option and tris regs. Addition at 20h50.
Please download the docs from Microchip. It is free.

Is your cable working now?

Phil.
phildc
 
Posts: 352
Joined: Fri May 14, 2004 8:57 am
Location: Brussels Belgium - Club: JDM-Nivelles

Postby jean-marc.beaune » Thu Feb 23, 2006 9:31 pm

phildc wrote:...Is your cable working now?

Yes ! It works perfectly, if anyone is interested in working with 12F629, this topic could help, I could also send source file and .hex file.

"option" command was used to move W to OPTION_REG and "tris" was used to move W to TRISIO. I replaced them with this :

Code: Select all
   bsf   STATUS,RP0   ; select BANK1
...
   movlw   B'00111010'    ; load option_reg value to W

   movwf   OPTION_REG   ; initialize option register
;   option         ; old command to move W to register
   bcf   STATUS,RP0   ; select BANK0
...
   bsf   STATUS,RP0   ; select BANK1
   movlw   B'00011110'   ; load TRISIO value to W
   movwf   TRISIO      ; initialize TRISIO
;   tris   GPIO      ; old command to move W to TRISIO
   bcf   STATUS,RP0   ; select BANK0



phildc wrote:Other remark: this topic had its place in "PIC interface" and not "Serialport -PPM- interface".

Definitly !!!

Thanks
Who's searching will find, who's asking will be replyed
jean-marc.beaune
 
Posts: 9
Joined: Sun Feb 19, 2006 6:43 pm
Location: Bussy St Georges (77)

Postby phildc » Thu Feb 23, 2006 9:41 pm

In fact, the 'banksel' instruction with a the name of a register located the desired bank, generates the bsf or bcf STATUS,... required. This is more flexible and less error-prone. Just an assembler trick, like a macro.

Phil.
phildc
 
Posts: 352
Joined: Fri May 14, 2004 8:57 am
Location: Brussels Belgium - Club: JDM-Nivelles

Postby jean-marc.beaune » Thu Feb 23, 2006 9:49 pm

So, to give an end to this topic :


Code: Select all
   BANKSEL  OPTION_REG   ; select BANK1
...
   movlw   B'00111010'    ; load option_reg value to W

   movwf   OPTION_REG   ; initialize option register
;   option         ; old command to move W to register
   bcf   STATUS,RP0   ; select BANK0
...
   BANKSEL  TRISIO     ; select BANK1
   movlw   B'00011110'   ; load TRISIO value to W
   movwf   TRISIO      ; initialize TRISIO
;   tris   GPIO      ; old command to move W to TRISIO
   bcf   STATUS,RP0   ; select BANK0

Who's searching will find, who's asking will be replyed
jean-marc.beaune
 
Posts: 9
Joined: Sun Feb 19, 2006 6:43 pm
Location: Bussy St Georges (77)

Postby phildc » Thu Feb 23, 2006 10:43 pm

One last thing, the return to bank 0 would be nicer with a:
banksel gpio

which would give an homogenous coding ;)

Phil.
phildc
 
Posts: 352
Joined: Fri May 14, 2004 8:57 am
Location: Brussels Belgium - Club: JDM-Nivelles


Return to Serialport-PPM-Interface

Who is online

Users browsing this forum: No registered users and 0 guests