Subject:
|
Re: Electrical Data Link between 2 RCXs
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Tue, 3 Apr 2001 23:18:50 GMT
|
Viewed:
|
2363 times
|
| |
| |
> However, there is a strange effect:
>
> When I start the program, the first message that is sent is corrupted, i.e.
> wrong pulses are created. E.g., if I send a "0" (binary 0000), I measured the
> following duration for the pulses (value of "very fast timer variables"):
>
> start: 2500 - 3600
> bit 3: 94
> bit 2: 4
> bit 1: 0
> bit 0: 1
>
> So a value of "12" was received. This effect always happens.
> After this, everything is fine. It seems that the RCX needs some time to adjust
> his output procedures ... (Anyone got an explanation for this ?)
>
> Of course, I can send a dummy, throw it away in the receiver and after this the
> communication will work.
>
> For those who are interested in the whole subject, here the programs for cut
> and paste:
>
> TRANSMITTER:
>
> int num = 0;
>
> task main ()
> {
> CreateDatalog (100);
> SetUserDisplay (num, 0);
> Float (OUT_B); // default condition (low)
>
> while (true)
> {
> num = 0;
> repeat (16)
> {
> Wait (20);
> PlayTone(2000, 5);
> send ();
> num ++;
> }
> }
> }
>
> sub send ()
> {
> #define _one 3
> #define _zero 1
>
> int _bit3 = _zero;
> int _bit2 = _zero;
> int _bit1 = _zero;
> int _bit0 = _zero;
>
> if ((num & 0x08) == 0x08) _bit3 = _one;
> if ((num & 0x04) == 0x04) _bit2 = _one;
> if ((num & 0x02) == 0x02) _bit1 = _one;
> if ((num & 0x01) == 0x01) _bit0 = _one;
>
> Off (OUT_B); Wait (_one); // Startbit (high)
> Float (OUT_B); Wait (_bit3); // Bit 3 (low)
> Off (OUT_B); Wait (_bit2); // Bit 2 (high)
> Float (OUT_B); Wait (_bit1); // Bit 1 (low)
> Off (OUT_B); Wait (_bit0); // Bit 0 (high)
> Float (OUT_B); // default (low)
> }
>
>
> RECEIVER:
>
> #define _threshold 3
>
> int _bit3;
> int _bit2;
> int _bit1;
> int _bit0;
> int _start;
>
> int num;
> int display = 0;
>
> task main ()
> {
> SetSensor (SENSOR_1, SENSOR_TOUCH);
> SetUserDisplay (display, 0);
> CreateDatalog (1000);
> ClearSensor (SENSOR_1);
>
> while (true)
> {
> num = 0;
> _bit3 = 0;
> _bit2 = 0;
> _bit1 = 0;
> _bit0 = 0;
> _start = 0;
>
> until (SENSOR_1 == 1); // wait for Startbit
> until (SENSOR_1 == 0) _start ++; // pulse length of Startbit
> until (SENSOR_1 == 1) _bit3 ++; // pulse length of bit 3
> until (SENSOR_1 == 0) _bit2 ++; // pulse length of bit 2
> until (SENSOR_1 == 1) _bit1 ++; // pulse length of bit 1
> until (SENSOR_1 == 0) _bit0 ++; // pulse length of bit 0
>
> if (_bit3 >= _threshold) num = num + 8;
> if (_bit2 >= _threshold) num = num + 4;
> if (_bit1 >= _threshold) num = num + 2;
> if (_bit0 >= _threshold) num = num + 1;
> PlayTone(4000, 5);
> display = num;
> }
> }
>
> Best regards
> Bernd Frassek
My guess is that SENSOR_1 in your receiving RCX is getting a 1 when your
program starts. I imagine that OFF is the default state for OUT_B in your
transmitter RCX, and that the receiver is seeing this before OUT_B is
switched to FLOAT. This is pretty easy to correct by putting an until
(SENSOR_1 == 0) before the while loop in your receiver program.
|
|
Message has 1 Reply: | | Re: Electrical Data Link between 2 RCXs
|
| It's me again with some improvements for an "Electrical Data Link between 2 RCX". In the current version I changed the default condition of the link to "high" (in the transmitter: OFF(OUT_B)) so that the receiver has a 1 at its sensor input. So, you (...) (24 years ago, 17-Apr-01, to lugnet.robotics.rcx.nqc)
|
Message is in Reply To:
| | Re: Electrical Data Link between 2 RCXs
|
| (...) Hi Dean, meanwhile I followed your suggestions and implemented a scheme that uses a pulse scheme like this: ______ ______ ______ __ ______ ______ ___...___ Start Bit3 Bit2 Bit1 Bit0 A bit value of 1 results in a long pulse, a bit value of 0 in (...) (24 years ago, 3-Apr-01, to lugnet.robotics.rcx.nqc)
|
11 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|