Problem with PINK and BS2

Community forum for discussion and support of the PINK product and development kit
Post Reply
Yaox
Posts: 4
Joined: Mon Jan 03, 2011 10:48 am

Problem with PINK and BS2

Post by Yaox »

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
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: Problem with PINK and BS2

Post by Chris Ruff »

I am a completely unqualified PINK-BS2 talker, but..

Do you have a scope to see if the Tx and Rx lines are wiggling?
Can you wire in a level shifter (MAX232) to each of the devices and try to talk with them, one-at-a-time with MTTTY?

Is someone forcing you to do this in BASIC? It is a truly nasty language and if I were you I would study and move to C ASAP.

I am not trying to be a jerk, as I started a long time ago with TINY BASIC on a Transwave 5270 (as I remember it) and I should have taken the week necessary at the time to study C, buy a compiler (they are free now for PIC - and great!) and save myself the many months of trouble I stuck myself with when I shipped my product running TINY BASIC.

my 2c

Chris
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Problem with PINK and BS2

Post by rnixon »

I'm not a pink guy either, but I did see a previous ticket where the programmer used the telnet connection to debug serial communication. Have you tried that?
Yaox
Posts: 4
Joined: Mon Jan 03, 2011 10:48 am

Re: Problem with PINK and BS2

Post by Yaox »

rnixon wrote:I'm not a pink guy either, but I did see a previous ticket where the programmer used the telnet connection to debug serial communication. Have you tried that?

I am using telnet connection to the debug the serial communication but all i get is this : http://www.freeimagehosting.net/image.p ... 51fc0d.jpg

I have to do this in Basic because is a college project, and i don't have the choice to make it in C.

I don't know if i am making a mistake or there is something that i am not considering, or in the worse case there is a problem with the PINK.

Thanks
wiresalot
Posts: 7
Joined: Mon Dec 27, 2010 4:01 pm

Re: Problem with PINK and BS2

Post by wiresalot »

Are you powering the PINK of the Stamp 5v Vdd and Vss?

Make sure your power supply is able to handle both of them (350ma) is what I believe it should be.
I had issues with mine before I upgraded to a bigger PS.

wiresalot
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Problem with PINK and BS2

Post by rnixon »

Definitely check the power supply, but it could also be a serial port setting issue. Make sure the baud rate, stop bits, start bits, parity, etc are all set correctly and match between the bs and pink.
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: Problem with PINK and BS2

Post by lgitlitz »

From your telnet output it looks like there is a problem with the serial communication from the stamp to the NetBurner. The first thing I would suspect is some sort of baud rate problem but you already looked into that. How long are the jumper wires from the stamp to the NetBurner? Have you ever gotten the PINK kit to work? If not then you should start from the provided documentation and follow it step by step. Use exactly the same hardware setup and example code provided in the PINK doc and see if you still have problems.

-Larry
Yaox
Posts: 4
Joined: Mon Jan 03, 2011 10:48 am

Re: Problem with PINK and BS2

Post by Yaox »

lgitlitz wrote:From your telnet output it looks like there is a problem with the serial communication from the stamp to the NetBurner. The first thing I would suspect is some sort of baud rate problem but you already looked into that. How long are the jumper wires from the stamp to the NetBurner? Have you ever gotten the PINK kit to work? If not then you should start from the provided documentation and follow it step by step. Use exactly the same hardware setup and example code provided in the PINK doc and see if you still have problems.

-Larry

Thanks for your support guys... well i started again from the beggining using the pink documentation, and i did everything it says, in fact i followed it step by step, then i got to the point where i had to run the "PINKTestV1.0" to test the communication between my BS2 and the PINK module, and the result was "FAILED" in the debug screen of my BS2.


The program:


' =========================================================================
'
' File...... PINKTestV1.0.bs2
' Purpose... Test Serial Communication Between PINK & BS2 Module
' Started...
' Updated... 09-10-2007
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------

' This program tests serial communication between the BASIC Stamp 2 and
' the PINK Module by writing four values to a variable and then verifying
' the data was written correctly. If all four variables write and verify
' the communication is assumed to be working.


' -----[ 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
verify VAR Byte ' Verification Data Variable
index VAR Byte ' Index Counter Byte


' -----[ EEPROM Data ]-----------------------------------------------------

TestBytes DATA $00, $55, $AA, $FF


' -----[ Program Code ]----------------------------------------------------

Main:
DEBUG "Testing communication with PINK Module..."
FOR index = 0 TO 3 ' Four Bytes
READ TestBytes + index, nbvar ' Fetch Next Test Byte
SEROUT TX, Baud, ["!NB0W00:", nbvar]' Send To PINK GP 00
DEBUG nbvar
SEROUT TX, Baud, ["!NB0R00"] ' Send Command To Read Variable
SERIN RX, Baud, 100, Timeout, [verify]' Get One Byte With Timeout
IF verify <> nbvar THEN Failure ' Check For Match
NEXT
DEBUG "PASSED!"
END

Failure:
DEBUG "FAILED!"
END

Timeout:
DEBUG "Failed!", CR, "Communication Timeout!"' Serial Timeout
END

I am kind of a newbie using these components (BS2 and PINK) and i don't know if something that i might had done damaged the device.

The wires that i am using are the ones that came with the PINK, the PINK is connected to a 5v 1Amp. I am connecting the wires directly from the I/O pins in the PINK module to the I/O pins in the BS2. I don't know if that has something to do with the problem that i have?

Is it possible that the PINK module is damaged beyond repair? should i buy a new one?
I don't know if there is a way to check if my BS2 serial port conf is set to : 2400 bauds, data bit = 8 bits, Parity NOne, and stop bit= 1.
In the code i'm using 396 in the baud element, but regarding the parity , stop bit and data bit i don't know if by default they are set to the values of the PINK.


Thanks again.
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Problem with PINK and BS2

Post by rnixon »

What does the telnet debug session show when you run this test?
Yaox
Posts: 4
Joined: Mon Jan 03, 2011 10:48 am

Re: Problem with PINK and BS2

Post by Yaox »

rnixon wrote:What does the telnet debug session show when you run this test?
I fixed it. It was the most stupid thing ever, i guess i didn't notice because i was confident that all the wires and connections were in a perfect state.
The problem was that the VSS of the PINK was not connected in the same place as the VSS of the BS2.

Anyway thanks for the help.
Post Reply