Problem with PINK and BS2
Posted: Tue Jan 04, 2011 11:41 am
Hello , i'm trying to establish communication between PINK and a BS2 using this code in picbasic 2.5, what i want to do is to write for example "57" in a PINK variable and after that be able to read it from the PINK :
' {$STAMP BS2}
' {$PBASIC 2.5}
NBVAR VAR Byte(10)
NBVAR2 VAR Byte(10)
DO
NBVAR(10) = 57
'DEBUG DEC NBVAR(10), CR
SEROUT 15,396,["!NB0W20:",DEC NBVAR(10),CLS] ' read variable #6
SEROUT 15,396,["!NB0R20"]
DEBUG DEC NBVAR(10), CR
PAUSE 100
SERIN 14,396, [DEC NBVAR2(10)]
DEBUG DEC NBVAR2(10),CR
LOOP
END
The program above stops at the SERIN instruction, and it doesn't continue. I have checked the baud rate on the web interface for the PINK, and in the IPSETUP, and it is at 2400. I also tried switching the I/O Pins of my BS2 and the PINK I/O pins TX1 and RX1 to TX0 and RX0 with not sucess.
I also tried using telnet to see if there was communication on the ip adress of the pink with the same results.
I have changed the IP adress, the wires in the connection of the BS2 and the PINK , i tried different example codes such as "PINKTestV1.0" and i got the FAILED result.
Please help, i don't know what else to try or do.
Thanks.
I tried with this program :
' =========================================================================
'
' File...... PINKWriteVariable.bs2
' Purpose... Write General Purpose Variables Serially
' Started...
' Updated... 09-10-2007
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' This programs writes some values to the PINK General Purpose Variables
' 01 through 03 using various methods (formats).
' See the PINKWriteString.bs2 for an example of writing multiple bytes to
' a variable.
' -----[ I/O Definitions ]-------------------------------------------------
RX PIN 14 ' Serial Receieve Pin --> PINK.TX
TX PIN 15 ' Serial Transmit Pin --> PINK.RX
' -----[ Constants ]-------------------------------------------------------
Baud CON 396 ' 2400 bps (BS2)
' -----[ Variables ]-------------------------------------------------------
nbvar VAR Byte ' PINK Data Variable
' -----[ Program Code ]----------------------------------------------------
Main:
nbvar = 200
SEROUT TX, Baud, ["!NB0W01:100", CLS] ' Write ASCII String 100 To GP01
SEROUT TX, Baud, ["!NB0W02:", 150, CLS]' Write Value 100 To GP02
SEROUT TX, Baud, ["!NB0W03:", nbvar, CLS]' Write Value In nbvar To GP03
END
THEN I RAN THIS ONE :
' =========================================================================
'
' File...... PINKReadVariable.bs2
' Purpose... Read General Purpose Variable 02 Serially
' Started...
' Updated... 09-10-2007
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' This programs reads the values from the PINK General Purpose Variables
' 01 through 03 that were written using the PINKWriteVariable.bs2 code.
' See the PINKReadString.bs2 for an example of reading multiple bytes from
' a variable.
' -----[ I/O Definitions ]-------------------------------------------------
RX PIN 14 ' Serial Receieve Pin --> PINK.TX
TX PIN 15 ' Serial Transmit Pin --> PINK.RX
' -----[ Constants ]-------------------------------------------------------
Baud CON 396 ' 2400 bps (BS2)
' -----[ Variables ]-------------------------------------------------------
nbvar VAR Byte ' PINK Data Variable
' -----[ Program Code ]----------------------------------------------------
Main:
SEROUT TX, Baud, ["!NB0R01"] ' Send Command To Read Variable 01
SERIN RX, Baud, 100, Timeout, [DEC nbvar]' Get Data With Timeout
DEBUG "Variable 01: ", DEC nbvar, CR ' Display Byte In Decimal
SEROUT TX, Baud, ["!NB0R02"] ' Send Command To Read Variable 02
SERIN RX, Baud, 100, Timeout, [nbvar]' Get One Byte With Timeout
DEBUG "Variable 02: ", DEC nbvar, CR ' Display Byte In Decimal
SEROUT TX, Baud, ["!NB0R03"] ' Send Command To Read Variable 03
SERIN RX, Baud, 100, Timeout, [nbvar]' Get One Byte With Timeout
DEBUG "Variable 03: ", DEC nbvar ' Display Byte In Decimal
END
Timeout:
DEBUG "Communication Timeout!" ' Serial Timeout
END
But it seems that the program stops at SERIN RX, Baud, 100, Timeout, [DEC nbvar]' Get Data With Timeout and doesn't do anything after that. It is like it is waiting for something that never comes.
Is my PINK malfunctioning?
Thanks again
' {$STAMP BS2}
' {$PBASIC 2.5}
NBVAR VAR Byte(10)
NBVAR2 VAR Byte(10)
DO
NBVAR(10) = 57
'DEBUG DEC NBVAR(10), CR
SEROUT 15,396,["!NB0W20:",DEC NBVAR(10),CLS] ' read variable #6
SEROUT 15,396,["!NB0R20"]
DEBUG DEC NBVAR(10), CR
PAUSE 100
SERIN 14,396, [DEC NBVAR2(10)]
DEBUG DEC NBVAR2(10),CR
LOOP
END
The program above stops at the SERIN instruction, and it doesn't continue. I have checked the baud rate on the web interface for the PINK, and in the IPSETUP, and it is at 2400. I also tried switching the I/O Pins of my BS2 and the PINK I/O pins TX1 and RX1 to TX0 and RX0 with not sucess.
I also tried using telnet to see if there was communication on the ip adress of the pink with the same results.
I have changed the IP adress, the wires in the connection of the BS2 and the PINK , i tried different example codes such as "PINKTestV1.0" and i got the FAILED result.
Please help, i don't know what else to try or do.
Thanks.
I tried with this program :
' =========================================================================
'
' File...... PINKWriteVariable.bs2
' Purpose... Write General Purpose Variables Serially
' Started...
' Updated... 09-10-2007
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' This programs writes some values to the PINK General Purpose Variables
' 01 through 03 using various methods (formats).
' See the PINKWriteString.bs2 for an example of writing multiple bytes to
' a variable.
' -----[ I/O Definitions ]-------------------------------------------------
RX PIN 14 ' Serial Receieve Pin --> PINK.TX
TX PIN 15 ' Serial Transmit Pin --> PINK.RX
' -----[ Constants ]-------------------------------------------------------
Baud CON 396 ' 2400 bps (BS2)
' -----[ Variables ]-------------------------------------------------------
nbvar VAR Byte ' PINK Data Variable
' -----[ Program Code ]----------------------------------------------------
Main:
nbvar = 200
SEROUT TX, Baud, ["!NB0W01:100", CLS] ' Write ASCII String 100 To GP01
SEROUT TX, Baud, ["!NB0W02:", 150, CLS]' Write Value 100 To GP02
SEROUT TX, Baud, ["!NB0W03:", nbvar, CLS]' Write Value In nbvar To GP03
END
THEN I RAN THIS ONE :
' =========================================================================
'
' File...... PINKReadVariable.bs2
' Purpose... Read General Purpose Variable 02 Serially
' Started...
' Updated... 09-10-2007
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' This programs reads the values from the PINK General Purpose Variables
' 01 through 03 that were written using the PINKWriteVariable.bs2 code.
' See the PINKReadString.bs2 for an example of reading multiple bytes from
' a variable.
' -----[ I/O Definitions ]-------------------------------------------------
RX PIN 14 ' Serial Receieve Pin --> PINK.TX
TX PIN 15 ' Serial Transmit Pin --> PINK.RX
' -----[ Constants ]-------------------------------------------------------
Baud CON 396 ' 2400 bps (BS2)
' -----[ Variables ]-------------------------------------------------------
nbvar VAR Byte ' PINK Data Variable
' -----[ Program Code ]----------------------------------------------------
Main:
SEROUT TX, Baud, ["!NB0R01"] ' Send Command To Read Variable 01
SERIN RX, Baud, 100, Timeout, [DEC nbvar]' Get Data With Timeout
DEBUG "Variable 01: ", DEC nbvar, CR ' Display Byte In Decimal
SEROUT TX, Baud, ["!NB0R02"] ' Send Command To Read Variable 02
SERIN RX, Baud, 100, Timeout, [nbvar]' Get One Byte With Timeout
DEBUG "Variable 02: ", DEC nbvar, CR ' Display Byte In Decimal
SEROUT TX, Baud, ["!NB0R03"] ' Send Command To Read Variable 03
SERIN RX, Baud, 100, Timeout, [nbvar]' Get One Byte With Timeout
DEBUG "Variable 03: ", DEC nbvar ' Display Byte In Decimal
END
Timeout:
DEBUG "Communication Timeout!" ' Serial Timeout
END
But it seems that the program stops at SERIN RX, Baud, 100, Timeout, [DEC nbvar]' Get Data With Timeout and doesn't do anything after that. It is like it is waiting for something that never comes.
Is my PINK malfunctioning?
Thanks again