Connect Basic Stamp 2 to Raspberry pi with C
satriaoo
Posts: 20
Dear sir,
I hava a project to connect raspberry Pi model B to Basic Stamp 2 Board of Education Development Board via LXTerminal with C .
Do you know how to connect it? Code?
Please help. Thanks.
I hava a project to connect raspberry Pi model B to Basic Stamp 2 Board of Education Development Board via LXTerminal with C .
Do you know how to connect it? Code?
Please help. Thanks.
Comments
I know nothing of the BASIC Stamp 2 but I'm certain you cannot program it in C.
LXTerminal is a terminal program used on the Pi. That can be used to talk to connected devices connected over a serial line.
So, where does the C code fit into this?
Any questions about writing programs to talk to the serial ports on a Pi are better asked on the Raspberry Pi forum.
A quick google search for "linux serial port programming C" will probably get you a lot of advice.
Unless it is a specific requirement of your homework or something to learn and do this in C I would suggest using Python or JavaScript instead.
The RaspberriPi uses the LXTerminal program for serial input and output using the console and C has some standard serial I/O
There are all sorts of ways to connect these two including via USB (if you have the USB Board of Education). You just need to connect the programming / debugging port on the Board of Education to one of the USB ports of the RaspberryPi and it'll show up as a serial port in /dev. LXTerminal should see it and be able to connect to it. In this case, you will be able to use the DEBUGIN and DEBUG statements in Stamp Basic which are simplified versions of SERIN and SEROUT. Look in the Reference Manual for details and examples.
The first two threads listed have a lot of useful information on the topic.
One thing I didn't see mentioned in the earlier threads was the need to protect the Raspberry Pi from the Stamp's 5V logic level. It would probably be a good idea to use a level shifter between the Stamp and Pi.
I mean, i program it from raspberry pi. btw, thanks for advice, sir.
Or is this another of Chip's assembler only creations that will only ever live on Intel?
Unfortunately, the downloads for Linux that you referenced won't work on the RaspberryPi. "tokenizer.so" is a binary library that contains the actual compiler for Stamp Basic and will only run on an Intel-compatible processor. The rest of the Linux code is in C++, but is only the editor and interface to "tokenizer.so".
Thanks for correcting me because I didn't see any comments for those downloads other than they weren't supported by Parallax.
Hmm, so, i have a project to running hexapod with Raspberry Pi and Basic Stamp (Basic stamp connected with Raspberry Pi using serial USB). I must controlling the hexapod via raspberry pi. But, i have a problem. I dont know what the C code (btw, im using LXTerminal) to connect them.
Btw, my Basic stamp using MAC BS2 pre-release. I didnt have any problem on this. My problem only on "Connecting Raspberry with Basic Stamp"
Could you help me please?
If you want to make a director connection between The Pi's serial port on GPIO and STAMP you will first need to prevent Linux using it: http://elinux.org/RPi_Serial_Connection#Preventing_Linux_using_the_serial_port
Do you really need to use C on the Pi? Life is much easier if you use say Python: http://elinux.org/Serial_port_programming
Or JavaScript: https://github.com/voodootikigod/node-serialport
If you want to do it in C it's a bit more long winded. See HOWTO article here:
http://tldp.org/HOWTO/Serial-Programming-HOWTO/x115.html
WOOOW! Thanks sir, connected! Iam using Python btw. Nice advice. :P
But one more sir. hehe. How to calling function (my code on Microcontroller) from python? Iam using MAC BS2-pre release btw.
Thank you, sir.
Both BASIC and Python can only call functions within the same program. Making calls from one language to another, even in the same program running on the same machine is generally impossible or hard.
What you have to do is write a function in Python that sends a message, some string of characters/bytes, to the STAMP over the serial line. The program in the STAMP receives those bytes, recognizes the message and does whatever action the message implies. Perhaps it then sends a message back to the Pi where to tell the Python program the result of the action.
Or the other way around of course.
I know nothing of BASIC STAMPS so I cannot help much with that.
Given your apparent level of experience I would suggest starting with something really simple:
Can you send a single character, say "1", from the Pi and have the STAMP receive it? Perhaps turn a LED on to indicate success. Then send a "0" and have the STAMP turn the LED off.
With that working we can look at what you actually want to do and how to send and decode messages between Pi and STAMP.
Hmmm, okay. i'll try. Thank you sir.