View previous topic :: View next topic |
Author |
Message |
alext
Joined: 27 Mar 2006 Posts: 11
|
Posted: Fri Jun 16, 2006 8:58 pm Post subject: Can't use Inverted in Open command |
|
|
Hi everybody
I have a problem using the option INVERTED with the open command to communicate two at89c2051
Im using:
Open "com3.7:4800,inverted" For Output As #2 in one of the micros
and
Open "com3.7:4800,inverted" For input As #2 in the other
I'm sending the following data
dig() is a byte variable
Dig(1) = 1
Dig(2) = 2
Dig(3) = 3
For I = 1 To 7
Put #2 , Dig(i)
Waitms 5
Next I
I receive other values in the second micro. What is the problem ??
Thanks for any help |
|
Back to top |
|
|
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Fri Jun 16, 2006 9:32 pm Post subject: |
|
|
Hi,
If the 2 micro's are directly connected simply don't use the inverted command.
Is the ground of the 2 micro's connected ?
Frank. |
|
Back to top |
|
|
alext
Joined: 27 Mar 2006 Posts: 11
|
Posted: Sat Jun 17, 2006 12:34 am Post subject: |
|
|
Hi Frank
At first, I didnt use the inverted option, and the transmission was Ok, but when I wasnt transmiting info, the channel stayed in logical 1 (high voltage). I'm using a RF transceiver with AM or OOK modulation to communicate the 2 micros, and I want to invert the output signal so when Im not sending data the RF transceiver dont generate the signal
What can I do??? |
|
Back to top |
|
|
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Sat Jun 17, 2006 7:33 am Post subject: |
|
|
If non inverted works and inverted not than the chance is great that it is a software bug.
What happens if you wire the to micro's together and than communicate,
is the inverting mode than also not working?
In the worst case the inverting can be done in hardware. |
|
Back to top |
|
|
4Stroke
Joined: 02 Aug 2004 Posts: 20 Location: Netherlands
|
Posted: Sat Jun 17, 2006 12:03 pm Post subject: |
|
|
Hi,
Isnt it
Open "com3:4800,inverted" For Output As #2
or
Open "comD.7:4800,inverted" For Output As #2
Instead of
Open "com3.7:4800,inverted" For Output As #2
Regards Nathan |
|
Back to top |
|
|
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Sat Jun 17, 2006 4:58 pm Post subject: |
|
|
The ports on 8051 chips have a number in contrast with an avr who uses a letter.
So open "com3.7:4800" means port 3, pin 7
Frank. |
|
Back to top |
|
|
alext
Joined: 27 Mar 2006 Posts: 11
|
Posted: Mon Jun 19, 2006 8:54 pm Post subject: |
|
|
Hi Frankeman
I think it would be better to do it in hardware. Now I have another question...
I can send a byte array without problem with the commands
Put #1 , Dig(i) and
Get #1 , Dig(i) Timeout = 100
but now I'm trying to send a string variable with
Dim Id As String * 5
id = "AR234"
Printbin #1, id and
inputbin #1, id
but the other micro receives just one character at a time an I need to define more varaibles to receive the next characters
Is there any way to receive the whole string with just one variable??? |
|
Back to top |
|
|
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Mon Jun 19, 2006 10:36 pm Post subject: |
|
|
you can't send a string like that, the string must be send char by char
Code: |
dim id as string * 5
dim L as byte
dim N as byte
dim A as byte
id = "AR234" 'assign string
L = len(id) 'get length of string
for N = 1 To L 'for all characters from left to right
A = mid(id , N , 1) 'get character
put #1 , A 'write it to comport
next
|
|
|
Back to top |
|
|
alext
Joined: 27 Mar 2006 Posts: 11
|
Posted: Wed Jun 21, 2006 9:06 pm Post subject: |
|
|
Hello everybady
At last I could resolve the problem of the INVERTED option.
The initial state of the port P0.7 remained on high voltage (1L) so I changed it to low with RESET P0.7 and finally it worked out!!!!!
And I could send the whole string too, without problem and just with one instruction.
Thanks everybody for your help
Regards
ALEX |
|
Back to top |
|
|
|