Shop OBEX P1 Docs P2 Docs Learn Events
Transmission and Reception Problem BS2 :( — Parallax Forums

Transmission and Reception Problem BS2 :(

A KrishA Krish Posts: 27
edited 2008-04-06 15:38 in BASIC Stamp
Hey Guys ...

I am running in to communication problem, plzzz give me·your suggestions its really urgent...

System Description:

I have·4 BS2 boards loaded with transmitters and receivers (27980 & 27981), Once the BS2 "A" initiates a code, this·should be recieved by BS2 "B", BS2 "C" and BS2 "D". Once BS2"B" and BS2"C" receive this activation code·they start sensing·and if a trigger comes to the sensor, it must transmit code's to BS2 "D".

Problem Statement:

Once BS2 "B" and BS2 "C" have received the activation code from BS2 "A", and have also sensed, they must transmit to BS2"D". Now my problem lies in the communciation.

I am unable to transmit data from BS2 "B" or BS2 "C"·to BS2 "D" after I have received the activation code from BS2 "A".

If i dont use the activation code .. and directly send the data from BS2 "B" and BS2 "C" then I am·able to receive the communication at BS2 "D".

Things I have already performed:

All transmitter and receiver are correctly attached to the BS2 boards. They have been tested with simple transmission and reception programs ..

Code:

BS2 "A"

' {$STAMP BS2}
' {$PBASIC 2.5}

Init:
x VAR Word
y VAR Word
a VAR Word··········· 'Prerssure Sensor
b VAR Word··········· 'PIR sensor
counter VAR Word
sensorpin CON 15

Sensor:
· DO
··· HIGH 15
··· PAUSE 10
··· RCTIME sensorpin,1,a
····· IF ((IN1 = 1) & (a > 100)) THEN········· 'IN1 is the input pin of PIR sensor
······· DEBUG "In Transmit Mode",LF,CR
······· PAUSE 3000
······· GOSUB Transmit
····· ELSE
······· DEBUG " In Sensor Mode",LF,CR
······· PAUSE 100
······· GOSUB Sensor
····· ENDIF
· LOOP
END

Transmit:····· ' Control passes to this section only when both the sensors sense a movement.

· x = 1011····· ' Data to be transmitted
··· PULSOUT 6, 1200
··· SEROUT 6,16780,[noparse][[/noparse]"!",DEC x,CR]
··· DEBUG ? x,LF,CR
··· GOSUB Sensor

BS2 "B"

' {$STAMP BS2}
' {$PBASIC 2.5}

Init:

x VAR Word
y VAR Word
a VAR Word··········· 'Prerssure Sensor
b VAR Word··········· 'PIR sensor
t VAR Word

counter VAR Word
sensorpin CON 15

Receive:
· DO
··· HIGH 0
··· SERIN 12,16780,300,Receive,[noparse][[/noparse]WAIT("!"),DEC4 y]
··· DEBUG ? y,LF,CR
··· LOW 0

····· IF ( y = 1011 ) THEN················· ' y = 1011 signifies that the sensor needs to be in full power mode
··········································· ' that is all the sensors would be in action to sense movement.
······· DEBUG "Get Awake",LF,CR
······· GOTO Sensor

····· ENDIF
· LOOP

GOTO Sensor

Sensor:
· DO
··· HIGH 15
··· PAUSE 10
··· RCTIME sensorpin,1,a
····· IF ((IN1 = 1) & (a > 100)) THEN
······· DEBUG "In Transmit Mode",LF,CR
······· GOSUB Transmit
····· ELSE
······· DEBUG " In Sensor Mode",LF,CR
······· PAUSE 1000
······· GOSUB Sensor
····· ENDIF
· LOOP
RETURN

Transmit:····· ' Control passes to this section only when both the sensors sense a movement.

··· x = 1010····· ' Data to be transmitted
··· PULSOUT 6, 1200
··· SEROUT 6,16780,[noparse][[/noparse]"!",DEC x,CR]
··· DEBUG ? x,LF,CR
··· GOTO Sensor
RETURN

BS2 "C"

' {$STAMP BS2}
' {$PBASIC 2.5}


Init:

x VAR Word
y VAR Word
a VAR Word··········· 'Prerssure Sensor
b VAR Word··········· 'PIR sensor
counter VAR Word
sensorpin CON 15

Receive:
· DO
··· HIGH 0
··· SERIN 12,16780,300,Receive,[noparse][[/noparse]WAIT("!"),DEC4 y]
··· DEBUG ? y,LF,CR
··· LOW 0
····· IF ( y = 1011 ) THEN················· ' y = 1100 signifies that the sensor needs to be in full power mode
··················································· ' that is all the sensors would be in action to sense movement.
······· DEBUG "Get Awake",LF,CR
······· GOTO Sensor

····· ENDIF
· LOOP

GOTO Sensor

Sensor:
· DO
··· HIGH 15
··· PAUSE 10
··· RCTIME sensorpin,1,a
····· IF ((IN1 = 1) & (a > 100)) THEN
······· DEBUG "In Transmit Mode",LF,CR
······· GOSUB Transmit
····· ELSE
······· DEBUG " In Sensor Mode",LF,CR
······· PAUSE 1000
······· GOSUB Sensor
····· ENDIF
· LOOP
RETURN

Transmit:····· ' Control passes to this section only when both the sensors sense a movement.

· x = 1001····· ' Data to be transmitted
··· PULSOUT 6, 1200
··· SEROUT 6,16780,[noparse][[/noparse]"!",DEC x,CR]
··· PAUSE 1000
··· GOTO Sensor

RETURN

BS2 "D"

' {$STAMP BS2}
' {$PBASIC 2.5}

Init:

x VAR Word
y VAR Word

Receive:

· DO
··· HIGH 0
··· SERIN 12,16780,100,Receive,[noparse][[/noparse]WAIT("!"),DEC4 x]
··· LOW 0
··· IF (x = 1010) THEN······························· ' Left Sub System
······· GOSUB Leftapproach
····· ELSEIF (x = 1001) THEN························· ' Right Sub System
······· GOSUB Rightapproach
····· ELSEIF (x = 1011) THEN························· ' Sleep Sub System
······· GOSUB Sleepsystem
··· ENDIF
· LOOP

Leftapproach:

· DEBUG " Vehicle approaching from the Left Side ",LF,CR
· 'DEBUG ? x
· GOTO Receive

Rightapproach:

· DEBUG " Vehicle approaching from the Right Side ",LF,CR
· 'DEBUG ? x
· GOTO Receive

Sleepsystem:

· DEBUG " Vehicle trying to merge with the highway ",LF,CR
· 'DEBUG ? x
· GOTO Transmit

Transmit:

· y = 1011
· PULSOUT 6,1200
· SEROUT 6,16780,[noparse][[/noparse]"!",DEC y,LF,CR]
· DEBUG " Wake up sub system 2 and Sub system 3 ",LF,CR
· GOTO Receive
· RETURN


Thanks in advance for your help ......

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-03 23:17
    You have to turn off the "A" transmitter in order to use the "D" transmitter. I think you could use a LOW 6 to do this. You'll need to turn off the "D" transmitter as well after that has sent its trigger.

    You could also use the PDN (Power Down) pin on the transmitter to turn it off (with LOW x).


    Post Edited (Mike Green) : 4/3/2008 11:22:30 PM GMT
  • A KrishA Krish Posts: 27
    edited 2008-04-03 23:39
    If I have understood you correctly ... I should basically ensure that at a time either the transmission takes place or reception takes place .. I am aware of that and in BS2 "A" code .. the transmission only takes place when the sensors are triggered ... I have made the PDN to low ...

    The point is ... if I make the BS2 "B", BS2 "C" work without the data accepted from BS2 "A" then data is being successfully transmitted and received by BS2 "D".

    What I am not sure of is... when I receive the data from BS2 "A" in "BS2"B" and Bs2"C" .... do i have to adds some code to it .. coz i am only recieving in BS2"D" data from Bs2 "A" .. not continuos but when ever there is a trigger at the sensor ...
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-04 00:04
    I don't quite understand what you're saying.

    I believe that, after "A" has sent its data, the transmitter remains on and interferes with "B" and "C" sending a response to sensor input. Note that "B" and "C" can not transmit at the same time.

    It would work better if only one unit is a "master", like "A". "A" can send a signal to "B" or to "C", maybe by including the letter of the unit in the message. One message tells "B" to turn on its sensor and take a reading. Another message might tell "C" to do the same. A third message tells "B" to transmit its result back to "A" after a short delay for "A" to turn off its transmitter. A fourth message tells "C" to do the same.
  • A KrishA Krish Posts: 27
    edited 2008-04-04 02:20
    I would like to bring to your kind notice that when BS2 "A" transmit I can very well receive the code by BS2"B" and BS2 "C" ... My point is I have to transmit data from BS2 "B" and BS2"C" once they have been activated·to BS2 "D".

    I know at a time only one thing would take place either transmission or reception ..... and in this code i beleive i am following that ...

    What I understand the problem is in the SEROUT and SERIN command... I mean once BS2"B" and BS2 "C"·receives and gets active .. BS2"D" does not receive data from BS2 "B" and BS2 "C"....

    Please read the query carefully .. I think you are misunderstanding me .. I really appricate for your efforts .. plzzz have a look at the problem statement ..
  • FranklinFranklin Posts: 4,747
    edited 2008-04-04 03:00
    Seems to me you have too many returns in your code. Could you attach the actual code you are trying and perhaps the actual hookup between the radios and the bs2s

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • A KrishA Krish Posts: 27
    edited 2008-04-04 03:06
    I am mailing you all the four codes .. hope this would help you to understand whats happening ...
  • FranklinFranklin Posts: 4,747
    edited 2008-04-04 03:18
    What is your output from bot B? Also you need returns if you have gosubs (BOTD)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • A KrishA Krish Posts: 27
    edited 2008-04-04 03:26
    1010 .... Once both the sensors are triggered that is PIR and Pressure ... 1010 would be transmitted by BS2 "B" ... This code should be received by BS2 "D".

    I am unable to do this part .. If you feel there is a problem with the Returns can you plzzz let me know a few ... coz I am new to this ...really appreciate your efforts ...
  • A KrishA Krish Posts: 27
    edited 2008-04-04 17:47
    Guys .. I am in a spoy of bother .. can any one plzzz assist me ...· I am unable to resolve this issue ..
  • FranklinFranklin Posts: 4,747
    edited 2008-04-04 21:02
    Are we not helping fast enough for you?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • A KrishA Krish Posts: 27
    edited 2008-04-04 21:05
    Please dont misunderstand me ... I really appreciate your efforts for helping me out ... I didnt receive any suggestion for a long time . ... so thought of just posting a reminder ... again plzz dont take me wrong ...
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-04-05 00:41
    Could it be that "B" and "C" are transmitting concurrently and jamming each other?· I gather that one transmits because of a Left_Approach and the other because of a Right_Approach.··However, is the sensor status of each known and known to be non-conflicting?· Can you disable "B" or "C" and then transmit to and successfully receive on·"D"?

    Post Edit -- Could "A" be used to key the transmissions from "B" and "C"?

    Post Edited (PJ Allen) : 4/5/2008 12:49:51 AM GMT
  • A KrishA Krish Posts: 27
    edited 2008-04-05 05:50
    Well ... What I have realized ... If I simply send msgs from BS2 "A" , BS2 "B" and BS2 "C" (by disabling the activation) to BS2 "D" directly .. Then I am able to receive the information from all the 3 BS2's i.e. BS2 "A", BS2 "B", BS2 "C" on BS2 "D"... So defenitley I dont see the receiver getting jammed by msgs..

    However when I make BS2 "A" activate BS2 "B" or BS2 "C" ... I do receive the activation code on these BS2's and the sensors start sensing but .. then the transmission from BS2 "B" and BS2 "C" is not received by BS2 "D" ...

    I am sure this is a piculiar problem .. what I understand is .. thers is some issue with the Serout and Serin code ... that I have given ... and I am failing to undertstand that ...
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-04-05 14:54
    I think that if A activates B and C, then A should cue B to send its results and then cue·C to send its results.·

    See how that works.

    Post Edit -- This is how I figure your current situation:

    ABCD.jpg


    Post Edited (PJ Allen) : 4/5/2008 3:35:59 PM GMT
  • A KrishA Krish Posts: 27
    edited 2008-04-05 20:36
    Hi ..

    You have pictured the process correctly .... smile.gif .. but the whole purpose gets defeated if BS2"A" only asks BS2 "B" and BS2 "C" to send data to BS2 "D" .. coz ... I need independently BS2 "B" and BS2 "C" to send data to BS2"D" i.e. only when it senses a pulse from the sensors ...
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-04-05 20:48
    If there is no control on when B or C can transmit, either or both can transmit away whenever they get a pulse·(concurrently, simultaneously, howbeit),·one can go off during the other's transmission, then that's a problem, as I see it.

    First, try with only·A, B, and D (no C, it's Off.)· "Works"?· Y/N

    Then try with only A, C, and D (no B, it's Off.)· "Works"?· Y/N
  • A KrishA Krish Posts: 27
    edited 2008-04-05 21:13
    I have tried this also ..

    case 1:

    BS2 "A", BS2 "B" and BS2"D" only ON... i.e. no BS2"C" ... Once BS2 "B" is activated by BS2"A" it should send msg .... but i dont see any msg on BS2 "D" ..

    case 2:

    BS2 "A", BS2 "C" and BS2"D" only ON... i.e. no BS2"B" ... Once BS2 "C" is activated by BS2"A" it should send msg .... but i dont see any msg on BS2 "D" ..

    case 3:

    If I change the program in such a way that BS2 "B", BS2 "C" and BS2 "A" all transmit data to BS2"D" then I am receiving data in BS2 "D" ....

    I think there is some problem in receiveing and then transmitting .. coz .. right now I am first receiving data from BS2"A" and then transmitting to BS2 "D" from BS2 "B" and BS2 "C" and meanwhile BS2 "D" has also received data from BS2 "A" .....
  • FranklinFranklin Posts: 4,747
    edited 2008-04-05 22:18
    Data from where? All three or A only, B only, C only, A and B, or A and C. It will make a difference.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • A KrishA Krish Posts: 27
    edited 2008-04-05 22:24
    I am not sure if I have understand what you are asking .... I want all 3 to i.e. A, B , C to communicate with D .. Not sure if this is what you are asking .. PJ Allen has added a process view .. plzz see that .. that would explain it better ...
  • FranklinFranklin Posts: 4,747
    edited 2008-04-05 22:32
    My question is What are you seeing on D? Are you getting anything or only messages from certain bots.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • A KrishA Krish Posts: 27
    edited 2008-04-05 22:43
    Right now .. with the codes that I have posted .. I can only see data from bot "A" on bot "D" ,,, nothing from "C" and "B" on "D" .......
  • FranklinFranklin Posts: 4,747
    edited 2008-04-05 22:55
    What is the debug output of B?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • A KrishA Krish Posts: 27
    edited 2008-04-05 23:57
    That it is transmitting data 1010 ...
  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-06 00:32
    Just a shot in the dark here, but looking at this from D code...

    DO
    HIGH 0
    SERIN 12,16780,100,Receive,[noparse][[/noparse]WAIT("!"),DEC4 x]
    LOW 0
    IF (x = 1010) THEN ' Left Sub System
    GOSUB Leftapproach
    ELSEIF (x = 1001) THEN ' Right Sub System
    GOSUB Rightapproach
    ELSEIF (x = 1011) THEN ' Sleep Sub System <
    HERE
    GOSUB Sleepsystem
    ENDIF
    LOOP

    Won't this put D into the sleepsystem as soon as A transmits 1011? It doesn't look like this would keep it from working, but makes it look like the flow would be A triggers B and C sensors and also puts D in sleepsystem, preventing it from receiving leftapproach or rightapproach on the first pass. The sleepsystem transmits 1011 and wakes up B and C, which would THEN trigger D on the 2nd pass. You've proabably tried 4,000 consecutive passes by now but I thought I'd point it out.
  • A KrishA Krish Posts: 27
    edited 2008-04-06 00:53
    ya .. I think .. you are right .. but what should I do to solve it .. plzzzz tell me ..
  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-06 01:17
    Why do you even need a sleepsystem on D? Eliminate it. "A" is steadily running the sleep system for you. "D" doesn't need to do it also.

    In "D," I think you could take out:

    ELSEIF (x = 1011) THEN ' Sleep Sub System
    GOSUB Sleepsystem

    And also:

    Sleepsystem:

    DEBUG " Vehicle trying to merge with the highway ",LF,CR
    'DEBUG ? x
    GOTO Transmit

    Transmit:

    y = 1011
    PULSOUT 6,1200
    SEROUT 6,16780,[noparse][[/noparse]"!",DEC y,LF,CR]
    DEBUG " Wake up sub system 2 and Sub system 3 ",LF,CR
    GOTO Receive
    RETURN


    If you want the "Vehicle trying to merge with the highway" debug then put it in "A" and display it the same time you transmit 1011 to B and C.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-04-06 15:38
    [noparse][[/noparse] I noted that "D" transmits !1011 (too),·in my usual understated fashion hoping·to draw attention to that situation,·hence the·two arrows·placed beside it in the "process view" that I posted earlier. ]

    Post Edit -- If "D" is knocking out a !1011 because it got a !1011 (at the same time as "B" and "C"), it could be at the end of this message when "B" and/or "C" knock out their sensor response/s;·the conflict I'd alluded to.

    Post Edited (PJ Allen) : 4/6/2008 3:43:31 PM GMT
Sign In or Register to comment.