packet streaming

General discussion on mikroC.
Author
Message
drdoug
Posts: 1074
Joined: 16 Aug 2007 03:49
Location: St. Louis, MO

#16 Post by drdoug » 20 May 2008 19:00

Some thoughts to consider for your RF project (review from old posts)

1. When you connect to the receiver you are likely to get a lot of false triggering due to noise. Ans: set up a preamble (ie #1#) to make sure the data is coming from your transmitter and not a ....blender. You may also miss the first byte or two so send a string of 1's first (ie 111#1#.. then data).

2. The UART line is held high. I inverted the tx and rx end so the transmitter would not be on continuously. You unit tx unit may only turn on with a line change in which case you won't need to worry.

thenoble66
Posts: 243
Joined: 28 Sep 2005 19:43
Location: Romania

#17 Post by thenoble66 » 20 May 2008 20:08

1. When you connect to the receiver you are likely to get a lot of false triggering due to noise.
Thanks for your hints. But in this case there are just basic settings in question. :)
The UART line is held high.
Hmmmm, it isn't. Only if you use a line driver, such as MAX232 or similar, but this is not the case.
An RS232 signal looks indeed "sitting" on high, but that is the live signal on the line. The PIC outputs non-inverted levels, which are later inverted by line driver into RS232 signal.
Regards,
thenoble66
--------------------------------------------------------------------

drdoug
Posts: 1074
Joined: 16 Aug 2007 03:49
Location: St. Louis, MO

#18 Post by drdoug » 20 May 2008 21:01

thenoble66 wrote:
The UART line is held high.
Hmmmm, it isn't. Only if you use a line driver, such as MAX232 or similar, but this is not the case.
My understanding of the datasheet(s) is that TX pin is held high until a start bit (0) is sent indicating the beginning of transmission. This also explains why the LED thingy is glowing when I set it up for USART transmission but pull the jumpers going to the Max232.

Also, please share your "basic settings" for error detection and false triggering.

atommic22
Posts: 24
Joined: 17 May 2008 12:39

#19 Post by atommic22 » 20 May 2008 23:47

My encoder outputs the USART code correctly. However, it is NOT assigning PORTA to the output. Do i have to use the "Button" command to read the logic levels? i.e. Button(&PORTA, 1, 1, 0)?
Encoder:

Code: Select all

void main() {

  TRISA = 0xFF;          // set PORTA to be input

// Initialize USART module
Usart_Init(600);

  do {
    Usart_Write(PORTA); // Send data via USART
  } while (1);
}//~!

thenoble66
Posts: 243
Joined: 28 Sep 2005 19:43
Location: Romania

#20 Post by thenoble66 » 21 May 2008 15:30

drdoug is right. Sorry for not being precise. :oops:

Code: Select all

   CMCON = 7;             // Comparators off
This line is necessary before doing anything with PORTA as digital port.
Regards,
thenoble66
--------------------------------------------------------------------

atommic22
Posts: 24
Joined: 17 May 2008 12:39

#21 Post by atommic22 » 22 May 2008 06:23

Fantastic! I got the USART code out of PORTB.RB2. I am yet to start the decoder chip, however I have a more urgent problem. It runs fine on the PIC board however when i try to transfer it over to a Breadboard it doesnt output anything. noble66, I wired it up the way you specified in your schematics, but there is no logic output whatsoever.
I tested the chip in the PIC board and there where no clock-pulses feeding into the chip so I must assume it is set to its own internal oscillator. Is there some way I can test this?

Thanxs again you guys for your support so far.

drdoug
Posts: 1074
Joined: 16 Aug 2007 03:49
Location: St. Louis, MO

#22 Post by drdoug » 22 May 2008 07:52

Definitely check that you are using the internal osc (under Edit Project) and make sure you have the proper power and ground connections (middle of the chip) which were not included in the schematic but is assumed a priori.
Also make sure you have included that pull up to RA5 or the chip will behave oddly.

atommic22
Posts: 24
Joined: 17 May 2008 12:39

#23 Post by atommic22 » 22 May 2008 13:35

See thats the problem. There's at least 5 different clock settings/flags in the set up. Right now _HS_OSC is set. There's _XT_OSC, _LP_OSC. Then theres all the INT_OSC functions. I'm not sure which flag sets the internal oscillator/RC.

drdoug
Posts: 1074
Joined: 16 Aug 2007 03:49
Location: St. Louis, MO

#24 Post by drdoug » 22 May 2008 14:05

I think you want INTOSC_OSC_NOCLKOUT as your oscillator. You can de-select the other items (for osc).

I also usually select MCLRE_OFF so I don't have to worry about the pull up on RA5.

I have not played with the RC osc mode but you can experiment with that once you get the unit working on a bread board (baby steps). The slower osc will save you power and it shouldn't mess up the UART since its in the hardware. Few components at this stage is desirable.
Last edited by drdoug on 22 May 2008 14:06, edited 1 time in total.

Jan Rune
Posts: 416
Joined: 21 Oct 2005 23:04
Location: Oslo, Norway

#25 Post by Jan Rune » 22 May 2008 14:05

The INT_OSC sets the internal oscillator...

Jan Rune
Posts: 416
Joined: 21 Oct 2005 23:04
Location: Oslo, Norway

#26 Post by Jan Rune » 22 May 2008 14:15

You should set your baudrate to 9600:

Code: Select all

Usart_Init(9600);
And you should consider using a crystal oscillator...

atommic22
Posts: 24
Joined: 17 May 2008 12:39

#27 Post by atommic22 » 22 May 2008 15:33

I've set my Baud rate to 4800 because 9600 may be too high for my RX/Tx radio units. you say INT_OSC but which one?

_INTOSC_OSC_CLKOUT
_INTOSC_OSC_NOCLKOUT
_INTRC_OSC_CLKOUT
_INTRC_OSC_NOCLKOUT

I would assume _INTOSC_OSC_NOCLKOUT but i think i tested that setting and it still didnt work. The other mehtods i have set by default are:

_HS_OSC
_WDT_OFF
_LVP_OFF

should I turn off _HS_OSC if i set an internal oscillator?

Jan Rune
Posts: 416
Joined: 21 Oct 2005 23:04
Location: Oslo, Norway

#28 Post by Jan Rune » 22 May 2008 15:36

should I turn off _HS_OSC if i set an internal oscillator?
Yes you should.

drdoug
Posts: 1074
Joined: 16 Aug 2007 03:49
Location: St. Louis, MO

#29 Post by drdoug » 22 May 2008 16:27

atommic22 wrote: I would assume _INTOSC_OSC_NOCLKOUT but i think i tested that setting and it still didnt work.
Make SURE you tested it in the EP board. This should be what you want and it should work in the breadboard as well. Does the RB2 light come on? - It should indicating the USART is initialized. You can even run it through the on board max232 to see if you get data from the pic using the terminal emulator.

atommic22
Posts: 24
Joined: 17 May 2008 12:39

#30 Post by atommic22 » 22 May 2008 16:45

Yes it works fine in the programming test bed. The RB2 output illuminates and i even ran it through an oscilloscope. The button states are interpreted fine. I will implement the clock changes tomorrow. Hopefully that will work.

Post Reply

Return to “mikroC General”