Shop OBEX P1 Docs P2 Docs Learn Events
Migration from Basic Stamp to SX using SX/B — Parallax Forums

Migration from Basic Stamp to SX using SX/B

WBA ConsultingWBA Consulting Posts: 2,935
edited 2009-04-20 20:15 in General Discussion
It hit me the other day that if SX/B is a basic compiler for SX devices, any of my Basic Stamp projects should work on an SX.

1) How true is that statement?
2) How long would it take "joe the stamp programmer" to migrate a project over to SX/B?
3) How troublesome would it be to changeover a BS2P40/Sensirion SHT11/Vmusic2 USB datalogger program over to an SX28?
http://forums.parallax.com/showthread.php?p=792332

With SX chip prices at $3.95 and my BS2P40 at $89, you could see why I am interested. Currently, my projects are limited to my single BS2P40 or my Homework Board. (IE: only two usable projects at a time). I'd love to be able to start using SX so I can leave my projects in a finished state, without buying the more expensive Stamp modules or without having to learn a completely new language (IE:spin since props are so cheap too)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andrew Williams
WBA Consulting
IT / Web / PCB / Audio

Comments

  • InSilicoInSilico Posts: 52
    edited 2009-04-17 06:05
    1) 100% true, anything you can do on the Basic Stamp, the SX can do (and perhaps more/better, if you have the coding skill). In fact, some of the Basic Stamps Parallax sells has an SX "brain".

    2) I don't know, I haven't extensively worked with Basic Stamps before so I'm the wrong person to ask. I can say that it will depend on the complexity of the code. There are some things you have to take into consideration when migrating code to different controllers/languagess

    3) The SX/B instruction set is basically almost identical to the Basic Stamp (albiet with some differences). So porting the code for the sensors and stuff shouldn't be too difficult, once you have the grasp of the SX/B language (which will be easy since you already know PBASIC).
  • InSilicoInSilico Posts: 52
    edited 2009-04-17 06:26
    SX/B also makes a great learning tool. If the idea of assembly doesn't fly with you, SX/B allows you to program the SX chips in a variant of BASIC. Also, with the SX/B it's possible to see the assembly output of the SX/B compiler (since all it does is spit out SX assembly which is downloaded to the SX). It's a way to "see how it's done".

    Then you can go on to learn·some SX assembly (SASM). With SASM, you can exploit the most power from the SX (which is quite powerful) in the most efficient way possible. The learning curve for SASM is much steeper, however.

    SX/B has a much more gentler learning curve, but allows for the mixing of SX/B and SASM. This way, you can optimize the performance critical parts with SASM and write the rest in SX/B. It's sort of a middle ground.

    The SX can do some things basic stamps can't, like multitasking. For example, you can have a serial UART running in the background while the SX is busy doing something else. I have one application where an SX was able to run multiple servos, handle multiple rotary encoder inputs, and a UART for desktop computer control, without breaking a sweat.

    The SX/B Help manual in the SX IDE has a bunch of sample SX/B projects and·example·code·- things like interfacing a DS1620, a timer with a 4 digit·7-segment display, interfacing a serial LCD, and even an 8-bit ADC. Some of the more recent Nuts and Volts columns (you can download from the Parallax site) has some more neat project ideas using the SX.
  • BeanBean Posts: 8,129
    edited 2009-04-17 11:42
    Andrew,
    That is exactly what SX/B was designed to do.

    It depends on the PBASIC program. Some are really easy to convert. Some require more work. PBASIC programs with lots of math will need some work, as SX/B only allows one operator per line. So you may need to use some temporary variables.

    I say, give it a try. We are always here to help if you get stuck.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2009-04-17 19:31
    InSilico/Bean,
    Thanks!!!! That was the response I was looking for. I have already installed the SX/B IDE and started going through a few of the sample programs to "take a peak". I would say that most of my programs are very basic (no pun intended) and I can easily make small PCBs for the SX20/SX28 chip.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    IT / Web / PCB / Audio
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2009-04-19 12:11
    @WBA
    Good luck, but keep in mind that SX/B is not an optimizing compiler. Memory usage is a bit different. For example, every PAUSE command spits out all the code needed to PAUSE, so you can waste memory if you issue the command frequently (make a subroutine to save memory). I suggest you do a bunch of small programs before attempting to port a larger one. The help file and 'practical SX.B 1 and 2" are good places to start

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thomas Talbot, MD
    Gunpowder, MD, USA
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2009-04-20 20:15
    Thanks for the memory tip. From what little I know of assembly, I gather that you are toggling bits/registers to perform functions so that every little step takes up memory space. With the BS2, I would assume this extra memory is already taken up by the interpreter code doing these actions, so my PBasic code doesn't "waste" any space on the BS2 side.

    I have downloaded practical SXB and pulled out the SX28 DIPs, resonators, SX-Key Manual, and Gunther's SX programming Guide that came with my PDB 2 years ago. Hoping to spend some time with a few sample programs over the next couple weeks. My first goal is to port my SHT11 datalogger program over. I'm thinking of picking up one of each of the SX28 and SX48 proto boards since they are so inexpensive.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    IT / Web / PCB / Audio
Sign In or Register to comment.