November 24, 2024, 06:07:44 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Stepping up from Prop-2 to Prop SX

Started by jukingeo, March 23, 2008, 05:39:15 PM

Previous topic - Next topic

jukingeo

Hello,

I am curious from the background of a Prop-2 programmer, what is needed and how long is the learning curve when stepping up to the Prop SX?

For the most part I am looking to create an MPU control system for a custom pinball machine.  At this point in time I am getting the gist that the Prop-2 isn't even going to handle this task...but with the Prop-SX's speed...well that should do it.

Thanx,
Geo

JonnyMac

The Prop-SX is infinitely more powerful than the Prop-2; however, access to that power requires more work on the programmer's part.  Thankfully, one can program the Prop-SX simply, using the SX/B BASIC Compiler from Parallax (I was part of the team that created it).  I'm still working on a book called "Practical SX/B" but Parallax has released the opening chapters to get folks going.   It would be good to read so that you begin to see the differences between a BASIC Stamp and programming the SX in SX/B.

Note that this is a rough draft and not yet fully edited; it is still useful, however.
-- http://www.parallax.com/Portals/0/Downloads/docs/prod/sx/PracticalSXB.pdf

Advance programmers will want to order Guenther Daubach's "Programming the SX Microcontroller" from Parallax; it's a great reference for SX assembly language.
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on March 23, 2008, 06:19:21 PM
The Prop-SX is infinitely more powerful than the Prop-2; however, access to that power requires more work on the programmer's part.  Thankfully, one can program the Prop-SX simply, using the SX/B BASIC Compiler from Parallax (I was part of the team that created it).  I'm still working on a book called "Practical SX/B" but Parallax has released the opening chapters to get folks going.   It would be good to read so that you begin to see the differences between a BASIC Stamp and programming the SX in SX/B.

Note that this is a rough draft and not yet fully edited; it is still useful, however.
-- http://www.parallax.com/Portals/0/Downloads/docs/prod/sx/PracticalSXB.pdf

Advance programmers will want to order Guenther Daubach's "Programming the SX Microcontroller" from Parallax; it's a great reference for SX assembly language.

Thanx Jon, I will download and start doing some reading tonight.

Geo

jukingeo

Is the Prop-2 using a BS2sx or is the SX microcontroller  that is being utilized a different animal entirely?


JonnyMac

BS2 uses a PIC16C57 which predates the SX28.  The SX28 uses the same pinout (this allows us to use the same PCB layout for the Prop-2 and Prop-SX) and has a compatible instruction set, though given the same external clock source (e.g., resonator) the SX28 can run 4x faster.

Remember, too, that the BASIC Stamp is running an interpreter inside the PIC; this interpreter has to fetch and decode PBASIC tokes from an external EEPROM.  When you use the Prop-SX you are programming the SX directly, hence have all its power at your disposal.  That the SX is running internal instructions versus an external fetch/decode cycle accounts for the massive speed improvement of the Prop-SX over the Prop-2.
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on March 26, 2008, 05:34:50 PM
BS2 uses a PIC16C57 which predates the SX28.  The SX28 uses the same pinout (this allows us to use the same PCB layout for the Prop-2 and Prop-SX) and has a compatible instruction set, though given the same external clock source (e.g., resonator) the SX28 can run 4x faster.

Remember, too, that the BASIC Stamp is running an interpreter inside the PIC; this interpreter has to fetch and decode PBASIC tokes from an external EEPROM.  When you use the Prop-SX you are programming the SX directly, hence have all its power at your disposal.  That the SX is running internal instructions versus an external fetch/decode cycle accounts for the massive speed improvement of the Prop-SX over the Prop-2.

Hello Jon,

I mentioned the BS2sx above.  However, what I am not clear on is that the BS2sx is the same or a different beast from the SX28.  It sounds to me like it is different. 

Given that it seems that the Prop-SX is now the same price as the Prop-2, it doesn't seem to make sense for me to get another Prop-2 when my next project could benefit from the speed of the Prop-SX.   Now I been doing some reading on that document you posted above.   Let's see if I get this straight in terms of speed:

1) BS-2   4khz
2) SX 4mhz (internal clock)
3) SX 50mhz (external clock via separately purchased resonator)

Finally the Prop-2 uses an SX28 IC which has no relation to the BS-2sx, correct?

I gone through much of your document that you posted above.   It does very much seem like that there isn't too much more of a learning curve from upgrading to the SX.  In fact it looks like there are way more powerful commands, such as Toggle and using '~' to invert an output (that is cool).

I got up to the part with using 7 segment displays.    But I am curious as how the SX handles faster and multi-tasking jobs.

One of my goals for an SX project is to use it as an MPU for a custom pinball machine.   So I am going to need something that runs a program and can accept input data, output data and update a display at the same time.   The Prop-2 is clearly too slow.   BUT it would seem that the SX sure could do it (speed wise).   However, I am still unsure if it has enough memory.  But it looks to be a promising way to go.

Thanx,

Geo


livinlowe

The Prop-2 doesn't use a sx28, it uses the PIC chip jon mentioned. The BS-2sx uses the sx28, but has to use a interpreter so it is slower than an sx28 native.
Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

Let me try again -- I'm not doing this very well.  The Prop-2 uses a PIC running at 20 MHz.  The PIC requires four clock cycles per instruction, so it's like running an SX28 at 5 MHz (the PIC has 1/4th the raw speed due to clock cycle usage).  Also, as Shawn points out above, the PIC is running an interpreter (a program to use PBASIC tokens) while the SX is running raw machine code.

There is a BIG difference in programming the Prop-SX to get the kind of power we use day-in and day-out, and this should not be taken for granted.  The reason the BASIC Stamp became so popular is that it unburdens the users from the gory details of working with a microcontroller, the SX does not (SX/B helps, but still relies on you knowing how microcontrollers work).

The SX has 2K of program memory and over a hundred bytes of user RAM... but, the user RAM is banked an not as easy to use as with the BASIC Stamp.  Also, you need and SX-Blitz or SX-Key to program the Prop-SX, it is not programmed through the serial port like the Prop-2 (the reason is that you're actually burning your program in to the SX28 while the Prop-2 stores its PBASIC tokens in an EEPROM).

The Prop-SX is fun and very powerful, but let me caution you that you're going to have to learn more about micros that you may have wanted in the past to be successful with it.  Your pinball project is not trivial, you should be prepared to go slowly and learn things in stages.
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on March 27, 2008, 09:11:51 AM

There is a BIG difference in programming the Prop-SX to get the kind of power we use day-in and day-out, and this should not be taken for granted.  The reason the BASIC Stamp became so popular is that it unburdens the users from the gory details of working with a microcontroller, the SX does not (SX/B helps, but still relies on you knowing how microcontrollers work).

Still, from what I was reading the SX/B programming would be a big help because it comments out the basic commands in relation to what is actually getting complied in terms of assembly code.  So I think that is a major plus over some of the other systems I was looking at for this project.


QuoteThe SX has 2K of program memory and over a hundred bytes of user RAM... but, the user RAM is banked an not as easy to use as with the BASIC Stamp.  Also, you need and SX-Blitz or SX-Key to program the Prop-SX, it is not programmed through the serial port like the Prop-2 (the reason is that you're actually burning your program in to the SX28 while the Prop-2 stores its PBASIC tokens in an EEPROM).

Yeah I was reading about that and it seems the "Key" would be preferred over the "Blitz", not that I know 100% the full details between the two.

QuoteThe Prop-SX is fun and very powerful, but let me caution you that you're going to have to learn more about micros that you may have wanted in the past to be successful with it.  Your pinball project is not trivial, you should be prepared to go slowly and learn things in stages.

Well, I am going to need to learn it eventually.  Most of the other more advanced systems I looked at for the project did require a good bit of knowledge in regards to programming in assembly code.

I have been putting it off for a long time now...Ever since C++ came out I been wanting to learn lower levels of programming, but didn't really have a good enough reason to "take the plunge".   But with the pinball project I am considering, I believe I have gone way past what I initially learned (mostly through you) in regards to basic stamp programming.

But as you did point out...I am probably not ready for this task now and I am probably not going to go ahead with the project until I gain a more clearer understanding of the SX microcontroller and whatever else is out there.   But thus far the SX looks like a good way to go for a simpler system.  But there probably is no way getting around something more advanced and I may have to bite in the sour apple and learn C++ or similar assembly language system.

Thank you for the information thusfar.  I think I may get a Prop-SX to dabble with anyway, I am sure I will have as much fun with it as I am having with the Prop-2.

Geo

JonnyMac

The Key and the Blitz are both programmers, i.e., they can burn a new program into the SX chip.  The difference between the two is that the Key has an onboard clock generator that can run the SX under control from the IDE.  This lets you run your SX without having a resonator installed; more importantly, it allows you to do single-step debugging -- this is kind of advanced but at some point you'll have to face it when working with complex systems.

I'm not a C++ programmer but there's a GINORMOUS difference between C++ and embedded BASIC.  I believe C++ does a lot of abstraction, hiding details from the programmer -- or making them trickier to get to, anyway.  SX/B is the opposite: you get full control, so long as you understand the SX's registers and what to do with them. 

As you point out, you can do quite a lot without using a shred of assembly.  The reason for this is that SX/B compiles in place to very lean assembly code.  Now, that compile-in-place process is a double-edged sword; if, for example, you use a lot of PAUSE statements in your program you can burn through a lot of code space.  Luckily, SX/B allows us to declare subroutines and functions and even supports parameter passing.  Every program I write in SX/B has a subroutine called DELAY_MS that replaces PAUSE:

' Use: DELAY_MS duration
' -- shell for PAUSE

SUB DELAY_MS
  IF __PARAMCNT = 1 THEN
    tmpW1 = __PARAM1
  ELSE
    tmpW1 = __WPARAM12
  ENDIF
  PAUSE tmpW1
  ENDSUB


By doing this I save code space as PAUSE is only expanded to assembly once, and this routine will accept byte or word values.  If I'm using an interrupt, PAUSE is replaced by a timing loop that works from an interrupt-set flag.

I think it would be worth your time to get a Prop-SX and start playing.  Rome wasn't built in a day; neither are our programming skills.  I've only recently become very confident in SX programming because -- unless I'm doing it for someone else -- I almost never program BASIC Stamps any more; all of my projects use SX chips.


Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on March 29, 2008, 01:00:45 PM
The Key and the Blitz are both programmers, i.e., they can burn a new program into the SX chip.  The difference between the two is that the Key has an onboard clock generator that can run the SX under control from the IDE.  This lets you run your SX without having a resonator installed; more importantly, it allows you to do single-step debugging -- this is kind of advanced but at some point you'll have to face it when working with complex systems.

So then as others are saying it is better to get the Key instead of the Blitz.

QuoteSX/B is the opposite: you get full control, so long as you understand the SX's registers and what to do with them. 

As you point out, you can do quite a lot without using a shred of assembly.  The reason for this is that SX/B compiles in place to very lean assembly code.  Now, that compile-in-place process is a double-edged sword; if, for example, you use a lot of PAUSE statements in your program you can burn through a lot of code space.  Luckily, SX/B allows us to declare subroutines and functions and even supports parameter passing.  Every program I write in SX/B has a subroutine called DELAY_MS that replaces PAUSE:


So in the case of the SX you are better off having one main pause command and work from that in a subroutine loop?  ...At least that is what I got from the code you wrote.

QuoteBy doing this I save code space as PAUSE is only expanded to assembly once, and this routine will accept byte or word values.  If I'm using an interrupt, PAUSE is replaced by a timing loop that works from an interrupt-set flag.

There usually are a couple of cases in programming pinballs where an interrupt flag comes to play.  For one updating the score, and updating the outputs.  So that is an important ability.  Of course you did mention to me early on in the Prop-2 forum that the SX can multi-task...so I did keep it in mind.   

I have looked into other systems too for the task...but the SX/B programming system seems to be the most attractive to me.  At least it could help me break out of BASIC (finally) and slowly start getting into assembly.

QuoteI think it would be worth your time to get a Prop-SX and start playing.  Rome wasn't built in a day; neither are our programming skills.  I've only recently become very confident in SX programming because -- unless I'm doing it for someone else -- I almost never program BASIC Stamps any more; all of my projects use SX chips.


Yeah, I been thinking about it. 

Would you happen to know if there is an interrupt driven SX program posted here I can look at?  I would like to see what the code is like.  I tried to find something along those lines on my own, but didn't come up with anything.

Thanx,

Geo

livinlowe

This thread in the parallax forums has excellent examples of interrupts as well as general programming:

http://forums.parallax.com/forums/default.aspx?f=7&m=182809
Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

Geo,

Have a look at the Library section for VSA -- I wrote a few programs that use interrupts that handle serial input from the PC as well as servo and PWM outputs.  Those will give you an idea of what can be done without too much stress.
Jon McPhalen
EFX-TEK Hollywood Office