PDA

View Full Version : What is the value???



AIman
09-10-2006, 08:43 AM
·· I am becoming increasingly confused about why people are trying to write or find ways to work with a language outside of Pbasic for the BS2. Since the BS2 is limited in memory and only uses Pbasic, what value is there in creating an interface between·Pbasic and·different·languages?
·· It makes no sense to me to write a program that requires conversion when we still have to use the same language·in the end. My understanding is that the BS2 will not accepted downloads during realtime functions but must be programed, and since it won't·slave to something·why waste the extra lines of code? In short,·what value is there in writing a program that must contain extra code and still end up in Pbasic.

·· I don't get it.

Could someone please explain this to me?

Chuck B
09-10-2006, 10:24 AM
Hi AIMan,
I think the overriding answer is that another language is like a 'security blanket'. All of my children had special blankets to snuggle and to nap with...any other would give them the fits. For example, this is very easy and natural for me...




for(int i = 0; i < 20; i += 2)
{
pulseout(12, 500);
pause(1000);
}




Now, if I have been doing this for 15 years or so, then the following way of typing can be really wierd...




i VAR Byte
FOR i = 0 TO 19 STEP 2
PULSOUT 12, 500
PAUSE 1000
NEXT




Anyway, I wouldn't be hard on folks who want to program the BS2 using different languages. It's all about preference.

Regards,
ChuckB

Mike Green
09-10-2006, 10:42 AM
Another thing is that some people don't understand that PBasic is compiled into interpretive code which is downloaded to the Stamp. There are several compilers available that will compile either C or something very similar to PBasic into instructions for the PIC or the SX processor. Perhaps they confuse the PBasic compiler with one of these.

Kevin Wood
09-10-2006, 11:20 AM
When you say "interface between PBasic and different languages," what do you have in mind?

PBasic only runs on the Basic Stamp, and there are millions of other systems out there that people might want to interface with a Basic Stamp. Except for other Parallax Basic Stamps, none of those systems can be programmed in PBasic. So if somebody want to create an interface between a Basic Stamp & a PC for some reason, you have to deal with a minimum of 2 systems, and 2 languages.

Even if Parallax created a version of PBasic that could run on a PC, you would still find differences and/or limitations when compared with other languages. For example, Spin is a language written for a very specific purpose, because other languages didn't meet the established design requirements. Most languages have been developed for similar reasons.

Perhaps the closest comparison that you could make with the Basic Stamp is the Javelin Stamp. It has specs very close to the other Stamps using the SX48 processor, but the diffences between PBasic & Javelin Java are considerable. There are some things that you could probably do more easily in PBasic, but there are things the Javelin can do that the Basic Stamp can't, simply because of the differences in language.

AIman
09-11-2006, 09:35 AM
So in other words its only about people using a different language they are used to, however, I use 2 languages at work regularly because the one is more difficult to work with and it is easier and faster both in programming and speed to start and end in a different language. In the end I still have to use the more difficult language for the direct data collection which means I still have to learn and use both languages.

Does Pbasic have a work around with this?

If one has to learn Pbasic anyway, then why do two languages? If you can write in C or VBA and run it in PBasic then it makes sense to do it that way, however if there is no way to write in C and download in Pbasic then aren't people doing twice the work?

For example I have to go make a transition by using this code

Set System = CreateObject("EXTRA.System")·· ' Gets the system object
If (System Is Nothing) Then MsgBox "Could not create the EXTRA System object.· Stopping macro playback.": Stop
Set Sessions = System.Sessions
If (Sessions Is Nothing) Then: MsgBox "Could not create the Sessions collection object.· Stopping macro playback.": Stop

Set Sess0 = System.ActiveSession
If (Sess0 Is Nothing) Then MsgBox "Could not create the Session object.· Stopping macro playback.": Stop

And then start using the other language.

Can Pbasic tolerate a transition like that? If it could then we could easily setup and use most any system to download and/or work with Pbasic, but again, we still aren't getting out of the way of using Pbasic? And how would we set up a reference library?

Kevin Wood
09-11-2006, 10:39 AM
If you don't mind my asking, what 2 languages are you using at work, and what exactly are you trying to do in regards to PBasic? What type of systems are you trying to get to communicate with each other?

As I stated, the ONLY computers that can be programmed using the PBasic language are the Parallax Basic Stamps. Also, the ONLY language that can be used to program the Parallax Basic Stamps is PBasic. Its very similar in that respect to the Spin language and the Propeller chip - one language & one platform to run it on.

When you're dealing with other languages and platforms, you have more options. So for instance, there are dozens of languages that you can use for programming MS Windows, but PBasic isn't one of them. That doesn't mean that you can't get a PC and Basic Stamp to communicate with each other. The way you do it is through some form of communications protocol that both systems can recognized and understand.

Mike Green
09-11-2006, 11:32 AM
In some ways you can think of PBasic as an "assembly language" with the basic operations being the PBasic operations. It is possible to create a compiler that can compile other languages (like C or VB) into PBasic with the exception of those operations for which there are no or inadequate facilities in PBasic. In particular, there are no non-constant strings, not much storage, no floating point. The truth is that the PIC or SX processor has very little storage available and can only handle bit and byte operations natively. What you would get is the "syntactic sugar coating" of the other language, but not necessarily the substance of the underlying operations (like fancy I/O, string manipulation, floating point, etc.).

Steel
09-12-2006, 02:11 AM
It can also be used as a form of 'code protection'.· If you are manufacturing a product, and having somebody else (on an assembly line) program your chips, you can use other programs to make it difficult for them to understand/steal/change any of your code.

With PBasic,
If I send something into mass manufacturing, and all I have is PBasic...the guy on the end of the assembly line who programs the chips can EASY accidentally change something in the code (comment something out)·and program 1000+ units wrong.· He can also copy/paste the code, and make his own project.

But with a compiler...I can use a 3rd party program to encrypt and lock my code.· That way nobody can change it or take it.· I can save it as a .hex file or anything else.· I can make a small program that decrypts my pbasic file, download it, and verify it...all without the guy on the end of the line knowing what the code looks like or how to 'open' it.

This will prevent errors on the line, and keep your product as you intended it.

Mike Green
09-12-2006, 02:43 AM
There's a nice device called a Stache. It clips onto a 9V battery and plugs into a serial port. To the PC, it looks like a Stamp board and you can download one or more programs to it. To a Stamp board, it looks like a PC and will program a Stamp with one of the programs in the device. It's designed for field distribution of Stamp program updates. Once loaded, you can't change the program in it except to replace it entirely. What's stored in the device is the interpretive byte codes which cannot be transformed back into the source program (except incompletely with a huge amount of manual, sophisticated work). Once upon a time, the Stamp Editor could make a "binary" file of the byte codes and there was a Stamp loader program that would copy this to a Stamp. I don't think the current editor can do this, but the Stamp Tokenizer is a library (for Windows, Mac, and Linux) that will take a PBasic source program in memory and produce a byte code stream that can be copied to a file like with the old DOS PBasic editors. There is a document available on the download protocol (to the Stamp) and it wouldn't be too difficult to program a PC for mass programming of Stamp-based devices just like any other microcontroller. Once the Stamp is programmed, it can't be read easily (you could probe the EEPROM on the Stamp substrate and build a hardware interface to copy the EEPROM contents, but you still wouldn't be able to modify it or recreate the source code in a useful way).

Be that as it may, it is harder to steal code from a preprogrammed PIC or SX chip than from a Stamp, but someone would have to want to really badly to put the effort in to do so. It's probably much easier to steal your laptop or desktop computer or go through your trash for old printouts, etc. if it's that important.

AIman
09-12-2006, 02:59 AM
Kevin Wood said...
If you don't mind my asking, what 2 languages are you using at work, and what exactly are you trying to do in regards to PBasic? What type of systems are you trying to get to communicate with each other?

Well, I use VBA and Extra Basic heavily at work. Because I use VBA so much it would be nice to be able to program in VBA and drop it to Pbasic, however every instance I can find shows the end result in Pbasic anyway.
Ideally I would like to get my PC and the BS2 to talk with each other. I can't get the BS2 to accept realtime uploads but I am thinking I might be able to get a wireless link on my desktop and then program the stamp to stop at certain points in a procedure or in the house and request a new program download. It would be slower, but I could potentially use a much larger program to accomplish things instead of having to worry about lines of code.
If memory serves we are limited to 800 lines of code in the BS2 but I could be wrong. Regardless, with using a wireless download I could conceivable write whatever I wanted so long as the downloads were timed at non-crucial junctions.

Kevin Wood
09-12-2006, 08:55 AM
All you really need to get your Stamp and PC communicationg is a serial connection. SERIN & SEROUT in PBasic - 2 commands. On the PC, you need to look at serial connections with VBA, Extra Basic, or whatevere language you work with.

If you want to remotely program your Stamp, you should be able to do it with the tokenizer mentioned by Mike Green. The tokenizer won't do it directly, but you can write a program that uses the tokenizer to compile(tokenize) your PBasic code and then upload it to your Stamp. It would be sort of like remote-controlling the Stamp IDE.

I'm not too clear on the overall benefit, however, since your PBasic program will be designed to control the circuitry connected to the Stamp, which you wouldn't be able to change remotely.