Unable to hook up BS2 with Java. Please help!!!
Archiver
Posts: 46,084
Hi,
I am new to Basic Stamp2. i have to submit a project in a short time.
I am trying to hook up Basic Stamp2 to my PC through the serial port (9600
baud, 8bit, no parity, 1 stop bit)
I am using Basic Stamp2 (not BS2E or BS2SX
I am also using the windows based editor. It runs by saying CTRL-R. It is a
little different than the DOS editor, i would think.
I am able to run the program without any problem, but i dont know if it is
downloading itself onto the chip (i think it would be. how else would it
run)
The problem i am facing is that i want to run the program on the IC using
my Java program which reads from and writes to the Serial port (I am using
COM1).
How do i do it?
Please, i wold appreciate a fast reply.
Rishi
Genius is 1% inspiration and 99% prespiration
Genius is 1% inspiration and 99% prespiration
I am new to Basic Stamp2. i have to submit a project in a short time.
I am trying to hook up Basic Stamp2 to my PC through the serial port (9600
baud, 8bit, no parity, 1 stop bit)
I am using Basic Stamp2 (not BS2E or BS2SX
I am also using the windows based editor. It runs by saying CTRL-R. It is a
little different than the DOS editor, i would think.
I am able to run the program without any problem, but i dont know if it is
downloading itself onto the chip (i think it would be. how else would it
run)
The problem i am facing is that i want to run the program on the IC using
my Java program which reads from and writes to the Serial port (I am using
COM1).
How do i do it?
Please, i wold appreciate a fast reply.
Rishi
Genius is 1% inspiration and 99% prespiration
Genius is 1% inspiration and 99% prespiration
Comments
Hi Rishi -
>Hi,
> I am new to Basic Stamp2. i have to submit a project in a short time.
> I am trying to hook up Basic Stamp2 to my PC through the serial port (9600
>baud, 8bit, no parity, 1 stop bit)
> I am using Basic Stamp2 (not BS2E or BS2SX
> I am also using the windows based editor. It runs by saying CTRL-R. It is a
>little different than the DOS editor, i would think.
> I am able to run the program without any problem, but i dont know if it is
>downloading itself onto the chip (i think it would be. how else would it
>run)
Enter one line which say DEBUG "Program Started" as the first statement.
> The problem i am facing is that i want to run the program on the IC using
>my Java program which reads from and writes to the Serial port (I am using
>COM1).
> How do i do it?
> Please, i wold appreciate a fast reply.
>Rishi
>If by "i want to run the program on the IC" you mean that you want to
>execute the code within the Stamp processor separately, and have it
>program-link to anything else, it's just NOT going to happen. The code
>within the IC is a p-Code interpreter and de-tokenizer (as opposed to a
>compiler, or assembly language EXE or operating system). There are
>specific requirements which are met by the HOST editior (the .EXE program
>supplied by Parallax), which is the p-Code emitter and source code syntax
>checker. In turn, it feeds these p-Code tokens to the embedded routines
>hard coded in the PIC processor.
At all times, the Interpreter must remain in control. The Alt-R (RUN
command) performs the transfer of control as the LAST thing that it does,
and that control, once relinquished, is NEVER returned to the operating
system. COMMUNICATION between the two IS possible, however - if this was
your goal.
If what you wish to do is to interface with the Stamp with a data-link,
such that data values within the Stamp at Stamp_Execution time (AFTER
tokenization, de-tokenization, etc) can be passed back, via a serial
connection for display by the HOST program (Java aside[noparse][[/noparse]2]), that is QUITE
doable. As a regular matter, DEBUG is used for this purpose, for small
volumes of data.
More information will be required for specific needs, but the easiest test
case is to use the DEBUG operator: DEBUG ? variable_name which will
transmit to the built-in Serial Port (Pin port 16) "&variable_Name =" [noparse][[/noparse]some
data value] where &variable_Name is replaced by the actual data_label as
defined in the program. This data is INTENDED to be received by the HOST -
what the user DOES with it, is another matter entirely !
The DEBUG serial protocol is 9600,8.N,1 [noparse][[/noparse]1] and responds and acts just like
a Serout operator would, EXCEPT that it uses the "special" DEBUG port (pin
Port 16).
Ref: Parallax Stamp I / II Manual Version 1.9. , (pp 326, 317-318, 320, 255).
- - - - -
[noparse][[/noparse]1] CAUTION - Data inversion should be considered, depending on the
application
[noparse][[/noparse]2} Java - ANY program COULD CAREFULLY "tap" the serial line;
essentially no different than an evesdropping phone tap. The
SAME caveats about
being discreet, and non-interfering apply here as well !
Impacting pin Port 16 is dangerous, since this is also the programming
port. USE with EXTREME caution. There are timing and signal considerations
which occur during programming which have NO bearing on the standard RS-232
protocol.
- - - - - -
Hope that gives you a start.
Regards,
Bruce Bates
thanx a lot for your prompt reply.
the program actually runs. i am able to output the data in the host program
using the debug command. the data even appears upon using Serout command.
However i am not able to use Serin command (where is the data supposed to
come for Serin. and conversely where does the serout data go?). Can i access
the serout data from the HOST Program at least (not my Java program. Java
program, i will call FOREIGN).
If it is not possible using BS2, how can we access data for several other
applications? I am sure BS2 doesnt have the capability to store huge
programs. I hear people talking about Robotics and Peizoelectric projects
and a lot more. How do they access the data. Will something like BS2SX help
me?
Expecting an early reply again.
Thanx for your attention
Rishi
Genius is 1% inspiration and 99% perspiration
Original Message
From: Bruce Bates [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=6vfwDz0UfhK0Q8yEGG7ibFzU48Wv-wqmWfszGcRgXUdmiNZnlDYnChegBnFfvWFl8OiZI9GEtoqnv2D29iDCJg]bvbates@u...[/url
Sent: Friday, December 08, 2000 1:38 AM
To: basicstamps@egroups.com
Subject: Re: [noparse][[/noparse]basicstamps] Unable to hook up BS2 with Java. Please
help!!!
At 12:33 AM Friday 12/8/2000 -0500, you wrote:
Hi Rishi -
>Hi,
> I am new to Basic Stamp2. i have to submit a project in a short time.
> I am trying to hook up Basic Stamp2 to my PC through the serial port
(9600
>baud, 8bit, no parity, 1 stop bit)
> I am using Basic Stamp2 (not BS2E or BS2SX
> I am also using the windows based editor. It runs by saying CTRL-R. It is
a
>little different than the DOS editor, i would think.
> I am able to run the program without any problem, but i dont know if it
is
>downloading itself onto the chip (i think it would be. how else would it
>run)
Enter one line which say DEBUG "Program Started" as the first statement.
> The problem i am facing is that i want to run the program on the IC using
>my Java program which reads from and writes to the Serial port (I am using
>COM1).
> How do i do it?
> Please, i wold appreciate a fast reply.
>Rishi
>If by "i want to run the program on the IC" you mean that you want to
>execute the code within the Stamp processor separately, and have it
>program-link to anything else, it's just NOT going to happen. The code
>within the IC is a p-Code interpreter and de-tokenizer (as opposed to a
>compiler, or assembly language EXE or operating system). There are
>specific requirements which are met by the HOST editior (the .EXE program
>supplied by Parallax), which is the p-Code emitter and source code syntax
>checker. In turn, it feeds these p-Code tokens to the embedded routines
>hard coded in the PIC processor.
At all times, the Interpreter must remain in control. The Alt-R (RUN
command) performs the transfer of control as the LAST thing that it does,
and that control, once relinquished, is NEVER returned to the operating
system. COMMUNICATION between the two IS possible, however - if this was
your goal.
If what you wish to do is to interface with the Stamp with a data-link,
such that data values within the Stamp at Stamp_Execution time (AFTER
tokenization, de-tokenization, etc) can be passed back, via a serial
connection for display by the HOST program (Java aside[noparse][[/noparse]2]), that is QUITE
doable. As a regular matter, DEBUG is used for this purpose, for small
volumes of data.
More information will be required for specific needs, but the easiest test
case is to use the DEBUG operator: DEBUG ? variable_name which will
transmit to the built-in Serial Port (Pin port 16) "&variable_Name =" [noparse][[/noparse]some
data value] where &variable_Name is replaced by the actual data_label as
defined in the program. This data is INTENDED to be received by the HOST -
what the user DOES with it, is another matter entirely !
The DEBUG serial protocol is 9600,8.N,1 [noparse][[/noparse]1] and responds and acts just like
a Serout operator would, EXCEPT that it uses the "special" DEBUG port (pin
Port 16).
Ref: Parallax Stamp I / II Manual Version 1.9. , (pp 326, 317-318, 320,
255).
- - - - -
[noparse][[/noparse]1] CAUTION - Data inversion should be considered, depending on the
application
[noparse][[/noparse]2} Java - ANY program COULD CAREFULLY "tap" the serial line;
essentially no different than an evesdropping phone tap. The
SAME caveats about
being discreet, and non-interfering apply here as well !
Impacting pin Port 16 is dangerous, since this is also the programming
port. USE with EXTREME caution. There are timing and signal considerations
which occur during programming which have NO bearing on the standard RS-232
protocol.
- - - - - -
Hope that gives you a start.
Regards,
Bruce Bates
>Bruce,
>thanx a lot for your prompt reply.
>the program actually runs. i am able to output the data in the host program
>using the debug command. the data even appears upon using Serout command.
>However i am not able to use Serin command (where is the data supposed to
>come for Serin. and conversely where does the serout data go?).
The data, ANY data, output from any Stamp, goes through the pin Port you
specify.
The understanding of the pin Ports and how they operate is CRUCIAL to the
understanding of the general Stamp (and MicroChip PIC) I/O philosophy.
> Can i access
>the serout data from the HOST Program at least (not my Java program. Java
>program, i will call FOREIGN).
DEBUG permits that direct and immediate facility, but that's JUST ONE of
the methods. Although it has been used for MANY purposes (due in no small
part to it versatility), the PRIMARY purpose of DEBUG is (as it implies) a
debugging tool.
Nothing is limiting about this function, in general, BUT the serial
parameters DIFFER from other, more ordinary methods of outputting RS-232
style SERIAL data.
>If it is not possible using BS2, how can we access data for several other
>applications? I am sure BS2 doesnt have the capability to store huge
>programs. I hear people talking about Robotics and Peizoelectric projects
>and a lot more. How do they access the data. Will something like BS2SX help
>me?
ANY Stamp can store data in onboard RAM, or in onboard EEPROM. OFF board
EEPROM is also possible via I2C (or SPI/Microwire) style accessability. It
really depends on your requirements. If you don't have a current manual
(V1.9), you need one pronto.
As you note, ONBOARD store space IS at a premium.
The manual can be download from the Parallax web site:
[noparse][[/noparse] http://www.parallaxinc.com ] in the Documentation section.
Additionally, I would recommend, the Stamp Differences Document as well.
This will document will indicate -
the relative processor speeds
how much space is available for: program, data
the relative speeds of the processors
the banked memory nature of the SX version
and other important information as well. This is an excellent OVERVIEW of
the processors.
The BS-2(any suffix) processors all permit SERIN and SEROUT to any of the
pin Ports 0-15. All use the ordinarily inaccessible pin Port 16 for DEBUG.
DEBUG is just a special case of SEROUT. At the end of the Manual is a
schemtic of the processor which may make understanding the programming Port
(SOut/pin Port 16) a bit more clear. SIN and SOut are ONE PIN port (pin
Port 16) which is shared for input AND output. This speaks to the
BI-DIRECTIONAL nature of Stamp i/o ports in general. This brings about an
entirely different discussion which is beyond the scope of this message.
Somewhat unfortunately, there is all too much data which is hidden in the
small print and footnotes. Doing what you want to do quickly and learn
about is NOT easily done. RISC processors are somewhat unique, and
MicroChip PICs and Scenix SX processors are even a bit unique within that
larger set.
My best advice is to copy directly from the manual and adapt your hardware
to it, if speed is the utmost goal. Specific examples riddle the Serin /
Serout section of the manual. From a hardware perspective, sharing data
with the outside world is found on page numbered 320. Sharing data with a
PC can be found on page numbered 328 with the Ping-Pong setup. Here, two
Stamps speak to each other, along with a PC which is able to monitor the
"conversation".
BAUDMODE concerns are addressed on page numbered 321 in the inset Figure I-22.
> Expecting an early reply again.
A more specific question may garner a better answer. Perhaps it's too late,
but your specific requirement or problem still seems vague to me.
> Thanx for your attention
>Rishi
Regards,
Bruce Bates
On the Stamp side you can use SERIN and SEROUT. Use Pin 16 if you don't want
to worry with line drivers (like a MAX232). If you do use pin 16, however,
you can only do half duplex and you will automatically echo everything to
the PC.
Now, on the java side you need the javax.comm package. This is pretty
straightforward as long as you are using Windows or Solaris which is where
the reference implementations run.
http://java.sun.com/products/javacomm/
There is a nasty bug in the Windows version of javax.comm right now that I
hope they will fix. Suppose you have a few disk drives like I do C: E: F:
G:. Now, say your JDK is installed on . You put your program on F:
Everything seems to work, but the javax.comm reports that no serial ports
are available. Nothing you can do will make it work. Except moving your
class files (at least) to the drive or moving the javax.comm libraries to
F.
Sigh.
You can find examples of doing I/O on the above site.
Regards,
Al Williams
AWC
* NEW: PAK-I math coprocessor is now 20MHz. Twice as fast!
http://www.al-williams.com/awce/pak1.htm
>
Original Message
> From: Rishi Bhatnagar [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=5CxiWjZ-TRywQn6bqrm6h6fB1nWZyZbLoFTnk1GIr_JtVCIJEi01TNT0-RdHdJ3VIOqCIxS1lnDX6gQ]rishi@c...[/url
> Sent: Thursday, December 07, 2000 11:34 PM
> To: Basic Stamp
> Subject: [noparse][[/noparse]basicstamps] Unable to hook up BS2 with Java. Please help!!!
>
>
>
> Hi,
> I am new to Basic Stamp2. i have to submit a project in a short time.
> I am trying to hook up Basic Stamp2 to my PC through the serial
> port (9600
> baud, 8bit, no parity, 1 stop bit)
> I am using Basic Stamp2 (not BS2E or BS2SX
> I am also using the windows based editor. It runs by saying
> CTRL-R. It is a
> little different than the DOS editor, i would think.
> I am able to run the program without any problem, but i dont
> know if it is
> downloading itself onto the chip (i think it would be. how else would it
> run)
> The problem i am facing is that i want to run the program on the IC using
> my Java program which reads from and writes to the Serial port (I am using
> COM1).
> How do i do it?
> Please, i wold appreciate a fast reply.
> Rishi
>
> Genius is 1% inspiration and 99% prespiration
> Genius is 1% inspiration and 99% prespiration
>
>
>