Problem with 433mhz and uart *noob* Solved it already

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
bunny-rabbit
Posts: 42
Joined: Fri Jan 18, 2008 10:39 am
Location: Emmen/ Netherlands

Problem with 433mhz and uart *noob* Solved it already

Post by bunny-rabbit » Thu Oct 30, 2008 3:46 pm

Hello!

Its me again :roll: .

I`m trying send data from pic to pic via usart.bas.

I`m having the following problem:

When i hard wire the 2 pic`s, TX and RX all goes well!

But when i plug the 433mhz thingies it works not nearly as well..

The 433mhz thingies
Image

Here`s my code for both RX an TX.


The TX code:

Code: Select all

Device = 18F452
Clock = 20

Include "usart.bas"

// opties voor usart.bas module
#option USART_BRGH = false

//Dim result As Boolean 
Dim led1 As Byte
Dim led2 As Byte
Dim syn As Byte
//dim syn2 as byte

syn = $AA
led1 = $3e
led2 = $89

SetBaudrate(br19200)

While true

//WriteByte(syn) //sync 433mhz

If PORTC.3 = 1
      Then
      WriteByte(led1) // send the command
      DelayMS(100)
        
      Else
      WriteByte(syn) //sync 433mhz
EndIf
    
    If PORTC.2 = 1
        Then
        WriteByte(led2)   // send the command
        DelayMS(100)
       
        Else
        WriteByte(syn) //sync 433mhz   
    EndIf
Wend
RX code:

Code: Select all

Device = 18F452
Clock = 20

Include "usart.bas"

// opties voor usart.bas module
#option USART_BRGH = false

Dim result As Boolean 
Dim ontvang2 As Byte
Dim led As PORTD.0
Dim led2 As PORTD.1
Dim ontvang1 As Byte

SetBaudrate(br19200)

ontvang1 = $3E
ontvang2 = $89


While true
result=USART.WaitForTimeout(ontvang1,20)  'look for return byte value and timeout(1000ms) if failed, result is true if value matches 
If result = true 

    Then
         High(led) 
         Low(led2)
         
         Else
         //low(led2)
         
             

EndIf

result=USART.WaitForTimeout(ontvang2,20)  'look for return byte value and timeout(1000ms) if failed, result is true if value matches 
If result = true 

    Then
         Low(led)
         High(led2)
         Else
         //High(led2)
         
             

EndIf

Wend
Sometimes it works for a few switches.
But most of the time i need to push the switch 3 or more time`s.

And when i disconnect power of the TX the RX switches constantly :evil: .

What can this be?

Greets.
Gert

Post Reply